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 *, SortByNameSet
typedef std::map< const char *, OksClass *, SortStrMap
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
OksKernelget_kernel () const noexcept
OksFileget_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 FListall_super_classes () const noexcept
const std::list< std::string * > * direct_super_classes () const noexcept
OksClassfind_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 FListall_sub_classes () const noexcept
const std::list< OksAttribute * > * all_attributes () const noexcept
const std::list< OksAttribute * > * direct_attributes () const noexcept
OksAttributefind_attribute (const std::string &name) const noexcept
 Find attribute (search in this and base classes).
OksAttributefind_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
OksClasssource_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
OksRelationshipfind_relationship (const std::string &name) const noexcept
 Find relationship (search in this and base classes).
OksRelationshipfind_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
OksClasssource_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
OksMethodfind_method (const std::string &name) const noexcept
 Find method (search in this and base classes).
OksMethodfind_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
OksClasssource_class (const OksMethod *m) const noexcept
 Get class owning given method.
size_t number_of_objects () const noexcept
const OksObject::Mapobjects () const noexcept
std::list< OksObject * > * create_list_of_all_objects () const noexcept
 Get all objects of the class (including derived).
OksObjectget_object (const std::string &id) const noexcept
 Get object by ID.
OksObjectget_object (const std::string *id) const noexcept
OksObject::Listexecute_query (OksQuery *query) const
 Execute query.
OksDataInfodata_info (const std::string &s) const noexcept
 Get OKS data information for attribute or relationship.
OksDataInfoget_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
FListp_all_super_classes
FListp_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
OksFilep_file
OksKernelp_kernel
size_t p_instance_size
OksDataInfo::Mapp_data_info
OksObject::Mapp_objects
OksIndex::Mapp_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 204 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 933 of file class.hpp.

◆ FList

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

Definition at line 240 of file class.hpp.

◆ Map

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

Definition at line 238 of file class.hpp.

◆ NotifyFN

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

Callback function invoked on OKS class creation or deletion

Definition at line 928 of file class.hpp.

◆ Set

Definition at line 227 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 894 of file class.hpp.

894 {
895
900
909
918
922
923 };
@ ChangeAttributeMultiValueCardinality
Definition class.hpp:905

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 80 of file class.cpp.

80 :
81 p_name (nm),
83 p_attributes (0),
85 p_methods (0),
86 p_abstract (false),
87 p_transient (t),
88 p_to_be_deleted (false),
93 p_all_methods (0),
95 p_kernel (k),
97 p_data_info (0),
98 p_objects (0),
99 p_indices (0)
100{
102
103 if(p_transient == false && p_kernel)
104 {
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}
OksKernel * p_kernel
Definition class.hpp:958
std::list< std::string * > * p_super_classes
Definition class.hpp:940
OksObject::Map * p_objects
Definition class.hpp:963
std::list< OksMethod * > * p_methods
Definition class.hpp:943
FList * p_all_sub_classes
Definition class.hpp:949
std::list< OksRelationship * > * p_relationships
Definition class.hpp:942
std::list< OksAttribute * > * p_attributes
Definition class.hpp:941
std::list< OksRelationship * > * p_all_relationships
Definition class.hpp:951
std::list< OksMethod * > * p_all_methods
Definition class.hpp:952
std::vector< OksClass * > * p_inheritance_hierarchy
Definition class.hpp:954
OksIndex::Map * p_indices
Definition class.hpp:964
std::string p_name
Definition class.hpp:938
std::list< OksAttribute * > * p_all_attributes
Definition class.hpp:950
OksDataInfo::Map * p_data_info
Definition class.hpp:962
FList * p_all_super_classes
Definition class.hpp:948
#define OSK_PROFILING(FID, K)
Definition defs.hpp:102
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 113 of file class.cpp.

113 :
114 p_name (nm),
115 p_description (d),
116 p_super_classes (0),
117 p_attributes (0),
118 p_relationships (0),
119 p_methods (0),
120 p_abstract (a),
121 p_transient (t),
122 p_to_be_deleted (false),
127 p_all_methods (0),
129 p_kernel (k),
130 p_instance_size (0),
131 p_data_info (0),
132 p_objects (0),
133 p_indices (0)
134{
136
137 if(p_transient == false && p_kernel)
138 {
139 oks::validate_not_empty(p_name, "class name");
140
141 std::unique_lock lock(p_kernel->p_kernel_mutex);
142 p_kernel->k_add(this);
143 }
144}
std::string p_description
Definition class.hpp:939

◆ 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 147 of file class.cpp.

147 :
148 p_name (name),
149 p_description (description),
150 p_super_classes (0),
151 p_attributes (0),
152 p_relationships (0),
153 p_methods (0),
154 p_abstract (is_abstract),
155 p_transient (false),
156 p_to_be_deleted (false),
161 p_all_methods (0),
163 p_file (kernel->p_active_schema),
164 p_kernel (kernel),
165 p_instance_size (0),
166 p_data_info (0),
167 p_objects (0),
168 p_indices (0)
169{
171 p_kernel->p_classes[p_name.c_str()] = this;
172}

◆ ~OksClass()

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

Definition at line 227 of file class.cpp.

228{
230
231 TLOG_DEBUG(2) << "destruct " << (p_transient ? "TRANSIENT" : "NORMAL") << " class \'" << get_name() << '\'' ;
232
233 // ~OksIndex() removes 'SELF' from OksClass and deletes 'indices' when there is no an index in it
234 while (p_indices)
235 delete (*(p_indices->begin())).second;
236
239
240 if (!p_transient && p_kernel)
241 {
242 p_kernel->k_remove(this);
243
245 for (const auto &c : *p_all_super_classes)
246 {
247 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
248 continue;
249
250 c->create_sub_classes();
251
253 (*OksClass::change_notify_fn)(c, ChangeSubClassesList, (const void*) &p_name);
254 }
255
257 for (const auto &c : *p_all_sub_classes)
258 {
259 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
260 continue;
261
262 try
263 {
264 c->registrate_class_change(ChangeSuperClassesList, (const void*) &p_name, false);
265 }
266 catch (oks::exception &ex)
267 {
268 std::cerr << "internal OKS error: registrate_class_change() failed during \'" << get_name() << "\' class destruction\ncaused by: " << ex.what() << std::endl;
269 }
270 }
271 }
272
277
278 if (!p_transient)
279 {
280 delete p_all_super_classes;
281 delete p_all_sub_classes;
282 delete p_all_attributes;
283 delete p_all_relationships;
284 delete p_all_methods;
286 }
287}
static void destroy_list(T list)
Definition class.cpp:203
static void destroy_map(T map)
Definition class.cpp:216
const std::string & get_name() const noexcept
Definition class.hpp:368
static ChangeNotifyFN change_notify_fn
Definition class.hpp:972
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ OksClass() [4/5]

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

Definition at line 518 of file class.cpp.

518 :
519 p_super_classes (0),
520 p_attributes (0),
521 p_relationships (0),
522 p_methods (0),
523 p_abstract (false),
524 p_transient (false),
525 p_to_be_deleted (false),
530 p_all_methods (0),
532 p_kernel (k),
533 p_instance_size (0),
534 p_data_info (0),
535 p_objects (0),
536 p_indices (0)
537{
538
539 // read 'relationship' tag header
540
541 {
542 try {
543 const char * tag_start = s.get_tag_start();
544
545 if(strcmp(tag_start, class_xml_tag)) {
546 if(!strcmp(tag_start, "/oks-schema")) {
547 goto end_of_stream; // re-throw of exception takes too much time; go to is better
548 }
549 s.throw_unexpected_tag(tag_start, class_xml_tag);
550 }
551 }
552 catch (oks::exception & e) {
553 throw oks::FailedRead("oks-class tag", e);
554 }
555 catch (std::exception & e) {
556 throw oks::FailedRead("oks-class tag", e.what());
557 }
558 }
559
560 // read class attributes
561
562 try {
563 while(true) {
564 OksXmlAttribute attr(s);
565
566 // check for close of tag
567
568 if(oks::cmp_str1(attr.name(), ">")) { break; }
569
570 // check for known oks-class' attributes
571
572 else if(oks::cmp_str4(attr.name(), name_xml_attr)) p_name.assign(attr.value(), attr.value_len());
573 else if(oks::cmp_str11(attr.name(), description_xml_attr)) p_description.assign(attr.value(), attr.value_len());
574 else if(oks::cmp_str11(attr.name(), is_abstract_xml_attr)) p_abstract = oks::xml::str2bool(attr.value());
575 else {
576 s.throw_unexpected_tag(attr.name(), "oks-class\' attribute");
577 }
578 }
579 }
580 catch (oks::exception & e) {
581 throw oks::FailedRead("oks-class description", e);
582 }
583 catch (std::exception & e) {
584 throw oks::FailedRead("oks-class description", e.what());
585 }
586
587
588 try {
589 oks::validate_not_empty(p_name, "class name");
590 }
591 catch(std::exception& ex) {
592 throw oks::FailedRead("oks class", oks::BadFileData(ex.what(), s.get_line_no(), s.get_line_pos()));
593 }
594
595
596 // read class body
597
598 while(true) {
599
600 try {
601
602 const char * tag_start = s.get_tag_start();
603
604 // check for closing tag and exit loop
605
606 if(oks::cmp_str6(tag_start, "/class")) { break; }
607
608
609 // create superclass
610
611 else if(oks::cmp_str10(tag_start, superclass_xml_attr)) {
612 unsigned long scl_pos = s.get_line_no();
613 try {
614 OksXmlAttribute attr(s);
615
616 if(!p_super_classes) p_super_classes = new std::list<std::string *>();
617 std::string * scl = new std::string(attr.value(), attr.value_len());
618 if(has_direct_super_class(*scl))
619 {
620 std::ostringstream text;
621 text << "second inclusion of super-class \"" + *scl + "\" at line " << scl_pos;
622 delete scl;
623 throw std::runtime_error(text.str().c_str());
624 }
625 p_super_classes->push_back(scl);
626
627 OksXmlAttribute attr2(s);
628 }
629 catch (oks::exception & e) {
630 throw oks::FailedRead(std::string("a superclass-name of class \"") + p_name + '\"', e);
631 }
632 catch (std::exception & e) {
633 throw oks::FailedRead(std::string("a superclass-name of class \"") + p_name + '\"', e.what());
634 }
635 }
636
637
638 // create attribute from stream and check attribute status
639
640 else if(oks::cmp_str9(tag_start, "attribute")) {
641 unsigned long attr_pos = s.get_line_no();
642 try {
643 if(!p_attributes) p_attributes = new std::list<OksAttribute *>();
644 OksAttribute * a = new OksAttribute(s, this);
645 if(find_direct_attribute(a->get_name()) != nullptr)
646 {
647 std::ostringstream text;
648 text << "redefinition of attribute with name \"" + a->get_name() + "\" at line " << attr_pos;
649 delete a;
650 throw std::runtime_error(text.str().c_str());
651 }
652 p_attributes->push_back(a);
653 }
654 catch (oks::exception & e) {
655 throw oks::FailedRead(std::string("an attribute of class \"") + p_name + '\"', e);
656 }
657 catch (std::exception & e) {
658 throw oks::FailedRead(std::string("an attribute of class \"") + p_name + '\"', e.what());
659 }
660 }
661
662
663 // create relationship from stream and check relationship status
664
665 else if(oks::cmp_str12(tag_start, "relationship")) {
666 unsigned long rel_pos = s.get_line_no();
667 try {
668 if(!p_relationships) p_relationships= new std::list<OksRelationship *>();
669 OksRelationship * r = new OksRelationship(s,this);
670 if(find_direct_relationship(r->get_name()) != nullptr)
671 {
672 std::ostringstream text;
673 text << "redefinition of relationship with name \"" + r->get_name() + "\" at line " << rel_pos;
674 delete r;
675 throw std::runtime_error(text.str().c_str());
676 }
677 p_relationships->push_back(r);
678 }
679 catch (oks::exception & e) {
680 throw oks::FailedRead(std::string("a relationship of class \"") + p_name + '\"', e);
681 }
682 catch (std::exception & e) {
683 throw oks::FailedRead(std::string("a relationship of class \"") + p_name + '\"', e.what());
684 }
685 }
686
687
688 // create method from stream and check method status
689
690 else if(oks::cmp_str6(tag_start, "method")) {
691 unsigned long method_pos = s.get_line_no();
692 try {
693 if(!p_methods) p_methods = new std::list<OksMethod *>();
694 OksMethod * m = new OksMethod(s,this);
695 if(find_direct_method(m->get_name()) != nullptr)
696 {
697 std::ostringstream text;
698 text << "redefinition of method with name \"" + m->get_name() + "\" at line " << method_pos;
699 delete m;
700 throw std::runtime_error(text.str().c_str());
701 }
702 p_methods->push_back(m);
703 }
704 catch (oks::exception & e) {
705 throw oks::FailedRead(std::string("a method of class \"") + p_name + '\"', e);
706 }
707 catch (std::exception & e) {
708 throw oks::FailedRead(std::string("a method of class \"") + p_name + '\"', e.what());
709 }
710 }
711
712
713 // report error if red something differnt from above
714 // and set bad status of constructor (suppose 'name' can't be empty)
715
716 else {
717 s.throw_unexpected_tag(tag_start);
718 }
719
720 }
721 catch (oks::FailedRead & e) {
722 throw; // re-throw attribute, relationship or method exception
723 }
724 catch (oks::exception & e) {
725 throw oks::FailedRead(std::string("a tag of class \"") + p_name + '\"', e);
726 }
727 catch (std::exception & e) {
728 throw oks::FailedRead(std::string("a tag of class \"") + p_name + '\"', e.what());
729 }
730
731 }
732
733 return;
734
735
736end_of_stream:
737
738 throw oks::EndOfXmlStream("oks-schema");
739}
friend class OksMethod
Definition class.hpp:210
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1178
static const char superclass_xml_attr[]
Definition class.hpp:1017
OksAttribute * find_direct_attribute(const std::string &name) const noexcept
Find direct attribute.
Definition class.cpp:1019
friend class OksAttribute
Definition class.hpp:208
static const char class_xml_tag[]
Definition class.hpp:1013
friend class OksRelationship
Definition class.hpp:209
static const char description_xml_attr[]
Definition class.hpp:1015
static const char is_abstract_xml_attr[]
Definition class.hpp:1016
static const char name_xml_attr[]
Definition class.hpp:1014
OksMethod * find_direct_method(const std::string &name) const noexcept
Find direct method.
Definition class.cpp:1335
bool has_direct_super_class(const std::string &) const noexcept
Definition class.cpp:759
bool str2bool(const char *s) noexcept
Definition xml.hpp:31
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:14
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:34
bool cmp_str6(const char *s1, const char s2[7])
Definition cstring.hpp:50
bool cmp_str10(const char *s1, const char s2[11])
Definition cstring.hpp:78
bool cmp_str9(const char *s1, const char s2[10])
Definition cstring.hpp:74
bool cmp_str11(const char *s1, const char s2[12])
Definition cstring.hpp:82
bool cmp_str12(const char *s1, const char s2[13])
Definition cstring.hpp:86

◆ OksClass() [5/5]

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

Definition at line 1075 of file class.hpp.

1075 :
1076 p_name (name, len),
1077 p_super_classes (0),
1078 p_attributes (0),
1079 p_relationships (0),
1080 p_methods (0),
1081 p_abstract (false),
1082 p_transient (true),
1083 p_to_be_deleted (false),
1086 p_all_attributes (0),
1088 p_all_methods (0),
1090 p_kernel (0),
1091 p_instance_size (0),
1092 p_data_info (0),
1093 p_objects (0),
1094 p_indices (0)
1095{ ; }

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 1057 of file class.cpp.

1058{
1059 const char * fname = "OksClass::add(OksAttribute *)";
1060
1061 if(!p_attributes) {
1062 p_attributes = new std::list<OksAttribute *>();
1063 }
1064 else {
1065 if(find_direct_attribute(attribute->get_name()) != 0) {
1066 std::ostringstream text;
1067 text << "cannot add attribute \"" << attribute->get_name() << "\" to class \"" << p_name << "\"\n"
1068 "because the class already has attribute with this name.\n";
1069 throw oks::SetOperationFailed(fname, text.str());
1070 }
1071 }
1072
1073 lock_file("OksClass::add[OksAttribute]");
1074
1075 p_attributes->push_back(attribute);
1076 attribute->p_class = this;
1077
1078 registrate_class_change(ChangeAttributesList, (const void *)attribute);
1079}
void registrate_class_change(ChangeType, const void *, bool=true)
Definition class.cpp:2040
void lock_file(const char *)
Definition class.cpp:771
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 1359 of file class.cpp.

1360{
1361 const char * fname = "OksClass::add(OksMethod *)";
1362
1363 if(!p_methods) {
1364 p_methods = new std::list<OksMethod *>();
1365 }
1366 else {
1367 if(find_direct_method(method->get_name())) {
1368 std::ostringstream text;
1369 text << "cannot add method \"" << method->get_name() << "\" to class \"" << p_name << "\"\n"
1370 "because the class already has method with this name.\n";
1371 throw oks::SetOperationFailed(fname, text.str());
1372 }
1373 }
1374
1375 // check that the file can be locked
1376
1377 lock_file("OksClass::add[OksMethod]");
1378
1379 p_methods->push_back(method);
1380 method->p_class = this;
1381
1382 registrate_class_change(ChangeMethodsList, (const void *)method);
1383}

◆ add() [3/4]

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

Definition at line 1544 of file class.cpp.

1545{
1546 std::unique_lock lock(p_mutex); // protect p_objects
1547
1548 if(!p_objects->insert(std::pair<const std::string *,OksObject *>(&object->uid.object_id,object) ).second) {
1549 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "add", "object already exists");
1550 }
1551}
std::shared_mutex p_mutex
Definition class.hpp:966
std::vector< T > object(tref const &)

◆ 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 1213 of file class.cpp.

1214{
1215 const char * fname = "OksClass::add(OksRelationship *)";
1216
1217 if(!p_relationships) {
1218 p_relationships = new std::list<OksRelationship *>();
1219 }
1220 else {
1221 if(find_direct_relationship(relationship->get_name())) {
1222 std::ostringstream text;
1223 text << "cannot add relationship \"" << relationship->get_name() << "\" to class \"" << p_name << "\"\n"
1224 "because the class already has relationship with this name.\n";
1225 throw oks::SetOperationFailed(fname, text.str());
1226 }
1227 }
1228
1229 lock_file("OksClass::add[OksRelationship]");
1230
1231 p_relationships->push_back(relationship);
1232 relationship->p_class = this;
1233
1234 registrate_class_change(ChangeRelationshipsList, (const void *)relationship);
1235}

◆ 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 883 of file class.cpp.

884{
885 if(!p_super_classes) {
886 p_super_classes = new std::list<std::string *>();
887 }
888 else {
889 if( has_direct_super_class(nm) ) {
890 std::string text(add_super_class_error(nm, p_name));
891 text += " because class \"" + p_name + "\" already has such superclass.";
892 throw oks::SetOperationFailed("OksClass::add_super_class", text);
893 }
894 }
895
896 if(nm == p_name) {
897 std::string text(add_super_class_error(nm, p_name));
898 text += " because names of classes are the same.";
899 throw oks::SetOperationFailed("OksClass::add_super_class", text);
900 }
901
902 if(p_kernel) {
903 OksClass * nmc = p_kernel->find_class(nm);
904 if(nmc) {
905 if(nmc->has_direct_super_class(p_name)) {
906 std::string text(add_super_class_error(nm, p_name));
907 text += " because class \"" + nm + "\" is already direct superclass of \"" + p_name + "\".";
908 throw oks::SetOperationFailed("OksClass::add_super_class", text);
909 }
910 else if(nmc->find_super_class(p_name)) {
911 std::string text(add_super_class_error(nm, p_name));
912 text += " because class \"" + nm + "\" is already non-direct superclass of \"" + p_name + "\".";
913 throw oks::SetOperationFailed("OksClass::add_super_class", text);
914 }
915 }
916 }
917
918 lock_file("OksClass::add_super_class");
919
920 p_super_classes->push_back((new std::string(nm)));
921
923}
OksClass(const std::string &name, OksKernel *kernel, bool transient=false)
Create OKS class.
Definition class.cpp:80
static std::string add_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:865

◆ add_super_classes()

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

Definition at line 1580 of file class.cpp.

1581{
1582 if(p_super_classes) {
1583 for(std::list<std::string *>::const_iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
1584 if(OksClass * c = p_kernel->find_class(**i)) {
1585 c->add_super_classes(clist);
1586 add_if_not_found(*clist, c);
1587 }
1588 else {
1589 throw oks::CannotFindSuperClass(*this, **i);
1590 }
1591 }
1592 }
1593}
void add_if_not_found(OksClass::FList &clist, OksClass *c)
Definition class.cpp:1570

◆ 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 480 of file class.hpp.

480{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 702 of file class.hpp.

702{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 590 of file class.hpp.

590{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 471 of file class.hpp.

471{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 2124 of file class.cpp.

2125{
2126 bool found_problems = false;
2127
2128 if(const std::list<OksRelationship *> * rels = direct_relationships())
2129 {
2130 for(auto & x : *rels)
2131 {
2132 if(x->get_class_type() == nullptr)
2133 {
2134 if(found_problems == false)
2135 {
2136 found_problems = true;
2137 out << " * there are problems with class \"" << get_name() << '\"';
2138 if(print_file_name)
2139 {
2140 out << " from file \"" << get_file()->get_full_file_name() << '\"';
2141 }
2142 out << ":\n";
2143 }
2144
2145 out << " - class type \"" << x->get_type() << "\" of relationship \"" << x->get_name() << "\" is not loaded\n";
2146 }
2147 }
2148 }
2149
2150 return found_problems;
2151}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:595
OksFile * get_file() const noexcept
Definition class.hpp:343
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 313 of file class.cpp.

314{
315 if(this == &c) return true;
316
317 if(
318 (p_name != c.p_name) ||
319 (p_description != c.p_description) ||
320 (p_abstract != c.p_abstract)
321 ) return false;
322
323
324 int l1 = (p_attributes == 0) ? 0 : p_attributes->size();
325 int l2 = (c.p_attributes == 0) ? 0 : c.p_attributes->size();
326
327 if(l1 != l2) return false;
328
329 if(l1 > 0) {
330 std::list<OksAttribute *>::const_iterator i1 = p_attributes->begin();
331 std::list<OksAttribute *>::const_iterator i2 = c.p_attributes->begin();
332
333 for(;i1 != p_attributes->end();++i1, ++i2)
334 if( !(*(*i1) == *(*i2)) ) return false;
335 }
336
337 l1 = (p_relationships == 0) ? 0 : p_relationships->size();
338 l2 = (c.p_relationships == 0) ? 0 : c.p_relationships->size();
339
340 if(l1 != l2) return false;
341
342 if(l1 > 0) {
343 std::list<OksRelationship *>::const_iterator i1 = p_relationships->begin();
344 std::list<OksRelationship *>::const_iterator i2 = c.p_relationships->begin();
345
346 for(;i1 != p_relationships->end();++i1, ++i2)
347 if( !(*(*i1) == *(*i2)) ) return false;
348 }
349
350 l1 = (p_super_classes == 0) ? 0 : p_super_classes->size();
351 l2 = (c.p_super_classes == 0) ? 0 : c.p_super_classes->size();
352
353 if(l1 != l2) return false;
354
355 if(l1 > 0) {
356 std::list<std::string *>::const_iterator i1 = p_super_classes->begin();
357 std::list<std::string *>::const_iterator i2 = c.p_super_classes->begin();
358
359 for(;i1 != p_super_classes->end();++i1, ++i2)
360 if( !(*(*i1) == *(*i2)) ) return false;
361 }
362
363 return true;
364}
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 1663 of file class.cpp.

1664{
1665 if(p_attributes)
1666 for(const auto& x : *p_attributes)
1667 x->set_init_data();
1668
1669 if(!p_all_attributes) p_all_attributes = new std::list<OksAttribute *>();
1670 else p_all_attributes->clear();
1671
1673 for(FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1674 OksClass * c(*i);
1675 if(c->p_attributes) {
1676 for(std::list<OksAttribute *>::iterator i2 = c->p_attributes->begin(); i2 != c->p_attributes->end(); ++i2) {
1677 OksAttribute * a(*i2);
1678 OksAttribute * a1 = find_direct_attribute(a->get_name());
1679 OksAttribute * a2 = find_attribute(a->get_name());
1680 if( a1 == 0 && a2 == 0 ) {
1681 p_all_attributes->push_back(a);
1682 }
1683 else if( !p_kernel->p_silence ) {
1684 if(a1) {
1685 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' direct attribute \'" << a1->get_name() <<
1686 "\' overrides one coming from superclass \'" << a->p_class->get_name() << '\'';
1687 if(are_types_different(a1, a)) {
1688 Oks::warning_msg("OksClass::create_attributes()")
1689 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1690 << " type of attribute in superclass \'" << a->p_class->get_name() << "\' is \'" << a->get_type() << "\'\n"
1691 << " type of attribute in class \'" << get_name() << "\' is \'" << a1->get_type() << "\'\n";
1692 }
1693
1694 if(a1->get_is_multi_values() != a->get_is_multi_values()) {
1695 Oks::warning_msg("OksClass::create_attributes()")
1696 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1697 << " attribute in superclass \'" << a->p_class->get_name() << "\' is " << bool2value_type(a->get_is_multi_values()) << "\n"
1698 << " attribute in class \'" << get_name() << "\' is \'" << bool2value_type(a1->get_is_multi_values()) << "\'\n";
1699 }
1700 }
1701 else if(a2) {
1702 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' attribute \'" << a2->get_name() <<
1703 "\' from superclass \'" << a2->p_class->get_name() << "\' overrides one coming from superclass \'" << a->p_class->get_name() << '\'';
1704 if(are_types_different(a2, a)) {
1705 Oks::warning_msg("OksClass::create_attributes()")
1706 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1707 << " type of attribute in superclass \'" << a->p_class->get_name() << "\' is \'" << a->get_type() << "\'\n"
1708 << " type of attribute in superclass \'" << a2->p_class->get_name() << "\' is \'" << a2->get_type() << "\'\n";
1709 }
1710
1711 if(a2->get_is_multi_values() != a->get_is_multi_values()) {
1712 Oks::warning_msg("OksClass::create_attributes()")
1713 << " found attribute \'" << a->get_name() << "\' types conflict in class \'" << get_name() << "\':\n"
1714 << " attribute in superclass \'" << a->p_class->get_name() << "\' is " << bool2value_type(a->get_is_multi_values()) << "\n"
1715 << " attribute in superclass \'" << get_name() << "\' is \'" << bool2value_type(a2->get_is_multi_values()) << "\'\n";
1716 }
1717 }
1718 }
1719 }
1720 }
1721 }
1722 }
1723
1724 if(p_attributes) {
1725 for(std::list<OksAttribute *>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1726 p_all_attributes->push_back(*i);
1727 }
1728 }
1729}
OksAttribute * find_attribute(const std::string &name) const noexcept
Find attribute (search in this and base classes).
Definition class.cpp:1031
static std::ostream & warning_msg(const char *)
Definition kernel.cpp:568
bool are_types_different(const OksAttribute *a1, const OksAttribute *a2)
Definition class.cpp:1649
const char * bool2value_type(bool v)
Definition class.cpp:1641

◆ 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 1491 of file class.cpp.

1492{
1493 std::list<OksObject *> * olist = 0;
1494
1495 // add instances of class
1496
1497 if(p_objects && !p_objects->empty()) {
1498 olist = new std::list<OksObject *>();
1499
1500 for(OksObject::Map::const_iterator i = p_objects->begin(); i != p_objects->end(); ++i)
1501 olist->push_back((*i).second);
1502 }
1503
1504 // build iterator over subclasses
1505
1506 if(p_all_sub_classes) {
1507 for(FList::const_iterator j = p_all_sub_classes->begin(); j != p_all_sub_classes->end(); ++j) {
1508 OksClass *sc = *j;
1509
1510 // add instances of subclass
1511
1512 if(sc->p_objects && !sc->p_objects->empty()) {
1513 if(!olist) olist = new std::list<OksObject *>();
1514
1515 for(OksObject::Map::const_iterator i = sc->p_objects->begin(); i != sc->p_objects->end(); ++i)
1516 olist->push_back((*i).second);
1517 }
1518 }
1519 }
1520
1521 return olist;
1522}

◆ create_methods()

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

Definition at line 1801 of file class.cpp.

1802{
1803 if(!p_all_methods) p_all_methods = new std::list<OksMethod *>();
1804 else p_all_methods->clear();
1805
1807 for(FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1808 std::list<OksMethod *>::iterator i2;
1809 if((*i)->p_methods) {
1810 for(i2 = (*i)->p_methods->begin(); i2 != (*i)->p_methods->end(); ++i2) {
1811 if(
1812 find_direct_method((*i2)->get_name()) == 0 &&
1813 find_method((*i2)->get_name()) == 0
1814 ) {
1815 p_all_methods->push_back(*i2);
1816 }
1817 }
1818 }
1819 }
1820 }
1821
1822 if(p_methods) {
1823 for(std::list<OksMethod *>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1824 p_all_methods->push_back(*i);
1825 }
1826 }
1827}
OksMethod * find_method(const std::string &name) const noexcept
Find method (search in this and base classes).
Definition class.cpp:1346

◆ create_relationships()

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

Definition at line 1740 of file class.cpp.

1741{
1742 if(!p_all_relationships ) p_all_relationships = new std::list<OksRelationship *>();
1743 else p_all_relationships->clear();
1744
1746 for(FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1747 OksClass * c(*i);
1748 if(c->p_relationships) {
1749 for(std::list<OksRelationship *>::iterator i2 = c->p_relationships->begin(); i2 != c->p_relationships->end(); ++i2) {
1750 OksRelationship * r = *i2;
1751 OksRelationship * r1 = find_direct_relationship(r->get_name());
1752 OksRelationship * r2 = find_relationship(r->get_name());
1753
1754 if(!r->p_class_type) { r->p_class_type = p_kernel->find_class(r->p_rclass); }
1755
1756 if( r1 == 0 && r2 == 0) {
1757 p_all_relationships->push_back(r);
1758 }
1759 else {
1760 if(r1) {
1761 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' direct relationship \'" << r1->get_name() <<
1762 "\' overrides one coming from superclass \'" << r->p_class->get_name() << '\'';
1763 if(r1->get_high_cardinality_constraint() != r->get_high_cardinality_constraint()) {
1764 Oks::warning_msg("OksClass::create_relationships()")
1765 << " found relationship \'" << r->get_name() << "\' cardinality conflict in class \'" << get_name() << "\':\n"
1766 << " relationship in superclass \'" << r->p_class->get_name() << "\' allows " << card2string(r->get_high_cardinality_constraint()) << "\n"
1767 << " relationship in class \'" << get_name() << "\' allows " << card2string(r1->get_high_cardinality_constraint()) << std::endl;
1768 }
1769 }
1770 else if(r2) {
1771 TLOG_DEBUG(1) << "in class \'" << get_name() << "\' relationship \'" << r2->get_name() <<
1772 "\' from superclass \'" << r2->p_class->get_name() << "\' overrides one coming from superclass \'" << r->p_class->get_name() << '\'';
1773 if(r2->get_high_cardinality_constraint() != r->get_high_cardinality_constraint()) {
1774 Oks::warning_msg("OksClass::create_relationships()")
1775 << " found relationship \'" << r->get_name() << "\' cardinality conflict in class \'" << get_name() << "\':\n"
1776 << " relationship in superclass \'" << r->p_class->get_name() << "\' allows " << card2string(r->get_high_cardinality_constraint()) << "\n"
1777 << " relationship in superclass \'" << r2->p_class->get_name() << "\' allows " << card2string(r2->get_high_cardinality_constraint()) << std::endl;
1778 }
1779 }
1780 }
1781 }
1782 }
1783 }
1784 }
1785
1786 if(p_relationships) {
1787 for(std::list<OksRelationship *>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1788 OksRelationship * r = *i;
1789
1790 if(!r->p_class_type) {
1791 r->p_class_type = p_kernel->find_class(r->p_rclass);
1792 }
1793
1794 p_all_relationships->push_back(r);
1795 }
1796 }
1797}
OksRelationship * find_relationship(const std::string &name) const noexcept
Find relationship (search in this and base classes).
Definition class.cpp:1189
const char * card2string(OksRelationship::CardinalityConstraint cc)
Definition class.cpp:1734

◆ create_sub_classes()

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

Definition at line 1621 of file class.cpp.

1622{
1624 else p_all_sub_classes->clear();
1625
1626 if(!p_kernel->p_classes.empty()) {
1627 for(Map::iterator i = p_kernel->p_classes.begin(); i != p_kernel->p_classes.end(); ++i) {
1628 OksClass *c = i->second;
1629
1630 if(const FList* scl = c->p_all_super_classes) {
1631 for(FList::const_iterator j = scl->begin(); j != scl->end(); ++j) {
1632 if(*j == this) { p_all_sub_classes->push_back(c); break; }
1633 }
1634 }
1635 }
1636 }
1637}
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:240

◆ create_super_classes()

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

Definition at line 1597 of file class.cpp.

1598{
1600 else p_all_super_classes->clear();
1601
1603
1604#ifndef ERS_NO_DEBUG
1605 if(ers::debug_level() >= 5) {
1606 std::ostringstream text;
1607 text << "found " << p_all_super_classes->size() << " superclass(es) in class \'" << get_name() << "\':\n";
1608 if(p_all_super_classes->size()) {
1609 for(FList::iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
1610 text << " - class \'" << (*i)->get_name() << "\'\n";
1611 }
1612 }
1613
1614 TLOG_DEBUG(5) << text.str();
1615 }
1616#endif
1617}
void add_super_classes(FList *) const
Definition class.cpp:1580
int debug_level()
Definition ers.hpp:77

◆ 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 865 of file class.hpp.

865{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 176 of file class.cpp.

177{
178 // obtain write mutex, if non-transient class is registered in the oks kernel
179
180 if(!c->p_transient && c->p_kernel) {
181 std::unique_lock lock(c->p_kernel->p_kernel_mutex);
182
183 try {
184 c->p_file->lock();
185 c->p_file->set_updated();
186 }
187 catch(oks::exception& ex) {
188 throw oks::CannotDestroyClass(*c, ex);
189 }
190
191 delete c;
192 }
193
194 // destroy class without get write mutex
195
196 else {
197 delete c;
198 }
199}

◆ destroy_list()

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

Definition at line 203 of file class.cpp.

204 {
205 if (list)
206 {
207 for (const auto &x : *list)
208 delete x;
209
210 delete list;
211 }
212 }

◆ destroy_map()

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

Definition at line 216 of file class.cpp.

217 {
218 if (map)
219 {
220 for (const auto &x : *map)
221 delete x.second;
222
223 delete map;
224 }
225 }

◆ direct_attributes()

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

Get list of direct attributes

Definition at line 485 of file class.hpp.

485{return p_attributes;}

◆ direct_methods()

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

Get list of direct methods

Definition at line 707 of file class.hpp.

707{return p_methods;}

◆ direct_relationships()

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

Get list of direct relationships

Definition at line 595 of file class.hpp.

595{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 418 of file class.hpp.

418{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 436 of file query.cpp.

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

◆ 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 1031 of file class.cpp.

1032{
1033 if(p_all_attributes) {
1034 for(std::list<OksAttribute *>::const_iterator i = p_all_attributes->begin(); i != p_all_attributes->end(); ++i)
1035 if(_name == (*i)->get_name()) return *i;
1036
1037 return 0;
1038 }
1039 else
1040 return find_direct_attribute(_name);
1041}

◆ 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 1019 of file class.cpp.

1020{
1021 if(p_attributes) {
1022 for(std::list<OksAttribute *>::const_iterator i = p_attributes->begin(); i != p_attributes->end(); ++i)
1023 if(_name == (*i)->get_name()) return *i;
1024 }
1025
1026 return 0;
1027}

◆ 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 1335 of file class.cpp.

1336{
1337 if(p_methods) {
1338 for(std::list<OksMethod *>::const_iterator i = p_methods->begin(); i != p_methods->end(); ++i)
1339 if(_name == (*i)->get_name()) return *i;
1340 }
1341
1342 return 0;
1343}

◆ 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 1178 of file class.cpp.

1179{
1180 if(p_relationships) {
1181 for(std::list<OksRelationship *>::const_iterator i = p_relationships->begin(); i != p_relationships->end(); ++i)
1182 if(_name == (*i)->get_name()) return *i;
1183 }
1184
1185 return 0;
1186}

◆ 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 1346 of file class.cpp.

1347{
1348 if(p_all_methods) {
1349 for(std::list<OksMethod *>::const_iterator i = p_all_methods->begin(); i != p_all_methods->end(); ++i)
1350 if(_name == (*i)->get_name()) return *i;
1351
1352 return 0;
1353 }
1354 else
1355 return find_direct_method(_name);
1356}

◆ 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 1189 of file class.cpp.

1190{
1192 for(std::list<OksRelationship *>::const_iterator i = p_all_relationships->begin(); i != p_all_relationships->end(); ++i)
1193 if(_name == (*i)->get_name()) return *i;
1194
1195 return 0;
1196 }
1197 else
1198 return find_direct_relationship(_name);
1199}

◆ 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 747 of file class.cpp.

748{
750 for(FList::const_iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
751 if((*i)->get_name() == nm) return *i;
752 }
753 }
754
755 return 0;
756}

◆ 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 879 of file class.hpp.

880 {
881 auto it = p_data_info->find(s);
882 return (it != p_data_info->end() ? it->second : nullptr);
883 }

◆ get_description()

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

Return description of class.

Definition at line 373 of file class.hpp.

373{return p_description;}

◆ get_file()

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

Get file of object.

Definition at line 343 of file class.hpp.

343{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 389 of file class.hpp.

389{return p_abstract;}

◆ get_kernel()

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

Get OKS kernel which registering given class.

Definition at line 338 of file class.hpp.

338{return p_kernel;}

◆ get_name()

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

Return name of class.

Definition at line 368 of file class.hpp.

368{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 1526 of file class.cpp.

1527{
1528 std::shared_lock lock(p_mutex); // protect p_objects
1529
1530 if(p_objects) {
1531 OksObject::Map::const_iterator i = p_objects->find(&id);
1532 if(i != p_objects->end()) return i->second;
1533 }
1534
1535 return nullptr;
1536}

◆ 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 837 of file class.hpp.

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

◆ 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 759 of file class.cpp.

760{
761 if(p_super_classes) {
762 for(std::list<std::string *>::const_iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i)
763 if(nm == *(*i)) return true;
764 }
765
766 return false;
767}

◆ k_add() [1/2]

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

Kernel method to add attribute.

Parameters
anew attribute

Definition at line 1045 of file class.cpp.

1046{
1047 if(!p_attributes) {
1048 p_attributes = new std::list<OksAttribute *>();
1049 }
1050
1051 p_attributes->push_back(attribute);
1052 attribute->p_class = this;
1053}

◆ k_add() [2/2]

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

Kernel method to add relationship.

Parameters
rnew relationship

Definition at line 1202 of file class.cpp.

1203{
1204 if(!p_relationships) {
1205 p_relationships = new std::list<OksRelationship *>();
1206 }
1207
1208 p_relationships->push_back(relationship);
1209 relationship->p_class = this;
1210}

◆ 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 872 of file class.cpp.

873{
874 if(!p_super_classes) {
875 p_super_classes = new std::list<std::string *>();
876 }
877
878 p_super_classes->push_back((new std::string(nm)));
879}

◆ lock_file()

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

Definition at line 771 of file class.cpp.

772{
773 if(p_kernel) {
774 try {
775 p_file->lock();
776 }
777 catch(oks::exception& ex) {
778 throw oks::SetOperationFailed(fname, ex);
779 }
780 }
781}

◆ 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 1041 of file class.hpp.

1042{
1043 return (p_all_attributes ? p_all_attributes->size() : 0);
1044}

◆ 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 1069 of file class.hpp.

1070{
1071 return (p_all_methods ? p_all_methods->size() : 0);
1072}

◆ 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 1055 of file class.hpp.

1056{
1057 return (p_all_relationships ? p_all_relationships->size() : 0);
1058}

◆ number_of_direct_attributes()

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

Get number of direct attributes

Definition at line 1034 of file class.hpp.

1035{
1036 return (p_attributes ? p_attributes->size() : 0);
1037}

◆ number_of_direct_methods()

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

Get number of direct methods

Definition at line 1062 of file class.hpp.

1063{
1064 return (p_methods ? p_methods->size() : 0);
1065}

◆ number_of_direct_relationships()

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

Get number of direct relationships

Definition at line 1048 of file class.hpp.

1049{
1050 return (p_relationships ? p_relationships->size() : 0);
1051}

◆ number_of_objects()

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

Get number of objects of given class

Definition at line 1479 of file class.cpp.

1480{
1481 return (!p_objects ? 0 : p_objects->size());
1482}

◆ objects()

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

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

Definition at line 809 of file class.hpp.

809{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 367 of file class.cpp.

368{
369 if(this == &c) return false;
370
371 if(compare_without_methods(c) == false) return true;
372
373 int l1 = (p_methods == 0) ? 0 : p_methods->size();
374 int l2 = (c.p_methods == 0) ? 0 : c.p_methods->size();
375
376 if(l1 != l2) return true;
377
378 if(l1 > 0) {
379 std::list<OksMethod *>::const_iterator i1 = p_methods->begin();
380 std::list<OksMethod *>::const_iterator i2 = c.p_methods->begin();
381
382 for(;i1 != p_methods->end();++i1, ++i2)
383 if( !(*(*i1) == *(*i2)) ) return true;
384 }
385
386 return false;
387}
bool compare_without_methods(const OksClass &c) const noexcept
Definition class.cpp:313

◆ 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 1027 of file class.hpp.

1028{
1029 return ((this == &c || p_name == c.p_name) ? true : false);
1030}

◆ registrate_attribute_change()

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

Definition at line 1834 of file class.cpp.

1835{
1837
1838 FList::iterator i;
1839 if(p_all_sub_classes) i = p_all_sub_classes->begin();
1840
1841 OksClass * c(this);
1842
1843 do {
1844 if(c->p_objects && !c->p_objects->empty()) {
1845 for(OksObject::Map::const_iterator i2 = c->p_objects->begin(); i2 != c->p_objects->end(); ++i2) {
1846 OksObject *o(i2->second);
1847 OksData newData;
1848 OksData *oldData = &o->data[((*(c->p_data_info))[a->p_name])->offset];
1849
1850 try {
1851 oldData->cvt(&newData, a);
1852 oldData->Clear();
1853 memcpy(static_cast<void *>(oldData), static_cast<void *>(&newData), sizeof(OksData));
1854 newData.Clear2(); // Do not free !
1855 }
1856 catch(oks::AttributeReadError & ex) {
1857 std::ostringstream text;
1858 text << "attribute \'" << a->get_name() << "\' change converting object " << o << ' ';
1859 throw oks::CannotRegisterClass(*this, text.str(), ex);
1860 }
1861 }
1862 }
1863 } while(p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
1864}
double offset

◆ registrate_class()

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

Definition at line 2009 of file class.cpp.

2010{
2012
2013 {
2015 if(!p_objects) {
2016 p_objects = new OksObject::Map( (p_abstract == false) ? 1024 : 1 );
2017 }
2018 }
2019
2020 if(!p_data_info->empty() && skip_registered) {
2021 TLOG_DEBUG(4) << "skip already registered " << get_name();
2022 return;
2023 }
2024
2025 try {
2030
2032 }
2033 catch(oks::exception& ex) {
2034 throw oks::CannotRegisterClass(*this, "", ex);
2035 }
2036}
std::unordered_map< const std::string *, OksObject *, oks::hash_str, oks::equal_str > Map
Definition object.hpp:870
std::map< std::string, OksDataInfo * > Map
Declare map of pointers to OksDataInfo (unsorted by name).
Definition object.hpp:351

◆ registrate_class_change()

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

Definition at line 2040 of file class.cpp.

2041{
2042 if(!p_kernel) return;
2043
2045
2046 try {
2047 if(update_file) p_file->set_updated();
2048
2049 FList superclasses;
2050
2051 if(changeType == ChangeSuperClassesList && !p_all_super_classes->empty())
2052 for(FList::iterator i2 = p_all_super_classes->begin(); i2 != p_all_super_classes->end(); ++i2) {
2053 superclasses.push_back(*i2);
2054 }
2055
2056 FList::iterator i;
2057 if(p_all_sub_classes) i = p_all_sub_classes->begin();
2058
2059 OksClass *c = this;
2060
2061 do {
2062 switch(changeType) {
2064 c->create_super_classes();
2065 c->create_attributes();
2066 c->create_relationships();
2067 c->create_methods();
2068 break;
2069
2071 c->create_attributes();
2072 break;
2073
2075 c->create_relationships();
2076 break;
2077
2078 case ChangeMethodsList:
2079 c->create_methods();
2080 break;
2081
2082 default:
2083 continue;
2084 }
2085
2086 if(changeType != ChangeMethodsList) c->registrate_instances();
2087 } while(p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
2088
2089
2090 if(changeType == ChangeSuperClassesList) {
2091 if(!p_all_super_classes->empty())
2092 for(FList::iterator i2 = p_all_super_classes->begin(); i2 != p_all_super_classes->end(); ++i2)
2093 if(find(superclasses.begin(), superclasses.end(), *i2) == superclasses.end()) {
2094 superclasses.push_back(*i2);
2095 }
2096
2097 for(FList::const_iterator i2 = superclasses.begin(); i2 != superclasses.end(); ++i2) {
2098 c = *i2;
2099
2100 if(p_kernel->is_dangling(c) || c->p_to_be_deleted) continue;
2101
2102 c->create_sub_classes();
2103
2105 (*OksClass::change_notify_fn)(c, ChangeSubClassesList, 0);
2106 }
2107 superclasses.clear();
2108 }
2109
2111 if(p_all_sub_classes) i = p_all_sub_classes->begin();
2112 c = this;
2113
2114 do (*OksClass::change_notify_fn)(c, changeType, parameter);
2115 while(p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
2116 }
2117 }
2118 catch(oks::exception& ex) {
2119 throw oks::CannotRegisterClass(*this, "change ", ex);
2120 }
2121}
Factory couldn t find
Definition Issues.hpp:24

◆ registrate_instances()

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

Definition at line 1898 of file class.cpp.

1899{
1901
1902 OksDataInfo::Map * dInfo = new OksDataInfo::Map();
1903
1904 size_t dInfoLength = 0;
1905 bool thereAreChanges = false;
1906
1907 if(!p_all_attributes->empty()) {
1908 for(std::list<OksAttribute *>::iterator i = p_all_attributes->begin(); i != p_all_attributes->end(); ++i) {
1909 OksAttribute *a = *i;
1910 if(!thereAreChanges) {
1911 OksDataInfo::Map::const_iterator x = p_data_info->find(a->get_name());
1912 if( x == p_data_info->end() || x->second->attribute == nullptr || x->second->offset != dInfoLength || !(*(x->second->attribute) == *a) ) {
1913 thereAreChanges = true;
1914 }
1915 }
1916
1917 (*dInfo)[a->get_name()] = new OksDataInfo(dInfoLength++, a);
1918 }
1919 }
1920
1921 if(!p_all_relationships->empty()) {
1922 for(std::list<OksRelationship *>::iterator i = p_all_relationships->begin(); i != p_all_relationships->end(); ++i) {
1923 OksRelationship *r = *i;
1924 if(!thereAreChanges) {
1925 OksDataInfo::Map::const_iterator x = p_data_info->find(r->get_name());
1926 if( x == p_data_info->end() || x->second->relationship == nullptr || x->second->offset != dInfoLength || !(*(x->second->relationship) == *r) ) {
1927 thereAreChanges = true;
1928 }
1929 }
1930
1931 (*dInfo)[r->get_name()] = new OksDataInfo(dInfoLength++, r);
1932 }
1933 }
1934
1935 if(thereAreChanges == true) {
1936 if(p_objects && !p_objects->empty()) {
1937 for(OksObject::Map::const_iterator i = p_objects->begin(); i != p_objects->end(); ++i) {
1938 OksObject *o = (*i).second;
1939 OksData * data = new OksData[dInfoLength];
1940 size_t count = 0;
1941
1942 if(!p_all_attributes->empty()) {
1943 for(std::list<OksAttribute *>::iterator i2 = p_all_attributes->begin(); i2 != p_all_attributes->end(); ++i2) {
1944 OksAttribute * a = *i2;
1945
1946 OksDataInfo::Map::const_iterator x = p_data_info->find(a->get_name());
1947
1948 if(x != p_data_info->end() && x->second->attribute) {
1949 OksData *oldData(&o->data[x->second->offset]);
1950
1951 if(*(x->second->attribute) == *a) {
1952 memcpy(static_cast<void *>(&data[count++]), static_cast<void *>(oldData), sizeof(OksData));
1953 oldData->type = OksData::unknown_type;
1954 }
1955 else {
1956 try {
1957 oldData->cvt(&data[count++], a);
1958 }
1959 catch(oks::AttributeReadError & ex) {
1960 throw oks::AttributeConversionFailed(*a, o, ex);
1961 }
1962 }
1963 }
1964 }
1965 }
1966
1967 if(!p_all_relationships->empty()) {
1968 for(std::list<OksRelationship *>::iterator i2 = p_all_relationships->begin(); i2 != p_all_relationships->end(); ++i2) {
1969 OksRelationship *r = *i2;
1970
1971 OksDataInfo::Map::const_iterator x = p_data_info->find(r->get_name());
1972
1973 if(x != p_data_info->end() && x->second->relationship) {
1974 OksData *oldData = &o->data[x->second->offset];
1975
1976 if(*(x->second->relationship) == *r) {
1977 memcpy(static_cast<void *>(&data[count++]), static_cast<void *>(oldData), sizeof(OksData));
1978 oldData->type = OksData::unknown_type;
1979 }
1980 else
1981 oldData->ConvertTo(&data[count++], r);
1982 }
1983 }
1984 }
1985
1986 int n = p_instance_size;
1987 while(n--) o->data[n].Clear();
1988 delete o->data;
1989
1990 o->data = data;
1991 }
1992 }
1993 }
1994
1995 if(!p_data_info->empty()) {
1996 for(OksDataInfo::Map::iterator i = p_data_info->begin(); i != p_data_info->end(); ++i) {
1997 delete i->second;
1998 }
1999 }
2000
2001 delete p_data_info;
2002
2003 p_data_info = dInfo;
2004 p_instance_size = dInfoLength;
2005}

◆ registrate_relationship_change()

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

Definition at line 1871 of file class.cpp.

1872{
1874
1875 FList::iterator i;
1876 if(p_all_sub_classes) i = p_all_sub_classes->begin();
1877
1878 OksClass * c(this);
1879
1880 do {
1881 if(c->p_objects && !c->p_objects->empty()) {
1882 for(OksObject::Map::const_iterator i2 = c->p_objects->begin(); i2 != c->p_objects->end(); ++i2) {
1883 OksObject *o(i2->second);
1884 OksData newData;
1885 OksData *oldData = &o->data[((*(c->p_data_info))[r->p_name])->offset];
1886
1887 oldData->ConvertTo(&newData, r);
1888 oldData->Clear();
1889 memcpy(static_cast<void *>(oldData), static_cast<void *>(&newData), sizeof(OksData));
1890 newData.Clear2(); // Do not free !
1891 }
1892 }
1893 } while(p_all_sub_classes && i != p_all_sub_classes->end() && (c = *(i++)));
1894}

◆ 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 1130 of file class.cpp.

1131{
1132 const char * fname = "OksClass::remove(OksAttribute *)";
1133
1134 if(!p_attributes) {
1135 std::ostringstream text;
1136 text << "cannot remove attribute \"" << attribute->get_name() << "\" from class \"" << p_name << "\"\n"
1137 "because the class has no attributes.\n";
1138 throw oks::SetOperationFailed(fname, text.str());
1139 }
1140
1141 for(std::list<OksAttribute *>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1142 if(attribute == *i) {
1143 lock_file("OksClass::remove[OksAttribute]");
1144
1145 p_attributes->erase(i);
1146 delete const_cast<OksAttribute *>(attribute);
1147
1148 if(p_attributes->empty()) {
1149 delete p_attributes;
1150 p_attributes = 0;
1151 }
1152
1154
1155 return;
1156 }
1157 }
1158
1159 std::ostringstream text;
1160 text << "cannot remove attribute \"" << attribute->get_name() << "\" from class \"" << p_name << "\"\n"
1161 "because the class has no such attribute with this name.\n";
1162 throw oks::SetOperationFailed(fname, text.str());
1163}

◆ 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 1386 of file class.cpp.

1387{
1388 const char * fname = "OksClass::remove(OksMethod *)";
1389
1390 if(!p_methods) {
1391 std::ostringstream text;
1392 text << "cannot remove method \"" << method->get_name() << "\" from class \"" << p_name << "\"\n"
1393 "because the class has no methods.\n";
1394 throw oks::SetOperationFailed(fname, text.str());
1395 }
1396
1397 for(std::list<OksMethod *>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1398 if(method == *i) {
1399 lock_file("OksClass::remove[OksMethod]");
1400
1401 p_methods->erase(i);
1402 delete const_cast<OksMethod *>(method);
1403
1404 if(p_methods->empty()) {
1405 delete p_methods;
1406 p_methods = 0;
1407 }
1408
1410
1411 return;
1412 }
1413 }
1414
1415 std::ostringstream text;
1416 text << "cannot remove method \"" << method->get_name() << "\" from class \"" << p_name << "\"\n"
1417 "because the class has no such method with this name.\n";
1418 throw oks::SetOperationFailed(fname, text.str());
1419}

◆ 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 1238 of file class.cpp.

1239{
1240 const char * fname = "OksClass::remove(OksRelationship *)";
1241
1242 if(!p_relationships) {
1243 std::ostringstream text;
1244 text << "cannot remove relationship \"" << relationship->get_name() << "\" from class \"" << p_name << "\"\n"
1245 "because the class has no relationships.\n";
1246 throw oks::SetOperationFailed(fname, text.str());
1247 }
1248
1249 for(std::list<OksRelationship *>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1250 if(relationship == *i) {
1251 lock_file("OksClass::remove[OksRelationship]");
1252
1253 p_relationships->erase(i);
1254 if(call_delete) {
1255 delete const_cast<OksRelationship *>(relationship);
1256 }
1257
1258 if(p_relationships->empty()) {
1259 delete p_relationships;
1260 p_relationships = 0;
1261 }
1262
1264
1265 return;
1266 }
1267 }
1268
1269 std::ostringstream text;
1270 text << "cannot remove relationship \"" << relationship->get_name() << "\" from class \"" << p_name << "\"\n"
1271 "because the class has no such relationship with this name.\n";
1272 throw oks::SetOperationFailed(fname, text.str());
1273}

◆ remove() [4/4]

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

Definition at line 1554 of file class.cpp.

1555{
1556 std::unique_lock lock(p_mutex); // protect p_objects
1557
1558 if(!p_objects) {
1559 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "remove", "OKS Kernel is not inited");
1560 }
1561
1562 OksObject::Map::iterator i = p_objects->find(&object->uid.object_id);
1563
1564 if(i != p_objects->end()) p_objects->erase(i);
1565 else {
1566 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "remove", "object does not exist");
1567 }
1568}

◆ 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 932 of file class.cpp.

933{
934 if( !p_super_classes ) {
935 std::string text(remove_super_class_error(nm, p_name));
936 text += " because class \"" + p_name + "\" has no superclasses at all.";
937 throw oks::SetOperationFailed("OksClass::remove_super_class", text);
938 }
939
940
941 for(std::list<std::string *>::iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
942 std::string * si(*i);
943 if(nm == *si) {
944 lock_file("OksClass::remove_super_class");
945
946 p_super_classes->erase(i);
947 delete si;
948
949 if(p_super_classes->empty()) {
950 delete p_super_classes;
951 p_super_classes = 0;
952 }
953
955
956 return;
957 }
958 }
959
960 std::string text(remove_super_class_error(nm, p_name));
961 text += " because class \"" + p_name + "\" has no superclass with this name.";
962 throw oks::SetOperationFailed("OksClass::remove_super_class", text);
963}
static std::string remove_super_class_error(const std::string &c1, const std::string &c2)
Definition class.cpp:926

◆ save()

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

Definition at line 463 of file class.cpp.

464{
465 try {
466 s.put_raw(' ');
467 s.put_start_tag(class_xml_tag, sizeof(class_xml_tag)-1);
468 s.put_attribute(name_xml_attr, sizeof(name_xml_attr)-1, p_name.c_str());
469
470 // store non-empty description only
471 if (!p_description.empty())
472 s.put_attribute(description_xml_attr, sizeof(description_xml_attr)-1, p_description.c_str());
473
474 // store abstract attribute only when the class is abstract
475 if (p_abstract)
477
478 s.put_raw('>');
479 s.put_raw('\n');
480
481 if (p_super_classes)
482 for(const auto& i : *p_super_classes) {
483 s.put_raw(' ');
484 s.put_raw(' ');
485 s.put_start_tag(superclass_xml_attr, sizeof(superclass_xml_attr)-1);
486 s.put_attribute(name_xml_attr, sizeof(name_xml_attr)-1, i->c_str());
487 s.put_end_tag();
488 }
489
490 if (p_attributes)
491 for (const auto &i : *p_attributes)
492 i->save(s);
493
494 if (p_relationships)
495 for (const auto &i : *p_relationships)
496 i->save(s);
497
498 if (p_methods)
499 for (const auto &i : *p_methods)
500 i->save(s);
501
502 s.put_raw(' ');
503 s.put_last_tag(class_xml_tag, sizeof(class_xml_tag)-1);
504 s.put_raw('\n');
505 }
506
507 catch (oks::exception & e) {
508 throw oks::FailedSave("oks-class", p_name, e);
509 }
510
511 catch (std::exception & e) {
512 throw oks::FailedSave("oks-class", p_name, e.what());
513 }
514
515}
const char * bool2str(bool b) noexcept
Definition xml.hpp:28

◆ 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 785 of file class.cpp.

786{
787 if(p_description != s) {
788 lock_file("OksClass::set_description");
789
791
792 if(p_kernel) {
793 p_file->set_updated();
795 (*OksClass::change_notify_fn)(this, ChangeDescription, 0);
796 }
797 }
798 }
799}

◆ 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 291 of file class.cpp.

292{
293 if(p_file != f) {
294 try {
295 if(update_owner) {
296 p_file->lock();
297 p_file->set_updated();
298 }
299
300 f->lock();
301 f->set_updated();
302
303 p_file = f;
304 }
305 catch(oks::exception& ex) {
306 throw oks::CanNotSetFile(this, 0, *f, ex);
307 }
308 }
309}

◆ 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 803 of file class.cpp.

804{
805 if(p_abstract != b) {
806 lock_file("OksClass::set_is_abstract");
807
808 p_abstract = b;
809
810 if(p_kernel) {
811 p_file->set_updated();
813 (*OksClass::change_notify_fn)(this, ChangeIsAbstaract, 0);
814 }
815 }
816 }
817}

◆ 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 1167 of file class.cpp.

1168{
1169 return a->p_class;
1170}

◆ 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 1468 of file class.cpp.

1469{
1470 return m->p_class;
1471}

◆ 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 1323 of file class.cpp.

1324{
1325 return r->p_class;
1326}

◆ 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 1083 of file class.cpp.

1084{
1085 const char * fname = "OksClass::swap(const OksAttribute *, const OksAttribute *)";
1086
1087
1088 // if attributes are equal, return success
1089
1090 if(a1 == a2) return;
1091
1092
1093 // check that an attributes is not (null)
1094
1095 check_and_report_empty_parameter(fname, (a1 == 0), (a2 == 0));
1096
1097
1098 // find requested attributes in the directed attributes list
1099
1100 std::list<OksAttribute *>::iterator i1 = p_attributes->end();
1101 std::list<OksAttribute *>::iterator i2 = p_attributes->end();
1102
1103 for(std::list<OksAttribute *>::iterator i = p_attributes->begin(); i != p_attributes->end(); ++i) {
1104 if((*i) == a1) i1 = i;
1105 else if((*i) == a2) i2 = i;
1106 }
1107
1108 // check that the attributes were found
1109
1111 fname, "attribute", a1->get_name(), a2->get_name(), p_name,
1112 (i1 == p_attributes->end()), (i2 == p_attributes->end())
1113 );
1114
1115
1116 // check that the file can be locked
1117
1118 lock_file("OksClass::swap[OksAttribute]");
1119
1120
1121 // replace the attributes and make notification
1122
1123 *i1 = const_cast<OksAttribute *>(a2);
1124 *i2 = const_cast<OksAttribute *>(a1);
1125
1127}
static void check_and_report_empty_parameter(const char *fname, bool b1, bool b2)
Definition class.cpp:823
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:838

◆ 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 1422 of file class.cpp.

1423{
1424 const char * fname = "OksClass::swap(const OksMethod *, const OksMethod *)";
1425
1426
1427 // if methods are equal, return success
1428
1429 if(m1 == m2) return;
1430
1431
1432 // check that an methods is not (null)
1433
1434 check_and_report_empty_parameter(fname, (m1 == 0), (m2 == 0));
1435
1436
1437 // find requested methods in the directed methods list
1438
1439 std::list<OksMethod *>::iterator i1 = p_methods->end();
1440 std::list<OksMethod *>::iterator i2 = p_methods->end();
1441
1442 for(std::list<OksMethod *>::iterator i = p_methods->begin(); i != p_methods->end(); ++i) {
1443 if((*i) == m1) i1 = i;
1444 else if((*i) == m2) i2 = i;
1445 }
1446
1447 // check that the methods were found
1448
1450 fname, "method", m1->get_name(), m2->get_name(), p_name,
1451 (i1 == p_methods->end()), (i2 == p_methods->end())
1452 );
1453
1454 // check that the file can be locked
1455
1456 lock_file("OksClass::swap[OksMethod]");
1457
1458 // replace the methods and make notification
1459
1460 *i1 = const_cast<OksMethod *>(m2);
1461 *i2 = const_cast<OksMethod *>(m1);
1462
1464}

◆ 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 1277 of file class.cpp.

1278{
1279 const char * fname = "OksClass::swap(const OksRelationship *, const OksRelationship *)";
1280
1281
1282 // if relationships are equal, return success
1283
1284 if(r1 == r2) return;
1285
1286
1287 // check that an relationships is not (null)
1288
1289 check_and_report_empty_parameter(fname, (r1 == 0), (r2 == 0));
1290
1291
1292 // find requested relationships in the directed relationships list
1293
1294 std::list<OksRelationship *>::iterator i1 = p_relationships->end();
1295 std::list<OksRelationship *>::iterator i2 = p_relationships->end();
1296
1297 for(std::list<OksRelationship *>::iterator i = p_relationships->begin(); i != p_relationships->end(); ++i) {
1298 if((*i) == r1) i1 = i;
1299 else if((*i) == r2) i2 = i;
1300 }
1301
1302 // check that the relationships were found
1303
1305 fname, "relationship", r1->get_name(), r2->get_name(), p_name,
1306 (i1 == p_relationships->end()), (i2 == p_relationships->end())
1307 );
1308
1309 // check that the file can be locked
1310
1311 lock_file("OksClass::swap[OksRelationship]");
1312
1313 // replace the relationships and make notification
1314
1315 *i1 = const_cast<OksRelationship *>(r2);
1316 *i2 = const_cast<OksRelationship *>(r1);
1317
1319}

◆ 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 967 of file class.cpp.

968{
969 const char * fname = "OksClass::swap_super_classes()";
970
971
972 // if classs are equal, return success
973
974 if(c1 == c2) return;
975
976
977 // check that an class name is not empty
978
979 check_and_report_empty_parameter(fname, c1.empty(), c2.empty());
980
981
982 // find requested classes in the directed classs list
983
984 std::list<std::string *>::iterator i1 = p_super_classes->end();
985 std::list<std::string *>::iterator i2 = p_super_classes->end();
986
987 for(std::list<std::string *>::iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i) {
988 if(*(*i) == c1) i1 = i;
989 else if(*(*i) == c2) i2 = i;
990 }
991
992 // check that the classes were found
993
995 "OksClass::swap_super_classes", "superclass", c1, c2, p_name,
996 (i1 == p_super_classes->end()), (i2 == p_super_classes->end())
997 );
998
999
1000 // replace the classs and make notification
1001
1002 lock_file("OksClass::swap_super_classes");
1003
1004 std::string * s1 = *i1;
1005 std::string * s2 = *i2;
1006
1007 *i1 = s2;
1008 *i2 = s1;
1009
1011}

◆ OksAttribute

friend class OksAttribute
friend

Definition at line 208 of file class.hpp.

◆ OksIndex

