Files
Jungfraujoch/broker/gen/model/Helpers.h
Filip Leonarski a0a659a02c
All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 7m48s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m22s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 6m47s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 7m15s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 7m35s
Build Packages / Generate python client (push) Successful in 29s
Build Packages / Build documentation (push) Successful in 47s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8) (push) Successful in 7m47s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m47s
Build Packages / build:rpm (rocky9) (push) Successful in 8m40s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 7m4s
Build Packages / Unit tests (push) Successful in 1h8m20s
v1.0.0-rc.120 (#27)
This is an UNSTABLE release.

* jfjoch_broker: Improve performance of binary plot export

Reviewed-on: #27
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
2025-12-09 15:21:40 +01:00

147 lines
5.6 KiB
C++

/**
* Jungfraujoch
* API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates. # License Clarification While this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply** when this file is used solely to generate OpenAPI clients or when implementing applications that interact with the API. Generated client code and applications using this API definition are not subject to the GPL license requirements and may be distributed under terms of your choosing. This exception is similar in spirit to the Linux Kernel's approach to userspace API headers and the GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that user programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not derivative works of the kernel and are not subject to the terms of the GPL. This exception is intended to allow wider use of this API specification without imposing GPL requirements on applications that merely interact with the API, regardless of whether they communicate through network calls or other mechanisms.
*
* The version of the OpenAPI document: 1.0.0-rc.120
* Contact: filip.leonarski@psi.ch
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Helpers.h
*
* This is the helper class for models and primitives
*/
#ifndef Helpers_H_
#define Helpers_H_
#include <ctime>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
namespace org::openapitools::server::helpers
{
class ValidationException : public std::runtime_error
{
public:
explicit ValidationException(const std::string& what)
: std::runtime_error(what)
{ }
~ValidationException() override = default;
};
/// <summary>
/// Validate a string against the full-date definition of RFC 3339, section 5.6.
/// </summary>
bool validateRfc3339_date(const std::string& str);
/// <summary>
/// Validate a string against the date-time definition of RFC 3339, section 5.6.
/// </summary>
bool validateRfc3339_date_time(const std::string& str);
namespace sfinae_helpers
{
struct NoType {};
template <typename T1, typename T2> NoType operator==(const T1&, const T2&);
template <typename T1, typename T2> class EqualsOperatorAvailable
{
public:
enum
{
value = !std::is_same< decltype(std::declval<T1>() == std::declval<T2>()), NoType >::value
};
};
} // namespace sfinae_helpers
/// <summary>
/// Determine if the given vector<T> only has unique elements. T must provide the == operator.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::vector<T>& vec)
{
static_assert(sfinae_helpers::EqualsOperatorAvailable<T, T>::value,
"hasOnlyUniqueItems<T> cannot be called, passed template type does not provide == operator.");
if (vec.size() <= 1)
{
return true;
}
// Compare every element of vec to every other element of vec.
// This isn't an elegant way to do this, since it's O(n^2),
// but it's the best solution working only with the == operator.
// This could be greatly improved if our models provided a valid hash
// and/or the < operator
for (size_t i = 0; i < vec.size() - 1; i++)
{
for (size_t j = i + 1; j < vec.size(); j++)
{
if (vec[i] == vec[j])
{
return false;
}
}
}
return true;
}
/// <summary>
/// Determine if the given set<T> only has unique elements.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::set<T>&)
{
return true;
}
std::string toStringValue(const std::string &value);
std::string toStringValue(const int32_t value);
std::string toStringValue(const int64_t value);
std::string toStringValue(const bool value);
std::string toStringValue(const float value);
std::string toStringValue(const double value);
bool fromStringValue(const std::string &inStr, std::string &value);
bool fromStringValue(const std::string &inStr, int32_t &value);
bool fromStringValue(const std::string &inStr, int64_t &value);
bool fromStringValue(const std::string &inStr, bool &value);
bool fromStringValue(const std::string &inStr, float &value);
bool fromStringValue(const std::string &inStr, double &value);
template<typename T>
bool fromStringValue(const std::vector<std::string> &inStr, std::vector<T> &value){
try{
for(auto & item : inStr){
T itemValue;
if(fromStringValue(item, itemValue)){
value.push_back(itemValue);
}
}
}
catch(...){
return false;
}
return value.size() > 0;
}
template<typename T>
bool fromStringValue(const std::string &inStr, std::vector<T> &value, char separator = ','){
std::vector<std::string> inStrings;
std::istringstream f(inStr);
std::string s;
while (std::getline(f, s, separator)) {
inStrings.push_back(s);
}
return fromStringValue(inStrings, value);
}
} // namespace org::openapitools::server::helpers
#endif // Helpers_H_