Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
WsNodeProperties Class Reference

Properties of a WsNode. More...

#include <WsNodeProperties.h>

Inheritance diagram for WsNodeProperties:
Inheritance graph
Collaboration diagram for WsNodeProperties:
Collaboration graph

Public Types

enum  Type { File, Dir }
 

Public Member Functions

 WsNodeProperties (boost::filesystem::path nodePath, Type t)
 Constructor. More...
 
 WsNodeProperties (std::string jsonInput)
 Constructor. Will create the property class from the Json input. More...
 
 ~WsNodeProperties ()
 
std::string get (const std::string &section, const std::string &id, const std::string &def)
 
std::set< std::string > getGroups ()
 Returns the groups that have access to the node If no groups are found in the file, an empty set is returned. More...
 
bool isAllowed (std::set< std::string > gids)
 Compare the gids with the node groups. If the user has access, true is returned, otherwise false is returned. More...
 
Json::Value getRoot ()
 Return the root of the Json tree. More...
 
void setRoot (Json::Value root)
 set the root of the Json tree More...
 
void setRoot (const std::string &jsonInput)
 set the root of the Json tree More...
 
void set (const std::string &section, const std::string &key, const std::string &value)
 Changes or sets the propety with key 'key' to value 'value' If the property already exist, it will be overriden This method does not however, update the config file. More...
 
void setGroups (std::set< std::string > grps)
 Sets the groups of the node to grps. All groups will be overriden. This method does not however, update the config file. More...
 
int createPropertiesDirectories ()
 Creates the directories for the properties. More...
 
int save ()
 save the properties to the disk The path of the file is set in m_nodePath and is set when building this object More...
 

Protected Member Functions

std::string getPath ()
 Get path of the node which the configuration belongs to. More...
 
int parse (const std::string &path)
 parse the Json config file More...
 

Protected Attributes

Json::Value m_root
 
bool m_parsed
 

Private Attributes

boost::filesystem::path m_nodePath
 
Type m_type
 
boost::mutex m_mutex
 

Detailed Description

Properties of a WsNode.

Definition at line 28 of file WsNodeProperties.h.

Member Enumeration Documentation

Enumerator
File 
Dir 

Definition at line 31 of file WsNodeProperties.h.

Constructor & Destructor Documentation

WsNodeProperties::WsNodeProperties ( boost::filesystem::path  nodePath,
Type  t 
)

Constructor.

Parameters
paththe path to the node
tthe Type

Definition at line 27 of file WsNodeProperties.cpp.

WsNodeProperties::WsNodeProperties ( std::string  jsonInput)

Constructor. Will create the property class from the Json input.

Parameters
jsonInputthe json input text
WsNodeProperties::~WsNodeProperties ( )

Definition at line 41 of file WsNodeProperties.cpp.

Member Function Documentation

int WsNodeProperties::createPropertiesDirectories ( )

Creates the directories for the properties.

Returns
SUCCESS or FAILURE

Definition at line 197 of file WsNodeProperties.cpp.

string WsNodeProperties::get ( const std::string &  section,
const std::string &  id,
const std::string &  def 
)
virtual

Implements WsAbstractProperties.

Definition at line 45 of file WsNodeProperties.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::set< string > WsNodeProperties::getGroups ( )

Returns the groups that have access to the node If no groups are found in the file, an empty set is returned.

Returns
a set of gid or empty vector if no groups found

Definition at line 62 of file WsNodeProperties.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

string WsNodeProperties::getPath ( )
protected

Get path of the node which the configuration belongs to.

Returns
a string containing the relative path

Definition at line 231 of file WsNodeProperties.cpp.

Here is the caller graph for this function:

Value WsNodeProperties::getRoot ( )

Return the root of the Json tree.

Definition at line 133 of file WsNodeProperties.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool WsNodeProperties::isAllowed ( std::set< std::string >  gids)

Compare the gids with the node groups. If the user has access, true is returned, otherwise false is returned.

Parameters
gidsa vector containing the gid

Definition at line 82 of file WsNodeProperties.cpp.

Here is the call graph for this function:

int WsAbstractProperties::parse ( const std::string &  path)
protectedinherited

parse the Json config file

Parameters
paththe path to the configuration file
Returns
SUCCESS if file is ok, FAILURE otherwise

Definition at line 28 of file WsAbstractProperties.cpp.

Here is the caller graph for this function:

int WsNodeProperties::save ( )

save the properties to the disk The path of the file is set in m_nodePath and is set when building this object

Returns
SUCCESS or FAILURE is failed

Definition at line 217 of file WsNodeProperties.cpp.

Here is the call graph for this function:

void WsNodeProperties::set ( const std::string &  section,
const std::string &  key,
const std::string &  value 
)

Changes or sets the propety with key 'key' to value 'value' If the property already exist, it will be overriden This method does not however, update the config file.

Definition at line 164 of file WsNodeProperties.cpp.

Here is the call graph for this function:

void WsNodeProperties::setGroups ( std::set< std::string >  grps)

Sets the groups of the node to grps. All groups will be overriden. This method does not however, update the config file.

Definition at line 179 of file WsNodeProperties.cpp.

Here is the call graph for this function:

void WsNodeProperties::setRoot ( Json::Value  root)

set the root of the Json tree

Parameters
rootthe root as Value object

Definition at line 146 of file WsNodeProperties.cpp.

void WsNodeProperties::setRoot ( const std::string &  jsonInput)

set the root of the Json tree

Parameters
jsonInputthe Json as string

Definition at line 152 of file WsNodeProperties.cpp.

Member Data Documentation

boost::mutex WsNodeProperties::m_mutex
private

Definition at line 126 of file WsNodeProperties.h.

boost::filesystem::path WsNodeProperties::m_nodePath
private

Definition at line 124 of file WsNodeProperties.h.

bool WsAbstractProperties::m_parsed
protectedinherited

True or false whether the configuration file has already be parsed or no This flag is changed by the WsAbstractProperties::parse method

Definition at line 66 of file WsAbstractProperties.h.

Json::Value WsAbstractProperties::m_root
protectedinherited

Root of the Json tree where. This is where the contents of Json parsed file is stored

Definition at line 60 of file WsAbstractProperties.h.

Type WsNodeProperties::m_type
private

Definition at line 125 of file WsNodeProperties.h.


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