friend class OksIndex
friend

Definition at line 212 of file class.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 207 of file class.hpp.

◆ OksMethod

friend class OksMethod
friend

Definition at line 210 of file class.hpp.

◆ OksMethodImplementation

friend class OksMethodImplementation
friend

Definition at line 211 of file class.hpp.

◆ OksObject

friend class OksObject
friend

Definition at line 206 of file class.hpp.

◆ OksRelationship

friend class OksRelationship
friend

Definition at line 209 of file class.hpp.

◆ OksSortedClass

friend class OksSortedClass
friend

Definition at line 213 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 390 of file class.cpp.

392{
394
395 s << "Class name: \"" << c.p_name << "\"\n"
396 " has description: \"" << c.p_description << "\"\n"
397 << (c.p_abstract == true ? " is abstract\n" : " is not abstract\n");
398
399 if(c.p_super_classes) {
400 s << "The class has superclasses:\n";
401 for(std::list<std::string *>::const_iterator i = c.p_super_classes->begin(); i != c.p_super_classes->end(); ++i) {
402 s << " - " << *(*i) << std::endl;
403 }
404 }
405 else
406 s << "The class has no superclasses\n";
407
408
409 if(c.p_attributes) {
410 s << "The attributes are:\n";
411 for(std::list<OksAttribute *>::const_iterator i = c.p_attributes->begin(); i != c.p_attributes->end(); ++i) {
412 s << *(*i);
413 }
414 }
415 else
416 s << "There are no attributes\n";
417
418
419 if(c.p_relationships) {
420 s << "The relationships are:\n";
421 for(std::list<OksRelationship *>::const_iterator i = c.p_relationships->begin(); i != c.p_relationships->end(); ++i) {
422 s << *(*i);
423 }
424 }
425 else
426 s << "There are no relationships\n";
427
428
429 if(c.p_methods) {
430 s << "The methods are:\n";
431 for(std::list<OksMethod *>::const_iterator i = c.p_methods->begin(); i != c.p_methods->end(); ++i) {
432 s << *(*i);
433 }
434 }
435 else
436 s << "There are no methods\n";
437
438
439 if(c.p_objects) {
440 OksObject::SMap sorted;
441
442 s << "The objects are:\n";
443
444 for(OksObject::Map::iterator i = c.p_objects->begin(); i != c.p_objects->end(); ++i) {
445 sorted[i->first] = i->second;
446 }
447
448 for(OksObject::SMap::iterator i = sorted.begin(); i != sorted.end(); ++i) {
449 s << *(i->second);
450 }
451 }
452 else
453 s << "There are no objects\n";
454
455
456 s << "End of Class \"" << c.p_name << "\"\n";
457
458 return s;
459}
std::map< const std::string *, OksObject *, SortById > SMap
Definition object.hpp:865

