Fledge
An open source edge computing platform for industrial users
ConfigurationManager Class Reference

Public Member Functions

ConfigCategories getAllCategoryNames () const
 Return all Fledge categories from storage layer. More...
 
ConfigCategory getCategoryAllItems (const std::string &categoryName) const
 Return all the items of a specific category from the storage layer. More...
 
ConfigCategory createCategory (const std::string &categoryName, const std::string &categoryDescription, const std::string &categoryItems, bool keepOriginalIterms=false) const
 Create or update a new category. More...
 
std::string getCategoryItem (const std::string &categoryName, const std::string &itemName) const
 Get a given item within a given category. More...
 
bool setCategoryItemValue (const std::string &categoryName, const std::string &itemName, const std::string &newValue) const
 Set the "value" entry of a given item within a given category. More...
 
std::string addChildCategory (const std::string &parentCategoryName, const std::string &childCategories) const
 Add child categories under a given (parent) category. More...
 
ConfigCategories getChildCategories (const std::string &parentCategoryName) const
 Get all the child categories of a given category name. More...
 
std::string deleteChildCategory (const std::string &parentCategoryName, const std::string &childCategory) const
 Remove the link between a child category and its parent. More...
 
std::string deleteCategoryItemValue (const std::string &categoryName, const std::string &itemName) const
 Unset the category item value. More...
 
ConfigCategories deleteCategory (const std::string &categoryName) const
 Delete a category from database. More...
 
std::string getCategoryItemValue (const std::string &categoryName, const std::string &itemName) const
 Get the value of a given item within a given category. More...
 

Static Public Member Functions

static ConfigurationManagergetInstance (const std::string &, short unsigned int)
 Return the singleton instance of the configuration manager. More...
 

Member Function Documentation

◆ addChildCategory()

string ConfigurationManager::addChildCategory ( const std::string &  parentCategoryName,
const std::string &  childCategories 
) const

Add child categories under a given (parent) category.

Parameters
parentCategoryNameThe parent category name
childCategoriesThe child categories list (JSON array)
Returns
The JSON string with all (old and new) child categories of the parent category name
Exceptions
ChildCategoriesExexception
ExistingChildCategoriesexception NoSuchCategory exception

Do the insert: we don't check for failed result as we checked parent/child presence above

◆ createCategory()

ConfigCategory ConfigurationManager::createCategory ( const std::string &  categoryName,
const std::string &  categoryDescription,
const std::string &  categoryItems,
bool  keepOriginalItems = false 
) const

Create or update a new category.

Parameters
categoryNameThe category name
categoryDescriptionThe category description
categoryItemsThe category items
keepOriginalItemsKeep stored iterms or replace them
Returns
The ConfigCategory object with "value" and "default" of the new category added or the merged configuration of the updated confguration.
Exceptions
CategoryDetailsExexception
ConfigCategoryExexception
ConfigCategoryDefaultWithValueexception

Merge input data with stored data: stored configuration items are merged or replaced accordingly to keepOriginalItems parameter value.

Items "value" are preserved for items being updated, only "default" values are overwritten.

◆ deleteCategory()

ConfigCategories ConfigurationManager::deleteCategory ( const std::string &  categoryName) const

Delete a category from database.

Also remove the link between a child category and its parent.

Parameters
categoryNameThe category being deleted
Returns
The remaining config categories as object
Exceptions
NoSuchCategoryexception
ConfigCategoryExexception

◆ deleteCategoryItemValue()

string ConfigurationManager::deleteCategoryItemValue ( const std::string &  categoryName,
const std::string &  itemName 
) const

Unset the category item value.

Parameters
categoryNameThe category name
itemNameThe item name
Returns
JSON string of category item
Exceptions
ConfigCategoryExexception
NoSuchCategoryItemexception

◆ deleteChildCategory()

string ConfigurationManager::deleteChildCategory ( const std::string &  parentCategoryName,
const std::string &  childCategory 
) const

Remove the link between a child category and its parent.

The child becomes a root category when the link is broken. Note the child category still exists after this call is made.

Parameters
parentCategoryNameThe parennt category
childCategoryThe child category to remove
Returns
JSON array string with remaining child categories
Exceptions
ChildCategoriesExexception

◆ getAllCategoryNames()

ConfigCategories ConfigurationManager::getAllCategoryNames ( ) const

Return all Fledge categories from storage layer.

Returns
ConfigCategories class object with key and description for all found categories.
Exceptions
CategoryDetailsExexception

◆ getCategoryAllItems()

ConfigCategory ConfigurationManager::getCategoryAllItems ( const std::string &  categoryName) const

Return all the items of a specific category from the storage layer.

Parameters
categoryNameThe specified category name
Returns
ConfigCategory calss object with all category items
Exceptions
NoSuchCategoryexception
ConfigCategoryExexception
CategoryDetailsExexception

◆ getCategoryItem()

string ConfigurationManager::getCategoryItem ( const std::string &  categoryName,
const std::string &  itemName 
) const

Get a given item within a given category.

Parameters
categoryNameThe given category
itemNameThe given item
Returns
JSON string with item details

◆ getCategoryItemValue()

string ConfigurationManager::getCategoryItemValue ( const std::string &  categoryName,
const std::string &  itemName 
) const

Get the value of a given item within a given category.

Parameters
categoryNameThe given category
itemNameThe given item
Returns
string with item value
Exceptions
NoSuchCategoryItemValueexception

◆ getChildCategories()

ConfigCategories ConfigurationManager::getChildCategories ( const std::string &  parentCategoryName) const

Get all the child categories of a given category name.

Parameters
parentCategoryNameThe given category name
Returns
A ConfigCategories object with child categories (name and description)
Exceptions
ChildCategoriesExexception

For each element fetch then category description and add the entry to ConfigCategories result

◆ getInstance()

ConfigurationManager * ConfigurationManager::getInstance ( const std::string &  ,
short unsigned  int 
)
static

Return the singleton instance of the configuration manager.

Parameters
hostStorage layer TCP address
portStorage layer TCP port
Returns
The configuration manager class instance

◆ setCategoryItemValue()

bool ConfigurationManager::setCategoryItemValue ( const std::string &  categoryName,
const std::string &  itemName,
const std::string &  newValue 
) const

Set the "value" entry of a given item within a given category.

Parameters
categoryNameThe given category
itemNameThe given item
newValueThe "value" entry to set
Returns
True on success. False on DB update error or storage layer exception
Exceptions
NoSuchCategoryItemexception if categoryName/itemName doesn't exist

Check whether newValue is the same as currentValue NOTE: Does it work if newValue represents JSON object istead of a simple value?


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