| helics 3.6.1

cpp98/Translator.hpp
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #ifndef HELICS_CPP98_TRANSLATOR_HPP_
8 #define HELICS_CPP98_TRANSLATOR_HPP_
9
10 #include "DataBuffer.hpp"
11 #include "helics/helics.h"
12 #include "helicsExceptions.hpp"
13
14 #include <string>
15
16 namespace helicscpp {
18 class Translator {
19 public:
21 explicit Translator(HelicsTranslator htrans) HELICS_NOTHROW: translator(htrans) {}
23 Translator() HELICS_NOTHROW: translator(HELICS_NULL_POINTER) {}
25 Translator(const Translator& trans): translator(trans.translator) {}
27 Translator& operator=(const Translator& translatorer)
28 {
29 translator = translatorer.translator;
30 return *this;
31 }
32
34 operator HelicsTranslator() const { return translator; }
36 HelicsTranslator baseObject() const { return translator; }
38 bool isValid() const { return (helicsTranslatorIsValid(translator) == HELICS_TRUE); }
40 const char* getName() const { return helicsTranslatorGetName(translator); }
45 void set(const std::string& property, double val)
46 {
47 helicsTranslatorSet(translator, property.c_str(), val, hThrowOnError());
48 }
53 void setString(const std::string& property, const std::string& val)
54 {
55 helicsTranslatorSetString(translator, property.c_str(), val.c_str(), hThrowOnError());
56 }
57
60 void addDestinationEndpoint(const std::string& dest)
61 {
62 helicsTranslatorAddDestinationEndpoint(translator, dest.c_str(), hThrowOnError());
63 }
64
67 void addSourceEndpoint(const std::string& source)
68 {
69 helicsTranslatorAddSourceEndpoint(translator, source.c_str(), hThrowOnError());
70 }
71
74 void addDestinationInput(const std::string& dest)
75 {
76 helicsTranslatorAddInputTarget(translator, dest.c_str(), hThrowOnError());
77 }
78
81 void addSourcePublication(const std::string& source)
82 {
83 helicsTranslatorAddPublicationTarget(translator, source.c_str(), hThrowOnError());
84 }
86 void removeTarget(const std::string& dest)
87 {
88 helicsTranslatorRemoveTarget(translator, dest.c_str(), hThrowOnError());
89 }
91 const char* getInfo() const { return helicsTranslatorGetInfo(translator); }
93 void setInfo(const std::string& info)
94 {
95 helicsTranslatorSetInfo(translator, info.c_str(), HELICS_IGNORE_ERROR);
96 }
98 const char* getTag(const std::string& tagname) const
99 {
100 return helicsTranslatorGetTag(translator, tagname.c_str());
101 }
103 void setTag(const std::string& tagname, const std::string& tagvalue)
104 {
105 helicsTranslatorSetTag(translator, tagname.c_str(), tagvalue.c_str(), HELICS_IGNORE_ERROR);
106 }
107 void setOption(int32_t option, int32_t value = 1)
108 {
109 helicsTranslatorSetOption(translator, option, value, HELICS_IGNORE_ERROR);
110 }
111 int32_t getOption(int32_t option) { return helicsTranslatorGetOption(translator, option); }
112
113 /*
114 void setCallback(HelicsMessage (*translatorCall)(HelicsMessage message, void* userData),
115 void* userData)
116 {
117 helicsTranslatorSetCustomCallback(translator, translatorCall, userData,
118 HELICS_IGNORE_ERROR);
119 }
120 */
121 protected:
122 HelicsTranslator translator;
123 };
124
125 } // namespace helicscpp
126 #endif
helicsTranslatorSetString
void helicsTranslatorSetString(HelicsTranslator trans, const char *prop, const char *val, HelicsError *err)
Definition: TranslatorExport.cpp:276
helicsTranslatorAddDestinationEndpoint
void helicsTranslatorAddDestinationEndpoint(HelicsTranslator trans, const char *ept, HelicsError *err)
Definition: TranslatorExport.cpp:325
helicsTranslatorGetName
const char * helicsTranslatorGetName(HelicsTranslator trans)
Definition: TranslatorExport.cpp:251
helicsTranslatorAddInputTarget
void helicsTranslatorAddInputTarget(HelicsTranslator trans, const char *input, HelicsError *err)
Definition: TranslatorExport.cpp:291
helicsTranslatorAddPublicationTarget
void helicsTranslatorAddPublicationTarget(HelicsTranslator trans, const char *pub, HelicsError *err)
Definition: TranslatorExport.cpp:308
helicsTranslatorSet
void helicsTranslatorSet(HelicsTranslator trans, const char *prop, double val, HelicsError *err)
Definition: TranslatorExport.cpp:261
helicsTranslatorIsValid
HelicsBool helicsTranslatorIsValid(HelicsTranslator trans)
Definition: TranslatorExport.cpp:241
helicsTranslatorAddSourceEndpoint
void helicsTranslatorAddSourceEndpoint(HelicsTranslator trans, const char *ept, HelicsError *err)
Definition: TranslatorExport.cpp:342
HelicsTranslator
void * HelicsTranslator
Definition: api-data.h:48
HELICS_TRUE
const HelicsBool HELICS_TRUE
Definition: api-data.h:120
helicscpp::Translator
Definition: cpp98/Translator.hpp:18
helicscpp::Translator::setString
void setString(const std::string &property, const std::string &val)
Definition: cpp98/Translator.hpp:53
helicscpp::Translator::setInfo
void setInfo(const std::string &info)
Definition: cpp98/Translator.hpp:93
helicscpp::Translator::translator
HelicsTranslator translator
the reference to the underlying HelicsTranslator object
Definition: cpp98/Translator.hpp:122
helicscpp::Translator::set
void set(const std::string &property, double val)
Definition: cpp98/Translator.hpp:45
helicscpp::Translator::setTag
void setTag(const std::string &tagname, const std::string &tagvalue)
Definition: cpp98/Translator.hpp:103
helicscpp::Translator::operator=
Translator & operator=(const Translator &translatorer)
Definition: cpp98/Translator.hpp:27
helicscpp::Translator::getInfo
const char * getInfo() const
Definition: cpp98/Translator.hpp:91
helicscpp::Translator::baseObject
HelicsTranslator baseObject() const
Definition: cpp98/Translator.hpp:36
helicscpp::Translator::Translator
Translator(HelicsTranslator htrans) HELICS_NOTHROW
Definition: cpp98/Translator.hpp:21
helicscpp::Translator::addSourcePublication
void addSourcePublication(const std::string &source)
Definition: cpp98/Translator.hpp:81
helicscpp::Translator::Translator
Translator() HELICS_NOTHROW
Definition: cpp98/Translator.hpp:23
helicscpp::Translator::isValid
bool isValid() const
Definition: cpp98/Translator.hpp:38
helicscpp::Translator::addSourceEndpoint
void addSourceEndpoint(const std::string &source)
Definition: cpp98/Translator.hpp:67
helicscpp::Translator::getTag
const char * getTag(const std::string &tagname) const
Definition: cpp98/Translator.hpp:98
helicscpp::Translator::addDestinationEndpoint
void addDestinationEndpoint(const std::string &dest)
Definition: cpp98/Translator.hpp:60
helicscpp::Translator::removeTarget
void removeTarget(const std::string &dest)
Definition: cpp98/Translator.hpp:86
helicscpp::Translator::getName
const char * getName() const
Definition: cpp98/Translator.hpp:40
helicscpp::Translator::Translator
Translator(const Translator &trans)
Definition: cpp98/Translator.hpp:25
helicscpp::Translator::addDestinationInput
void addDestinationInput(const std::string &dest)
Definition: cpp98/Translator.hpp:74
helicscpp::hThrowOnError
Definition: helicsExceptions.hpp:38
helicsTranslatorSetOption
void helicsTranslatorSetOption(HelicsTranslator trans, int option, int value, HelicsError *err)
Definition: TranslatorExport.cpp:442
helicsTranslatorSetTag
void helicsTranslatorSetTag(HelicsTranslator trans, const char *tagname, const char *tagvalue, HelicsError *err)
Definition: TranslatorExport.cpp:426
helicsTranslatorGetOption
int helicsTranslatorGetOption(HelicsTranslator trans, int option)
Definition: TranslatorExport.cpp:458
helicsTranslatorGetInfo
const char * helicsTranslatorGetInfo(HelicsTranslator trans)
Definition: TranslatorExport.cpp:376
helicsTranslatorRemoveTarget
void helicsTranslatorRemoveTarget(HelicsTranslator trans, const char *target, HelicsError *err)
Definition: TranslatorExport.cpp:359
helicsTranslatorGetTag
const char * helicsTranslatorGetTag(HelicsTranslator trans, const char *tagname)
Definition: TranslatorExport.cpp:409
helicsTranslatorSetInfo
void helicsTranslatorSetInfo(HelicsTranslator trans, const char *info, HelicsError *err)
Definition: TranslatorExport.cpp:393
helicscpp
Definition: cpp98/Broker.hpp:18