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

The OKS class. More...

#include <class.hpp>

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

Classes

struct  SortByName
struct  SortStr

Public Types

enum  ChangeType {
  ChangeSuperClassesList , ChangeSubClassesList , ChangeDescription , ChangeIsAbstaract ,
  ChangeAttributesList , ChangeAttributeType , ChangeAttributeRange , ChangeAttributeFormat ,
  ChangeAttributeMultiValueCardinality , ChangeAttributeInitValue , ChangeAttributeDescription , ChangeAttributeIsNoNull ,
  ChangeRelationshipsList , ChangeRelationshipClassType , ChangeRelationshipDescription , ChangeRelationshipLowCC ,
  ChangeRelationshipHighCC , ChangeRelationshipComposite , ChangeRelationshipExclusive , ChangeRelationshipDependent ,
  ChangeMethodsList , ChangeMethodDescription , ChangeMethodImplementation
}
 Information about class property changes. More...
typedef std::set< OksClass *, SortByName > Set
typedef std::map< const char *, OksClass *, SortStr > Map
typedef std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
typedef void(*) NotifyFN(OksClass *)
typedef void(*) ChangeNotifyFN(OksClass *, ChangeType, const void *)

Public Member Functions

 OksClass (const std::string &name, OksKernel *kernel, bool transient=false)
 Create OKS class.
 OksClass (const std::string &name, const std::string &description, bool is_abstract, OksKernel *kernel, bool transient=false)
 Create OKS class and set its basic properties.
 OksClass (OksKernel *kernel, const std::string &name, const std::string &description, bool is_abstract)
 Create OKS class for internal usage (fast, no complete registration).
bool operator== (const OksClass &) const
 The equality operator.
bool operator!= (const OksClass &) const
 The not equal operator.
bool compare_without_methods (const OksClass &c) const noexcept
OksKernel * get_kernel () const noexcept
OksFile * get_file () const noexcept
void set_file (OksFile *f, bool update_owner=true)
 Move class to different file.
const std::string & get_name () const noexcept
const std::string & get_description () const noexcept
void set_description (const std::string &description)
 Set class description.
bool get_is_abstract () const noexcept
void set_is_abstract (bool abstract)
 Set class abstract property.
const FList * all_super_classes () const noexcept
const std::list< std::string * > * direct_super_classes () const noexcept
OksClass * find_super_class (const std::string &) const noexcept
bool has_direct_super_class (const std::string &) const noexcept
void add_super_class (const std::string &name)
void k_add_super_class (const std::string &name)
void remove_super_class (const std::string &name)
void swap_super_classes (const std::string &c1, const std::string &c2)
 Swap order of two superclasses.
const FList * all_sub_classes () const noexcept
const std::list< OksAttribute * > * all_attributes () const noexcept
const std::list< OksAttribute * > * direct_attributes () const noexcept
OksAttribute * find_attribute (const std::string &name) const noexcept
 Find attribute (search in this and base classes).
OksAttribute * find_direct_attribute (const std::string &name) const noexcept
 Find direct attribute.
void add (OksAttribute *a)
 Add attribute.
void k_add (OksAttribute *a)
 Kernel method to add attribute.
void remove (const OksAttribute *a)
 Remove attribute.
void swap (const OksAttribute *a1, const OksAttribute *a2)
 Swap order of two attributes.
size_t number_of_direct_attributes () const noexcept
size_t number_of_all_attributes () const noexcept
OksClass * source_class (const OksAttribute *a) const noexcept
 Get class owning given attribute.
const std::list< OksRelationship * > * all_relationships () const noexcept
const std::list< OksRelationship * > * direct_relationships () const noexcept
OksRelationship * find_relationship (const std::string &name) const noexcept
 Find relationship (search in this and base classes).
OksRelationship * find_direct_relationship (const std::string &name) const noexcept
 Find direct relationship.
void add (OksRelationship *r)
 Add relationship.
void k_add (OksRelationship *r)
 Kernel method to add relationship.
void remove (const OksRelationship *r, bool call_delete=true)
 Remove relationship.
void swap (const OksRelationship *r1, const OksRelationship *r2)
 Swap order of two relationships.
size_t number_of_direct_relationships () const noexcept
size_t number_of_all_relationships () const noexcept
OksClass * source_class (const OksRelationship *r) const noexcept
 Get class owning given relationship.
const std::list< OksMethod * > * all_methods () const noexcept
const std::list< OksMethod * > * direct_methods () const noexcept
OksMethod * find_method (const std::string &name) const noexcept
 Find method (search in this and base classes).
OksMethod * find_direct_method (const std::string &name) const noexcept
 Find direct method.
void add (OksMethod *m)
 Add method.
void remove (const OksMethod *m)
 Remove method.
void swap (const OksMethod *m1, const OksMethod *m2)
 Swap order of two methods.
size_t number_of_direct_methods () const noexcept
size_t number_of_all_methods () const noexcept
OksClass * source_class (const OksMethod *m) const noexcept
 Get class owning given method.
size_t number_of_objects () const noexcept
const OksObject::Map * objects () const noexcept
std::list< OksObject * > * create_list_of_all_objects () const noexcept
 Get all objects of the class (including derived).
OksObject * get_object (const std::string &id) const noexcept
 Get object by ID.
OksObject * get_object (const std::string *id) const noexcept
OksObject::List * execute_query (OksQuery *query) const
 Execute query.
OksDataInfo * data_info (const std::string &s) const noexcept
 Get OKS data information for attribute or relationship.
OksDataInfo * get_data_info (const std::string &s) const noexcept
 Get OKS data information for attribute or relationship.

Static Public Member Functions

static void destroy (OksClass *c)
 Destroy OKS class.

Private Member Functions

 ~OksClass ()
 OksClass (OksXmlInputStream &, OksKernel *)
 OksClass (const char *name, size_t len)
void save (OksXmlOutputStream &) const
void add (OksObject *)
void remove (OksObject *)
void registrate_class (bool skip_registered)
void registrate_class_change (ChangeType, const void *, bool=true)
void registrate_attribute_change (OksAttribute *)
void registrate_relationship_change (OksRelationship *)
void registrate_instances ()
void add_super_classes (FList *) const
void create_super_classes ()
void create_sub_classes ()
void create_attributes ()
void create_relationships ()
void create_methods ()
void lock_file (const char *)
bool check_relationships (std::ostringstream &out, bool print_file_name) const noexcept

Static Private Member Functions

template<class T>
static void destroy_map (T map)
template<class T>
static void destroy_list (T list)

Private Attributes

std::string p_name
std::string p_description
std::list< std::string * > * p_super_classes
std::list< OksAttribute * > * p_attributes
std::list< OksRelationship * > * p_relationships
std::list< OksMethod * > * p_methods
bool p_abstract
bool p_transient
bool p_to_be_deleted
FList * p_all_super_classes
FList * p_all_sub_classes
std::list< OksAttribute * > * p_all_attributes
std::list< OksRelationship * > * p_all_relationships
std::list< OksMethod * > * p_all_methods
std::vector< OksClass * > * p_inheritance_hierarchy
unsigned int p_id
OksFile * p_file
OksKernel * p_kernel
size_t p_instance_size
OksDataInfo::Map * p_data_info
OksObject::Map * p_objects
OksIndex::Map * p_indices
std::shared_mutex p_mutex
std::mutex p_unique_id_mutex

Static Private Attributes

static NotifyFN create_notify_fn
static ChangeNotifyFN change_notify_fn
static NotifyFN delete_notify_fn
static const char class_xml_tag [] = "class"
static const char name_xml_attr [] = "name"
static const char description_xml_attr [] = "description"
static const char is_abstract_xml_attr [] = "is-abstract"
static const char superclass_xml_attr [] = "superclass"

Friends

class OksObject
class OksKernel
class OksAttribute
class OksRelationship
class OksMethod
class OksMethodImplementation
class OksIndex
class OksSortedClass
std::ostream & operator<< (std::ostream &s, const OksClass &c)
 Stream operator.
std::ostream & operator<< (std::ostream &s, const OksObject &o)

Detailed Description

The OKS class.

An OKS class has name, documentation, attributes (list of OksAttribute objects), relationships (list of OksRelationship objects) and methods (list of OksMethod objects).

A class may participate in inheritance (multiple): in such case the class inherits all attributes, relationships and methods of its base classes.

An OKS class can be abstract (i.e. it does not have any instances). Otherwise the objects of class can be accessed via:

  • objects() : get all objects of given class
  • create_list_of_all_objects() : get all objects of given and derived classes
  • get_object(const std::string&) : get object by unique identity
  • execute_query() : get objects satisfying a query See OksObject class to get information how to access properties of object, to create new or to delete existing object.

An OKS class can be made persistent, i.e. stored on OKS schema file.

Definition at line 222 of file class.hpp.

Member Typedef Documentation

◆ ChangeNotifyFN

typedef void(*) dunedaq::oks::OksClass::ChangeNotifyFN(OksClass *, ChangeType, const void *)

Callback function invoked on OKS class modification

Definition at line 877 of file class.hpp.

◆ FList

typedef std::list<OksClass*, boost::fast_pool_allocator<OksClass*> > dunedaq::oks::OksClass::FList

Definition at line 254 of file class.hpp.

◆ Map

typedef std::map<const char*, OksClass*, SortStr> dunedaq::oks::OksClass::Map

Definition at line 252 of file class.hpp.

◆ NotifyFN

typedef void(*) dunedaq::oks::OksClass::NotifyFN(OksClass *)

Callback function invoked on OKS class creation or deletion

Definition at line 873 of file class.hpp.

◆ Set

Definition at line 243 of file class.hpp.

Member Enumeration Documentation

◆ ChangeType

Information about class property changes.

It is used in the ChangeNotifyFN callback, that can be used by user to subscribe on schema changes.

Enumerator
ChangeSuperClassesList 
ChangeSubClassesList 
ChangeDescription 
ChangeIsAbstaract 
ChangeAttributesList 
ChangeAttributeType 
ChangeAttributeRange 
ChangeAttributeFormat 
ChangeAttributeMultiValueCardinality 
ChangeAttributeInitValue 
ChangeAttributeDescription 
ChangeAttributeIsNoNull 
ChangeRelationshipsList 
ChangeRelationshipClassType 
ChangeRelationshipDescription 
ChangeRelationshipLowCC 
ChangeRelationshipHighCC 
ChangeRelationshipComposite 
ChangeRelationshipExclusive 
ChangeRelationshipDependent 
ChangeMethodsList 
ChangeMethodDescription 
ChangeMethodImplementation 

Definition at line 839 of file class.hpp.

840 {
841
846
855
864
868
869 };
@ ChangeAttributeMultiValueCardinality
Definition class.hpp:851

Constructor & Destructor Documentation

◆ OksClass() [1/5]

dunedaq::oks::OksClass::OksClass ( const std::string & name,
OksKernel * kernel,
bool transient = false )

Create OKS class.

The parameters are:

Parameters
namename of new class
kernelOKS kernel owning this class (if empty, class will not be registered)
transientif true, the class is transient (is used by OKS tools, do not change default value)

Definition at line 81 of file class.cpp.

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}
std::list< std::string * > * p_super_classes
Definition class.hpp:882
OksKernel * p_kernel
Definition class.hpp:900
OksObject::Map * p_objects
Definition class.hpp:905
FList * p_all_sub_classes
Definition class.hpp:891
std::list< OksAttribute * > * p_all_attributes
Definition class.hpp:892
std::list< OksMethod * > * p_all_methods
Definition class.hpp:894
OksIndex::Map * p_indices
Definition class.hpp:906
std::list< OksRelationship * > * p_relationships
Definition class.hpp:884
std::string p_name
Definition class.hpp:880
std::vector< OksClass * > * p_inheritance_hierarchy
Definition class.hpp:896
std::list< OksAttribute * > * p_attributes
Definition class.hpp:883
std::list< OksMethod * > * p_methods
Definition class.hpp:885
OksDataInfo::Map * p_data_info
Definition class.hpp:904
std::list< OksRelationship * > * p_all_relationships
Definition class.hpp:893
FList * p_all_super_classes
Definition class.hpp:890
void k_add(OksClass *)
Definition kernel.cpp:4231
std::shared_mutex p_kernel_mutex
Definition kernel.hpp:1965
#define OSK_PROFILING(FID, K)
Definition defs.hpp:96
void validate_not_empty(const std::string &value, const char *name)

◆ OksClass() [2/5]

dunedaq::oks::OksClass::OksClass ( const std::string & name,
const std::string & description,
bool is_abstract,
OksKernel * kernel,
bool transient = false )

Create OKS class and set its basic properties.

