DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
class.cpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
3// Fork baseline commit: oks-08-03-04 (2022-04-14).
4// Renamed since fork: no.
5
6#define _OksBuildDll_
7
8#include "oks/class.hpp"
9#include "oks/cstring.hpp"
10#include "oks/index.hpp"
11#include "oks/kernel.hpp"
12#include "oks/method.hpp"
13#include "oks/object.hpp"
14#include "oks/profiler.hpp"
15#include "oks/relationship.hpp"
16#include "oks/xml.hpp"
17
18#include "ers/ers.hpp"
19#include "logging/Logging.hpp"
20
21#include <stdlib.h>
22
23#include <algorithm>
24#include <stdexcept>
25#include <string>
26
27namespace dunedaq {
28namespace oks {
29
30const char OksClass::class_xml_tag[] = "class";
31const char OksClass::name_xml_attr[] = "name";
32const char OksClass::description_xml_attr[] = "description";
33const char OksClass::is_abstract_xml_attr[] = "is-abstract";
34const char OksClass::superclass_xml_attr[] = "superclass";
35
39
40std::string
41CannotFindSuperClass::fill(const OksClass& c, const std::string& name) noexcept
42{
43 return std::string("cannot find superclass \'") + name + "\' of class \'" + c.get_name() + '\'';
44}
45
46std::string
47AttributeConversionFailed::fill(const OksAttribute& a, const OksObject* o, const std::string& reason) noexcept
48{
49 std::ostringstream s;
50 s << "failed to convert \'" << a.get_name() << "\" value of object " << o << " because:\n" + reason;
51 return s.str();
52}
53
54std::string
55CannotRegisterClass::fill(const OksClass& c, const std::string& what, const std::string& reason) noexcept
56{
57 return std::string("cannot register class \'") + c.get_name() + "\' " + what + "because:\n" + reason;
58}
59
60std::string
61CannotDestroyClass::fill(const OksClass& c, const std::string& reason) noexcept
62{
63 return std::string("cannot destroy class \'") + c.get_name() + "\' because:\n" + reason;
64}
65
66std::string
68 const std::string& oid,
69 const char* op,
70 const std::string& reason) noexcept
71{
72 return std::string("cannot ") + op + " object \'" + oid + "\' in class \'" + c.get_name() + "\' because:\n" + reason;
73}
74
75std::string
76SetOperationFailed::fill(const char* op, const std::string& reason) noexcept
77{
78 return std::string("method \'") + op + "()\' failed because:\n" + reason;
79}
80
81OksClass::OksClass(const std::string& nm, OksKernel* k, bool t)
82 : p_name(nm)
84 , p_attributes(0)
86 , p_methods(0)
87 , p_abstract(false)
88 , p_transient(t)
89 , p_to_be_deleted(false)
94 , p_all_methods(0)
96 , p_kernel(k)
98 , p_data_info(0)
99 , p_objects(0)
100 , p_indices(0)
101{
103
104 if (p_transient == false && p_kernel) {
105 oks::validate_not_empty(p_name, "class name");
106
107 std::unique_lock lock(p_kernel->p_kernel_mutex);
108 p_kernel->k_add(this);
109 }
110}
111
112OksClass::OksClass(const std::string& nm, const std::string& d, bool a, OksKernel* k, bool t)
113 : p_name(nm)
114 , p_description(d)
115 , p_super_classes(0)
116 , p_attributes(0)
117 , p_relationships(0)
118 , p_methods(0)
119 , p_abstract(a)
120 , p_transient(t)
121 , p_to_be_deleted(false)
126 , p_all_methods(0)
128 , p_kernel(k)
129 , p_instance_size(0)
130 , p_data_info(0)
131 , p_objects(0)
132 , p_indices(0)
133{
135
136 if (p_transient == false && p_kernel) {
137 oks::validate_not_empty(p_name, "class name");
138
139 std::unique_lock lock(p_kernel->p_kernel_mutex);
140 p_kernel->k_add(this);
141 }
142}
143
144OksClass::OksClass(OksKernel* kernel, const std::string& name, const std::string& description, bool is_abstract)
145 : p_name(name)
146 , p_description(description)
147 , p_super_classes(0)
148 , p_attributes(0)
149 , p_relationships(0)
150 , p_methods(0)
151 , p_abstract(is_abstract)
152 , p_transient(false)
153 , p_to_be_deleted(false)
158 , p_all_methods(0)
160 , p_file(kernel->p_active_schema)
161 , p_kernel(kernel)
162 , p_instance_size(0)
163 , p_data_info(0)
164 , p_objects(0)
165 , p_indices(0)
166{
168 p_kernel->p_classes[p_name.c_str()] = this;
169}
170
171void
173{
174 // obtain write mutex, if non-transient class is registered in the oks kernel
175
176 if (!c->p_transient && c->p_kernel) {
177 std::unique_lock lock(c->p_kernel->p_kernel_mutex);
178
179 try {
180 c->p_file->lock();
181 c->p_file->set_updated();
182 } catch (oks::exception& ex) {
183 throw oks::CannotDestroyClass(*c, ex);
184 }
185
186 delete c;
187 }
188
189 // destroy class without get write mutex
190
191 else {
192 delete c;
193 }
194}
195
196template<class T>
197void
199{
200 if (list) {
201 for (const auto& x : *list)
202 delete x;
203
204 delete list;
205 }
206}
207
208template<class T>
209void
211{
212 if (map) {
213 for (const auto& x : *map)
214 delete x.second;
215
216 delete map;
217 }
218}
219
221{
223
224 TLOG_DEBUG(2) << "destruct " << (p_transient ? "TRANSIENT" : "NORMAL") << " class \'" << get_name() << '\'';
225
226 // ~OksIndex() removes 'SELF' from OksClass and deletes 'indices' when there is no an index in it
227 while (p_indices)
228 delete (*(p_indices->begin())).second;
229
232
233 if (!p_transient && p_kernel) {
234 p_kernel->k_remove(this);
235
237 for (const auto& c : *p_all_super_classes) {
238 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
239 continue;
240
241 c->create_sub_classes();
242
244 (*OksClass::change_notify_fn)(c, ChangeSubClassesList, (const void*)&p_name);
245 }
246
248 for (const auto& c : *p_all_sub_classes) {
249 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
250 continue;
251
252 try {
253 c->registrate_class_change(ChangeSuperClassesList, (const void*)&p_name, false);
254 } catch (oks::exception& ex) {
255 std::cerr << "internal OKS error: registrate_class_change() failed during \'" << get_name()
256 << "\' class destruction\ncaused by: " << ex.what() << std::endl;
257 }
258 }
259 }
260
265
266 if (!p_transient) {
267 delete p_all_super_classes;
268 delete p_all_sub_classes;
269 delete p_all_attributes;
270 delete p_all_relationships;
271 delete p_all_methods;
273 }
274}
275
276void
277OksClass::set_file(OksFile* f, bool update_owner)
278{
279 if (p_file != f) {
280 try {
281 if (update_owner) {
282 p_file->lock();
284 }
285
286 f->lock();
287 f->set_updated();
288
289 p_file = f;
290 } catch (oks::exception& ex) {
291 throw oks::CanNotSetFile(this, 0, *f, ex);
292 }
293 }
294}
295
296bool
298{
299 if (this == &c)
300 return true;
301
302 if ((p_name != c.p_name) || (p_description != c.p_description) || (p_abstract != c.p_abstract))
303 return false;
304
305 int l1 = (p_attributes == 0) ? 0 : p_attributes->size();
306 int l2 = (c.p_attributes == 0) ? 0 : c.p_attributes->size();
307
308 if (l1 != l2)
309 return false;
310
311 if (l1 > 0) {
312 std::list<OksAttribute*>::const_iterator i1 = p_attributes->begin();
313 std::list<OksAttribute*>::const_iterator i2 = c.p_attributes->begin();
314
315 for (; i1 != p_attributes->end(); ++i1, ++i2)
316 if (!(*(*i1) == *(*i2)))
317 return false;
318 }
319
320 l1 = (p_relationships == 0) ? 0 : p_relationships->size();
321 l2 = (c.p_relationships == 0) ? 0 : c.p_relationships->size();
322
323 if (l1 != l2)
324 return false;
325
326 if (l1 > 0) {
327 std::list<OksRelationship*>::const_iterator i1 = p_relationships->begin();
328 std::list<OksRelationship*>::const_iterator i2 = c.p_relationships->begin();
329
330 for (; i1 != p_relationships->end(); ++i1, ++i2)
331 if (!(*(*i1) == *(*i2)))
332 return false;
333 }
334
335 l1 = (p_super_classes == 0) ? 0 : p_super_classes->size();
336 l2 = (c.p_super_classes == 0) ? 0 : c.p_super_classes->size();
337
338 if (l1 != l2)
339 return false;
340
341 if (l1 > 0) {
342 std::list<std::string*>::const_iterator i1 = p_super_classes->begin();
343 std::list<std::string*>::const_iterator i2 = c.p_super_classes->begin();
344
345 for (; i1 != p_super_classes->end(); ++i1, ++i2)
346 if (!(*(*i1) == *(*i2)))
347 return false;
348 }
349
350 return true;
351}
352
353bool
355{
356 if (this == &c)
357 return false;
358
359 if (compare_without_methods(c) == false)
360 return true;
361
362 int l1 = (p_methods == 0) ? 0 : p_methods->size();
363 int l2 = (c.p_methods == 0) ? 0 : c.p_methods->size();
364
365 if (l1 != l2)
366 return true;
367
368 if (l1 > 0) {
369 std::list<OksMethod*>::const_iterator i1 = p_methods->begin();
370 std::list<OksMethod*>::const_iterator i2 = c.p_methods->begin();
371
372 for (; i1 != p_methods->end(); ++i1, ++i2)
373 if (!(*(*i1) == *(*i2)))
374 return true;
375 }
376
377 return false;
378}
379
380std::ostream&
381operator<<(std::ostream& s, const OksClass& c)
382{
384
385 s << "Class name: \"" << c.p_name
386 << "\"\n"
387 " has description: \""
388 << c.p_description << "\"\n"
389 << (c.p_abstract == true ? " is abstract\n" : " is not abstract\n");
390
391 if (c.p_super_classes) {
392 s << "The class has superclasses:\n";
393 for (std::list<std::string*>::const_iterator i = c.p_super_classes->begin(); i != c.p_super_classes->end(); ++i) {
394 s << " - " << *(*i) << std::endl;
395 }
396 } else
397 s << "The class has no superclasses\n";
398
399 if (c.p_attributes) {
400 s << "The attributes are:\n";
401 for (std::list<OksAttribute*>::const_iterator i = c.p_attributes->begin(); i != c.p_attributes->end(); ++i) {
402 s << *(*i);
403 }
404 } else
405 s << "There are no attributes\n";
406
407 if (c.p_relationships) {
408 s << "The relationships are:\n";
409 for (std::list<OksRelationship*>::const_iterator i = c.p_relationships->begin(); i != c.p_relationships->end();
410 ++i) {
411 s << *(*i);
412 }
413 } else
414 s << "There are no relationships\n";
415
416 if (c.p_methods) {
417 s << "The methods are:\n";
418 for (std::list<OksMethod*>::const_iterator i = c.p_methods->begin(); i != c.p_methods->end(); ++i) {
419 s << *(*i);
420 }
421 } else
422 s << "There are no methods\n";
423
424 if (c.p_objects) {
425 OksObject::SMap sorted;
426
427 s << "The objects are:\n";
428
429 for (OksObject::Map::iterator i = c.p_objects->begin(); i != c.p_objects->end(); ++i) {
430 sorted[i->first] = i->second;
431 }
432
433 for (OksObject::SMap::iterator i = sorted.begin(); i != sorted.end(); ++i) {
434 s << *(i->second);
435 }
436 } else
437 s << "There are no objects\n";
438
439 s << "End of Class \"" << c.p_name << "\"\n";
440
441 return s;
442}
443
444void
446{
447 try {
448 s.put_raw(' ');
449 s.put_start_tag(class_xml_tag, sizeof(class_xml_tag) - 1);
450 s.put_attribute(name_xml_attr, sizeof(name_xml_attr) - 1, p_name.c_str());
451
452 // store non-empty description only
453 if (!p_description.empty())
454 s.put_attribute(description_xml_attr, sizeof(description_xml_attr) - 1, p_description.c_str());
455
456 // store abstract attribute only when the class is abstract
457 if (p_abstract)
459
460 s.put_raw('>');
461 s.put_raw('\n');
462
463 if (p_super_classes)
464 for (const auto& i : *p_super_classes) {
465 s.put_raw(' ');
466 s.put_raw(' ');
467 s.put_start_tag(superclass_xml_attr, sizeof(superclass_xml_attr) - 1);
468 s.put_attribute(name_xml_attr, sizeof(name_xml_attr) - 1, i->c_str());
469 s.put_end_tag();
470 }
471
472 if (p_attributes)
473 for (const auto& i : *p_attributes)
474 i->save(s);
475
476 if (p_relationships)
477 for (const auto& i : *p_relationships)
478 i->save(s);
479
480 if (p_methods)
481 for (const auto& i : *p_methods)
482 i->save(s);
483
484 s.put_raw(' ');
485 s.put_last_tag(class_xml_tag, sizeof(class_xml_tag) - 1);
486 s.put_raw('\n');
487 }
488
489 catch (oks::exception& e) {
490 throw oks::FailedSave("oks-class", p_name, e);
491 }
492
493 catch (std::exception& e) {
494 throw oks::FailedSave("oks-class", p_name, e.what());
495 }
496}
497
499 : p_super_classes(0)
500 , p_attributes(0)
501 , p_relationships(0)
502 , p_methods(0)
503 , p_abstract(false)
504 , p_transient(false)
505 , p_to_be_deleted(false)
510 , p_all_methods(0)
512 , p_kernel(k)
513 , p_instance_size(0)
514 , p_data_info(0)
515 , p_objects(0)
516 , p_indices(0)
517{
518
519 // read 'relationship' tag header
520
521 {
522 try {
523 const char* tag_start = s.get_tag_start();
524
525 if (strcmp(tag_start, class_xml_tag)) {
526 if (!strcmp(tag_start, "/oks-schema")) {
527 goto end_of_stream; // re-throw of exception takes too much time; go to is better
528 }
529 s.throw_unexpected_tag(tag_start, class_xml_tag);
530 }
531 } catch (oks::exception& e) {
532 throw oks::FailedRead("oks-class tag", e);
533 } catch (std::exception& e) {
534 throw oks::FailedRead("oks-class tag", e.what());
535 }
536 }
537
538 // read class attributes
539
540 try {
541 while (true) {
542 OksXmlAttribute attr(s);
543
544 // check for close of tag
545
546 if (oks::cmp_str1(attr.name(), ">")) {
547 break;
548 }
549
550 // check for known oks-class' attributes
551
552 else if (oks::cmp_str4(attr.name(), name_xml_attr))
553 p_name.assign(attr.value(), attr.value_len());
554 else if (oks::cmp_str11(attr.name(), description_xml_attr))
555 p_description.assign(attr.value(), attr.value_len());
556 else if (oks::cmp_str11(attr.name(), is_abstract_xml_attr))
558 else {
559 s.throw_unexpected_tag(attr.name(), "oks-class\' attribute");
560 }
561 }
562 } catch (oks::exception& e) {
563 throw oks::FailedRead("oks-class description", e);
564 } catch (std::exception& e) {
565 throw oks::FailedRead("oks-class description", e.what());
566 }
567
568 try {
569 oks::validate_not_empty(p_name, "class name");
570 } catch (std::exception& ex) {
571 throw oks::FailedRead("oks class", oks::BadFileData(ex.what(), s.get_line_no(), s.get_line_pos()));
572 }
573
574 // read class body
575
576 while (true) {
577
578 try {
579
580 const char* tag_start = s.get_tag_start();
581
582 // check for closing tag and exit loop
583
584 if (oks::cmp_str6(tag_start, "/class")) {
585 break;
586 }
587
588 // create superclass
589
590 else if (oks::cmp_str10(tag_start, superclass_xml_attr)) {
591 unsigned long scl_pos = s.get_line_no();
592 try {
593 OksXmlAttribute attr(s);
594
595 if (!p_super_classes)
596 p_super_classes = new std::list<std::string*>();
597 std::string* scl = new std::string(attr.value(), attr.value_len());
598 if (has_direct_super_class(*scl)) {
599 std::ostringstream text;
600 text << "second inclusion of super-class \"" + *scl + "\" at line " << scl_pos;
601 delete scl;
602 throw std::runtime_error(text.str().c_str());
603 }
604 p_super_classes->push_back(scl);
605
606 OksXmlAttribute attr2(s);
607 } catch (oks::exception& e) {
608 throw oks::FailedRead(std::string("a superclass-name of class \"") + p_name + '\"', e);
609 } catch (std::exception& e) {
610 throw oks::FailedRead(std::string("a superclass-name of class \"") + p_name + '\"', e.what());
611 }
612 }
613
614 // create attribute from stream and check attribute status
615
616 else if (oks::cmp_str9(tag_start, "attribute")) {
617 unsigned long attr_pos = s.get_line_no();
618 try {
619 if (!p_attributes)
620 p_attributes = new std::list<OksAttribute*>();
621 OksAttribute* a = new OksAttribute(s, this);
622 if (find_direct_attribute(a->get_name()) != nullptr) {
623 std::ostringstream text;
624 text << "redefinition of attribute with name \"" + a->get_name() + "\" at line " << attr_pos;
625 delete a;
626 throw std::runtime_error(text.str().c_str());
627 }
628 p_attributes->push_back(a);
629 } catch (oks::exception& e) {
630 throw oks::FailedRead(std::string("an attribute of class \"") + p_name + '\"', e);
631 } catch (std::exception& e) {
632 throw oks::FailedRead(std::string("an attribute of class \"") + p_name + '\"', e.what());
633 }
634 }
635
636 // create relationship from stream and check relationship status
637
638 else if (oks::cmp_str12(tag_start, "relationship")) {
639 unsigned long rel_pos = s.get_line_no();
640 try {
641 if (!p_relationships)
642 p_relationships = new std::list<OksRelationship*>();
643 OksRelationship* r = new OksRelationship(s, this);
644 if (find_direct_relationship(r->get_name()) != nullptr) {
645 std::ostringstream text;
646 text << "redefinition of relationship with name \"" + r->get_name() + "\" at line " << rel_pos;
647 delete r;
648 throw std::runtime_error(text.str().c_str());
649 }
650 p_relationships->push_back(r);
651 } catch (oks::exception& e) {
652 throw oks::FailedRead(std::string("a relationship of class \"") + p_name + '\"', e);
653 } catch (std::exception& e) {
654 throw oks::FailedRead(std::string("a relationship of class \"") + p_name + '\"', e.what());
655 }
656 }
657
658 // create method from stream and check method status
659
660 else if (oks::cmp_str6(tag_start, "method")) {
661 unsigned long method_pos = s.get_line_no();
662 try {
663 if (!p_methods)
664 p_methods = new std::list<OksMethod*>();
665 OksMethod* m = new OksMethod(s, this);
666 if (find_direct_method(m->get_name()) != nullptr) {
667 std::ostringstream text;
668 text << "redefinition of method with name \"" + m->get_name() + "\" at line " << method_pos;
669 delete m;
670 throw std::runtime_error(text.str().c_str());
671 }
672 p_methods->push_back(m);
673 } catch (oks::exception& e) {
674 throw oks::FailedRead(std::string("a method of class \"") + p_name + '\"', e);
675 } catch (std::exception& e) {
676 throw oks::FailedRead(std::string("a method of class \"") + p_name + '\"', e.what());
677 }
678 }
679
680 // report error if red something differnt from above
681 // and set bad status of constructor (suppose 'name' can't be empty)
682
683 else {
684 s.throw_unexpected_tag(tag_start);
685 }
686
687 } catch (oks::FailedRead& e) {
688 throw; // re-throw attribute, relationship or method exception
689 } catch (oks::exception& e) {
690 throw oks::FailedRead(std::string("a tag of class \"") + p_name + '\"', e);
691 } catch (std::exception& e) {
692 throw oks::FailedRead(std::string("a tag of class \"") + p_name + '\"', e.what());
693 }
694 }
695
696 return;
697
698end_of_stream:
699
700 throw oks::EndOfXmlStream("oks-schema");
701}
702
703/******************************************************************************/
704/****************************** OKS SUPERCLASSES ******************************/
705/******************************************************************************/
706
708OksClass::find_super_class(const std::string& nm) const noexcept
709{
710 if (p_all_super_classes && !p_all_super_classes->empty()) {
711 for (FList::const_iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
712 if ((*i)->get_name() == nm)
713 return *i;
714 }
715 }
716
717 return 0;
718}
719
720bool
721OksClass::has_direct_super_class(const std::string& nm) const noexcept
722{
723 if (p_super_classes) {
724 for (std::list<std::string*>::const_iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i)
725 if (nm == *(*i))
726 return true;
727 }
728
729 return false;
730}
731
732void
733OksClass::lock_file(const char* fname)
734{
735 if (p_kernel) {
736 try {
737 p_file->lock();
738 } catch (oks::exception& ex) {
739 throw oks::SetOperationFailed(fname, ex);
740 }
741 }
742}
743
744void
745OksClass::set_description(const std::string& s)
746{
747 if (p_description != s) {
748 lock_file("OksClass::set_description");
749
750 p_description = s;
751
752 if (p_kernel) {
755 (*OksClass::change_notify_fn)(this, ChangeDescription, 0);
756 }
757 }
758 }
759}
760
761void
763{
764 if (p_abstract != b) {
765 lock_file("OksClass::set_is_abstract");
766
767 p_abstract = b;
768
769 if (p_kernel) {
772 (*OksClass::change_notify_fn)(this, ChangeIsAbstaract, 0);
773 }
774 }
775 }
776}
777
778// Function to report problem with arguments of swap(...) methods
779
780static void
781check_and_report_empty_parameter(const char* fname, bool b1, bool b2)
782{
783 if (b1) {
784 throw oks::SetOperationFailed(fname, "First parameter is (null)");
785 }
786
787 if (b2) {
788 throw oks::SetOperationFailed(fname, "Second parameter is (null)");
789 }
790}
791
792// Function to report problem with found items of swap(...) methods
793
794static void
796 const char* item_type,
797 const std::string& item1_name,
798 const std::string& item2_name,
799 const std::string& class_name,
800 bool b1,
801 bool b2)
802{
803 struct
804 {
805 bool b;
806 const std::string* name;
807 } info[] = { { b1, &item1_name }, { b2, &item2_name } };
808
809 for (int i = 0; i < 2; ++i) {
810 if (info[i].b) {
811 std::string text("cannot find direct ");
812 text += item_type;
813 text += " \"";
814 text += *info[i].name;
815 text += "\" in class \"";
816 text += class_name;
817 text += '\"';
818 throw oks::SetOperationFailed(fname, text);
819 }
820 }
821}
822
823static std::string
824add_super_class_error(const std::string& c1, const std::string& c2)
825{
826 return (std::string("cannot add superclass \"") + c1 + "\" to class \"" + c2 + '\"');
827}
828
829void
830OksClass::k_add_super_class(const std::string& nm)
831{
832 if (!p_super_classes) {
833 p_super_classes = new std::list<std::string*>();
834 }
835
836 p_super_classes->push_back((new std::string(nm)));
837}
838
839void
840OksClass::add_super_class(const std::string& nm)
841{
842 if (!p_super_classes) {
843 p_super_classes = new std::list<std::string*>();
844 } else {
845 if (has_direct_super_class(nm)) {
846 std::string text(add_super_class_error(nm, p_name));
847 text += " because class \"" + p_name + "\" already has such superclass.";
848 throw oks::SetOperationFailed("OksClass::add_super_class", text);
849 }
850 }
851
852 if (nm == p_name) {
853 std::string text(add_super_class_error(nm, p_name));
854 text += " because names of classes are the same.";
855 throw oks::SetOperationFailed("OksClass::add_super_class", text);
856 }
857
858 if (p_kernel) {
859 OksClass* nmc = p_kernel->find_class(nm);
860 if (nmc) {
861 if (nmc->has_direct_super_class(p_name)) {
862 std::string text(add_super_class_error(nm, p_name));
863 text += " because class \"" + nm + "\" is already direct superclass of \"" + p_name + "\".";
864 throw oks::SetOperationFailed("OksClass::add_super_class", text);
865 } else if (nmc->find_super_class(p_name)) {
866 std::string text(add_super_class_error(nm, p_name));
867 text += " because class \"" + nm + "\" is already non-direct superclass of \"" + p_name + "\".";
868 throw oks::SetOperationFailed("OksClass::add_super_class", text);
869 }
870 }
871 }
872
873 lock_file("OksClass::add_super_class");
874
875 p_super_classes->push_back((new std::string(nm)));
876
878}
879
880static std::string
881remove_super_class_error(const std::string& c1, const std::string& c2)
882{
883 return (std::string("cannot remove superclass \"") + c1 + "\" from class \"" + c2 + '\"');
884}
885
886void
887OksClass::remove_super_class(const std::string& nm)
888{
889 if (!p_super_classes) {
890 std::string text(remove_super_class_error(nm, p_name));
891 text += " because class \"" + p_name + "\" has no superclasses at all.";
892 throw oks::SetOperationFailed("OksClass::remove_super_class", text);
893 }
894
895 for (std::list<std::string*>::iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
896 std::string* si(*i);
897 if (nm == *si) {
898 lock_file("OksClass::remove_super_class");
899
900 p_super_classes->erase(i);
901 delete si;
902
903 if (p_super_classes->empty()) {
904 delete p_super_classes;
905 p_super_classes = 0;
906 }
907
909
910 return;
911 }
912 }
913
914 std::string text(remove_super_class_error(nm, p_name));
915 text += " because class \"" + p_name + "\" has no superclass with this name.";
916 throw oks::SetOperationFailed("OksClass::remove_super_class", text);
917}
918
919void
920OksClass::swap_super_classes(const std::string& c1, const std::string& c2)
921{
922 const char* fname = "OksClass::swap_super_classes()";
923
924 // if classs are equal, return success
925
926 if (c1 == c2)
927 return;
928
929 // check that an class name is not empty
930
931 check_and_report_empty_parameter(fname, c1.empty(), c2.empty());
932
933 // find requested classes in the directed classs list
934
935 std::list<std::string*>::iterator i1 = p_super_classes->end();
936 std::list<std::string*>::iterator i2 = p_super_classes->end();
937
938 for (std::list<std::string*>::iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
939 if (*(*i) == c1)
940 i1 = i;
941 else if (*(*i) == c2)
942 i2 = i;
943 }
944
945 // check that the classes were found
946
947 check_and_report_found_items("OksClass::swap_super_classes",
948 "superclass",
949 c1,
950 c2,
951 p_name,
952 (i1 == p_super_classes->end()),
953 (i2 == p_super_classes->end()));
954
955 // replace the classs and make notification
956
957 lock_file("OksClass::swap_super_classes");
958
959 std::string* s1 = *i1;
960 std::string* s2 = *i2;
961
962 *i1 = s2;
963 *i2 = s1;
964
966}
967
968/******************************************************************************/
969/******************************* OKS ATTRIBUTES *******************************/
970/******************************************************************************/
971
973OksClass::find_direct_attribute(const std::string& _name) const noexcept
974{
975 if (p_attributes) {
976 for (std::list<OksAttribute*>::const_iterator i = p_attributes->begin(); i != p_attributes->end(); ++i)
977 if (_name == (*i)->get_name())
978 return *i;
979 }
980
981 return 0;
982}
983
985OksClass::find_attribute(const std::string& _name) const noexcept
986{
987 if (p_all_attributes) {
988 for (std::list<OksAttribute*>::const_iterator i = p_all_attributes->begin(); i != p_all_attributes->end(); ++i)
989 if (_name == (*i)->get_name())
990 return *i;
991
992 return 0;
993 } else
994 return find_direct_attribute(_name);
995}
996
997void
999{
1000 if (!p_attributes) {
1001 p_attributes = new std::list<OksAttribute*>();
1002 }
1003
1004 p_attributes->push_back(attribute);
1005 attribute->p_class = this;
1006}
1007
1008void
1010{
1011 const char* fname = "OksClass::add(OksAttribute *)";
1012
1013 if (!p_attributes) {
1014 p_attributes = new std::list<OksAttribute*>();
1015 } else {
1016 if (find_direct_attribute(attribute->get_name()) != 0) {
1017 std::ostringstream text;
1018 text << "cannot add attribute \"" << attribute->get_name() << "\" to class \"" << p_name
1019 << "\"\n"
1020 "because the class already has attribute with this name.\n";
1021 throw oks::SetOperationFailed(fname, text.str());
1022 }
1023 }
1024
1025 lock_file("OksClass::add[OksAttribute]");
1026
1027 p_attributes->push_back(attribute);
1028 attribute->p_class = this;
1029
1030 registrate_class_change(ChangeAttributesList, (const void*)attribute);
1031}
1032
1033void
1035{
1036 const char* fname = "OksClass::swap(const OksAttribute *, const OksAttribute *)";
1037
1038 // if attributes are equal, return success
1039
1040 if (a1 == a2)
1041 return;
1042
1043 // check that an attributes is not (null)
1044
1045 check_and_report_empty_parameter(fname, (a1 == 0), (a2 == 0));
1046
1047 // find requested attributes in the directed attributes list
1048
1049 std::list<OksAttribute*>::iterator i1 = p_attributes->end();
1050 std::list<OksAttribute*>::iterator i2 = p_attributes->end();
1051
1052 for (std::list<OksAttribute*>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1053 if ((*i) == a1)
1054 i1 = i;
1055 else if ((*i) == a2)
1056 i2 = i;
1057 }
1058
1059 // check that the attributes were found
1060
1062 "attribute",
1063 a1->get_name(),
1064 a2->get_name(),
1065 p_name,
1066 (i1 == p_attributes->end()),
1067 (i2 == p_attributes->end()));
1068
1069 // check that the file can be locked
1070
1071 lock_file("OksClass::swap[OksAttribute]");
1072
1073 // replace the attributes and make notification
1074
1075 *i1 = const_cast<OksAttribute*>(a2);
1076 *i2 = const_cast<OksAttribute*>(a1);
1077
1079}
1080
1081void
1083{
1084 const char* fname = "OksClass::remove(OksAttribute *)";
1085
1086 if (!p_attributes) {
1087 std::ostringstream text;
1088 text << "cannot remove attribute \"" << attribute->get_name() << "\" from class \"" << p_name
1089 << "\"\n"
1090 "because the class has no attributes.\n";
1091 throw oks::SetOperationFailed(fname, text.str());
1092 }
1093
1094 for (std::list<OksAttribute*>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1095 if (attribute == *i) {
1096 lock_file("OksClass::remove[OksAttribute]");
1097
1098 p_attributes->erase(i);
1099 delete const_cast<OksAttribute*>(attribute);
1100
1101 if (p_attributes->empty()) {
1102 delete p_attributes;
1103 p_attributes = 0;
1104 }
1105
1107
1108 return;
1109 }
1110 }
1111
1112 std::ostringstream text;
1113 text << "cannot remove attribute \"" << attribute->get_name() << "\" from class \"" << p_name
1114 << "\"\n"
1115 "because the class has no such attribute with this name.\n";
1116 throw oks::SetOperationFailed(fname, text.str());
1117}
1118
1119OksClass*
1120OksClass::source_class(const OksAttribute* a) const noexcept
1121{
1122 return a->p_class;
1123}
1124
1125/******************************************************************************/
1126/***************************** OKS RELATIONSHIPS *****************************/
1127/******************************************************************************/
1128
1130OksClass::find_direct_relationship(const std::string& _name) const noexcept
1131{
1132 if (p_relationships) {
1133 for (std::list<OksRelationship*>::const_iterator i = p_relationships->begin(); i != p_relationships->end(); ++i)
1134 if (_name == (*i)->get_name())
1135 return *i;
1136 }
1137
1138 return 0;
1139}
1140
1142OksClass::find_relationship(const std::string& _name) const noexcept
1143{
1144 if (p_all_relationships) {
1145 for (std::list<OksRelationship*>::const_iterator i = p_all_relationships->begin(); i != p_all_relationships->end();
1146 ++i)
1147 if (_name == (*i)->get_name())
1148 return *i;
1149
1150 return 0;
1151 } else
1152 return find_direct_relationship(_name);
1153}
1154
1155void
1157{
1158 if (!p_relationships) {
1159 p_relationships = new std::list<OksRelationship*>();
1160 }
1161
1162 p_relationships->push_back(relationship);
1163 relationship->p_class = this;
1164}
1165
1166void
1168{
1169 const char* fname = "OksClass::add(OksRelationship *)";
1170
1171 if (!p_relationships) {
1172 p_relationships = new std::list<OksRelationship*>();
1173 } else {
1174 if (find_direct_relationship(relationship->get_name())) {
1175 std::ostringstream text;
1176 text << "cannot add relationship \"" << relationship->get_name() << "\" to class \"" << p_name
1177 << "\"\n"
1178 "because the class already has relationship with this name.\n";
1179 throw oks::SetOperationFailed(fname, text.str());
1180 }
1181 }
1182
1183 lock_file("OksClass::add[OksRelationship]");
1184
1185 p_relationships->push_back(relationship);
1186 relationship->p_class = this;
1187
1188 registrate_class_change(ChangeRelationshipsList, (const void*)relationship);
1189}
1190
1191void
1192OksClass::remove(const OksRelationship* relationship, bool call_delete)
1193{
1194 const char* fname = "OksClass::remove(OksRelationship *)";
1195
1196 if (!p_relationships) {
1197 std::ostringstream text;
1198 text << "cannot remove relationship \"" << relationship->get_name() << "\" from class \"" << p_name
1199 << "\"\n"
1200 "because the class has no relationships.\n";
1201 throw oks::SetOperationFailed(fname, text.str());
1202 }
1203
1204 for (std::list<OksRelationship*>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1205 if (relationship == *i) {
1206 lock_file("OksClass::remove[OksRelationship]");
1207
1208 p_relationships->erase(i);
1209 if (call_delete) {
1210 delete const_cast<OksRelationship*>(relationship);
1211 }
1212
1213 if (p_relationships->empty()) {
1214 delete p_relationships;
1215 p_relationships = 0;
1216 }
1217
1219
1220 return;
1221 }
1222 }
1223
1224 std::ostringstream text;
1225 text << "cannot remove relationship \"" << relationship->get_name() << "\" from class \"" << p_name
1226 << "\"\n"
1227 "because the class has no such relationship with this name.\n";
1228 throw oks::SetOperationFailed(fname, text.str());
1229}
1230
1231void
1233{
1234 const char* fname = "OksClass::swap(const OksRelationship *, const OksRelationship *)";
1235
1236 // if relationships are equal, return success
1237
1238 if (r1 == r2)
1239 return;
1240
1241 // check that an relationships is not (null)
1242
1243 check_and_report_empty_parameter(fname, (r1 == 0), (r2 == 0));
1244
1245 // find requested relationships in the directed relationships list
1246
1247 std::list<OksRelationship*>::iterator i1 = p_relationships->end();
1248 std::list<OksRelationship*>::iterator i2 = p_relationships->end();
1249
1250 for (std::list<OksRelationship*>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1251 if ((*i) == r1)
1252 i1 = i;
1253 else if ((*i) == r2)
1254 i2 = i;
1255 }
1256
1257 // check that the relationships were found
1258
1260 "relationship",
1261 r1->get_name(),
1262 r2->get_name(),
1263 p_name,
1264 (i1 == p_relationships->end()),
1265 (i2 == p_relationships->end()));
1266
1267 // check that the file can be locked
1268
1269 lock_file("OksClass::swap[OksRelationship]");
1270
1271 // replace the relationships and make notification
1272
1273 *i1 = const_cast<OksRelationship*>(r2);
1274 *i2 = const_cast<OksRelationship*>(r1);
1275
1277}
1278
1279OksClass*
1281{
1282 return r->p_class;
1283}
1284
1285/******************************************************************************/
1286/******************************** OKS METHODS ********************************/
1287/******************************************************************************/
1288
1289OksMethod*
1290OksClass::find_direct_method(const std::string& _name) const noexcept
1291{
1292 if (p_methods) {
1293 for (std::list<OksMethod*>::const_iterator i = p_methods->begin(); i != p_methods->end(); ++i)
1294 if (_name == (*i)->get_name())
1295 return *i;
1296 }
1297
1298 return 0;
1299}
1300
1301OksMethod*
1302OksClass::find_method(const std::string& _name) const noexcept
1303{
1304 if (p_all_methods) {
1305 for (std::list<OksMethod*>::const_iterator i = p_all_methods->begin(); i != p_all_methods->end(); ++i)
1306 if (_name == (*i)->get_name())
1307 return *i;
1308
1309 return 0;
1310 } else
1311 return find_direct_method(_name);
1312}
1313
1314void
1316{
1317 const char* fname = "OksClass::add(OksMethod *)";
1318
1319 if (!p_methods) {
1320 p_methods = new std::list<OksMethod*>();
1321 } else {
1322 if (find_direct_method(method->get_name())) {
1323 std::ostringstream text;
1324 text << "cannot add method \"" << method->get_name() << "\" to class \"" << p_name
1325 << "\"\n"
1326 "because the class already has method with this name.\n";
1327 throw oks::SetOperationFailed(fname, text.str());
1328 }
1329 }
1330
1331 // check that the file can be locked
1332
1333 lock_file("OksClass::add[OksMethod]");
1334
1335 p_methods->push_back(method);
1336 method->p_class = this;
1337
1338 registrate_class_change(ChangeMethodsList, (const void*)method);
1339}
1340
1341void
1343{
1344 const char* fname = "OksClass::remove(OksMethod *)";
1345
1346 if (!p_methods) {
1347 std::ostringstream text;
1348 text << "cannot remove method \"" << method->get_name() << "\" from class \"" << p_name
1349 << "\"\n"
1350 "because the class has no methods.\n";
1351 throw oks::SetOperationFailed(fname, text.str());
1352 }
1353
1354 for (std::list<OksMethod*>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1355 if (method == *i) {
1356 lock_file("OksClass::remove[OksMethod]");
1357
1358 p_methods->erase(i);
1359 delete const_cast<OksMethod*>(method);
1360
1361 if (p_methods->empty()) {
1362 delete p_methods;
1363 p_methods = 0;
1364 }
1365
1367
1368 return;
1369 }
1370 }
1371
1372 std::ostringstream text;
1373 text << "cannot remove method \"" << method->get_name() << "\" from class \"" << p_name
1374 << "\"\n"
1375 "because the class has no such method with this name.\n";
1376 throw oks::SetOperationFailed(fname, text.str());
1377}
1378
1379void
1381{
1382 const char* fname = "OksClass::swap(const OksMethod *, const OksMethod *)";
1383
1384 // if methods are equal, return success
1385
1386 if (m1 == m2)
1387 return;
1388
1389 // check that an methods is not (null)
1390
1391 check_and_report_empty_parameter(fname, (m1 == 0), (m2 == 0));
1392
1393 // find requested methods in the directed methods list
1394
1395 std::list<OksMethod*>::iterator i1 = p_methods->end();
1396 std::list<OksMethod*>::iterator i2 = p_methods->end();
1397
1398 for (std::list<OksMethod*>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1399 if ((*i) == m1)
1400 i1 = i;
1401 else if ((*i) == m2)
1402 i2 = i;
1403 }
1404
1405 // check that the methods were found
1406
1408 fname, "method", m1->get_name(), m2->get_name(), p_name, (i1 == p_methods->end()), (i2 == p_methods->end()));
1409
1410 // check that the file can be locked
1411
1412 lock_file("OksClass::swap[OksMethod]");
1413
1414 // replace the methods and make notification
1415
1416 *i1 = const_cast<OksMethod*>(m2);
1417 *i2 = const_cast<OksMethod*>(m1);
1418
1420}
1421
1422OksClass*
1423OksClass::source_class(const OksMethod* m) const noexcept
1424{
1425 return m->p_class;
1426}
1427
1428/******************************************************************************/
1429/******************************** OKS OBJECTS ********************************/
1430/******************************************************************************/
1431
1432size_t
1434{
1435 return (!p_objects ? 0 : p_objects->size());
1436}
1437
1438//
1439// Creates list of class instances and instances of
1440// all subclasses
1441//
1442
1443std::list<OksObject*>*
1445{
1446 std::list<OksObject*>* olist = 0;
1447
1448 // add instances of class
1449
1450 if (p_objects && !p_objects->empty()) {
1451 olist = new std::list<OksObject*>();
1452
1453 for (OksObject::Map::const_iterator i = p_objects->begin(); i != p_objects->end(); ++i)
1454 olist->push_back((*i).second);
1455 }
1456
1457 // build iterator over subclasses
1458
1459 if (p_all_sub_classes) {
1460 for (FList::const_iterator j = p_all_sub_classes->begin(); j != p_all_sub_classes->end(); ++j) {
1461 OksClass* sc = *j;
1462
1463 // add instances of subclass
1464
1465 if (sc->p_objects && !sc->p_objects->empty()) {
1466 if (!olist)
1467 olist = new std::list<OksObject*>();
1468
1469 for (OksObject::Map::const_iterator i = sc->p_objects->begin(); i != sc->p_objects->end(); ++i)
1470 olist->push_back((*i).second);
1471 }
1472 }
1473 }
1474
1475 return olist;
1476}
1477
1478OksObject*
1479OksClass::get_object(const std::string& id) const noexcept
1480{
1481 std::shared_lock lock(p_mutex); // protect p_objects
1482
1483 if (p_objects) {
1484 OksObject::Map::const_iterator i = p_objects->find(&id);
1485 if (i != p_objects->end())
1486 return i->second;
1487 }
1488
1489 return nullptr;
1490}
1491
1492/******************************************************************************/
1493/****************************** PRIVATE METHODS ******************************/
1494/******************************************************************************/
1495
1496void
1498{
1499 std::unique_lock lock(p_mutex); // protect p_objects
1500
1501 if (!p_objects->insert(std::pair<const std::string*, OksObject*>(&object->uid.object_id, object)).second) {
1502 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "add", "object already exists");
1503 }
1504}
1505
1506void
1508{
1509 std::unique_lock lock(p_mutex); // protect p_objects
1510
1511 if (!p_objects) {
1512 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "remove", "OKS Kernel is not inited");
1513 }
1514
1515 OksObject::Map::iterator i = p_objects->find(&object->uid.object_id);
1516
1517 if (i != p_objects->end())
1518 p_objects->erase(i);
1519 else {
1520 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "remove", "object does not exist");
1521 }
1522}
1523
1524inline void
1526{
1527 for (OksClass::FList::const_iterator i = clist.begin(); i != clist.end(); ++i) {
1528 if (*i == c)
1529 return;
1530 }
1531 clist.push_back(c);
1532}
1533
1534void
1536{
1537 if (p_super_classes) {
1538 for (std::list<std::string*>::const_iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
1539 if (OksClass* c = p_kernel->find_class(**i)) {
1540 c->add_super_classes(clist);
1541 add_if_not_found(*clist, c);
1542 } else {
1543 throw oks::CannotFindSuperClass(*this, **i);
1544 }
1545 }
1546 }
1547}
1548
1549void
1551{
1553 p_all_super_classes = new FList();
1554 else
1555 p_all_super_classes->clear();
1556
1558
1559#ifndef ERS_NO_DEBUG
1560 if (ers::debug_level() >= 5) {
1561 std::ostringstream text;
1562 text << "found " << p_all_super_classes->size() << " superclass(es) in class \'" << get_name() << "\':\n";
1563 if (p_all_super_classes->size()) {
1564 for (FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1565 text << " - class \'" << (*i)->get_name() << "\'\n";
1566 }
1567 }
1568
1569 TLOG_DEBUG(5) << text.str();
1570 }
1571#endif
1572}
1573
1574void
1576{
1577 if (!p_all_sub_classes)
1578 p_all_sub_classes = new FList();
1579 else
1580 p_all_sub_classes->clear();
1581
1582 if (!p_kernel->p_classes.empty()) {
1583 for (Map::iterator i = p_kernel->p_classes.begin(); i != p_kernel->p_classes.end(); ++i) {
1584 OksClass* c = i->second;
1585
1586 if (const FList* scl = c->p_all_super_classes) {
1587 for (FList::const_iterator j = scl->begin(); j != scl->end(); ++j) {
1588 if (*j == this) {
1589 p_all_sub_classes->push_back(c);
1590 break;
1591 }
1592 }
1593 }
1594 }
1595 }
1596}
1597
1598inline const char*
1600{
1601 return (v ? "multi-value" : "single-value");
1602}
1603
1604// skip differency between enum and string
1605
1606inline bool
1608{
1609 static const std::string __enum_str__("enum");
1610 static const std::string __string_str__("string");
1611
1612 const std::string& s1 = a1->get_type();
1613 const std::string& s2 = a2->get_type();
1614
1615 return (
1616 !((s1 == s2) || ((s1 == __enum_str__ && s2 == __string_str__) || (s1 == __string_str__ && s2 == __enum_str__))));
1617}
1618
1619void
1621{
1622 if (p_attributes)
1623 for (const auto& x : *p_attributes)
1624 x->set_init_data();
1625
1626 if (!p_all_attributes)
1627 p_all_attributes = new std::list<OksAttribute*>();
1628 else
1629 p_all_attributes->clear();
1630
1631 if (p_all_super_classes) {
1632 for (FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1633 OksClass* c(*i);
1634 if (c->p_attributes) {
1635 for (std::list<OksAttribute*>::iterator i2 = c->p_attributes->begin(); i2 != c->p_attributes->end(); ++i2) {
1636 OksAttribute* a(*i2);
1639 if (a1 == 0 && a2 == 0) {
1640 p_all_attributes->push_back(a);
1641 } else if (!p_kernel->p_silence) {
1642 if (a1) {
1643 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' direct attribute \'" << a1->get_name()
1644 << "\' overrides one coming from superclass \'" << a->p_class->get_name() << '\'';
1645 if (are_types_different(a1, a)) {
1646 Oks::warning_msg("OksClass::create_attributes()")
1647 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1648 << " type of attribute in superclass \'" << a->p_class->get_name() << "\' is \'" << a->get_type()
1649 << "\'\n"
1650 << " type of attribute in class \'" << get_name() << "\' is \'" << a1->get_type() << "\'\n";
1651 }
1652
1653 if (a1->get_is_multi_values() != a->get_is_multi_values()) {
1654 Oks::warning_msg("OksClass::create_attributes()")
1655 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1656 << " attribute in superclass \'" << a->p_class->get_name() << "\' is "
1657 << bool2value_type(a->get_is_multi_values()) << "\n"
1658 << " attribute in class \'" << get_name() << "\' is \'" << bool2value_type(a1->get_is_multi_values())
1659 << "\'\n";
1660 }
1661 } else if (a2) {
1662 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' attribute \'" << a2->get_name()
1663 << "\' from superclass \'" << a2->p_class->get_name()
1664 << "\' overrides one coming from superclass \'" << a->p_class->get_name() << '\'';
1665 if (are_types_different(a2, a)) {
1666 Oks::warning_msg("OksClass::create_attributes()")
1667 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1668 << " type of attribute in superclass \'" << a->p_class->get_name() << "\' is \'" << a->get_type()
1669 << "\'\n"
1670 << " type of attribute in superclass \'" << a2->p_class->get_name() << "\' is \'" << a2->get_type()
1671 << "\'\n";
1672 }
1673
1674 if (a2->get_is_multi_values() != a->get_is_multi_values()) {
1675 Oks::warning_msg("OksClass::create_attributes()")
1676 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1677 << " attribute in superclass \'" << a->p_class->get_name() << "\' is "
1678 << bool2value_type(a->get_is_multi_values()) << "\n"
1679 << " attribute in superclass \'" << get_name() << "\' is \'"
1680 << bool2value_type(a2->get_is_multi_values()) << "\'\n";
1681 }
1682 }
1683 }
1684 }
1685 }
1686 }
1687 }
1688
1689 if (p_attributes) {
1690 for (std::list<OksAttribute*>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1691 p_all_attributes->push_back(*i);
1692 }
1693 }
1694}
1695
1696inline const char*
1698{
1699 return (cc == OksRelationship::One ? "one object" : "many objects");
1700}
1701
1702void
1704{
1706 p_all_relationships = new std::list<OksRelationship*>();
1707 else
1708 p_all_relationships->clear();
1709
1710 if (p_all_super_classes) {
1711 for (FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1712 OksClass* c(*i);
1713 if (c->p_relationships) {
1714 for (std::list<OksRelationship*>::iterator i2 = c->p_relationships->begin(); i2 != c->p_relationships->end();
1715 ++i2) {
1716 OksRelationship* r = *i2;
1717 OksRelationship* r1 = find_direct_relationship(r->get_name());
1718 OksRelationship* r2 = find_relationship(r->get_name());
1719
1720 if (!r->p_class_type) {
1721 r->p_class_type = p_kernel->find_class(r->p_rclass);
1722 }
1723
1724 if (r1 == 0 && r2 == 0) {
1725 p_all_relationships->push_back(r);
1726 } else {
1727 if (r1) {
1728 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' direct relationship \'" << r1->get_name()
1729 << "\' overrides one coming from superclass \'" << r->p_class->get_name() << '\'';
1730 if (r1->get_high_cardinality_constraint() != r->get_high_cardinality_constraint()) {
1731 Oks::warning_msg("OksClass::create_relationships()")
1732 << " found relationship \'" << r->get_name() << "\' cardinality conflict in class \'" << get_name()
1733 << "\':\n"
1734 << " relationship in superclass \'" << r->p_class->get_name() << "\' allows "
1735 << card2string(r->get_high_cardinality_constraint()) << "\n"
1736 << " relationship in class \'" << get_name() << "\' allows "
1737 << card2string(r1->get_high_cardinality_constraint()) << std::endl;
1738 }
1739 } else if (r2) {
1740 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' relationship \'" << r2->get_name()
1741 << "\' from superclass \'" << r2->p_class->get_name()
1742 << "\' overrides one coming from superclass \'" << r->p_class->get_name() << '\'';
1743 if (r2->get_high_cardinality_constraint() != r->get_high_cardinality_constraint()) {
1744 Oks::warning_msg("OksClass::create_relationships()")
1745 << " found relationship \'" << r->get_name() << "\' cardinality conflict in class \'" << get_name()
1746 << "\':\n"
1747 << " relationship in superclass \'" << r->p_class->get_name() << "\' allows "
1748 << card2string(r->get_high_cardinality_constraint()) << "\n"
1749 << " relationship in superclass \'" << r2->p_class->get_name() << "\' allows "
1750 << card2string(r2->get_high_cardinality_constraint()) << std::endl;
1751 }
1752 }
1753 }
1754 }
1755 }
1756 }
1757 }
1758
1759 if (p_relationships) {
1760 for (std::list<OksRelationship*>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1761 OksRelationship* r = *i;
1762
1763 if (!r->p_class_type) {
1764 r->p_class_type = p_kernel->find_class(r->p_rclass);
1765 }
1766
1767 p_all_relationships->push_back(r);
1768 }
1769 }
1770}
1771
1772void
1774{
1775 if (!p_all_methods)
1776 p_all_methods = new std::list<OksMethod*>();
1777 else
1778 p_all_methods->clear();
1779
1780 if (p_all_super_classes) {
1781 for (FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1782 std::list<OksMethod*>::iterator i2;
1783 if ((*i)->p_methods) {
1784 for (i2 = (*i)->p_methods->begin(); i2 != (*i)->p_methods->end(); ++i2) {
1785 if (find_direct_method((*i2)->get_name()) == 0 && find_method((*i2)->get_name()) == 0) {
1786 p_all_methods->push_back(*i2);
1787 }
1788 }
1789 }
1790 }
1791 }
1792
1793 if (p_methods) {
1794 for (std::list<OksMethod*>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1795 p_all_methods->push_back(*i);
1796 }
1797 }
1798}
1799
1800// Updates the values of the instances of the class and all their subclasses
1801// in case of a change of the attribute's type or multi values cardinality
1802
1803void
1805{
1807
1808 FList::iterator i;
1810 i = p_all_sub_classes->begin();
1811
1812 OksClass* c(this);
1813
1814 do {
1815 if (c->p_objects && !c->p_objects->empty()) {
1816 for (OksObject::Map::const_iterator i2 = c->p_objects->begin(); i2 != c->p_objects->end(); ++i2) {
1817 OksObject* o(i2->second);
1818 OksData newData;
1819 OksData* oldData = &o->data[((*(c->p_data_info))[a->p_name])->offset];
1820
1821 try {
1822 oldData->cvt(&newData, a);
1823 oldData->Clear();
1824 memcpy(static_cast<void*>(oldData), static_cast<void*>(&newData), sizeof(OksData));
1825 newData.Clear2(); // Do not free !
1826 } catch (oks::AttributeReadError& ex) {
1827 std::ostringstream text;
1828 text << "attribute \'" << a->get_name() << "\' change converting object " << o << ' ';
1829 throw oks::CannotRegisterClass(*this, text.str(), ex);
1830 }
1831 }
1832 }
1833 } while (p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
1834}
1835
1836// Updates the values of the instances of the class and all their subclasses
1837// in case of a change of the relationship's class type or a cardinality
1838
1839void
1841{
1843
1844 FList::iterator i;
1846 i = p_all_sub_classes->begin();
1847
1848 OksClass* c(this);
1849
1850 do {
1851 if (c->p_objects && !c->p_objects->empty()) {
1852 for (OksObject::Map::const_iterator i2 = c->p_objects->begin(); i2 != c->p_objects->end(); ++i2) {
1853 OksObject* o(i2->second);
1854 OksData newData;
1855 OksData* oldData = &o->data[((*(c->p_data_info))[r->p_name])->offset];
1856
1857 oldData->ConvertTo(&newData, r);
1858 oldData->Clear();
1859 memcpy(static_cast<void*>(oldData), static_cast<void*>(&newData), sizeof(OksData));
1860 newData.Clear2(); // Do not free !
1861 }
1862 }
1863 } while (p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
1864}
1865
1866void
1868{
1870
1871 OksDataInfo::Map* dInfo = new OksDataInfo::Map();
1872
1873 size_t dInfoLength = 0;
1874 bool thereAreChanges = false;
1875
1876 if (!p_all_attributes->empty()) {
1877 for (std::list<OksAttribute*>::iterator i = p_all_attributes->begin(); i != p_all_attributes->end(); ++i) {
1878 OksAttribute* a = *i;
1879 if (!thereAreChanges) {
1880 OksDataInfo::Map::const_iterator x = p_data_info->find(a->get_name());
1881 if (x == p_data_info->end() || x->second->attribute == nullptr || x->second->offset != dInfoLength ||
1882 !(*(x->second->attribute) == *a)) {
1883 thereAreChanges = true;
1884 }
1885 }
1886
1887 (*dInfo)[a->get_name()] = new OksDataInfo(dInfoLength++, a);
1888 }
1889 }
1890
1891 if (!p_all_relationships->empty()) {
1892 for (std::list<OksRelationship*>::iterator i = p_all_relationships->begin(); i != p_all_relationships->end(); ++i) {
1893 OksRelationship* r = *i;
1894 if (!thereAreChanges) {
1895 OksDataInfo::Map::const_iterator x = p_data_info->find(r->get_name());
1896 if (x == p_data_info->end() || x->second->relationship == nullptr || x->second->offset != dInfoLength ||
1897 !(*(x->second->relationship) == *r)) {
1898 thereAreChanges = true;
1899 }
1900 }
1901
1902 (*dInfo)[r->get_name()] = new OksDataInfo(dInfoLength++, r);
1903 }
1904 }
1905
1906 if (thereAreChanges == true) {
1907 if (p_objects && !p_objects->empty()) {
1908 for (OksObject::Map::const_iterator i = p_objects->begin(); i != p_objects->end(); ++i) {
1909 OksObject* o = (*i).second;
1910 OksData* data = new OksData[dInfoLength];
1911 size_t count = 0;
1912
1913 if (!p_all_attributes->empty()) {
1914 for (std::list<OksAttribute*>::iterator i2 = p_all_attributes->begin(); i2 != p_all_attributes->end(); ++i2) {
1915 OksAttribute* a = *i2;
1916
1917 OksDataInfo::Map::const_iterator x = p_data_info->find(a->get_name());
1918
1919 if (x != p_data_info->end() && x->second->attribute) {
1920 OksData* oldData(&o->data[x->second->offset]);
1921
1922 if (*(x->second->attribute) == *a) {
1923 memcpy(static_cast<void*>(&data[count++]), static_cast<void*>(oldData), sizeof(OksData));
1924 oldData->type = OksData::unknown_type;
1925 } else {
1926 try {
1927 oldData->cvt(&data[count++], a);
1928 } catch (oks::AttributeReadError& ex) {
1929 throw oks::AttributeConversionFailed(*a, o, ex);
1930 }
1931 }
1932 }
1933 }
1934 }
1935
1936 if (!p_all_relationships->empty()) {
1937 for (std::list<OksRelationship*>::iterator i2 = p_all_relationships->begin();
1938 i2 != p_all_relationships->end();
1939 ++i2) {
1940 OksRelationship* r = *i2;
1941
1942 OksDataInfo::Map::const_iterator x = p_data_info->find(r->get_name());
1943
1944 if (x != p_data_info->end() && x->second->relationship) {
1945 OksData* oldData = &o->data[x->second->offset];
1946
1947 if (*(x->second->relationship) == *r) {
1948 memcpy(static_cast<void*>(&data[count++]), static_cast<void*>(oldData), sizeof(OksData));
1949 oldData->type = OksData::unknown_type;
1950 } else
1951 oldData->ConvertTo(&data[count++], r);
1952 }
1953 }
1954 }
1955
1956 int n = p_instance_size;
1957 while (n--)
1958 o->data[n].Clear();
1959 delete o->data;
1960
1961 o->data = data;
1962 }
1963 }
1964 }
1965
1966 if (!p_data_info->empty()) {
1967 for (OksDataInfo::Map::iterator i = p_data_info->begin(); i != p_data_info->end(); ++i) {
1968 delete i->second;
1969 }
1970 }
1971
1972 delete p_data_info;
1973
1974 p_data_info = dInfo;
1975 p_instance_size = dInfoLength;
1976}
1977
1978void
1979OksClass::registrate_class(bool skip_registered)
1980{
1982
1983 {
1984 if (!p_data_info)
1986 if (!p_objects) {
1987 p_objects = new OksObject::Map((p_abstract == false) ? 1024 : 1);
1988 }
1989 }
1990
1991 if (!p_data_info->empty() && skip_registered) {
1992 TLOG_DEBUG(4) << "skip already registered " << get_name();
1993 return;
1994 }
1995
1996 try {
2001
2003 } catch (oks::exception& ex) {
2004 throw oks::CannotRegisterClass(*this, "", ex);
2005 }
2006}
2007
2008void
2009OksClass::registrate_class_change(ChangeType changeType, const void* parameter, bool update_file)
2010{
2011 if (!p_kernel)
2012 return;
2013
2015
2016 try {
2017 if (update_file)
2019
2020 FList superclasses;
2021
2022 if (changeType == ChangeSuperClassesList && !p_all_super_classes->empty())
2023 for (FList::iterator i2 = p_all_super_classes->begin(); i2 != p_all_super_classes->end(); ++i2) {
2024 superclasses.push_back(*i2);
2025 }
2026
2027 FList::iterator i;
2029 i = p_all_sub_classes->begin();
2030
2031 OksClass* c = this;
2032
2033 do {
2034 switch (changeType) {
2036 c->create_super_classes();
2037 c->create_attributes();
2038 c->create_relationships();
2039 c->create_methods();
2040 break;
2041
2043 c->create_attributes();
2044 break;
2045
2047 c->create_relationships();
2048 break;
2049
2050 case ChangeMethodsList:
2051 c->create_methods();
2052 break;
2053
2054 default:
2055 continue;
2056 }
2057
2058 if (changeType != ChangeMethodsList)
2059 c->registrate_instances();
2060 } while (p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
2061
2062 if (changeType == ChangeSuperClassesList) {
2063 if (!p_all_super_classes->empty())
2064 for (FList::iterator i2 = p_all_super_classes->begin(); i2 != p_all_super_classes->end(); ++i2)
2065 if (find(superclasses.begin(), superclasses.end(), *i2) == superclasses.end()) {
2066 superclasses.push_back(*i2);
2067 }
2068
2069 for (FList::const_iterator i2 = superclasses.begin(); i2 != superclasses.end(); ++i2) {
2070 c = *i2;
2071
2072 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
2073 continue;
2074
2075 c->create_sub_classes();
2076
2078 (*OksClass::change_notify_fn)(c, ChangeSubClassesList, 0);
2079 }
2080 superclasses.clear();
2081 }
2082
2085 i = p_all_sub_classes->begin();
2086 c = this;
2087
2088 do
2089 (*OksClass::change_notify_fn)(c, changeType, parameter);
2090 while (p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
2091 }
2092 } catch (oks::exception& ex) {
2093 throw oks::CannotRegisterClass(*this, "change ", ex);
2094 }
2095}
2096
2097bool
2098OksClass::check_relationships(std::ostringstream& out, bool print_file_name) const noexcept
2099{
2100 bool found_problems = false;
2101
2102 if (const std::list<OksRelationship*>* rels = direct_relationships()) {
2103 for (auto& x : *rels) {
2104 if (x->get_class_type() == nullptr) {
2105 if (found_problems == false) {
2106 found_problems = true;
2107 out << " * there are problems with class \"" << get_name() << '\"';
2108 if (print_file_name) {
2109 out << " from file \"" << get_file()->get_full_file_name() << '\"';
2110 }
2111 out << ":\n";
2112 }
2113
2114 out << " - class type \"" << x->get_type() << "\" of relationship \"" << x->get_name()
2115 << "\" is not loaded\n";
2116 }
2117 }
2118 }
2119
2120 return found_problems;
2121}
2122
2123} // namespace oks
2124} // namespace dunedaq
static std::string fill(const OksAttribute &a, const OksObject *o, const std::string &reason) noexcept
Definition class.cpp:47
Failed move item to file.
Definition kernel.hpp:296
static std::string fill(const OksClass &c, const std::string &reason) noexcept
Definition class.cpp:61
static std::string fill(const OksClass &c, const std::string &name) noexcept
Definition class.cpp:41
static std::string fill(const OksClass &c, const std::string &what, const std::string &reason) noexcept
Definition class.cpp:55
static std::string fill(const OksClass &c, const std::string &oid, const char *op, const std::string &reason) noexcept
Definition class.cpp:67
OKS attribute class.
Definition attribute.hpp:94
bool get_is_multi_values() const noexcept
const std::string & get_type() const noexcept
Get attribute string type.
const std::string & get_name() const noexcept
out stream operator
OksAttribute(const std::string &name, OksClass *p=nullptr)
OKS attribute simple constructor.
The OKS class.
Definition class.hpp:223
std::list< std::string * > * p_super_classes
Definition class.hpp:882
OksKernel * p_kernel
Definition class.hpp:900
void(*) NotifyFN(OksClass *)
Definition class.hpp:873
friend class OksMethod
Definition class.hpp:228
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1130
size_t number_of_objects() const noexcept
Definition class.cpp:1433
void set_file(OksFile *f, bool update_owner=true)
Move class to different file.
Definition class.cpp:277
bool check_relationships(std::ostringstream &out, bool print_file_name) const noexcept
Definition class.cpp:2098
OksObject::Map * p_objects
Definition class.hpp:905
static const char superclass_xml_attr[]
Definition class.hpp:956
OksClass * find_super_class(const std::string &) const noexcept
Definition class.cpp:708
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:254
OksAttribute * find_direct_attribute(const std::string &name) const noexcept
Find direct attribute.
Definition class.cpp:973
void add_super_class(const std::string &name)
Definition class.cpp:840
friend class OksAttribute
Definition class.hpp:226
static void destroy_list(T list)
Definition class.cpp:198
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1302
void registrate_class(bool skip_registered)
Definition class.cpp:1979
FList * p_all_sub_classes
Definition class.hpp:891
static NotifyFN create_notify_fn
Definition class.hpp:911
std::list< OksAttribute * > * p_all_attributes
Definition class.hpp:892
static void destroy_map(T map)
Definition class.cpp:210
void add_super_classes(FList *) const
Definition class.cpp:1535
std::string p_description
Definition class.hpp:881
static const char class_xml_tag[]
Definition class.hpp:952
std::list< OksMethod * > * p_all_methods
Definition class.hpp:894
bool operator!=(const OksClass &) const
The not equal operator.
Definition class.cpp:354
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
Definition class.cpp:1142
friend class OksRelationship
Definition class.hpp:227
static const char description_xml_attr[]
Definition class.hpp:954
void swap(const OksAttribute *a1, const OksAttribute *a2)
Swap order of two attributes.
Definition class.cpp:1034
void registrate_class_change(ChangeType, const void *, bool=true)
Definition class.cpp:2009
friend class OksKernel
Definition class.hpp:225
void add(OksAttribute *a)
Add attribute.
Definition class.cpp:1009
void swap_super_classes(const std::string &c1, const std::string &c2)
Swap order of two superclasses.
Definition class.cpp:920
void registrate_relationship_change(OksRelationship *)
Definition class.cpp:1840
void save(OksXmlOutputStream &) const
Definition class.cpp:445
void set_is_abstract(bool abstract)
Set class abstract property.
Definition class.cpp:762
OksIndex::Map * p_indices
Definition class.hpp:906
void(*) ChangeNotifyFN(OksClass *, ChangeType, const void *)
Definition class.hpp:877
static NotifyFN delete_notify_fn
Definition class.hpp:913
static const char is_abstract_xml_attr[]
Definition class.hpp:955
void remove_super_class(const std::string &name)
Definition class.cpp:887
const std::string & get_name() const noexcept
Definition class.hpp:374
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Definition class.cpp:985
std::list< OksRelationship * > * p_relationships
Definition class.hpp:884
std::string p_name
Definition class.hpp:880
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:572
void remove(const OksAttribute *a)
Remove attribute.
Definition class.cpp:1082
static ChangeNotifyFN change_notify_fn
Definition class.hpp:912
void set_description(const std::string &description)
Set class description.
Definition class.cpp:745
std::shared_mutex p_mutex
Definition class.hpp:908
OksClass * source_class(const OksAttribute *a) const noexcept
Get class owning given attribute.
Definition class.cpp:1120
static const char name_xml_attr[]
Definition class.hpp:953
bool compare_without_methods(const OksClass &c) const noexcept
Definition class.cpp:297
OksClass(const std::string &name, OksKernel *kernel, bool transient=false)
Create OKS class.
Definition class.cpp:81
friend class OksObject
Definition class.hpp:224
std::vector< OksClass * > * p_inheritance_hierarchy
Definition class.hpp:896
std::list< OksAttribute * > * p_attributes
Definition class.hpp:883
OksObject * get_object(const std::string &id) const noexcept
Get object by ID.
Definition class.cpp:1479
void k_add(OksAttribute *a)
Kernel method to add attribute.
Definition class.cpp:998
void registrate_attribute_change(OksAttribute *)
Definition class.cpp:1804
std::list< OksMethod * > * p_methods
Definition class.hpp:885
std::list< OksObject * > * create_list_of_all_objects() const noexcept
Get all objects of the class (including derived).
Definition class.cpp:1444
OksDataInfo::Map * p_data_info
Definition class.hpp:904
void lock_file(const char *)
Definition class.cpp:733
OksFile * get_file() const noexcept
Definition class.hpp:352
void k_add_super_class(const std::string &name)
Definition class.cpp:830
static void destroy(OksClass *c)
Destroy OKS class.
Definition class.cpp:172
std::list< OksRelationship * > * p_all_relationships
Definition class.hpp:893
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1290
ChangeType
Information about class property changes.
Definition class.hpp:840
friend std::ostream & operator<<(std::ostream &, const OksClass &)
Stream operator.
Definition class.cpp:381
bool has_direct_super_class(const std::string &) const noexcept
Definition class.cpp:721
FList * p_all_super_classes
Definition class.hpp:890
Provides interface to the OKS XML schema and data files.
Definition file.hpp:355
void lock()
Lock OKS file.
Definition file.cpp:1004
bool is_dangling(OksClass *class_ptr) const
Check pointer on oks class.
Definition kernel.cpp:4415
OksClass::Map p_classes
Definition kernel.hpp:1987
void k_add(OksClass *)
Definition kernel.cpp:4231
void k_remove(OksClass *)
Definition kernel.cpp:4260
std::shared_mutex p_kernel_mutex
Definition kernel.hpp:1965
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
Definition kernel.hpp:1754
OKS method class.
Definition method.hpp:147
const std::string & get_name() const noexcept
Definition method.hpp:185
OksMethod(const std::string &name, OksClass *p=nullptr)
OKS method constructor.
Definition method.cpp:116
OksObject describes instance of OksClass.
Definition object.hpp:1144
std::map< const std::string *, OksObject *, SortById > SMap
Definition object.hpp:1166
std::unordered_map< const std::string *, OksObject *, oks::hash_str, oks::equal_str > Map
Definition object.hpp:1170
const std::string & get_name() const noexcept
CardinalityConstraint get_high_cardinality_constraint() const noexcept
Get relationship high cardinality constraint.
OksRelationship(const std::string &name, OksClass *p=nullptr)
OKS relationship simple constructor.
static std::ostream & warning_msg(const char *)
Definition kernel.cpp:518
static std::string fill(const char *op, const std::string &reason) noexcept
Definition class.cpp:76
virtual const char * what() const noexcept
double offset
#define OSK_PROFILING(FID, K)
Definition defs.hpp:96
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
const char * bool2str(bool b) noexcept
Definition xml.hpp:29
bool str2bool(const char *s) noexcept
Definition xml.hpp:36
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:15
static void check_and_report_empty_parameter(const char *fname, bool b1, bool b2)
Definition class.cpp:781
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:45
bool cmp_str6(const char *s1, const char s2[7])
Definition cstring.hpp:69
bool are_types_different(const OksAttribute *a1, const OksAttribute *a2)
Definition class.cpp:1607
static void check_and_report_found_items(const char *fname, const char *item_type, const std::string &item1_name, const std::string &item2_name, const std::string &class_name, bool b1, bool b2)
Definition class.cpp:795
bool cmp_str10(const char *s1, const char s2[11])
Definition cstring.hpp:111
const char * bool2value_type(bool v)
Definition class.cpp:1599
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:105
static std::string add_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:824
const char * card2string(OksRelationship::CardinalityConstraint cc)
Definition class.cpp:1697
void validate_not_empty(const std::string &value, const char *name)
void add_if_not_found(OksClass::FList &clist, OksClass *c)
Definition class.cpp:1525
bool cmp_str11(const char *s1, const char s2[12])
Definition cstring.hpp:117
bool cmp_str12(const char *s1, const char s2[13])
Definition cstring.hpp:123
static std::string remove_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:881
The DUNE-DAQ namespace.
FELIX Initialization std::string initerror FELIX queue timed out
default char v[0]
int debug_level()
Definition ers.hpp:80
Definition ral.hpp:59
OksDataInfo(size_t o, const OksAttribute *a)
Constructors.
Definition object.hpp:387
std::map< std::string, OksDataInfo * > Map
Declare map of pointers to OksDataInfo (unsorted by name).
Definition object.hpp:383
Struct OKS data.
Definition object.hpp:510
void cvt(OksData *to, const OksAttribute *attr) const
Convert data to new type.
enum dunedaq::oks::OksData::Type type
void ConvertTo(OksData *, const OksRelationship *) const
size_t value_len() const
Definition xml.hpp:288
Factory couldn t find
Definition Issues.hpp:24