DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
The OKS class. More...
#include <class.hpp>
Classes | |
struct | SortByName |
struct | SortStr |
Public Types | |
enum | ChangeType { ChangeSuperClassesList , ChangeSubClassesList , ChangeDescription , ChangeIsAbstaract , ChangeAttributesList , ChangeAttributeType , ChangeAttributeRange , ChangeAttributeFormat , ChangeAttributeMultiValueCardinality , ChangeAttributeInitValue , ChangeAttributeDescription , ChangeAttributeIsNoNull , ChangeRelationshipsList , ChangeRelationshipClassType , ChangeRelationshipDescription , ChangeRelationshipLowCC , ChangeRelationshipHighCC , ChangeRelationshipComposite , ChangeRelationshipExclusive , ChangeRelationshipDependent , ChangeMethodsList , ChangeMethodDescription , ChangeMethodImplementation } |
Information about class property changes. More... | |
typedef std::set< OksClass *, SortByName > | Set |
typedef std::map< const char *, OksClass *, SortStr > | Map |
typedef std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > | FList |
typedef void(*) | NotifyFN(OksClass *) |
typedef void(*) | ChangeNotifyFN(OksClass *, ChangeType, const void *) |
Public Member Functions | |
OksClass (const std::string &name, OksKernel *kernel, bool transient=false) | |
Create OKS class. | |
OksClass (const std::string &name, const std::string &description, bool is_abstract, OksKernel *kernel, bool transient=false) | |
Create OKS class and set its basic properties. | |
OksClass (OksKernel *kernel, const std::string &name, const std::string &description, bool is_abstract) | |
Create OKS class for internal usage (fast, no complete registration). | |
bool | operator== (const OksClass &) const |
The equality operator. | |
bool | operator!= (const OksClass &) const |
The not equal operator. | |
bool | compare_without_methods (const OksClass &c) const noexcept |
OksKernel * | get_kernel () const noexcept |
OksFile * | get_file () const noexcept |
void | set_file (OksFile *f, bool update_owner=true) |
Move class to different file. | |
const std::string & | get_name () const noexcept |
const std::string & | get_description () const noexcept |
void | set_description (const std::string &description) |
Set class description. | |
bool | get_is_abstract () const noexcept |
void | set_is_abstract (bool abstract) |
Set class abstract property. | |
const FList * | all_super_classes () const noexcept |
const std::list< std::string * > * | direct_super_classes () const noexcept |
OksClass * | find_super_class (const std::string &) const noexcept |
bool | has_direct_super_class (const std::string &) const noexcept |
void | add_super_class (const std::string &name) |
void | k_add_super_class (const std::string &name) |
void | remove_super_class (const std::string &name) |
void | swap_super_classes (const std::string &c1, const std::string &c2) |
Swap order of two superclasses. | |
const FList * | all_sub_classes () const noexcept |
const std::list< OksAttribute * > * | all_attributes () const noexcept |
const std::list< OksAttribute * > * | direct_attributes () const noexcept |
OksAttribute * | find_attribute (const std::string &name) const noexcept |
Find attribute (search in this and base classes). | |
OksAttribute * | find_direct_attribute (const std::string &name) const noexcept |
Find direct attribute. | |
void | add (OksAttribute *a) |
Add attribute. | |
void | k_add (OksAttribute *a) |
Kernel method to add attribute. | |
void | remove (const OksAttribute *a) |
Remove attribute. | |
void | swap (const OksAttribute *a1, const OksAttribute *a2) |
Swap order of two attributes. | |
size_t | number_of_direct_attributes () const noexcept |
size_t | number_of_all_attributes () const noexcept |
OksClass * | source_class (const OksAttribute *a) const noexcept |
Get class owning given attribute. | |
const std::list< OksRelationship * > * | all_relationships () const noexcept |
const std::list< OksRelationship * > * | direct_relationships () const noexcept |
OksRelationship * | find_relationship (const std::string &name) const noexcept |
Find relationship (search in this and base classes). | |
OksRelationship * | find_direct_relationship (const std::string &name) const noexcept |
Find direct relationship. | |
void | add (OksRelationship *r) |
Add relationship. | |
void | k_add (OksRelationship *r) |
Kernel method to add relationship. | |
void | remove (const OksRelationship *r, bool call_delete=true) |
Remove relationship. | |
void | swap (const OksRelationship *r1, const OksRelationship *r2) |
Swap order of two relationships. | |
size_t | number_of_direct_relationships () const noexcept |
size_t | number_of_all_relationships () const noexcept |
OksClass * | source_class (const OksRelationship *r) const noexcept |
Get class owning given relationship. | |
const std::list< OksMethod * > * | all_methods () const noexcept |
const std::list< OksMethod * > * | direct_methods () const noexcept |
OksMethod * | find_method (const std::string &name) const noexcept |
Find method (search in this and base classes). | |
OksMethod * | find_direct_method (const std::string &name) const noexcept |
Find direct method. | |
void | add (OksMethod *m) |
Add method. | |
void | remove (const OksMethod *m) |
Remove method. | |
void | swap (const OksMethod *m1, const OksMethod *m2) |
Swap order of two methods. | |
size_t | number_of_direct_methods () const noexcept |
size_t | number_of_all_methods () const noexcept |
OksClass * | source_class (const OksMethod *m) const noexcept |
Get class owning given method. | |
size_t | number_of_objects () const noexcept |
const OksObject::Map * | objects () const noexcept |
std::list< OksObject * > * | create_list_of_all_objects () const noexcept |
Get all objects of the class (including derived). | |
OksObject * | get_object (const std::string &id) const noexcept |
Get object by ID. | |
OksObject * | get_object (const std::string *id) const noexcept |
OksObject::List * | execute_query (OksQuery *query) const |
Execute query. | |
OksDataInfo * | data_info (const std::string &s) const noexcept |
Get OKS data information for attribute or relationship. | |
OksDataInfo * | get_data_info (const std::string &s) const noexcept |
Get OKS data information for attribute or relationship. | |
Static Public Member Functions | |
static void | destroy (OksClass *c) |
Destroy OKS class. | |
Private Member Functions | |
~OksClass () | |
OksClass (OksXmlInputStream &, OksKernel *) | |
OksClass (const char *name, size_t len) | |
void | save (OksXmlOutputStream &) const |
void | add (OksObject *) |
void | remove (OksObject *) |
void | registrate_class (bool skip_registered) |
void | registrate_class_change (ChangeType, const void *, bool=true) |
void | registrate_attribute_change (OksAttribute *) |
void | registrate_relationship_change (OksRelationship *) |
void | registrate_instances () |
void | add_super_classes (FList *) const |
void | create_super_classes () |
void | create_sub_classes () |
void | create_attributes () |
void | create_relationships () |
void | create_methods () |
void | lock_file (const char *) |
bool | check_relationships (std::ostringstream &out, bool print_file_name) const noexcept |
Static Private Member Functions | |
template<class T > | |
static void | destroy_map (T map) |
template<class T > | |
static void | destroy_list (T list) |
Private Attributes | |
std::string | p_name |
std::string | p_description |
std::list< std::string * > * | p_super_classes |
std::list< OksAttribute * > * | p_attributes |
std::list< OksRelationship * > * | p_relationships |
std::list< OksMethod * > * | p_methods |
bool | p_abstract |
bool | p_transient |
bool | p_to_be_deleted |
FList * | p_all_super_classes |
FList * | p_all_sub_classes |
std::list< OksAttribute * > * | p_all_attributes |
std::list< OksRelationship * > * | p_all_relationships |
std::list< OksMethod * > * | p_all_methods |
std::vector< OksClass * > * | p_inheritance_hierarchy |
unsigned int | p_id |
OksFile * | p_file |
OksKernel * | p_kernel |
size_t | p_instance_size |
OksDataInfo::Map * | p_data_info |
OksObject::Map * | p_objects |
OksIndex::Map * | p_indices |
std::shared_mutex | p_mutex |
std::mutex | p_unique_id_mutex |
Static Private Attributes | |
static NotifyFN | create_notify_fn |
static ChangeNotifyFN | change_notify_fn |
static NotifyFN | delete_notify_fn |
static const char | class_xml_tag [] = "class" |
static const char | name_xml_attr [] = "name" |
static const char | description_xml_attr [] = "description" |
static const char | is_abstract_xml_attr [] = "is-abstract" |
static const char | superclass_xml_attr [] = "superclass" |
Friends | |
class | OksObject |
class | OksKernel |
class | OksAttribute |
class | OksRelationship |
class | OksMethod |
class | OksMethodImplementation |
class | OksIndex |
class | OksSortedClass |
std::ostream & | operator<< (std::ostream &s, const OksClass &c) |
Stream operator. | |
std::ostream & | operator<< (std::ostream &s, const OksObject &o) |
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:
An OKS class can be made persistent, i.e. stored on OKS schema file.
void(*) dunedaq::oks::OksClass::ChangeNotifyFN(OksClass *, ChangeType, const void *) |
std::list<OksClass *, boost::fast_pool_allocator<OksClass *> > dunedaq::oks::OksClass::FList |
std::map<const char * , OksClass *, SortStr> dunedaq::oks::OksClass::Map |
void(*) dunedaq::oks::OksClass::NotifyFN(OksClass *) |
std::set<OksClass *, SortByName> dunedaq::oks::OksClass::Set |
Information about class property changes.
It is used in the ChangeNotifyFN callback, that can be used by user to subscribe on schema changes.
Definition at line 889 of file class.hpp.
dunedaq::oks::OksClass::OksClass | ( | const std::string & | name, |
OksKernel * | kernel, | ||
bool | transient = false ) |
Create OKS class.
The parameters are:
name | name of new class |
kernel | OKS kernel owning this class (if empty, class will not be registered) |
transient | if true, the class is transient (is used by OKS tools, do not change default value) |
Definition at line 75 of file class.cpp.
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:
name | name of new class |
description | description of new class |
is_abstract | if true, new class is abstract (i.e. may not have objects) |
kernel | OKS kernel owning this class (if empty, class will not be registered) |
transient | if true, the class is transient (is used by OKS tools, do not change default value) |
Definition at line 108 of file class.cpp.
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:
kernel | OKS kernel owning this class |
name | name of new class |
description | description of new class |
is_abstract | if true, new class is abstract (i.e. may not have objects) |
Definition at line 142 of file class.cpp.
|
private |
Definition at line 222 of file class.cpp.
|
private |
Definition at line 513 of file class.cpp.
|
inlineprivate |
Definition at line 1070 of file class.hpp.
void dunedaq::oks::OksClass::add | ( | OksAttribute * | a | ) |
Add attribute.
Add new attribute to class. The class must not have attributes with such name.
a | new attribute |
oks::exception | is thrown in case of problems |
Definition at line 1052 of file class.cpp.
void dunedaq::oks::OksClass::add | ( | OksMethod * | m | ) |
Add method.
Add new method to class. The class must not have methods with such name.
m | new method |
oks::exception | is thrown in case of problems |
Definition at line 1354 of file class.cpp.
|
private |
void dunedaq::oks::OksClass::add | ( | OksRelationship * | r | ) |
Add relationship.
Add new relationship to class. The class must not have relationships with such name.
r | new relationship |
oks::exception | is thrown in case of problems |
Definition at line 1208 of file class.cpp.
void dunedaq::oks::OksClass::add_super_class | ( | const std::string & | name | ) |
Add direct base class with given name.
name | name of superclass |
oks::exception | is thrown in case of problems |
Definition at line 878 of file class.cpp.
|
private |
Definition at line 1575 of file class.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
privatenoexcept |
Definition at line 2119 of file class.cpp.
|
noexcept |
Compare all properties of classes excluding methods
Definition at line 308 of file class.cpp.
|
private |
Definition at line 1658 of file class.cpp.
|
noexcept |
Get all objects of the class (including derived).
Return all objects of given and derived classes. The list to be deleted by user.
Definition at line 1486 of file class.cpp.
|
private |
Definition at line 1796 of file class.cpp.
|
private |
Definition at line 1735 of file class.cpp.
|
private |
Definition at line 1616 of file class.cpp.
|
private |
Definition at line 1592 of file class.cpp.
|
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).
s | name of existing OKS attribute or relationship |
Definition at line 860 of file class.hpp.
|
static |
Destroy OKS class.
This the the only way available to user to destroy OKS class since ~OksClass() is private.
The parameter is:
c | the pointer to class |
oks::exception | is thrown in case of problems |
Definition at line 171 of file class.cpp.
|
staticprivate |
|
staticprivate |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
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.
query | OKS query |
In | case of problems the oks::exception is thrown. |
Definition at line 431 of file query.cpp.
|
noexcept |
Find attribute (search in this and base classes).
Get attribute by name.
name | attribute name |
Definition at line 1026 of file class.cpp.
|
noexcept |
Find direct attribute.
Get attribute by name.
name | attribute name |
Definition at line 1014 of file class.cpp.
|
noexcept |
Find direct method.
Get method by name.
name | method name |
|
noexcept |
Find direct relationship.
Get relationship by name.
name | relationship name |
Definition at line 1173 of file class.cpp.
|
noexcept |
Find method (search in this and base classes).
Get method by name.
name | method name |
Definition at line 1341 of file class.cpp.
|
noexcept |
Find relationship (search in this and base classes).
Get relationship by name.
name | relationship name |
Definition at line 1184 of file class.cpp.
|
noexcept |
Search class by name among all base classes of given class.
Definition at line 742 of file class.cpp.
|
inlinenoexcept |
Get OKS data information for attribute or relationship.
Pass name of attribute or relationship defined for given class. Safe version of data_info()
s | name of existing OKS attribute or relationship |
Definition at line 874 of file class.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Get object by ID.
Return pointer to object of given class by identity.
|
inlinenoexcept |
See get_object(const std::string&)
Definition at line 832 of file class.hpp.
|
noexcept |
Return true, if class has direct base class with given name.
Definition at line 754 of file class.cpp.
void dunedaq::oks::OksClass::k_add | ( | OksAttribute * | a | ) |
Kernel method to add attribute.
a | new attribute |
void dunedaq::oks::OksClass::k_add | ( | OksRelationship * | r | ) |
Kernel method to add relationship.
r | new relationship |
Definition at line 1197 of file class.cpp.
void dunedaq::oks::OksClass::k_add_super_class | ( | const std::string & | name | ) |
|
private |
|
inlinenoexcept |
Get number of all attributes (including attributes from this and base classes)
|
inlinenoexcept |
Get number of all methods (including methods from this and base classes)
|
inlinenoexcept |
Get number of all relationships (including relationships from this and base classes)
|
inlinenoexcept |
Get number of direct attributes
|
inlinenoexcept |
|
inlinenoexcept |
Get number of direct relationships
|
noexcept |
|
inlinenoexcept |
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.
|
inline |
|
private |
Definition at line 1829 of file class.cpp.
|
private |
Definition at line 2004 of file class.cpp.
|
private |
Definition at line 2035 of file class.cpp.
|
private |
Definition at line 1893 of file class.cpp.
|
private |
Definition at line 1866 of file class.cpp.
void dunedaq::oks::OksClass::remove | ( | const OksAttribute * | a | ) |
Remove attribute.
Remove attribute from class. The attribute mush be direct attribute of the class.
a | attribute to be removed |
oks::exception | is thrown in case of problems |
Definition at line 1125 of file class.cpp.
void dunedaq::oks::OksClass::remove | ( | const OksMethod * | m | ) |
Remove method.
Remove method from class. The method mush be direct method of the class.
m | method to be removed |
oks::exception | is thrown in case of problems |
Definition at line 1381 of file class.cpp.
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.
r | relationship to be removed |
call_delete | if true, delete removed relationship |
oks::exception | is thrown in case of problems |
Definition at line 1233 of file class.cpp.
|
private |
Definition at line 1549 of file class.cpp.
void dunedaq::oks::OksClass::remove_super_class | ( | const std::string & | name | ) |
Remove direct base class with given name.
name | name of superclass |
oks::exception | is thrown in case of problems |
Definition at line 927 of file class.cpp.
|
private |
Definition at line 458 of file class.cpp.
void dunedaq::oks::OksClass::set_description | ( | const std::string & | description | ) |
Set class description.
description | new description of attribute (max 2000 bytes, see #s_max_description_length variable) |
oks::exception | is thrown in case of problems |
Definition at line 780 of file class.cpp.
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:
file | destination file |
update_owner | mark original file as updated |
oks::exception | is thrown in case of problems |
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.
abstract | pass true to make class abstract |
oks::exception | is thrown in case of problems |
|
noexcept |
|
noexcept |
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.
a1 | first attribute |
a2 | second attribute |
oks::exception | is thrown in case of problems |
Definition at line 1078 of file class.cpp.
Swap order of two methods.
Swap position of two methods. The methods must be direct methods of given class.
m1 | first method |
m2 | second method |
oks::exception | is thrown in case of problems |
Definition at line 1417 of file class.cpp.
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.
r1 | first relationship |
r2 | second relationship |
oks::exception | is thrown in case of problems |
Definition at line 1272 of file class.cpp.
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.
c1 | name of first superclass |
c2 | name of second superclass |
oks::exception | is thrown in case of problems |
Definition at line 962 of file class.cpp.
|
friend |
|
friend |
|
friend |
|
friend |
Stream operator.
Send to stream complete description of OKS class:
Definition at line 385 of file class.cpp.
|
friend |
Definition at line 1649 of file object.cpp.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
mutableprivate |
|
staticprivate |