mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-15 22:31:32 +01:00
support for scoped enums and operators in Python
This commit is contained in:
@@ -395,7 +395,7 @@ typedef struct {
|
||||
enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL };
|
||||
|
||||
#ifdef __cplusplus
|
||||
enum class EthernetInterface : int32_t {
|
||||
enum class EthernetInterface {
|
||||
#else
|
||||
enum EthernetInterface {
|
||||
#endif
|
||||
@@ -497,15 +497,15 @@ typedef struct {
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
inline slsDetectorDefs::EthernetInterface
|
||||
operator|(const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
operator|( const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) |
|
||||
static_cast<int32_t>(b));
|
||||
};
|
||||
|
||||
inline bool operator&(const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
return (static_cast<int32_t>(a) & static_cast<int32_t>(b));
|
||||
inline slsDetectorDefs::EthernetInterface operator&( const slsDetectorDefs::EthernetInterface &a,
|
||||
const slsDetectorDefs::EthernetInterface &b) {
|
||||
return slsDetectorDefs::EthernetInterface(static_cast<int32_t>(a) & static_cast<int32_t>(b));
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -653,3 +653,4 @@ using Positions = const std::vector<int> &;
|
||||
using defs = slsDetectorDefs;
|
||||
} // namespace sls
|
||||
#endif
|
||||
|
||||
|
||||
@@ -526,9 +526,9 @@ std::string ToString(const defs::EthernetInterface s) {
|
||||
case defs::EthernetInterface::NONE:
|
||||
return std::string("none");
|
||||
default:
|
||||
if (s & defs::EthernetInterface::I3GBE)
|
||||
if ((s & defs::EthernetInterface::I3GBE)!=defs::EthernetInterface::NONE)
|
||||
os << "3gbe, ";
|
||||
if (s & defs::EthernetInterface::I10GBE)
|
||||
if ((s & defs::EthernetInterface::I10GBE)!=defs::EthernetInterface::NONE)
|
||||
os << "10gbe, ";
|
||||
auto rs = os.str();
|
||||
rs.erase(rs.end() - 2, rs.end());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
std::vector<char> server() {
|
||||
std::cout << "starting server\n";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "catch.hpp"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/TimeHelper.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/network_utils.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/network_utils.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
@@ -302,25 +302,32 @@ TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Printing c style arrays of int"){
|
||||
TEST_CASE("Printing c style arrays of int") {
|
||||
int arr[]{3, 5};
|
||||
REQUIRE(ToString(arr) == "[3, 5]");
|
||||
}
|
||||
|
||||
TEST_CASE("Printing c style arrays of uint8"){
|
||||
uint8_t arr[]{1,2,3,4,5};
|
||||
TEST_CASE("Printing c style arrays of uint8") {
|
||||
uint8_t arr[]{1, 2, 3, 4, 5};
|
||||
REQUIRE(ToString(arr) == "[1, 2, 3, 4, 5]");
|
||||
}
|
||||
|
||||
TEST_CASE("Printing c style arrays of double"){
|
||||
TEST_CASE("Printing c style arrays of double") {
|
||||
double arr[]{3.4, 5.3, 6.2};
|
||||
REQUIRE(ToString(arr) == "[3.4, 5.3, 6.2]");
|
||||
}
|
||||
|
||||
TEST_CASE("Print a member of patternParameters"){
|
||||
TEST_CASE("Print a member of patternParameters") {
|
||||
auto pat = sls::make_unique<sls::patternParameters>();
|
||||
pat->limits[0] = 4;
|
||||
pat->limits[1] = 100;
|
||||
REQUIRE(ToString(pat->limits) == "[4, 100]");
|
||||
}
|
||||
|
||||
TEST_CASE("EthernetInterface") {
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::NONE) == "none");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I10GBE) == "10gbe");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE) == "3gbe");
|
||||
REQUIRE(ToString(sls::defs::EthernetInterface::I3GBE |
|
||||
sls::defs::EthernetInterface::I10GBE) == "3gbe, 10gbe");
|
||||
}
|
||||
Reference in New Issue
Block a user