|
Friendly LWM2M client
|
The Resource class in the wpp namespace is a comprehensive and flexible class designed to handle different types of data within a resource-oriented architecture. It offers a range of functionalities including storing, retrieving, and validating various data types, as well as managing multiple instances of a resource. More...
#include <Resource.h>
Collaboration diagram for wpp::Resource:Classes | |
| struct | ResInst |
| Type for resource instance. More... | |
Public Types | |
| using | DATA_T = std::variant< BOOL_T, INT_T, UINT_T, FLOAT_T, OPAQUE_T, OBJ_LINK_T, STRING_T, EXECUTE_T > |
| Universal type for data. More... | |
| using | DATA_VERIFIER_T = std::variant< VERIFY_INT_T, VERIFY_UINT_T, VERIFY_FLOAT_T, VERIFY_OPAQUE_T, VERIFY_BOOL_T, VERIFY_OBJ_LINK_T, VERIFY_STRING_T, VERIFY_EXECUTE_T > |
| Universal type for data validation functions. More... | |
Public Member Functions | |
| Resource () | |
| Resource (ID_T id, const ItemOp &operation, IS_SINGLE isSingle, IS_MANDATORY isMandatory, TYPE_ID dataType) | |
| Resource (const Resource &resource) | |
| Resource (Resource &&resource) | |
| Resource & | operator= (const Resource &other) |
| Resource & | operator= (Resource &&other) |
| ID_T | getId () const |
| TYPE_ID | getTypeId () const |
| const ItemOp & | getOperation () const |
| bool | isMandatory () const |
| bool | isOptional () const |
| bool | isSingle () const |
| bool | isMultiple () const |
| template<typename T > | |
| bool | isDataValueValid (const T &data) const |
| Check if the data type and value are valid. More... | |
| bool | isExist (ID_T resInstId) const |
| Check if the instance ID is exist. More... | |
| size_t | instCount () const |
| Get the number of resource instances. More... | |
| std::vector< ID_T > | instIds () const |
| Returns vector with available ids of resource instances. More... | |
| ID_T | newInstId () const |
| Find first available instance ID that is not used. More... | |
| bool | setDataVerifier (const DATA_VERIFIER_T &verifier) |
| Set data verifier for the resource. More... | |
| template<typename T > | |
| bool | set (const T &value, ID_T resInstId=SINGLE_INSTANCE_ID) |
| Set data value by copy for the resource (instance) More... | |
| template<typename T > | |
| bool | set (T &&value, ID_T resInstId=SINGLE_INSTANCE_ID) |
| Set data value by move for the resource (instance) More... | |
| template<typename T > | |
| const T & | get (ID_T resInstId=SINGLE_INSTANCE_ID) |
| template<typename T > | |
| bool | add (const T &value) |
| Add new instance with data value by copy for the MULTIPLE resource. More... | |
| template<typename T > | |
| bool | add (T &&value) |
| Add new instance with data value by move for the MULTIPLE resource. More... | |
| bool | remove (ID_T resInstId) |
| Remove resource instance if resource is MULTIPLE and instance exists, if the resource is SINGLE remove is not possible. More... | |
| bool | clear () |
| Remove all instances. More... | |
The Resource class in the wpp namespace is a comprehensive and flexible class designed to handle different types of data within a resource-oriented architecture. It offers a range of functionalities including storing, retrieving, and validating various data types, as well as managing multiple instances of a resource.
This class provides methods for managing and manipulating a resource, including getting and setting resource metadata, checking resource parameters, managing resource data, and managing verifiers for the resource data.
The Resource class contains public subtypes, such as the DATA_T type for storing data of various types, the ResInst struct for representing a resource instance, and the DATA_VERIFIER_T type for storing data validation functions.
The Resource class also provides public methods for common usage, such as constructors, assignment operators, and methods for retrieving resource metadata.
Additionally, the Resource class provides helpful methods for checking resource parameters, managing resource data, and managing verifiers. These methods include checking the validity of the data type, checking the validity of a data value, checking the validity of a data verifier, checking the validity of an operation, checking the possibility of an instance ID, checking the existence of an instance, checking the compatibility of a type ID, checking if the resource is empty, retrieving the number of resource instances, and getting the available IDs of resource instances.
The Resource class also provides methods for managing resource data, including generating prototypes for getting and setting data of various supported types, disabling implicit conversions, setting data values, getting data values, and getting pointers to data values.
Furthermore, the Resource class provides methods for removing resource instances, clearing all instances, and setting the data verifier for the resource.
Definition at line 49 of file Resource.h.
| using wpp::Resource::DATA_T = std::variant<BOOL_T, INT_T, UINT_T, FLOAT_T, OPAQUE_T, OBJ_LINK_T, STRING_T, EXECUTE_T> |
Universal type for data.
Definition at line 54 of file Resource.h.
| using wpp::Resource::DATA_VERIFIER_T = std::variant<VERIFY_INT_T, VERIFY_UINT_T, VERIFY_FLOAT_T, VERIFY_OPAQUE_T, VERIFY_BOOL_T, VERIFY_OBJ_LINK_T, VERIFY_STRING_T, VERIFY_EXECUTE_T> |
Universal type for data validation functions.
Definition at line 67 of file Resource.h.
| wpp::Resource::Resource | ( | ) |
Definition at line 14 of file Resource.cpp.
| wpp::Resource::Resource | ( | ID_T | id, |
| const ItemOp & | operation, | ||
| IS_SINGLE | isSingle, | ||
| IS_MANDATORY | isMandatory, | ||
| TYPE_ID | dataType | ||
| ) |
Definition at line 18 of file Resource.cpp.
| wpp::Resource::Resource | ( | const Resource & | resource | ) |
Definition at line 22 of file Resource.cpp.
| wpp::Resource::Resource | ( | Resource && | resource | ) |
Definition at line 32 of file Resource.cpp.
| bool wpp::Resource::add | ( | const T & | value | ) |
Add new instance with data value by copy for the MULTIPLE resource.
| value | The data value to add |
Definition at line 306 of file Resource.h.
Here is the call graph for this function:| bool wpp::Resource::add | ( | T && | value | ) |
Add new instance with data value by move for the MULTIPLE resource.
| value | The data value to add |
Definition at line 327 of file Resource.h.
Here is the call graph for this function:| bool wpp::Resource::clear | ( | ) |
Remove all instances.
Definition at line 155 of file Resource.cpp.
Here is the call graph for this function:| const T & wpp::Resource::get | ( | ID_T | resInstId = SINGLE_INSTANCE_ID | ) |
Definition at line 290 of file Resource.h.
Here is the call graph for this function:
Here is the caller graph for this function:| ID_T wpp::Resource::getId | ( | ) | const |
| const ItemOp & wpp::Resource::getOperation | ( | ) | const |
Definition at line 80 of file Resource.cpp.
| TYPE_ID wpp::Resource::getTypeId | ( | ) | const |
Definition at line 76 of file Resource.cpp.
| size_t wpp::Resource::instCount | ( | ) | const |
Get the number of resource instances.
Definition at line 123 of file Resource.cpp.
| std::vector< ID_T > wpp::Resource::instIds | ( | ) | const |
Returns vector with available ids of resource instances.
Definition at line 127 of file Resource.cpp.
| bool wpp::Resource::isDataValueValid | ( | const T & | data | ) | const |
Check if the data type and value are valid.
| data | The data value to check |
Definition at line 349 of file Resource.h.
Here is the caller graph for this function:| bool wpp::Resource::isExist | ( | ID_T | resInstId | ) | const |
Check if the instance ID is exist.
| resInstId | The instance ID to check |
Definition at line 104 of file Resource.cpp.
Here is the caller graph for this function:| bool wpp::Resource::isMandatory | ( | ) | const |
Definition at line 84 of file Resource.cpp.
| bool wpp::Resource::isMultiple | ( | ) | const |
Definition at line 96 of file Resource.cpp.
| bool wpp::Resource::isOptional | ( | ) | const |
Definition at line 88 of file Resource.cpp.
| bool wpp::Resource::isSingle | ( | ) | const |
| ID_T wpp::Resource::newInstId | ( | ) | const |
Find first available instance ID that is not used.
Definition at line 134 of file Resource.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 43 of file Resource.cpp.
Definition at line 57 of file Resource.cpp.
| bool wpp::Resource::remove | ( | ID_T | resInstId | ) |
Remove resource instance if resource is MULTIPLE and instance exists, if the resource is SINGLE remove is not possible.
| resInstId | The instance ID to remove |
Definition at line 144 of file Resource.cpp.
Here is the call graph for this function:| bool wpp::Resource::set | ( | const T & | value, |
| ID_T | resInstId = SINGLE_INSTANCE_ID |
||
| ) |
Set data value by copy for the resource (instance)
| value | The data value to set |
| resInstId | The instance ID to set the value, used only for multiple resources |
Definition at line 253 of file Resource.h.
Here is the call graph for this function:
Here is the caller graph for this function:| bool wpp::Resource::set | ( | T && | value, |
| ID_T | resInstId = SINGLE_INSTANCE_ID |
||
| ) |
Set data value by move for the resource (instance)
| value | The data value to set |
| resInstId | The instance ID to set the value, used only for multiple resources |
Definition at line 271 of file Resource.h.
Here is the call graph for this function:| bool wpp::Resource::setDataVerifier | ( | const DATA_VERIFIER_T & | verifier | ) |
Set data verifier for the resource.
| verifier | Function that verifies the data value it will be called each time when the method set is called |
Definition at line 164 of file Resource.cpp.