The parameters are:

Parameters
namename of new class
descriptiondescription of new class
is_abstractif true, new class is abstract (i.e. may not have objects)
kernelOKS kernel owning this class (if empty, class will not be registered)
transientif true, the class is transient (is used by OKS tools, do not change default value)

Definition at line 112 of file class.cpp.

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}
std::string p_description
Definition class.hpp:881

◆ OksClass() [3/5]

dunedaq::oks::OksClass::OksClass ( OksKernel * kernel,
const std::string & name,
const std::string & description,
bool is_abstract )

Create OKS class for internal usage (fast, no complete registration).

The parameters are:

Parameters
kernelOKS kernel owning this class
namename of new class
descriptiondescription of new class
is_abstractif true, new class is abstract (i.e. may not have objects)

Definition at line 144 of file class.cpp.

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}
OksClass::Map p_classes
Definition kernel.hpp:1987

◆ ~OksClass()

dunedaq::oks::OksClass::~OksClass ( )
private

Definition at line 220 of file class.cpp.

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}
static void destroy_list(T list)
Definition class.cpp:198
static void destroy_map(T map)
Definition class.cpp:210
const std::string & get_name() const noexcept
Definition class.hpp:374
static ChangeNotifyFN change_notify_fn
Definition class.hpp:912
bool is_dangling(OksClass *class_ptr) const
Check pointer on oks class.
Definition kernel.cpp:4415
void k_remove(OksClass *)
Definition kernel.cpp:4260
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116

◆ OksClass() [4/5]

dunedaq::oks::OksClass::OksClass ( OksXmlInputStream & s,
OksKernel * k )
private

Definition at line 498 of file class.cpp.

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))
557 p_abstract = oks::xml::str2bool(attr.value());
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}
OksAttribute(const std::string &name, OksClass *p=nullptr)
OKS attribute simple constructor.
friend class OksMethod
Definition class.hpp:228
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1130
static const char superclass_xml_attr[]
Definition class.hpp:956
OksAttribute * find_direct_attribute(const std::string &name) const noexcept
Find direct attribute.
Definition class.cpp:973
friend class OksAttribute
Definition class.hpp:226
static const char class_xml_tag[]
Definition class.hpp:952
friend class OksRelationship
Definition class.hpp:227
static const char description_xml_attr[]
Definition class.hpp:954
static const char is_abstract_xml_attr[]
Definition class.hpp:955
static const char name_xml_attr[]
Definition class.hpp:953
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1290
bool has_direct_super_class(const std::string &) const noexcept
Definition class.cpp:721
OksMethod(const std::string &name, OksClass *p=nullptr)
OKS method constructor.
Definition method.cpp:116
OksRelationship(const std::string &name, OksClass *p=nullptr)
OKS relationship simple constructor.
bool str2bool(const char *s) noexcept
Definition xml.hpp:36
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:15
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:45
bool cmp_str6(const char *s1, const char s2[7])
Definition cstring.hpp:69
bool cmp_str10(const char *s1, const char s2[11])
Definition cstring.hpp:111
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:105
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

◆ OksClass() [5/5]

dunedaq::oks::OksClass::OksClass ( const char * name,
size_t len )
inlineprivate

Definition at line 1005 of file class.hpp.

1006 : p_name(name, len)
1007 , p_super_classes(0)
1008 , p_attributes(0)
1009 , p_relationships(0)
1010 , p_methods(0)
1011 , p_abstract(false)
1012 , p_transient(true)
1013 , p_to_be_deleted(false)
1016 , p_all_attributes(0)
1018 , p_all_methods(0)
1020 , p_kernel(0)
1021 , p_instance_size(0)
1022 , p_data_info(0)
1023 , p_objects(0)
1024 , p_indices(0)
1025{
1026 ;
1027}

Member Function Documentation

◆ add() [1/4]

void dunedaq::oks::OksClass::add ( OksAttribute * a)

Add attribute.

Add new attribute to class. The class must not have attributes with such name.

Parameters
anew attribute
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1009 of file class.cpp.

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}
void registrate_class_change(ChangeType, const void *, bool=true)
Definition class.cpp:2009
void lock_file(const char *)
Definition class.cpp:733
T attribute(tref item, dunedaq::conffwk::attribute_t const &attr)

◆ add() [2/4]

void dunedaq::oks::OksClass::add ( OksMethod * m)

Add method.

Add new method to class. The class must not have methods with such name.

Parameters
mnew method
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1315 of file class.cpp.

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}

◆ add() [3/4]

void dunedaq::oks::OksClass::add ( OksObject * object)
private

Definition at line 1497 of file class.cpp.

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}
std::shared_mutex p_mutex
Definition class.hpp:908
Changes could not be no object was Database change was not no object was not An invalid qmodel index has been Config layer returned null reference for object

◆ add() [4/4]

void dunedaq::oks::OksClass::add ( OksRelationship * r)

Add relationship.

Add new relationship to class. The class must not have relationships with such name.

Parameters
rnew relationship
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1167 of file class.cpp.

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}

◆ add_super_class()

void dunedaq::oks::OksClass::add_super_class ( const std::string & name)

Add direct base class with given name.

Parameters
namename of superclass
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 840 of file class.cpp.

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}
OksClass(const std::string &name, OksKernel *kernel, bool transient=false)
Create OKS class.
Definition class.cpp:81
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
Definition kernel.hpp:1754
static std::string add_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:824

◆ add_super_classes()

void dunedaq::oks::OksClass::add_super_classes ( FList * clist) const
private

Definition at line 1535 of file class.cpp.

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}
void add_if_not_found(OksClass::FList &clist, OksClass *c)
Definition class.cpp:1525

◆ all_attributes()

const std::list< OksAttribute * > * dunedaq::oks::OksClass::all_attributes ( ) const
inlinenoexcept

Get list of all attributes (including defined in base classes)

Definition at line 470 of file class.hpp.

470{ return p_all_attributes; }

◆ all_methods()

const std::list< OksMethod * > * dunedaq::oks::OksClass::all_methods ( ) const
inlinenoexcept

Get list of all methods (including defined in base classes)

Definition at line 667 of file class.hpp.

667{ return p_all_methods; }

◆ all_relationships()

const std::list< OksRelationship * > * dunedaq::oks::OksClass::all_relationships ( ) const
inlinenoexcept

Get list of all relationships (including defined in base classes)

Definition at line 568 of file class.hpp.

