DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::OksMethodImplementation Class Reference

OKS method implementation class. More...

#include <method.hpp>

Collaboration diagram for dunedaq::oks::OksMethodImplementation:
[legend]

Public Member Functions

 OksMethodImplementation (const std::string &language, const std::string &prototype, const std::string &body, OksMethod *p=nullptr)
 OKS method implementation constructor.
bool operator== (const class OksMethodImplementation &) const
const std::string & get_language () const noexcept
void set_language (const std::string &language)
 Set method implementation language.
const std::string & get_prototype () const noexcept
void set_prototype (const std::string &prototype)
 Set method implementation prototype.
const std::string & get_body () const noexcept
void set_body (const std::string &body)
 Set method implementation body.

Private Member Functions

 OksMethodImplementation (OksXmlInputStream &, OksMethod *)
void save (OksXmlOutputStream &) const

Private Attributes

std::string p_language
std::string p_prototype
std::string p_body
OksMethod * p_method

Static Private Attributes

static const char method_impl_xml_tag [] = "method-implementation"
static const char language_xml_attr [] = "language"
static const char prototype_xml_attr [] = "prototype"
static const char body_xml_attr [] = "body"

Friends

class OksKernel
class OksMethod
std::ostream & operator<< (std::ostream &s, const OksMethodImplementation &i)

Detailed Description

OKS method implementation class.

An OKS method may have implementations on different languages (e.g. "c++", "java", etc.). Implementations linked with a method shall have different languages. The method implementations are used by oksdalgen package generating DAL.

Definition at line 38 of file method.hpp.

Constructor & Destructor Documentation

◆ OksMethodImplementation() [1/2]

dunedaq::oks::OksMethodImplementation::OksMethodImplementation ( const std::string & language,
const std::string & prototype,
const std::string & body,
OksMethod * p = nullptr )

OKS method implementation constructor.

Create new OKS method implementation providing language, method prototype and body.

The parameters are:

Parameters
languageprogramming language used for given method implementation (max 16 bytes, see #s_max_language_length variable)
prototypeprototype of method implementation for selected programming language (max 1024 bytes, see #s_max_prototype_length variable)
bodyoptional body of method implementation (max 2048 bytes, see #s_max_body_length variable)
Exceptions
oks::exceptionis thrown in case of problems.

Definition at line 28 of file method.cpp.

32 : p_language(language)
33 , p_prototype(prototype)
34 , p_body(body)
35 , p_method(p)
36{
37 oks::validate_not_empty(p_language, "method implementation language");
38 oks::validate_not_empty(p_prototype, "method implementation prototype");
39}
void validate_not_empty(const std::string &value, const char *name)

◆ OksMethodImplementation() [2/2]

dunedaq::oks::OksMethodImplementation::OksMethodImplementation ( OksXmlInputStream & s,
OksMethod * parent )
private

Definition at line 77 of file method.cpp.

78 : p_method(parent)
79{
80 try {
81 while (true) {
82 OksXmlAttribute attr(s);
83
84 // check for close of tag
85
86 if (oks::cmp_str1(attr.name(), "/")) {
87 break;
88 }
89
90 // check for known oks-method-implementation' attributes
91
92 else if (oks::cmp_str8(attr.name(), language_xml_attr))
93 p_language.assign(attr.value(), attr.value_len());
94 else if (oks::cmp_str9(attr.name(), prototype_xml_attr))
95 p_prototype.assign(attr.value(), attr.value_len());
96 else if (oks::cmp_str4(attr.name(), body_xml_attr))
97 p_body.assign(attr.value(), attr.value_len());
98 else {
99 s.throw_unexpected_attribute(attr.name());
100 }
101 }
102 } catch (oks::exception& e) {
103 throw oks::FailedRead("xml method implementation", e);
104 } catch (std::exception& e) {
105 throw oks::FailedRead("xml method implementation", e.what());
106 }
107
108 try {
109 oks::validate_not_empty(p_language, "method implementation language");
110 oks::validate_not_empty(p_prototype, "method implementation prototype");
111 } catch (std::exception& ex) {
112 throw oks::FailedRead("oks method implementation", oks::BadFileData(ex.what(), s.get_line_no(), s.get_line_pos()));
113 }
114}
static const char prototype_xml_attr[]
Definition method.hpp:130
static const char language_xml_attr[]
Definition method.hpp:129
static const char body_xml_attr[]
Definition method.hpp:131
bool cmp_str8(const char *s1, const char s2[9])
Definition cstring.hpp:93
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:15
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:45
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:105

Member Function Documentation

◆ get_body()

const std::string & dunedaq::oks::OksMethodImplementation::get_body ( ) const
inlinenoexcept

Get body of method implementation.

Definition at line 101 of file method.hpp.

101{ return p_body; }

◆ get_language()

const std::string & dunedaq::oks::OksMethodImplementation::get_language ( ) const
inlinenoexcept

Get method implementation language.

Definition at line 69 of file method.hpp.

69{ return p_language; }

◆ get_prototype()

const std::string & dunedaq::oks::OksMethodImplementation::get_prototype ( ) const
inlinenoexcept

Get prototype of method implementation.

Definition at line 86 of file method.hpp.

86{ return p_prototype; }

◆ operator==()

bool dunedaq::oks::OksMethodImplementation::operator== ( const class OksMethodImplementation & i) const

Definition at line 42 of file method.cpp.

43{
44 return ((this == &i) || (p_language == i.p_language && p_prototype == i.p_prototype && p_body == i.p_body));
45}

◆ save()

void dunedaq::oks::OksMethodImplementation::save ( OksXmlOutputStream & s) const
private

Definition at line 64 of file method.cpp.

65{
66 s.put(" ");
67
68 s.put_start_tag(method_impl_xml_tag, sizeof(method_impl_xml_tag) - 1);
69
70 s.put_attribute(language_xml_attr, sizeof(language_xml_attr) - 1, get_language().c_str());
71 s.put_attribute(prototype_xml_attr, sizeof(prototype_xml_attr) - 1, get_prototype().c_str());
72 s.put_attribute(body_xml_attr, sizeof(body_xml_attr) - 1, get_body().c_str());
73
74 s.put_end_tag();
75}
const std::string & get_body() const noexcept
Definition method.hpp:101
const std::string & get_language() const noexcept
Definition method.hpp:69
const std::string & get_prototype() const noexcept
Definition method.hpp:86
static const char method_impl_xml_tag[]
Definition method.hpp:128

◆ set_body()

void dunedaq::oks::OksMethodImplementation::set_body ( const std::string & body)

Set method implementation body.

Parameters
bodynew method implementation body (max 2048 bytes, see #s_max_body_length variable) In case of problems the oks::exception is thrown.
Exceptions
oks::exceptionis thrown in case of problems.

Definition at line 486 of file method.cpp.

487{
488 if (p_body != s) {
489 if (p_method && p_method->p_class)
490 p_method->p_class->lock_file("OksMethodImplementation::set_body");
491
492 p_body = s;
493
494 if (p_method && p_method->p_class) {
496 }
497 }
498}
void registrate_class_change(ChangeType, const void *, bool=true)
Definition class.cpp:2009
void lock_file(const char *)
Definition class.cpp:733

◆ set_language()

void dunedaq::oks::OksMethodImplementation::set_language ( const std::string & language)

Set method implementation language.

Implementations linked with a method shall have different languages.

Parameters
languagenew method implementation language (max 16 bytes, see #s_max_language_length variable) In case of problems the oks::exception is thrown.
Exceptions
oks::exceptionis thrown in case of problems.

Definition at line 434 of file method.cpp.

435{
436 if (p_language != s) {
437 if (p_method) {
438 if (p_method->find_implementation(s) != 0) {
439 std::ostringstream text;
440 text << "cannot rename \"" << p_method->p_name << "\" method implementation to language \"" << s
441 << "\" "
442 "since the method already has implementation with such language.";
443 throw oks::SetOperationFailed("OksMethodImplementation::set_language", text.str());
444 }
445
446 try {
447 oks::validate_not_empty(s, "language");
448 } catch (std::exception& ex) {
449 throw oks::SetOperationFailed("OksMethodImplementation::set_language", ex.what());
450 }
451
452 if (p_method->p_class)
453 p_method->p_class->lock_file("OksMethodImplementation::set_language");
454 }
455
456 p_language = s;
457
458 if (p_method && p_method->p_class) {
460 }
461 }
462}
OksMethodImplementation * find_implementation(const std::string &language) const
Find method implementation.
Definition method.cpp:357

◆ set_prototype()

void dunedaq::oks::OksMethodImplementation::set_prototype ( const std::string & prototype)

Set method implementation prototype.

Parameters
prototypenew method implementation prototype (max 1024 bytes, see #s_max_prototype_length variable) In case of problems the oks::exception is thrown.
Exceptions
oks::exceptionis thrown in case of problems.

Definition at line 465 of file method.cpp.

466{
467 if (p_prototype != s) {
468 try {
469 oks::validate_not_empty(s, "prototype");
470 } catch (std::exception& ex) {
471 throw oks::SetOperationFailed("OksMethodImplementation::set_prototype", ex.what());
472 }
473
474 if (p_method && p_method->p_class)
475 p_method->p_class->lock_file("OksMethodImplementation::set_prototype");
476
477 p_prototype = s;
478
479 if (p_method && p_method->p_class) {
481 }
482 }
483}

◆ OksKernel

friend class OksKernel
friend

Definition at line 40 of file method.hpp.

◆ OksMethod

friend class OksMethod
friend

Definition at line 41 of file method.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const OksMethodImplementation & i )
friend

Definition at line 47 of file method.cpp.

49{
50 s << " Method implementation:\n"
51 " language: \""
52 << i.get_language()
53 << "\"\n"
54 " prototype: \""
55 << i.get_prototype()
56 << "\"\n"
57 " body: \""
58 << i.get_body() << "\"\n";
59
60 return s;
61}

Member Data Documentation

◆ body_xml_attr

const char dunedaq::oks::OksMethodImplementation::body_xml_attr = "body"
staticprivate

Definition at line 131 of file method.hpp.

◆ language_xml_attr

const char dunedaq::oks::OksMethodImplementation::language_xml_attr = "language"
staticprivate

Definition at line 129 of file method.hpp.

◆ method_impl_xml_tag

const char dunedaq::oks::OksMethodImplementation::method_impl_xml_tag = "method-implementation"
staticprivate

Definition at line 128 of file method.hpp.

◆ p_body

std::string dunedaq::oks::OksMethodImplementation::p_body
private

Definition at line 117 of file method.hpp.

◆ p_language

std::string dunedaq::oks::OksMethodImplementation::p_language
private

Definition at line 115 of file method.hpp.

◆ p_method

OksMethod* dunedaq::oks::OksMethodImplementation::p_method
private

Definition at line 119 of file method.hpp.

◆ p_prototype

std::string dunedaq::oks::OksMethodImplementation::p_prototype
private

Definition at line 116 of file method.hpp.

◆ prototype_xml_attr

const char dunedaq::oks::OksMethodImplementation::prototype_xml_attr = "prototype"
staticprivate

Definition at line 130 of file method.hpp.


The documentation for this class was generated from the following files: