Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsNodeProperties.h
Go to the documentation of this file.
1 
14 #ifndef WS_FILE_PROPERTIES_H__
15 #define WS_FILE_PROPERTIES_H__
16 
17 #include <iostream>
18 #include <set>
19 #include <boost/filesystem.hpp>
20 #include <boost/thread/mutex.hpp>
21 
22 #include "WsAbstractProperties.h"
23 
29 public:
30 
31  enum Type {File, Dir};
32 
38  WsNodeProperties(boost::filesystem::path nodePath, Type t );
39 
44  WsNodeProperties(std::string jsonInput);
45 
47 
55  std::string get(const std::string& section, const std::string& id, const std::string& def);
56 
62  std::set<std::string> getGroups();
63 
69  bool isAllowed(std::set<std::string> gids);
70 
75 
80  void setRoot(Json::Value root);
81 
86  void setRoot(const std::string& jsonInput);
87 
93  void set(const std::string& section, const std::string& key, const std::string& value);
94 
99  void setGroups(std::set<std::string> grps);
100 
106 
112  int save();
113 
114 protected:
115 
121  std::string getPath();
122 
123 private:
124  boost::filesystem::path m_nodePath;
126  boost::mutex m_mutex;
127 
128 };
129 #endif
std::string getPath()
Get path of the node which the configuration belongs to.
boost::filesystem::path m_nodePath
int createPropertiesDirectories()
Creates the directories for the properties.
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.
Properties of a WsNode.
int save()
save the properties to the disk The path of the file is set in m_nodePath and is set when building th...
void setRoot(Json::Value root)
set the root of the Json tree
Json::Value getRoot()
Return the root of the Json tree.
Abstract Properties class.
const std::string Value
Definition: WsRequestType.h:39
WsNodeProperties(boost::filesystem::path nodePath, Type t)
Constructor.
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...
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 r...
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...
boost::mutex m_mutex
Abstract class for properties.