568{ return p_all_relationships; }

◆ all_sub_classes()

const FList * dunedaq::oks::OksClass::all_sub_classes ( ) const
inlinenoexcept

Return list of all derived classes.

Definition at line 463 of file class.hpp.

463{ return p_all_sub_classes; }

◆ all_super_classes()

const FList * dunedaq::oks::OksClass::all_super_classes ( ) const
inlinenoexcept

Return list of all base classes of given class.

Definition at line 413 of file class.hpp.

413{ return p_all_super_classes; }

◆ check_relationships()

bool dunedaq::oks::OksClass::check_relationships ( std::ostringstream & out,
bool print_file_name ) const
privatenoexcept

Definition at line 2098 of file class.cpp.

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}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:572
OksFile * get_file() const noexcept
Definition class.hpp:352
const std::string & get_full_file_name() const
Definition file.hpp:528
FELIX Initialization std::string initerror FELIX queue timed out

◆ compare_without_methods()

bool dunedaq::oks::OksClass::compare_without_methods ( const OksClass & c) const
noexcept

Compare all properties of classes excluding methods

Definition at line 297 of file class.cpp.

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}
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

◆ create_attributes()

void dunedaq::oks::OksClass::create_attributes ( )
private

Definition at line 1620 of file class.cpp.

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);
1637 OksAttribute* a1 = find_direct_attribute(a->get_name());
1638 OksAttribute* a2 = find_attribute(a->get_name());
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}
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Definition class.cpp:985
static std::ostream & warning_msg(const char *)
Definition kernel.cpp:518
bool are_types_different(const OksAttribute *a1, const OksAttribute *a2)
Definition class.cpp:1607
const char * bool2value_type(bool v)
Definition class.cpp:1599

◆ create_list_of_all_objects()

std::list< OksObject * > * dunedaq::oks::OksClass::create_list_of_all_objects ( ) const
noexcept

Get all objects of the class (including derived).

Return all objects of given and derived classes. The list to be deleted by user.

Returns
pointer to list of all objects, or 0 if there are no objects

Definition at line 1444 of file class.cpp.

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}

◆ create_methods()

void dunedaq::oks::OksClass::create_methods ( )
private

Definition at line 1773 of file class.cpp.

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}
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1302

◆ create_relationships()

void dunedaq::oks::OksClass::create_relationships ( )
private

Definition at line 1703 of file class.cpp.

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}
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
Definition class.cpp:1142
const char * card2string(OksRelationship::CardinalityConstraint cc)
Definition class.cpp:1697

◆ create_sub_classes()

void dunedaq::oks::OksClass::create_sub_classes ( )
private

Definition at line 1575 of file class.cpp.

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}
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:254

◆ create_super_classes()

void dunedaq::oks::OksClass::create_super_classes ( )
private

Definition at line 1550 of file class.cpp.

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}
void add_super_classes(FList *) const
Definition class.cpp:1535
int debug_level()
Definition ers.hpp:80

◆ data_info()

OksDataInfo * dunedaq::oks::OksClass::data_info ( const std::string & s) const
inlinenoexcept

Get OKS data information for attribute or relationship.

Pass name of attribute or relationship defined for given class. If it is not defined, the application will crash (no extra checks by efficiency reasons).

Parameters
sname of existing OKS attribute or relationship
Returns
OKS data information pointer

Definition at line 813 of file class.hpp.

813{ return p_data_info->find(s)->second; }

◆ destroy()

void dunedaq::oks::OksClass::destroy ( OksClass * c)
static

Destroy OKS class.

This the the only way available to user to destroy OKS class since ~OksClass() is private.

The parameter is:

Parameters
cthe pointer to class
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 172 of file class.cpp.

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}

◆ destroy_list()

template<class T>
void dunedaq::oks::OksClass::destroy_list ( T list)
staticprivate

Definition at line 198 of file class.cpp.

199{
200 if (list) {
201 for (const auto& x : *list)
202 delete x;
203
204 delete list;
205 }
206}

◆ destroy_map()

template<class T>
void dunedaq::oks::OksClass::destroy_map ( T map)
staticprivate

Definition at line 210 of file class.cpp.

211{
212 if (map) {
213 for (const auto& x : *map)
214 delete x.second;
215
216 delete map;
217 }
218}

◆ direct_attributes()

const std::list< OksAttribute * > * dunedaq::oks::OksClass::direct_attributes ( ) const
inlinenoexcept

Get list of direct attributes

Definition at line 474 of file class.hpp.

474{ return p_attributes; }

◆ direct_methods()

const std::list< OksMethod * > * dunedaq::oks::OksClass::direct_methods ( ) const
inlinenoexcept

Get list of direct methods

Definition at line 671 of file class.hpp.

671{ return p_methods; }

◆ direct_relationships()

const std::list< OksRelationship * > * dunedaq::oks::OksClass::direct_relationships ( ) const
inlinenoexcept

Get list of direct relationships

Definition at line 572 of file class.hpp.

572{ return p_relationships; }

◆ direct_super_classes()

const std::list< std::string * > * dunedaq::oks::OksClass::direct_super_classes ( ) const
inlinenoexcept

Return list of direct base classes of given class.

Definition at line 417 of file class.hpp.

417{ return p_super_classes; }

◆ execute_query()

OksObject::List * dunedaq::oks::OksClass::execute_query ( OksQuery * query) const

Execute query.

Return list of objects satisfying given query. The list to be deleted by user.

Parameters
queryOKS query
Returns
pointer to list of all objects, or 0 if there are no objects
Exceptions
Incase of problems the oks::exception is thrown.

Definition at line 446 of file query.cpp.

