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

Member Typedef Documentation

◆ ChangeNotifyFN

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

Callback function invoked on OKS class modification

Definition at line 928 of file class.hpp.

◆ FList

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

Definition at line 235 of file class.hpp.

◆ Map

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

Definition at line 233 of file class.hpp.

◆ NotifyFN

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

Callback function invoked on OKS class creation or deletion

Definition at line 923 of file class.hpp.

◆ Set

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

889 {
890
895
904
913
917
918 };
@ ChangeAttributeMultiValueCardinality
Definition class.hpp:900

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

75 :
76 p_name (nm),
78 p_attributes (0),
80 p_methods (0),
81 p_abstract (false),
82 p_transient (t),
83 p_to_be_deleted (false),
88 p_all_methods (0),
90 p_kernel (k),
92 p_data_info (0),
93 p_objects (0),
94 p_indices (0)
95{
97
98 if(p_transient == false && p_kernel)
99 {
100 oks::validate_not_empty(p_name, "class name");
101
102 std::unique_lock lock(p_kernel->p_kernel_mutex);
103 p_kernel->k_add(this);
104 }
105}
OksKernel * p_kernel
Definition class.hpp:953
std::list< std::string * > * p_super_classes
Definition class.hpp:935
OksObject::Map * p_objects
Definition class.hpp:958
std::list< OksMethod * > * p_methods
Definition class.hpp:938
FList * p_all_sub_classes
Definition class.hpp:944
std::list< OksRelationship * > * p_relationships
Definition class.hpp:937
std::list< OksAttribute * > * p_attributes
Definition class.hpp:936
std::list< OksRelationship * > * p_all_relationships
Definition class.hpp:946
std::list< OksMethod * > * p_all_methods
Definition class.hpp:947
std::vector< OksClass * > * p_inheritance_hierarchy
Definition class.hpp:949
OksIndex::Map * p_indices
Definition class.hpp:959
std::string p_name
Definition class.hpp:933
std::list< OksAttribute * > * p_all_attributes
Definition class.hpp:945
OksDataInfo::Map * p_data_info
Definition class.hpp:957
FList * p_all_super_classes
Definition class.hpp:943
void k_add(OksClass *)
Definition kernel.cpp:4459
std::shared_mutex p_kernel_mutex
Definition kernel.hpp:2042
#define OSK_PROFILING(FID, K)
Definition defs.hpp:97
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 108 of file class.cpp.

108 :
109 p_name (nm),
110 p_description (d),
111 p_super_classes (0),
112 p_attributes (0),
113 p_relationships (0),
114 p_methods (0),
115 p_abstract (a),
116 p_transient (t),
117 p_to_be_deleted (false),
122 p_all_methods (0),
124 p_kernel (k),
125 p_instance_size (0),
126 p_data_info (0),
127 p_objects (0),
128 p_indices (0)
129{
131
132 if(p_transient == false && p_kernel)
133 {
134 oks::validate_not_empty(p_name, "class name");
135
136 std::unique_lock lock(p_kernel->p_kernel_mutex);
137 p_kernel->k_add(this);
138 }
139}
std::string p_description
Definition class.hpp:934

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

142 :
143 p_name (name),
144 p_description (description),
145 p_super_classes (0),
146 p_attributes (0),
147 p_relationships (0),
148 p_methods (0),
149 p_abstract (is_abstract),
150 p_transient (false),
151 p_to_be_deleted (false),
156 p_all_methods (0),
158 p_file (kernel->p_active_schema),
159 p_kernel (kernel),
160 p_instance_size (0),
161 p_data_info (0),
162 p_objects (0),
163 p_indices (0)
164{
166 p_kernel->p_classes[p_name.c_str()] = this;
167}
OksClass::Map p_classes
Definition kernel.hpp:2066

◆ ~OksClass()

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

Definition at line 222 of file class.cpp.

223{
225
226 TLOG_DEBUG(2) << "destruct " << (p_transient ? "TRANSIENT" : "NORMAL") << " class \'" << get_name() << '\'' ;
227
228 // ~OksIndex() removes 'SELF' from OksClass and deletes 'indices' when there is no an index in it
229 while (p_indices)
230 delete (*(p_indices->begin())).second;
231
234
235 if (!p_transient && p_kernel)
236 {
237 p_kernel->k_remove(this);
238
240 for (const auto &c : *p_all_super_classes)
241 {
242 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
243 continue;
244
245 c->create_sub_classes();
246
248 (*OksClass::change_notify_fn)(c, ChangeSubClassesList, (const void*) &p_name);
249 }
250
252 for (const auto &c : *p_all_sub_classes)
253 {
254 if (p_kernel->is_dangling(c) || c->p_to_be_deleted)
255 continue;
256
257 try
258 {
259 c->registrate_class_change(ChangeSuperClassesList, (const void*) &p_name, false);
260 }
261 catch (oks::exception &ex)
262 {
263 std::cerr << "internal OKS error: registrate_class_change() failed during \'" << get_name() << "\' class destruction\ncaused by: " << ex.what() << std::endl;
264 }
265 }
266 }
267
272
273 if (!p_transient)
274 {
275 delete p_all_super_classes;
276 delete p_all_sub_classes;
277 delete p_all_attributes;
278 delete p_all_relationships;
279 delete p_all_methods;
281 }
282}
static void destroy_list(T list)
Definition class.cpp:198
static void destroy_map(T map)
Definition class.cpp:211
const std::string & get_name() const noexcept
Definition class.hpp:363
static ChangeNotifyFN change_notify_fn
Definition class.hpp:967
bool is_dangling(OksClass *class_ptr) const
Check pointer on oks class.
Definition kernel.cpp:4638
void k_remove(OksClass *)
Definition kernel.cpp:4488
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ OksClass() [4/5]

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

Definition at line 513 of file class.cpp.

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

◆ OksClass() [5/5]

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

Definition at line 1070 of file class.hpp.

1070 :
1071 p_name (name, len),
1072 p_super_classes (0),
1073 p_attributes (0),
1074 p_relationships (0),
1075 p_methods (0),
1076 p_abstract (false),
1077 p_transient (true),
1078 p_to_be_deleted (false),
1081 p_all_attributes (0),
1083 p_all_methods (0),
1085 p_kernel (0),
1086 p_instance_size (0),
1087 p_data_info (0),
1088 p_objects (0),
1089 p_indices (0)
1090{ ; }

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

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

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

◆ add() [3/4]

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

Definition at line 1539 of file class.cpp.

1540{
1541 std::unique_lock lock(p_mutex); // protect p_objects
1542
1543 if(!p_objects->insert(std::pair<const std::string *,OksObject *>(&object->uid.object_id,object) ).second) {
1544 throw oks::ObjectOperationFailed(*this, object->uid.object_id, "add", "object already exists");
1545 }
1546}
std::shared_mutex p_mutex
Definition class.hpp:961

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

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

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

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

◆ add_super_classes()

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

Definition at line 1575 of file class.cpp.

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

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

475{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 697 of file class.hpp.

697{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 585 of file class.hpp.

585{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 466 of file class.hpp.

466{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 408 of file class.hpp.

408{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 2119 of file class.cpp.

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

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

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

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

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

◆ create_methods()

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

Definition at line 1796 of file class.cpp.

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

◆ create_relationships()

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

Definition at line 1735 of file class.cpp.

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

◆ create_sub_classes()

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

Definition at line 1616 of file class.cpp.

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

◆ create_super_classes()

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

Definition at line 1592 of file class.cpp.

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

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

860{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 171 of file class.cpp.

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

◆ destroy_list()

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

Definition at line 198 of file class.cpp.

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

◆ destroy_map()

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

Definition at line 211 of file class.cpp.

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

◆ direct_attributes()

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

Get list of direct attributes

Definition at line 480 of file class.hpp.

480{return p_attributes;}

◆ direct_methods()

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

Get list of direct methods

Definition at line 702 of file class.hpp.

702{return p_methods;}

◆ direct_relationships()

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

Get list of direct relationships

Definition at line 590 of file class.hpp.

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

413{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 431 of file query.cpp.

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

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

1027{
1028 if(p_all_attributes) {
1029 for(std::list<OksAttribute *>::const_iterator i = p_all_attributes->begin(); i != p_all_attributes->end(); ++i)
1030 if(_name == (*i)->get_name()) return *i;
1031
1032 return 0;
1033 }
1034 else
1035 return find_direct_attribute(_name);
1036}

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

1015{
1016 if(p_attributes) {
1017 for(std::list<OksAttribute *>::const_iterator i = p_attributes->begin(); i != p_attributes->end(); ++i)
1018 if(_name == (*i)->get_name()) return *i;
1019 }
1020
1021 return 0;
1022}

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

1331{
1332 if(p_methods) {
1333 for(std::list<OksMethod *>::const_iterator i = p_methods->begin(); i != p_methods->end(); ++i)
1334 if(_name == (*i)->get_name()) return *i;
1335 }
1336
1337 return 0;
1338}

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

1174{
1175 if(p_relationships) {
1176 for(std::list<OksRelationship *>::const_iterator i = p_relationships->begin(); i != p_relationships->end(); ++i)
1177 if(_name == (*i)->get_name()) return *i;
1178 }
1179
1180 return 0;
1181}

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

1342{
1343 if(p_all_methods) {
1344 for(std::list<OksMethod *>::const_iterator i = p_all_methods->begin(); i != p_all_methods->end(); ++i)
1345 if(_name == (*i)->get_name()) return *i;
1346
1347 return 0;
1348 }
1349 else
1350 return find_direct_method(_name);
1351}

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

1185{
1187 for(std::list<OksRelationship *>::const_iterator i = p_all_relationships->begin(); i != p_all_relationships->end(); ++i)
1188 if(_name == (*i)->get_name()) return *i;
1189
1190 return 0;
1191 }
1192 else
1193 return find_direct_relationship(_name);
1194}

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

743{
745 for(FList::const_iterator i = p_all_super_classes->begin(); i != p_all_super_classes->end(); ++i) {
746 if((*i)->get_name() == nm) return *i;
747 }
748 }
749
750 return 0;
751}

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

875 {
876 auto it = p_data_info->find(s);
877 return (it != p_data_info->end() ? it->second : nullptr);
878 }

◆ get_description()

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

Return description of class.

Definition at line 368 of file class.hpp.

368{return p_description;}

◆ get_file()

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

Get file of object.

Definition at line 338 of file class.hpp.

338{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 384 of file class.hpp.

384{return p_abstract;}

◆ get_kernel()

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

Get OKS kernel which registering given class.

Definition at line 333 of file class.hpp.

333{return p_kernel;}

◆ get_name()

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

Return name of class.

Definition at line 363 of file class.hpp.

363{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 1521 of file class.cpp.

1522{
1523 std::shared_lock lock(p_mutex); // protect p_objects
1524
1525 if(p_objects) {
1526 OksObject::Map::const_iterator i = p_objects->find(&id);
1527 if(i != p_objects->end()) return i->second;
1528 }
1529
1530 return nullptr;
1531}

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

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

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

755{
756 if(p_super_classes) {
757 for(std::list<std::string *>::const_iterator i = p_super_classes->begin(); i != p_super_classes->end(); ++i)
758 if(nm == *(*i)) return true;
759 }
760
761 return false;
762}

◆ k_add() [1/2]

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

Kernel method to add attribute.

Parameters
anew attribute

Definition at line 1040 of file class.cpp.

1041{
1042 if(!p_attributes) {
1043 p_attributes = new std::list<OksAttribute *>();
1044 }
1045
1046 p_attributes->push_back(attribute);
1047 attribute->p_class = this;
1048}

◆ k_add() [2/2]

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

Kernel method to add relationship.

Parameters
rnew relationship

Definition at line 1197 of file class.cpp.

1198{
1199 if(!p_relationships) {
1200 p_relationships = new std::list<OksRelationship *>();
1201 }
1202
1203 p_relationships->push_back(relationship);
1204 relationship->p_class = this;
1205}

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

868{
869 if(!p_super_classes) {
870 p_super_classes = new std::list<std::string *>();
871 }
872
873 p_super_classes->push_back((new std::string(nm)));
874}

◆ lock_file()

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

Definition at line 766 of file class.cpp.

767{
768 if(p_kernel) {
769 try {
770 p_file->lock();
771 }
772 catch(oks::exception& ex) {
773 throw oks::SetOperationFailed(fname, ex);
774 }
775 }
776}
void lock()
Lock OKS file.
Definition file.cpp:1012

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

1037{
1038 return (p_all_attributes ? p_all_attributes->size() : 0);
1039}

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

1065{
1066 return (p_all_methods ? p_all_methods->size() : 0);
1067}

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

1051{
1052 return (p_all_relationships ? p_all_relationships->size() : 0);
1053}

◆ number_of_direct_attributes()

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

Get number of direct attributes

Definition at line 1029 of file class.hpp.

1030{
1031 return (p_attributes ? p_attributes->size() : 0);
1032}

◆ number_of_direct_methods()

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

Get number of direct methods

Definition at line 1057 of file class.hpp.

1058{
1059 return (p_methods ? p_methods->size() : 0);
1060}

◆ number_of_direct_relationships()

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

Get number of direct relationships

Definition at line 1043 of file class.hpp.

1044{
1045 return (p_relationships ? p_relationships->size() : 0);
1046}

◆ number_of_objects()

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

Get number of objects of given class

Definition at line 1474 of file class.cpp.

1475{
1476 return (!p_objects ? 0 : p_objects->size());
1477}

◆ objects()

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

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

Definition at line 804 of file class.hpp.

804{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 362 of file class.cpp.

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

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

1023{
1024 return ((this == &c || p_name == c.p_name) ? true : false);
1025}

◆ registrate_attribute_change()

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

Definition at line 1829 of file class.cpp.

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

◆ registrate_class()

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

Definition at line 2004 of file class.cpp.

2005{
2007
2008 {
2010 if(!p_objects) {
2011 p_objects = new OksObject::Map( (p_abstract == false) ? 1024 : 1 );
2012 }
2013 }
2014
2015 if(!p_data_info->empty() && skip_registered) {
2016 TLOG_DEBUG(4) << "skip already registered " << get_name();
2017 return;
2018 }
2019
2020 try {
2025
2027 }
2028 catch(oks::exception& ex) {
2029 throw oks::CannotRegisterClass(*this, "", ex);
2030 }
2031}
std::unordered_map< const std::string *, OksObject *, oks::hash_str, oks::equal_str > Map
Definition object.hpp:865
std::map< std::string, OksDataInfo * > Map
Declare map of pointers to OksDataInfo (unsorted by name)
Definition object.hpp:346

◆ registrate_class_change()

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

Definition at line 2035 of file class.cpp.

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

◆ registrate_instances()

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

Definition at line 1893 of file class.cpp.

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

◆ registrate_relationship_change()

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

Definition at line 1866 of file class.cpp.

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

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

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

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

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

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

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

◆ remove() [4/4]

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

Definition at line 1549 of file class.cpp.

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

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

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

◆ save()

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

Definition at line 458 of file class.cpp.

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

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

781{
782 if(p_description != s) {
783 lock_file("OksClass::set_description");
784
786
787 if(p_kernel) {
790 (*OksClass::change_notify_fn)(this, ChangeDescription, 0);
791 }
792 }
793 }
794}

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

287{
288 if(p_file != f) {
289 try {
290 if(update_owner) {
291 p_file->lock();
293 }
294
295 f->lock();
296 f->set_updated();
297
298 p_file = f;
299 }
300 catch(oks::exception& ex) {
301 throw oks::CanNotSetFile(this, 0, *f, ex);
302 }
303 }
304}

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

799{
800 if(p_abstract != b) {
801 lock_file("OksClass::set_is_abstract");
802
803 p_abstract = b;
804
805 if(p_kernel) {
808 (*OksClass::change_notify_fn)(this, ChangeIsAbstaract, 0);
809 }
810 }
811 }
812}

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

1163{
1164 return a->p_class;
1165}

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

1464{
1465 return m->p_class;
1466}

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

1319{
1320 return r->p_class;
1321}

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

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

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

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

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

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

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

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

Friends And Related Symbol Documentation

◆ OksAttribute

friend class OksAttribute
friend

Definition at line 203 of file class.hpp.

◆ OksIndex

friend class OksIndex
friend

Definition at line 207 of file class.hpp.

◆ OksKernel

friend class OksKernel
friend

Definition at line 202 of file class.hpp.

◆ OksMethod

friend class OksMethod
friend

Definition at line 205 of file class.hpp.

◆ OksMethodImplementation

friend class OksMethodImplementation
friend

Definition at line 206 of file class.hpp.

◆ OksObject

friend class OksObject
friend

Definition at line 201 of file class.hpp.

◆ OksRelationship

friend class OksRelationship
friend

Definition at line 204 of file class.hpp.

◆ OksSortedClass

friend class OksSortedClass
friend

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

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

◆ operator<< [2/2]

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

Definition at line 1649 of file object.cpp.

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

Member Data Documentation

◆ change_notify_fn

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

Definition at line 967 of file class.hpp.

◆ class_xml_tag

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

Definition at line 1008 of file class.hpp.

◆ create_notify_fn

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

Definition at line 966 of file class.hpp.

◆ delete_notify_fn

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

Definition at line 968 of file class.hpp.

◆ description_xml_attr

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

Definition at line 1010 of file class.hpp.

◆ is_abstract_xml_attr

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

Definition at line 1011 of file class.hpp.

◆ name_xml_attr

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

Definition at line 1009 of file class.hpp.

◆ p_abstract

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

Definition at line 939 of file class.hpp.

◆ p_all_attributes

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

Definition at line 945 of file class.hpp.

◆ p_all_methods

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

Definition at line 947 of file class.hpp.

◆ p_all_relationships

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

Definition at line 946 of file class.hpp.

◆ p_all_sub_classes

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

Definition at line 944 of file class.hpp.

◆ p_all_super_classes

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

Definition at line 943 of file class.hpp.

◆ p_attributes

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

Definition at line 936 of file class.hpp.

◆ p_data_info

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

Definition at line 957 of file class.hpp.

◆ p_description

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

Definition at line 934 of file class.hpp.

◆ p_file

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

Definition at line 952 of file class.hpp.

◆ p_id

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

Definition at line 950 of file class.hpp.

◆ p_indices

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

Definition at line 959 of file class.hpp.

◆ p_inheritance_hierarchy

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

Definition at line 949 of file class.hpp.

◆ p_instance_size

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

Definition at line 955 of file class.hpp.

◆ p_kernel

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

Definition at line 953 of file class.hpp.

◆ p_methods

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

Definition at line 938 of file class.hpp.

◆ p_mutex

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

Definition at line 961 of file class.hpp.

◆ p_name

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

Definition at line 933 of file class.hpp.

◆ p_objects

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

Definition at line 958 of file class.hpp.

◆ p_relationships

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

Definition at line 937 of file class.hpp.

◆ p_super_classes

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

Definition at line 935 of file class.hpp.

◆ p_to_be_deleted

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

Definition at line 941 of file class.hpp.

◆ p_transient

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

Definition at line 940 of file class.hpp.

◆ p_unique_id_mutex

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

Definition at line 962 of file class.hpp.

◆ superclass_xml_attr

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

Definition at line 1012 of file class.hpp.


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