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