447{
448 const char* fname = "OksClass::execute_query()";
449
451
452 OksObject::List* olist = 0;
453 OksQueryExpression* sqe = qe->get();
454
455 if (sqe->CheckSyntax() == false) {
456 Oks::error_msg(fname) << "Can't execute query \"" << *sqe << "\"\n";
457 return 0;
458 }
459
460 if (p_objects && !p_objects->empty()) {
461 bool indexedSearch = false;
462
463 if (p_indices) {
464 if (sqe->type() == OksQuery::comparator_type) {
465 OksComparator* cq = (OksComparator*)sqe;
466 OksIndex::Map::iterator j = p_indices->find(cq->GetAttribute());
467
468 if (j != p_indices->end()) {
469 indexedSearch = true;
470 olist = (*j).second->find_all(cq->GetValue(), cq->GetFunction());
471 }
472 } else if ((sqe->type() == OksQuery::and_type) || (sqe->type() == OksQuery::or_type)) {
473 std::list<OksQueryExpression*>* qlist = &((OksListBaseQueryExpression*)sqe)->p_expressions;
474 OksQueryExpression *q1, *q2;
475 OksComparator *cq1 = 0, *cq2 = 0;
476
477 if ((qlist->size() == 2) && ((q1 = qlist->front())->type() == OksQuery::comparator_type) &&
478 ((q2 = qlist->back())->type() == OksQuery::comparator_type) && ((cq1 = (OksComparator*)q1) != 0) &&
479 ((cq2 = (OksComparator*)q2) != 0) && (cq1->GetAttribute() == cq2->GetAttribute())) {
480 OksIndex::Map::iterator j = p_indices->find(cq1->GetAttribute());
481
482 if (j != p_indices->end()) {
483 indexedSearch = true;
484
485 olist = (*j).second->find_all(((sqe->type() == OksQuery::and_type) ? true : false),
486 cq1->GetValue(),
487 cq1->GetFunction(),
488 cq2->GetValue(),
489 cq2->GetFunction());
490 }
491 }
492 }
493 }
494
495 if (indexedSearch == false) {
496 for (OksObject::Map::iterator i = p_objects->begin(); i != p_objects->end(); ++i) {
497 OksObject* o = (*i).second;
498
499 try {
500 if (o->SatisfiesQueryExpression(sqe) == true) {
501 if (!olist)
502 olist = new OksObject::List();
503 olist->push_back(o);
504 }
505 } catch (oks::exception& ex) {
506 throw oks::QueryFailed(*sqe, *this, ex);
507 } catch (std::exception& ex) {
508 throw oks::QueryFailed(*sqe, *this, ex.what());
509 }
510 }
511 }
512 }
513
514 if (qe->search_in_subclasses() == true && p_all_sub_classes && !p_all_sub_classes->empty()) {
515 for (OksClass::FList::iterator i = p_all_sub_classes->begin(); i != p_all_sub_classes->end(); ++i) {
516 OksClass* c = *i;
517
518 if (c->p_objects && !c->p_objects->empty()) {
519 for (OksObject::Map::iterator i2 = c->p_objects->begin(); i2 != c->p_objects->end(); ++i2) {
520 OksObject* o = (*i2).second;
521
522 try {
523 if (o->SatisfiesQueryExpression(sqe) == true) {
524 if (!olist)
525 olist = new OksObject::List();
526 olist->push_back(o);
527 }
528 } catch (oks::exception& ex) {
529 throw oks::QueryFailed(*sqe, *this, ex);
530 } catch (std::exception& ex) {
531 throw oks::QueryFailed(*sqe, *this, ex.what());
532 }
533 }
534 }
535 }
536 }
537
538 return olist;
539}
friend class OksObject
Definition class.hpp:224
std::list< OksObject * > List
Definition object.hpp:1179
static std::ostream & error_msg(const char *)
Definition kernel.cpp:511

◆ find_attribute()

OksAttribute * dunedaq::oks::OksClass::find_attribute ( const std::string & name) const
noexcept

Find attribute (search in this and base classes).

Get attribute by name.

Parameters
nameattribute name
Returns
found attribute or 0, if this and base classes have no attribute with such name

Definition at line 985 of file class.cpp.

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}

◆ find_direct_attribute()

OksAttribute * dunedaq::oks::OksClass::find_direct_attribute ( const std::string & name) const
noexcept

Find direct attribute.

Get attribute by name.

Parameters
nameattribute name
Returns
found attribute or 0, if this class has no attribute with such name

Definition at line 973 of file class.cpp.

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}

◆ find_direct_method()

OksMethod * dunedaq::oks::OksClass::find_direct_method ( const std::string & name) const
noexcept

Find direct method.

Get method by name.

Parameters
namemethod name
Returns
found method or 0, if this class has no method with such name

Definition at line 1290 of file class.cpp.

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}

◆ find_direct_relationship()

OksRelationship * dunedaq::oks::OksClass::find_direct_relationship ( const std::string & name) const
noexcept

Find direct relationship.

Get relationship by name.

Parameters
namerelationship name
Returns
found relationship or 0, if this class has no relationship with such name

Definition at line 1130 of file class.cpp.

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}

◆ find_method()

OksMethod * dunedaq::oks::OksClass::find_method ( const std::string & name) const
noexcept

Find method (search in this and base classes).

Get method by name.

Parameters
namemethod name
Returns
found method or 0, if this and base classes have no method with such name

Definition at line 1302 of file class.cpp.

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}

◆ find_relationship()

OksRelationship * dunedaq::oks::OksClass::find_relationship ( const std::string & name) const
noexcept

Find relationship (search in this and base classes).

Get relationship by name.

Parameters
namerelationship name
Returns
found relationship or 0, if this and base classes have no relationship with such name

Definition at line 1142 of file class.cpp.

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}

◆ find_super_class()

OksClass * dunedaq::oks::OksClass::find_super_class ( const std::string & nm) const
noexcept

Search class by name among all base classes of given class.

Definition at line 708 of file class.cpp.

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}

◆ get_data_info()

OksDataInfo * dunedaq::oks::OksClass::get_data_info ( const std::string & s) const
inlinenoexcept

Get OKS data information for attribute or relationship.

Pass name of attribute or relationship defined for given class. Safe version of data_info()

Parameters
sname of existing OKS attribute or relationship
Returns
OKS data information pointer or nullptr if no such attribute or relationship

Definition at line 825 of file class.hpp.

826 {
827 auto it = p_data_info->find(s);
828 return (it != p_data_info->end() ? it->second : nullptr);
829 }

◆ get_description()

const std::string & dunedaq::oks::OksClass::get_description ( ) const
inlinenoexcept

Return description of class.

Definition at line 378 of file class.hpp.

378{ return p_description; }

◆ get_file()

OksFile * dunedaq::oks::OksClass::get_file ( ) const
inlinenoexcept

Get file of object.

Definition at line 352 of file class.hpp.

352{ return p_file; }

◆ get_is_abstract()

bool dunedaq::oks::OksClass::get_is_abstract ( ) const
inlinenoexcept

Return true if class is abstract (i.e. has no objects).

Definition at line 392 of file class.hpp.

392{ return p_abstract; }

