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
 
OksMethodp_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 34 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 24 of file method.cpp.

24 :
25 p_language (language),
26 p_prototype (prototype),
27 p_body (body),
28 p_method (p)
29{
30 oks::validate_not_empty(p_language, "method implementation language");
31 oks::validate_not_empty(p_prototype, "method implementation prototype");
32}
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 70 of file method.cpp.

70 :
71 p_method (parent)
72{
73 try {
74 while(true) {
75 OksXmlAttribute attr(s);
76
77 // check for close of tag
78
79 if(oks::cmp_str1(attr.name(), "/")) { break; }
80
81 // check for known oks-method-implementation' attributes
82
83 else if( oks::cmp_str8(attr.name(), language_xml_attr) ) p_language.assign(attr.value(), attr.value_len());
84 else if( oks::cmp_str9(attr.name(), prototype_xml_attr) ) p_prototype.assign(attr.value(), attr.value_len());
85 else if( oks::cmp_str4(attr.name(), body_xml_attr) ) p_body.assign(attr.value(), attr.value_len());
86 else {
87 s.throw_unexpected_attribute(attr.name());
88 }
89 }
90 }
91 catch(oks::exception & e) {
92 throw oks::FailedRead("xml method implementation", e);
93 }
94 catch (std::exception & e) {
95 throw oks::FailedRead("xml method implementation", e.what());
96 }
97
98 try {
99 oks::validate_not_empty(p_language, "method implementation language");
100 oks::validate_not_empty(p_prototype, "method implementation prototype");
101 }
102 catch(std::exception& ex) {
103 throw oks::FailedRead("oks method implementation", oks::BadFileData(ex.what(), s.get_line_no(), s.get_line_pos()));
104 }
105}
static const char prototype_xml_attr[]
Definition method.hpp:133
static const char language_xml_attr[]
Definition method.hpp:132
static const char body_xml_attr[]
Definition method.hpp:134
bool cmp_str8(const char *s1, const char s2[9])
Definition cstring.hpp:61
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:9
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:29
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:69

Member Function Documentation

◆ get_body()

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

Get body of method implementation.

Definition at line 99 of file method.hpp.

99{return p_body;}

◆ get_language()

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

Get method implementation language.

Definition at line 63 of file method.hpp.

63{return p_language;}

◆ get_prototype()

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

Get prototype of method implementation.

Definition at line 82 of file method.hpp.

82{return p_prototype;}

◆ operator==()

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

Definition at line 35 of file method.cpp.

36{
37 return (
38 ( this == &i ) ||
39 ( p_language == i.p_language && p_prototype == i.p_prototype && p_body == i.p_body )
40 );
41}

◆ save()

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

Definition at line 56 of file method.cpp.

57{
58 s.put(" ");
59
60 s.put_start_tag(method_impl_xml_tag, sizeof(method_impl_xml_tag)-1);
61
62 s.put_attribute( language_xml_attr, sizeof(language_xml_attr)-1, get_language().c_str() );
63 s.put_attribute( prototype_xml_attr, sizeof(prototype_xml_attr)-1, get_prototype().c_str() );
64 s.put_attribute( body_xml_attr, sizeof(body_xml_attr)-1, get_body().c_str() );
65
66 s.put_end_tag();
67}
const std::string & get_body() const noexcept
Definition method.hpp:99
const std::string & get_language() const noexcept
Definition method.hpp:63
const std::string & get_prototype() const noexcept
Definition method.hpp:82
static const char method_impl_xml_tag[]
Definition method.hpp:131

◆ 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 475 of file method.cpp.

476{
477 if(p_body != s) {
478 if(p_method && p_method->p_class) p_method->p_class->lock_file("OksMethodImplementation::set_body");
479
480 p_body = s;
481
482 if(p_method && p_method->p_class) {
484 }
485 }
486}
void registrate_class_change(ChangeType, const void *, bool=true)
Definition class.cpp:2035
void lock_file(const char *)
Definition class.cpp:766

◆ 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 424 of file method.cpp.

425{
426 if(p_language != s) {
427 if(p_method) {
428 if(p_method->find_implementation(s) != 0) {
429 std::ostringstream text;
430 text << "cannot rename \"" << p_method->p_name << "\" method implementation to language \"" << s << "\" "
431 "since the method already has implementation with such language.";
432 throw oks::SetOperationFailed("OksMethodImplementation::set_language", text.str());
433 }
434
435 try {
436 oks::validate_not_empty(s, "language");
437 }
438 catch(std::exception& ex) {
439 throw oks::SetOperationFailed("OksMethodImplementation::set_language", ex.what());
440 }
441
442 if(p_method->p_class) p_method->p_class->lock_file("OksMethodImplementation::set_language");
443 }
444
445 p_language = s;
446
447 if(p_method && p_method->p_class) {
449 }
450 }
451}
OksMethodImplementation * find_implementation(const std::string &language) const
Find method implementation.
Definition method.cpp:354

◆ 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 454 of file method.cpp.

455{
456 if(p_prototype != s) {
457 try {
458 oks::validate_not_empty(s, "prototype");
459 }
460 catch(std::exception& ex) {
461 throw oks::SetOperationFailed("OksMethodImplementation::set_prototype", ex.what());
462 }
463
464 if(p_method && p_method->p_class) p_method->p_class->lock_file("OksMethodImplementation::set_prototype");
465
466 p_prototype = s;
467
468 if(p_method && p_method->p_class) {
470 }
471 }
472}

Friends And Related Symbol Documentation

◆ OksKernel

friend class OksKernel
friend

Definition at line 36 of file method.hpp.

◆ OksMethod

friend class OksMethod
friend

Definition at line 37 of file method.hpp.

◆ operator<<

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

Definition at line 43 of file method.cpp.

45{
46 s << " Method implementation:\n"
47 " language: \"" << i.get_language() << "\"\n"
48 " prototype: \"" << i.get_prototype() << "\"\n"
49 " body: \"" << i.get_body() << "\"\n";
50
51 return s;
52}

Member Data Documentation

◆ body_xml_attr

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

Definition at line 134 of file method.hpp.

◆ language_xml_attr

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

Definition at line 132 of file method.hpp.

◆ method_impl_xml_tag

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

Definition at line 131 of file method.hpp.

◆ p_body

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

Definition at line 118 of file method.hpp.

◆ p_language

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

Definition at line 116 of file method.hpp.

◆ p_method

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

Definition at line 120 of file method.hpp.

◆ p_prototype

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

Definition at line 117 of file method.hpp.

◆ prototype_xml_attr

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

Definition at line 133 of file method.hpp.


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