◆ operator<< [2/2]

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

Definition at line 1654 of file object.cpp.

1656{
1657 OSK_PROFILING(OksProfiler::ObjectOperatorOut, o.uid.class_id->p_kernel)
1658
1659 const OksClass * c = o.uid.class_id;
1660
1661 s << "Object " << &o << std::endl;
1662
1663 OksData * di = o.data;
1664
1665
1666 // print attributes
1667
1668 {
1669 const std::list<OksAttribute *> * alist = c->all_attributes();
1670
1671 if(alist && !alist->empty()) {
1672 s << " Attributes are:\n";
1673
1674 for(std::list<OksAttribute *>::const_iterator i = alist->begin(); i != alist->end(); ++i) {
1675 if((*i)->is_integer() && (*i)->get_format() != OksAttribute::Dec) {
1676 s.setf(((*i)->get_format() == OksAttribute::Hex ? std::ios::hex : std::ios::oct), std::ios::basefield);
1677 s.setf(std::ios::showbase);
1678 }
1679
1680 s << " " << (*i)->get_name() << ": " << *di++ << std::endl;
1681
1682 if((*i)->is_integer() && (*i)->get_format() != OksAttribute::Dec) {
1683 s.setf(std::ios::dec, std::ios::basefield);
1684 s.unsetf(std::ios::showbase);
1685 }
1686 }
1687 }
1688 else
1689 s << " There are no attributes\n";
1690 }
1691
1692
1693 // print relationships
1694
1695 {
1696 const std::list<OksRelationship *> * rlist = c->all_relationships();
1697
1698 if(rlist && !rlist->empty()) {
1699 s << " Relationships are:\n";
1700
1701 for(std::list<OksRelationship *>::const_iterator i = rlist->begin(); i != rlist->end(); ++i)
1702 s << " " << (*i)->get_name() << ": " << *di++ << std::endl;
1703 }
1704 else
1705 s << " There are no relationships\n";
1706 }
1707
1708 return s;
1709}

Member Data Documentation

◆ change_notify_fn

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

Definition at line 972 of file class.hpp.

◆ class_xml_tag

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

Definition at line 1013 of file class.hpp.

◆ create_notify_fn

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

Definition at line 971 of file class.hpp.

◆ delete_notify_fn

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

Definition at line 973 of file class.hpp.

◆ description_xml_attr

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

Definition at line 1015 of file class.hpp.

◆ is_abstract_xml_attr

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

Definition at line 1016 of file class.hpp.

◆ name_xml_attr

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

Definition at line 1014 of file class.hpp.

◆ p_abstract

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

Definition at line 944 of file class.hpp.

◆ p_all_attributes

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

Definition at line 950 of file class.hpp.

◆ p_all_methods

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

Definition at line 952 of file class.hpp.

◆ p_all_relationships

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

Definition at line 951 of file class.hpp.

◆ p_all_sub_classes

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

Definition at line 949 of file class.hpp.

◆ p_all_super_classes

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

Definition at line 948 of file class.hpp.

◆ p_attributes

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

Definition at line 941 of file class.hpp.

◆ p_data_info

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

Definition at line 962 of file class.hpp.

◆ p_description

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

Definition at line 939 of file class.hpp.

◆ p_file

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

Definition at line 957 of file class.hpp.

◆ p_id

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

Definition at line 955 of file class.hpp.

◆ p_indices

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

Definition at line 964 of file class.hpp.

◆ p_inheritance_hierarchy

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

Definition at line 954 of file class.hpp.

◆ p_instance_size

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

Definition at line 960 of file class.hpp.

◆ p_kernel

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

Definition at line 958 of file class.hpp.

◆ p_methods

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

Definition at line 943 of file class.hpp.

◆ p_mutex

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

Definition at line 966 of file class.hpp.

◆ p_name

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

Definition at line 938 of file class.hpp.

◆ p_objects

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

Definition at line 963 of file class.hpp.

◆ p_relationships

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

Definition at line 942 of file class.hpp.

◆ p_super_classes

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

Definition at line 940 of file class.hpp.

◆ p_to_be_deleted

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

Definition at line 946 of file class.hpp.

◆ p_transient

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

Definition at line 945 of file class.hpp.

◆ p_unique_id_mutex

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

Definition at line 967 of file class.hpp.

◆ superclass_xml_attr

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

Definition at line 1017 of file class.hpp.


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