◆ get_kernel()

OksKernel * dunedaq::oks::OksClass::get_kernel ( ) const
inlinenoexcept

Get OKS kernel which registering given class.

Definition at line 348 of file class.hpp.

348{ return p_kernel; }

◆ get_name()

const std::string & dunedaq::oks::OksClass::get_name ( ) const
inlinenoexcept

Return name of class.

Definition at line 374 of file class.hpp.

374{ return p_name; }

◆ get_object() [1/2]

OksObject * dunedaq::oks::OksClass::get_object ( const std::string & id) const
noexcept

Get object by ID.

Return pointer to object of given class by identity.

Returns
pointer to object, or 0 if there is no such object

Definition at line 1479 of file class.cpp.

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}

◆ get_object() [2/2]

OksObject * dunedaq::oks::OksClass::get_object ( const std::string * id) const
inlinenoexcept

See get_object(const std::string&)

Definition at line 787 of file class.hpp.

787{ return get_object(*id); }
OksObject * get_object(const std::string &id) const noexcept
Get object by ID.
Definition class.cpp:1479

◆ has_direct_super_class()

bool dunedaq::oks::OksClass::has_direct_super_class ( const std::string & nm) const
noexcept

Return true, if class has direct base class with given name.

Definition at line 721 of file class.cpp.

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}

◆ k_add() [1/2]

void dunedaq::oks::OksClass::k_add ( OksAttribute * a)

Kernel method to add attribute.

Parameters
anew attribute

Definition at line 998 of file class.cpp.

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}

◆ k_add() [2/2]

void dunedaq::oks::OksClass::k_add ( OksRelationship * r)

Kernel method to add relationship.

Parameters
rnew relationship

Definition at line 1156 of file class.cpp.

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}

◆ k_add_super_class()

void dunedaq::oks::OksClass::k_add_super_class ( const std::string & name)

Kernel method to add direct base class with given name.

Definition at line 830 of file class.cpp.

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}

◆ lock_file()

void dunedaq::oks::OksClass::lock_file ( const char * fname)
private

Definition at line 733 of file class.cpp.

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}
void lock()
Lock OKS file.
Definition file.cpp:1004

◆ number_of_all_attributes()

size_t dunedaq::oks::OksClass::number_of_all_attributes ( ) const
inlinenoexcept

Get number of all attributes (including attributes from this and base classes)

Definition at line 976 of file class.hpp.

977{
978 return (p_all_attributes ? p_all_attributes->size() : 0);
979}

◆ number_of_all_methods()

size_t dunedaq::oks::OksClass::number_of_all_methods ( ) const
inlinenoexcept

Get number of all methods (including methods from this and base classes)

Definition at line 1000 of file class.hpp.

1001{
1002 return (p_all_methods ? p_all_methods->size() : 0);
1003}

◆ number_of_all_relationships()

size_t dunedaq::oks::OksClass::number_of_all_relationships ( ) const
inlinenoexcept

Get number of all relationships (including relationships from this and base classes)

Definition at line 988 of file class.hpp.

989{
990 return (p_all_relationships ? p_all_relationships->size() : 0);
991}

◆ number_of_direct_attributes()

size_t dunedaq::oks::OksClass::number_of_direct_attributes ( ) const
inlinenoexcept

Get number of direct attributes

Definition at line 970 of file class.hpp.

971{
972 return (p_attributes ? p_attributes->size() : 0);
973}

◆ number_of_direct_methods()

size_t dunedaq::oks::OksClass::number_of_direct_methods ( ) const
inlinenoexcept

Get number of direct methods

Definition at line 994 of file class.hpp.

995{
996 return (p_methods ? p_methods->size() : 0);
997}

◆ number_of_direct_relationships()

size_t dunedaq::oks::OksClass::number_of_direct_relationships ( ) const
inlinenoexcept

Get number of direct relationships

Definition at line 982 of file class.hpp.

983{
984 return (p_relationships ? p_relationships->size() : 0);
985}

◆ number_of_objects()

size_t dunedaq::oks::OksClass::number_of_objects ( ) const
noexcept

Get number of objects of given class

Definition at line 1433 of file class.cpp.

1434{
1435 return (!p_objects ? 0 : p_objects->size());
1436}

◆ objects()

const OksObject::Map * dunedaq::oks::OksClass::objects ( ) const
inlinenoexcept

Get objects of given class (the pointer can be 0)

Definition at line 762 of file class.hpp.

762{ return p_objects; }

◆ operator!=()

bool dunedaq::oks::OksClass::operator!= ( const OksClass & c) const

The not equal operator.

The operator returns false, if two classes have equal attributes, relationships and methods.

Definition at line 354 of file class.cpp.

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}
bool compare_without_methods(const OksClass &c) const noexcept
Definition class.cpp:297

◆ operator==()

bool dunedaq::oks::OksClass::operator== ( const OksClass & c) const
inline

The equality operator.

The operator returns true, if two classes have equal names.

Definition at line 964 of file class.hpp.

965{
966 return ((this == &c || p_name == c.p_name) ? true : false);
967}

◆ registrate_attribute_change()

void dunedaq::oks::OksClass::registrate_attribute_change ( OksAttribute * a)
private

Definition at line 1804 of file class.cpp.

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}
double offset

◆ registrate_class()

void dunedaq::oks::OksClass::registrate_class ( bool skip_registered)
private

Definition at line 1979 of file class.cpp.

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}
std::unordered_map< const std::string *, OksObject *, oks::hash_str, oks::equal_str > Map
Definition object.hpp:1170
std::map< std::string, OksDataInfo * > Map
Declare map of pointers to OksDataInfo (unsorted by name).
Definition object.hpp:383

◆ registrate_class_change()

void dunedaq::oks::OksClass::registrate_class_change ( ChangeType changeType,
const void * parameter,
bool update_file = true )
private

Definition at line 2009 of file class.cpp.

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}
Factory couldn t find
Definition Issues.hpp:24

◆ registrate_instances()

void dunedaq::oks::OksClass::registrate_instances ( )
private

Definition at line 1867 of file class.cpp.

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}
OksDataInfo(size_t o, const OksAttribute *a)
Constructors.
Definition object.hpp:387

◆ registrate_relationship_change()

void dunedaq::oks::OksClass::registrate_relationship_change ( OksRelationship * r)
private

Definition at line 1840 of file class.cpp.

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}

◆ remove() [1/4]

