![]() |
Fledge
An open source edge computing platform for industrial users
|
Classes | |
class | CategoryItem |
Public Types | |
enum | ItemType { UnknownType, StringItem, EnumerationItem, JsonItem, BoolItem, NumberItem, DoubleItem, ScriptItem, CategoryType, CodeItem, BucketItem, ListItem, KVListItem } |
enum | ItemAttribute { ORDER_ATTR, READONLY_ATTR, MANDATORY_ATTR, FILE_ATTR, MINIMUM_ATTR, MAXIMUM_ATTR, LENGTH_ATTR, VALIDITY_ATTR, GROUP_ATTR, DISPLAY_NAME_ATTR, DEPRECATED_ATTR, RULE_ATTR, BUCKET_PROPERTIES_ATTR, LIST_SIZE_ATTR, ITEM_TYPE_ATTR, LIST_NAME_ATTR, KVLIST_KEY_NAME_ATTR, KVLIST_KEY_DESCRIPTION_ATTR, JSON_SCHEMA_ATTR } |
using | iterator = std::vector< CategoryItem * >::iterator |
using | const_iterator = std::vector< CategoryItem * >::const_iterator |
Public Member Functions | |
ConfigCategory (const std::string &name, const std::string &json) | |
ConfigCategory (const ConfigCategory &orig) | |
Copy constructor for a configuration category. More... | |
ConfigCategory (const ConfigCategory *orig) | |
Copy constructor for a configuration category when copying from a pointer. More... | |
~ConfigCategory () | |
Configuration category destructor. | |
void | addItem (const std::string &name, const std::string description, const std::string &type, const std::string def, const std::string &value) |
Add an item to a configuration category. | |
void | addItem (const std::string &name, const std::string description, const std::string def, const std::string &value, const std::vector< std::string > options) |
void | removeItems () |
Delete all the items from the configuration category. More... | |
void | removeItemsType (ItemType type) |
Delete all the items from the configuration category having a specific type. More... | |
void | keepItemsType (ItemType type) |
Delete all the items from the configuration category not having a specific type. More... | |
bool | extractSubcategory (ConfigCategory &subCategories) |
Extracts, process and adds subcategory information from a given category to the current instance. More... | |
void | setDescription (const std::string &description) |
Set the description for the configuration category. More... | |
std::string | getName () const |
std::string | getDescription () const |
std::string | getDisplayName () const |
void | setDisplayName (const std::string &displayName) |
unsigned int | getCount () const |
bool | itemExists (const std::string &name) const |
Check for the existence of an item within the configuration category. More... | |
bool | setItemDisplayName (const std::string &name, const std::string &displayName) |
Set the display name of an item. More... | |
std::string | getValue (const std::string &name) const |
Return the value of the configuration category item. More... | |
std::vector< std::string > | getValueList (const std::string &name) const |
Return the value of the configuration category item list, this is a convience function used when simple lists are defined and allows for central processing of the list values. More... | |
std::map< std::string, std::string > | getValueKVList (const std::string &name) const |
Return the value of the configuration category item kvlist, this is a convience function used when key/value lists are defined and allows for central processing of the list values. More... | |
std::string | getType (const std::string &name) const |
Return the type of the configuration category item. More... | |
std::string | getDescription (const std::string &name) const |
std::string | getDefault (const std::string &name) const |
Return the default value of the configuration category item. More... | |
bool | setDefault (const std::string &name, const std::string &value) |
Update the default value of the configuration category item. More... | |
bool | setValue (const std::string &name, const std::string &value) |
Update the value of the configuration category item. More... | |
std::string | getDisplayName (const std::string &name) const |
std::string | getmParentName () const |
std::vector< std::string > | getOptions (const std::string &name) const |
Return the options of the configuration category item. More... | |
std::string | getLength (const std::string &name) const |
Return the length value of the configuration category item. More... | |
std::string | getMinimum (const std::string &name) const |
Return the minimum value of the configuration category item. More... | |
std::string | getMaximum (const std::string &name) const |
Return the maximum of the configuration category item. More... | |
bool | isString (const std::string &name) const |
Return if the configuration item is a string item. More... | |
bool | isEnumeration (const std::string &name) const |
Return if the configuration item is an enumeration item. More... | |
bool | isJSON (const std::string &name) const |
Return if the configuration item is a JSON item. More... | |
bool | isBool (const std::string &name) const |
Return if the configuration item is a Bool item. More... | |
bool | isNumber (const std::string &name) const |
Return if the configuration item is a Numeric item. More... | |
bool | isDouble (const std::string &name) const |
Return if the configuration item is a Double item. More... | |
bool | isList (const std::string &name) const |
Return if the configuration item is a list item. More... | |
bool | isKVList (const std::string &name) const |
Return if the configuration item is a kvlist item. More... | |
bool | isDeprecated (const std::string &name) const |
Return if the configuration item is deprecated a item. More... | |
std::string | toJSON (const bool full=false) const |
Return JSON string of all category components. More... | |
std::string | itemsToJSON (const bool full=false) const |
Return JSON string of category items only. More... | |
ConfigCategory & | operator= (ConfigCategory const &rhs) |
Operator= for ConfigCategory. | |
ConfigCategory & | operator+= (ConfigCategory const &rhs) |
Operator+= for ConfigCategory. | |
void | setItemsValueFromDefault () |
Set the m_value from m_default for each item. | |
void | checkDefaultValuesOnly () const |
Check whether at least one item in the category object has both 'value' and 'default' set. More... | |
std::string | itemToJSON (const std::string &itemName) const |
Return JSON string of a category item. More... | |
std::string | to_string (const rapidjson::Value &v) const |
Convert a RapidJSON value to a string. More... | |
std::vector< std::string > | getPermissions (const std::string &name) const |
Return the permissions of the configuration category item. More... | |
bool | hasPermission (const std::string &name, const std::string &username) const |
Return true if the user has permission to update the named item. More... | |
std::string | getItemAttribute (const std::string &itemName, ItemAttribute itemAttribute) const |
Return the requested attribute of a configuration category item. More... | |
bool | setItemAttribute (const std::string &itemName, ItemAttribute itemAttribute, const std::string &value) |
Set the requested attribute of a configuration category item. More... | |
std::vector< std::pair< std::string, std::string > > * | parseBucketItemValue (const std::string &) |
Parse BucketItem value in JSON dict format and return the key value pairs within that. More... | |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
Protected Attributes | |
std::vector< CategoryItem * > | m_items |
std::string | m_name |
std::string | m_parent_name |
std::string | m_description |
std::string | m_displayName |
ConfigCategory::ConfigCategory | ( | const ConfigCategory & | orig | ) |
Copy constructor for a configuration category.
rhs | The configuration category to copy |
ConfigCategory::ConfigCategory | ( | const ConfigCategory * | orig | ) |
Copy constructor for a configuration category when copying from a pointer.
rhs | The configuration category to copy |
void ConfigCategory::checkDefaultValuesOnly | ( | ) | const |
Check whether at least one item in the category object has both 'value' and 'default' set.
ConfigValueFoundWithDefault |
bool ConfigCategory::extractSubcategory | ( | ConfigCategory & | subCategories | ) |
Extracts, process and adds subcategory information from a given category to the current instance.
subCategories | Configuration category from which the subcategories information should be extracted |
string ConfigCategory::getDefault | ( | const std::string & | name | ) | const |
Return the default value of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
string ConfigCategory::getItemAttribute | ( | const std::string & | itemName, |
ItemAttribute | itemAttribute | ||
) | const |
Return the requested attribute of a configuration category item.
name | The name of the configuration item to return |
itemAttribute | The item attribute (such as "file", "order", "readonly" |
ConfigItemNotFound | if the item does not exist in the category ConfigItemAttributeNotFound if the requested attribute does not exist for the found item. |
string ConfigCategory::getLength | ( | const std::string & | name | ) | const |
Return the length value of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
string ConfigCategory::getMaximum | ( | const std::string & | name | ) | const |
Return the maximum of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
string ConfigCategory::getMinimum | ( | const std::string & | name | ) | const |
Return the minimum value of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
vector< string > ConfigCategory::getOptions | ( | const std::string & | name | ) | const |
Return the options of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
vector< string > ConfigCategory::getPermissions | ( | const std::string & | name | ) | const |
Return the permissions of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
string ConfigCategory::getType | ( | const std::string & | name | ) | const |
Return the type of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
string ConfigCategory::getValue | ( | const std::string & | name | ) | const |
Return the value of the configuration category item.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
map< string, string > ConfigCategory::getValueKVList | ( | const std::string & | name | ) | const |
Return the value of the configuration category item kvlist, this is a convience function used when key/value lists are defined and allows for central processing of the list values.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
vector< string > ConfigCategory::getValueList | ( | const std::string & | name | ) | const |
Return the value of the configuration category item list, this is a convience function used when simple lists are defined and allows for central processing of the list values.
name | The name of the configuration item to return |
exception | if the item does not exist in the category |
bool ConfigCategory::hasPermission | ( | const std::string & | name, |
const std::string & | rolename | ||
) | const |
Return true if the user has permission to update the named item.
name | The name of the configuration item to return |
rolename | The name of the user role to test |
exception | if the item does not exist in the category |
bool ConfigCategory::isBool | ( | const std::string & | name | ) | const |
Return if the configuration item is a Bool item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isDeprecated | ( | const std::string & | name | ) | const |
Return if the configuration item is deprecated a item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isDouble | ( | const std::string & | name | ) | const |
Return if the configuration item is a Double item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isEnumeration | ( | const std::string & | name | ) | const |
Return if the configuration item is an enumeration item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isJSON | ( | const std::string & | name | ) | const |
Return if the configuration item is a JSON item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isKVList | ( | const std::string & | name | ) | const |
Return if the configuration item is a kvlist item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isList | ( | const std::string & | name | ) | const |
Return if the configuration item is a list item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isNumber | ( | const std::string & | name | ) | const |
Return if the configuration item is a Numeric item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::isString | ( | const std::string & | name | ) | const |
Return if the configuration item is a string item.
name | The name of the item to test |
exception | If the item was not found in the configuration category |
bool ConfigCategory::itemExists | ( | const std::string & | name | ) | const |
Check for the existence of an item within the configuration category.
name | Item name to check within the category |
string ConfigCategory::itemsToJSON | ( | const bool | full = false | ) | const |
Return JSON string of category items only.
full | false is the deafult, true evaluates all the members of the CategoryItems |
string ConfigCategory::itemToJSON | ( | const std::string & | itemName | ) | const |
Return JSON string of a category item.
itemName | The given item within current category |
void ConfigCategory::keepItemsType | ( | ConfigCategory::ItemType | type | ) |
Delete all the items from the configuration category not having a specific type.
type | Type to maintain |
vector< pair< string, string > > * ConfigCategory::parseBucketItemValue | ( | const std::string & | ) |
Parse BucketItem value in JSON dict format and return the key value pairs within that.
json | JSON string representing the BucketItem value |
void ConfigCategory::removeItems | ( | ) |
Delete all the items from the configuration category.
void ConfigCategory::removeItemsType | ( | ConfigCategory::ItemType | type | ) |
Delete all the items from the configuration category having a specific type.
type | Type to delete |
bool ConfigCategory::setDefault | ( | const std::string & | name, |
const std::string & | value | ||
) |
Update the default value of the configuration category item.
name | The name of the configuration item to update |
value | New value of the configuration item |
void ConfigCategory::setDescription | ( | const std::string & | description | ) |
Set the description for the configuration category.
description | The configuration category description |
bool ConfigCategory::setItemAttribute | ( | const std::string & | itemName, |
ItemAttribute | itemAttribute, | ||
const std::string & | value | ||
) |
Set the requested attribute of a configuration category item.
name | The name of the configuration item to return |
itemAttribute | The item attribute (such as "file", "order", "readonly" |
value | The value to set |
ConfigItemNotFound | if the item does not exist in the category ConfigItemAttributeNotFound if the requested attribute does not exist for the found item. |
bool ConfigCategory::setItemDisplayName | ( | const std::string & | name, |
const std::string & | displayName | ||
) |
Set the display name of an item.
name | The item name in the category |
displayName | The display name to set |
bool ConfigCategory::setValue | ( | const std::string & | name, |
const std::string & | value | ||
) |
Update the value of the configuration category item.
name | The name of the configuration item to update |
value | New value of the configuration item |
std::string ConfigCategory::to_string | ( | const rapidjson::Value & | v | ) | const |
Convert a RapidJSON value to a string.
v | The RapidJSON value |
string ConfigCategory::toJSON | ( | const bool | full = false | ) | const |
Return JSON string of all category components.
full | false is the deafult, true evaluates all the members of the CategoryItems |