void dunedaq::oks::OksClass::remove ( const OksAttribute * a)

Remove attribute.

Remove attribute from class. The attribute mush be direct attribute of the class.

Parameters
aattribute to be removed
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1082 of file class.cpp.

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}

◆ remove() [2/4]

void dunedaq::oks::OksClass::remove ( const OksMethod * m)

Remove method.

Remove method from class. The method mush be direct method of the class.

Parameters
mmethod to be removed
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1342 of file class.cpp.

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}

◆ remove() [3/4]

void dunedaq::oks::OksClass::remove ( const OksRelationship * r,
bool call_delete = true )

Remove relationship.

Remove relationship from class. The relationship must be direct method of the class.

Parameters
rrelationship to be removed
call_deleteif true, delete removed relationship
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1192 of file class.cpp.

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}

◆ remove() [4/4]

void dunedaq::oks::OksClass::remove ( OksObject * object)
private

Definition at line 1507 of file class.cpp.

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}

◆ remove_super_class()

void dunedaq::oks::OksClass::remove_super_class ( const std::string & name)

Remove direct base class with given name.

Parameters
namename of superclass
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 887 of file class.cpp.

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}
static std::string remove_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:881

◆ save()

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

Definition at line 445 of file class.cpp.

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}
const char * bool2str(bool b) noexcept
Definition xml.hpp:29

◆ set_description()

void dunedaq::oks::OksClass::set_description ( const std::string & description)

Set class description.

Parameters
descriptionnew description of attribute (max 2000 bytes, see #s_max_description_length variable)
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 745 of file class.cpp.

746{
747 if (p_description != s) {
748 lock_file("OksClass::set_description");
749
751
752 if (p_kernel) {
755 (*OksClass::change_notify_fn)(this, ChangeDescription, 0);
756 }
757 }
758 }
759}

◆ set_file()

void dunedaq::oks::OksClass::set_file ( OksFile * f,
bool update_owner = true )

Move class to different file.

Move class to an existing file. Both, present file where object is stored and new destination file have to be writable by user.

The parameters are:

Parameters
filedestination file
update_ownermark original file as updated
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 277 of file class.cpp.

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}

◆ set_is_abstract()

void dunedaq::oks::OksClass::set_is_abstract ( bool abstract)

Set class abstract property.

If the class is abstract, it may not have objects. However the derived classes may have, if they are not abstract themselves.

Parameters
abstractpass true to make class abstract
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 762 of file class.cpp.

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}

◆ source_class() [1/3]

OksClass * dunedaq::oks::OksClass::source_class ( const OksAttribute * a) const
noexcept

Get class owning given attribute.

Return class where attribute is defined.

Parameters
athe attribute
Returns
pointer to class where attribute is defined or 0, if the attribute does not belong to a class

Definition at line 1120 of file class.cpp.

1121{
1122 return a->p_class;
1123}

◆ source_class() [2/3]

OksClass * dunedaq::oks::OksClass::source_class ( const OksMethod * m) const
noexcept

Get class owning given method.

Return class where method is defined.

Parameters
mthe method
Returns
pointer to class where method is defined or 0, if the method does not belong to a class

Definition at line 1423 of file class.cpp.

1424{
1425 return m->p_class;
1426}

◆ source_class() [3/3]

OksClass * dunedaq::oks::OksClass::source_class ( const OksRelationship * r) const
noexcept

Get class owning given relationship.

Return class where relationship is defined.

Parameters
rthe relationship
Returns
pointer to class where relationship is defined or 0, if the relationship does not belong to a class

Definition at line 1280 of file class.cpp.

1281{
1282 return r->p_class;
1283}

◆ swap() [1/3]

void dunedaq::oks::OksClass::swap ( const OksAttribute * a1,
const OksAttribute * a2 )

Swap order of two attributes.

Swap position of two attributes. The attributes must be direct attributes of given class.

Parameters
a1first attribute
a2second attribute
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1034 of file class.cpp.

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}
static void check_and_report_empty_parameter(const char *fname, bool b1, bool b2)
Definition class.cpp:781
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

◆ swap() [2/3]

void dunedaq::oks::OksClass::swap ( const OksMethod * m1,
const OksMethod * m2 )

Swap order of two methods.

Swap position of two methods. The methods must be direct methods of given class.

Parameters
m1first method
m2second method
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1380 of file class.cpp.

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}

◆ swap() [3/3]

void dunedaq::oks::OksClass::swap ( const OksRelationship * r1,
const OksRelationship * r2 )

Swap order of two relationships.

Swap position of two relationships. The relationships must be direct relationships of given class.

Parameters
r1first relationship
r2second relationship
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 1232 of file class.cpp.

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}

◆ swap_super_classes()

void dunedaq::oks::OksClass::swap_super_classes ( const std::string & c1,
const std::string & c2 )

Swap order of two superclasses.

Swap position of two superclasses. The superclasses must be direct superclasses of given class.

Parameters
c1name of first superclass
c2name of second superclass
Exceptions
oks::exceptionis thrown in case of problems

Definition at line 920 of file class.cpp.

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}

◆ OksAttribute

friend class OksAttribute
friend

Definition at line 226 of file class.hpp.

◆ OksIndex

friend class OksIndex
friend

Definition at line 230 of file class.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 225 of file class.hpp.

◆ OksMethod

friend class OksMethod
friend

Definition at line 228 of file class.hpp.

◆ OksMethodImplementation

friend class OksMethodImplementation
friend

Definition at line 229 of file class.hpp.

◆ OksObject

friend class OksObject
friend

Definition at line 224 of file class.hpp.

◆ OksRelationship

friend class OksRelationship
friend

Definition at line 227 of file class.hpp.

◆ OksSortedClass

friend class OksSortedClass
friend

Definition at line 231 of file class.hpp.

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & s,
const OksClass & c )
friend

Stream operator.

Send to stream complete description of OKS class:

  • print class name
  • print details of attributes, relationships and methods
  • print details of objects

Definition at line 380 of file class.cpp.

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}
std::map< const std::string *, OksObject *, SortById > SMap
Definition object.hpp:1166

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & s,
const OksObject & o )
friend

Definition at line 1624 of file object.cpp.

1626{
1627 OSK_PROFILING(OksProfiler::ObjectOperatorOut, o.uid.class_id->p_kernel)
1628
1629 const OksClass* c = o.uid.class_id;
1630
1631 s << "Object " << &o << std::endl;
1632
1633 OksData* di = o.data;
1634
1635 // print attributes
1636
1637 {
1638 const std::list<OksAttribute*>* alist = c->all_attributes();
1639
1640 if (alist && !alist->empty()) {
1641 s << " Attributes are:\n";
1642
1643 for (std::list<OksAttribute*>::const_iterator i = alist->begin(); i != alist->end(); ++i) {
1644 if ((*i)->is_integer() && (*i)->get_format() != OksAttribute::Dec) {
1645 s.setf(((*i)->get_format() == OksAttribute::Hex ? std::ios::hex : std::ios::oct), std::ios::basefield);
1646 s.setf(std::ios::showbase);
1647 }
1648
1649 s << " " << (*i)->get_name() << ": " << *di++ << std::endl;
1650
1651 if ((*i)->is_integer() && (*i)->get_format() != OksAttribute::Dec) {
1652 s.setf(std::ios::dec, std::ios::basefield);
1653 s.unsetf(std::ios::showbase);
1654 }
1655 }
1656 } else
1657 s << " There are no attributes\n";
1658 }
1659
1660 // print relationships
1661
1662 {
1663 const std::list<OksRelationship*>* rlist = c->all_relationships();
1664
1665 if (rlist && !rlist->empty()) {
1666 s << " Relationships are:\n";
1667
1668 for (std::list<OksRelationship*>::const_iterator i = rlist->begin(); i != rlist->end(); ++i)
1669 s << " " << (*i)->get_name() << ": " << *di++ << std::endl;
1670 } else
1671 s << " There are no relationships\n";
1672 }
1673
1674 return s;
1675}

Member Data Documentation

◆ change_notify_fn

OksClass::ChangeNotifyFN dunedaq::oks::OksClass::change_notify_fn
staticprivate

Definition at line 912 of file class.hpp.

◆ class_xml_tag

const char dunedaq::oks::OksClass::class_xml_tag = "class"
staticprivate

Definition at line 952 of file class.hpp.

◆ create_notify_fn

OksClass::NotifyFN dunedaq::oks::OksClass::create_notify_fn
staticprivate

Definition at line 911 of file class.hpp.

◆ delete_notify_fn

OksClass::NotifyFN dunedaq::oks::OksClass::delete_notify_fn
staticprivate

Definition at line 913 of file class.hpp.

◆ description_xml_attr

const char dunedaq::oks::OksClass::description_xml_attr = "description"
staticprivate

Definition at line 954 of file class.hpp.

◆ is_abstract_xml_attr

const char dunedaq::oks::OksClass::is_abstract_xml_attr = "is-abstract"
staticprivate

Definition at line 955 of file class.hpp.

◆ name_xml_attr

const char dunedaq::oks::OksClass::name_xml_attr = "name"
staticprivate

Definition at line 953 of file class.hpp.

◆ p_abstract

bool dunedaq::oks::OksClass::p_abstract
private

Definition at line 886 of file class.hpp.

◆ p_all_attributes

std::list<OksAttribute*>* dunedaq::oks::OksClass::p_all_attributes
private

Definition at line 892 of file class.hpp.

◆ p_all_methods

std::list<OksMethod*>* dunedaq::oks::OksClass::p_all_methods
private

Definition at line 894 of file class.hpp.

◆ p_all_relationships

std::list<OksRelationship*>* dunedaq::oks::OksClass::p_all_relationships
private

Definition at line 893 of file class.hpp.

◆ p_all_sub_classes

FList* dunedaq::oks::OksClass::p_all_sub_classes
private

Definition at line 891 of file class.hpp.

◆ p_all_super_classes

FList* dunedaq::oks::OksClass::p_all_super_classes
private

Definition at line 890 of file class.hpp.

◆ p_attributes

std::list<OksAttribute*>* dunedaq::oks::OksClass::p_attributes
private

Definition at line 883 of file class.hpp.

◆ p_data_info

OksDataInfo::Map* dunedaq::oks::OksClass::p_data_info
private

Definition at line 904 of file class.hpp.

◆ p_description

std::string dunedaq::oks::OksClass::p_description
private

Definition at line 881 of file class.hpp.

◆ p_file

OksFile* dunedaq::oks::OksClass::p_file
private

Definition at line 899 of file class.hpp.

◆ p_id

unsigned int dunedaq::oks::OksClass::p_id
private

Definition at line 897 of file class.hpp.

◆ p_indices

OksIndex::Map* dunedaq::oks::OksClass::p_indices
private

Definition at line 906 of file class.hpp.

◆ p_inheritance_hierarchy

std::vector<OksClass*>* dunedaq::oks::OksClass::p_inheritance_hierarchy
private

Definition at line 896 of file class.hpp.

◆ p_instance_size

size_t dunedaq::oks::OksClass::p_instance_size
private

Definition at line 902 of file class.hpp.

◆ p_kernel

OksKernel* dunedaq::oks::OksClass::p_kernel
private

Definition at line 900 of file class.hpp.

◆ p_methods

std::list<OksMethod*>* dunedaq::oks::OksClass::p_methods
private

Definition at line 885 of file class.hpp.

◆ p_mutex

std::shared_mutex dunedaq::oks::OksClass::p_mutex
mutableprivate

Definition at line 908 of file class.hpp.

◆ p_name

std::string dunedaq::oks::OksClass::p_name
private

Definition at line 880 of file class.hpp.

◆ p_objects

OksObject::Map* dunedaq::oks::OksClass::p_objects
private

Definition at line 905 of file class.hpp.

◆ p_relationships

std::list<OksRelationship*>* dunedaq::oks::OksClass::p_relationships
private

Definition at line 884 of file class.hpp.

◆ p_super_classes

std::list<std::string*>* dunedaq::oks::OksClass::p_super_classes
private

Definition at line 882 of file class.hpp.

◆ p_to_be_deleted

bool dunedaq::oks::OksClass::p_to_be_deleted
private

Definition at line 888 of file class.hpp.

◆ p_transient

bool dunedaq::oks::OksClass::p_transient
private

Definition at line 887 of file class.hpp.

◆ p_unique_id_mutex

std::mutex dunedaq::oks::OksClass::p_unique_id_mutex
mutableprivate

Definition at line 909 of file class.hpp.

◆ superclass_xml_attr

const char dunedaq::oks::OksClass::superclass_xml_attr = "superclass"
staticprivate

Definition at line 956 of file class.hpp.


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