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

Represents a node on disk. More...

#include <WsNode.h>

Inheritance diagram for WsNode:
Inheritance graph
Collaboration diagram for WsNode:
Collaboration graph

Classes

struct  compareNodes
 Compares two nodes and returns true or false depending on : If Sort order is asc in the node configuration file, return true if the lhs sort number > rhs sort number, false otherwise If there are no sort number return true if lhs.getName < rhs.getName. If the sort order is desc, the return values are inversed. More...
 

Public Types

enum  ResourceType { Icones, Images, Templates }
 

Public Member Functions

 WsNode (const path &fullPath, const path &rootPath)
 Constructor for the node. More...
 
 WsNode ()
 
virtual ~WsNode ()
 
const path & getPath ()
 returns the relative path of the node More...
 
const path & getFullPath ()
 returns the full path of the node More...
 
string getName (const bool noExt=false)
 returns the name of the node More...
 
const string getDisplayName (const bool noExt=false)
 returns the display name of the node More...
 
int addChildDirectory (NodePtr f)
 adds a node as a child directory The Directory is added to the WsAbstractNode::m_dirVect More...
 
int addChildFile (NodePtr f)
 adds a node as a child file The Directory is added to the WsAbstractNode::m_fileVect More...
 
int addChildNode (NodePtr f)
 add a Node to the combined vect WsAbstractNode::m_combinedVect More...
 
void setParent (NodePtr n)
 sets the parent of the node represented by this More...
 
NodePtr getParent ()
 returns the parent node of this More...
 
const vector< NodePtrgetFiles ()
 returns the list of all the file contained in the directory represented by this More...
 
const vector< NodePtrgetDirectories ()
 returns the list of all the file contained in the file reprensented by this More...
 
const vector< NodePtrgetAll ()
 combine the vector of files and directories into a single one More...
 
NodePtr getNodeByName (const std::string &name)
 Searches for the NodePtr reprenting the filename. More...
 
bool getDisplayInMenu ()
 returns true if the item should be displayed in the menu. This value is set in the configuration file of the node More...
 
void setProperties (NodePropertiesPtr properties)
 set the properties of the node. The properties are a WsAbstractProperties object. More...
 
NodePropertiesPtr getProperties ()
 get the properties of the node If the properties are not set (no conf found, or node retrieved from server) empty properties are returned. To get the properties for a node retrieved from server use WsUser::getProperties More...
 
std::string getProperty (const std::string &section, const std::string &id, const std::string &def, bool recurse=false)
 get a node property reprensented by section/id If no value found, the value def is returned More...
 
void sort ()
 sort the nodes using the sort number or the name if not provided More...
 
virtual bool isDirectory ()=0
 returns true if Node is a WsDirNode, false otherwise More...
 
virtual bool isRegularFile ()=0
 returns true if Node is a WsFileNode, false otherwise More...
 
const time_t & getModifyDate ()
 returns the modification date of the file reprenseted by the node More...
 
const time_t & getCreateDate ()
 WsAbstractNode::getCreateDate() More...
 
void setCreateDate (const time_t &t)
 sets the creation date of the file. This method does not change the actual creation date of the file represented by the node More...
 
void setModifyDate (const time_t &t)
 sets the modification date of the file. This method does not change the actual modification date of the file represented by the node More...
 
void setSize (const uintmax_t &size)
 sets the file size in the node. Typically called by WsFileSystemTree when building the FileSystemTree More...
 
virtual const uintmax_t getSize ()=0
 returns the file size. If the Node is a WsDirNode, 0 is returned. if the global property dir_size is set to true, the number of items in the node is returned (one level) More...
 
NodePtr eatPath (const std::string &path)
 resolves the path and returns the node reprenseted by this path The path should be starting from the rootPath otherwise the method won't be able to resolve it. More...
 
virtual bool isAllowed (const std::set< string > &gids)=0
 return true if one of the groups contained in gids has access to the node false otherwise If the node is retrieved from the daemon use WsUser::isAllowed instead More...
 

Public Attributes

WNodePtr m_parent
 
vector< NodePtrm_fileVect
 
vector< NodePtrm_dirVect
 
vector< NodePtrm_combinedVect
 
path m_fullPath
 
path m_relPath
 
uintmax_t m_size
 

Protected Attributes

NodePropertiesPtr m_properties
 
time_t m_createTime
 
time_t m_modifyTime
 
boost::mutex * m_mutexSort
 

Detailed Description

Represents a node on disk.

Definition at line 27 of file WsNode.h.

Member Enumeration Documentation

Type of ressource

Enumerator
Icones 
Images 
Templates 

Definition at line 57 of file WsAbstractNode.h.

Constructor & Destructor Documentation

WsNode::WsNode ( const path &  fullPath,
const path &  rootPath 
)

Constructor for the node.

Parameters
fullPaththe fullPath of the node
rootPaththe rootPath (ie the directory of the site)

Definition at line 28 of file WsNode.cpp.

WsNode::WsNode ( )

Empty Constructor

Definition at line 17 of file WsNode.cpp.

WsNode::~WsNode ( )
virtual

Defaut Destructor

Definition at line 24 of file WsNode.cpp.

Member Function Documentation

int WsNode::addChildDirectory ( NodePtr  f)
virtual

adds a node as a child directory The Directory is added to the WsAbstractNode::m_dirVect

Parameters
fa NodePtr of the WsAbstractNode representing the directory
Returns
SUCCESS or FAILURE

Implements WsAbstractNode.

Definition at line 47 of file WsNode.cpp.

int WsNode::addChildFile ( NodePtr  f)
virtual

adds a node as a child file The Directory is added to the WsAbstractNode::m_fileVect

Parameters
fa NodePtr of the WsAbstractNode representing the file

Implements WsAbstractNode.

Definition at line 60 of file WsNode.cpp.

int WsNode::addChildNode ( NodePtr  f)
virtual

add a Node to the combined vect WsAbstractNode::m_combinedVect

Parameters
fa NodePtr of the WsAbstractNode representing the file or directory

Implements WsAbstractNode.

Definition at line 73 of file WsNode.cpp.

NodePtr WsNode::eatPath ( const std::string &  path)
virtual

resolves the path and returns the node reprenseted by this path The path should be starting from the rootPath otherwise the method won't be able to resolve it.

Parameters
paththe path of the node we are searching starting from the rootPath
Returns
The corresponding NodePtr reprensenting the WsAbstractNode if found or an empty NodePtr

Implements WsAbstractNode.

Definition at line 207 of file WsNode.cpp.

Here is the call graph for this function:

const vector< NodePtr > WsNode::getAll ( )
virtual

combine the vector of files and directories into a single one

Returns
the combined vector

Implements WsAbstractNode.

Definition at line 130 of file WsNode.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const time_t & WsNode::getCreateDate ( )
virtual

WsAbstractNode::getCreateDate()

Implements WsAbstractNode.

Definition at line 244 of file WsNode.cpp.

const vector< NodePtr > WsNode::getDirectories ( )
virtual

returns the list of all the file contained in the file reprensented by this

Returns
a list of Nodes containing these children

Implements WsAbstractNode.

Definition at line 124 of file WsNode.cpp.

Here is the call graph for this function:

bool WsNode::getDisplayInMenu ( )
virtual

returns true if the item should be displayed in the menu. This value is set in the configuration file of the node

Implements WsAbstractNode.

Definition at line 156 of file WsNode.cpp.

const string WsNode::getDisplayName ( const bool  noExt = false)
virtual

returns the display name of the node

Returns
the display name of the node if set in the configuration file of the node, otherwise WsAbstractNode::getName() is returned

Implements WsAbstractNode.

Definition at line 111 of file WsNode.cpp.

Here is the call graph for this function:

const vector< NodePtr > WsNode::getFiles ( )
virtual

returns the list of all the file contained in the directory represented by this

Returns
a list of Nodes containing these children

Implements WsAbstractNode.

Definition at line 118 of file WsNode.cpp.

Here is the call graph for this function:

const path & WsNode::getFullPath ( )
virtual

returns the full path of the node

Implements WsAbstractNode.

Definition at line 99 of file WsNode.cpp.

const time_t & WsNode::getModifyDate ( )
virtual

returns the modification date of the file reprenseted by the node

Implements WsAbstractNode.

Definition at line 239 of file WsNode.cpp.

string WsNode::getName ( const bool  noExt = false)
virtual

returns the name of the node

Returns
the name of the node. ie the text contained between the last '/' and the end

Implements WsAbstractNode.

Definition at line 104 of file WsNode.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

NodePtr WsNode::getNodeByName ( const std::string &  name)
virtual

Searches for the NodePtr reprenting the filename.

Parameters
namethe name of the node with the extension
Returns
the corresponding NodePtr or an empty NodePtr if not found

Implements WsAbstractNode.

Definition at line 138 of file WsNode.cpp.

Here is the caller graph for this function:

NodePtr WsNode::getParent ( )
virtual

returns the parent node of this

Returns
the parent Node, a NodePtr representing a WsDirNode if existing otherwise returns NULL

Implements WsAbstractNode.

Definition at line 88 of file WsNode.cpp.

const path & WsNode::getPath ( )
virtual

returns the relative path of the node

Returns
the relative path of the node, ie the Full path without the rootPath

Implements WsAbstractNode.

Definition at line 94 of file WsNode.cpp.

Here is the caller graph for this function:

NodePropertiesPtr WsNode::getProperties ( )
virtual

get the properties of the node If the properties are not set (no conf found, or node retrieved from server) empty properties are returned. To get the properties for a node retrieved from server use WsUser::getProperties

See Also
WsUser::getProperties

Implements WsAbstractNode.

Definition at line 175 of file WsNode.cpp.

Here is the caller graph for this function:

string WsNode::getProperty ( const std::string &  section,
const std::string &  id,
const std::string &  def,
bool  recurse = false 
)
virtual

get a node property reprensented by section/id If no value found, the value def is returned

Parameters
sectionthe section of the key we are searching
idthe key we are searching
defthe default value to return if not found
recurseif set to true and no value found , the method will look for parent values until a value is found.

Implements WsAbstractNode.

Definition at line 180 of file WsNode.cpp.

Here is the caller graph for this function:

virtual const uintmax_t WsNode::getSize ( )
pure virtual

returns the file size. If the Node is a WsDirNode, 0 is returned. if the global property dir_size is set to true, the number of items in the node is returned (one level)

Implements WsAbstractNode.

Implemented in WsDirNode, and WsFileNode.

virtual bool WsAbstractNode::isAllowed ( const std::set< string > &  gids)
pure virtualinherited

return true if one of the groups contained in gids has access to the node false otherwise If the node is retrieved from the daemon use WsUser::isAllowed instead

Parameters
gidsa set of gids (Typically the gids of a user
Returns
true if one or more gid that have access are present in gids, false otherwise
See Also
WsUser::isAllowed

Implemented in WsFileNode, and WsDirNode.

virtual bool WsNode::isDirectory ( )
pure virtual

returns true if Node is a WsDirNode, false otherwise

Implements WsAbstractNode.

Implemented in WsFileNode, and WsDirNode.

virtual bool WsNode::isRegularFile ( )
pure virtual

returns true if Node is a WsFileNode, false otherwise

Implements WsAbstractNode.

Implemented in WsFileNode, and WsDirNode.

void WsNode::setCreateDate ( const time_t &  t)
virtual

sets the creation date of the file. This method does not change the actual creation date of the file represented by the node

Implements WsAbstractNode.

Definition at line 249 of file WsNode.cpp.

void WsNode::setModifyDate ( const time_t &  t)
virtual

sets the modification date of the file. This method does not change the actual modification date of the file represented by the node

Implements WsAbstractNode.

Definition at line 254 of file WsNode.cpp.

Here is the caller graph for this function:

void WsNode::setParent ( NodePtr  n)
virtual

sets the parent of the node represented by this

Parameters
nthe parent node that is a NodePtr representing a WsDirNode

Implements WsAbstractNode.

Definition at line 83 of file WsNode.cpp.

void WsNode::setProperties ( NodePropertiesPtr  properties)
virtual

set the properties of the node. The properties are a WsAbstractProperties object.

Parameters
propertiesw WsNodeProperties representing the properties of the node. The object should be instanciated and values set in it

Implements WsAbstractNode.

Definition at line 165 of file WsNode.cpp.

Here is the caller graph for this function:

void WsNode::setSize ( const uintmax_t &  size)
virtual

sets the file size in the node. Typically called by WsFileSystemTree when building the FileSystemTree

Implements WsAbstractNode.

Definition at line 170 of file WsNode.cpp.

Here is the caller graph for this function:

void WsNode::sort ( )
virtual

sort the nodes using the sort number or the name if not provided

Implements WsAbstractNode.

Definition at line 192 of file WsNode.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

vector<NodePtr> WsAbstractNode::m_combinedVect
inherited

A combined vector of WsAbstractNode::m_fileVect and WsAbstractNode::m_dirVect It is built in the WsAbstractNode::sort() method

Definition at line 258 of file WsAbstractNode.h.

time_t WsNode::m_createTime
protected

The creation date of the node

Definition at line 222 of file WsNode.h.

vector<NodePtr> WsAbstractNode::m_dirVect
inherited

The std::vector containing the children directories of the Node represented by this

Definition at line 253 of file WsAbstractNode.h.

vector<NodePtr> WsAbstractNode::m_fileVect
inherited

The std::vector containing the children files of the Node represented by this

Definition at line 249 of file WsAbstractNode.h.

path WsAbstractNode::m_fullPath
inherited

The full path of the Node (ie the rootPath + m_relPath)

Definition at line 262 of file WsAbstractNode.h.

time_t WsNode::m_modifyTime
protected

The modification date of the node

Definition at line 226 of file WsNode.h.

boost::mutex* WsNode::m_mutexSort
protected

Definition at line 228 of file WsNode.h.

WNodePtr WsAbstractNode::m_parent
inherited

The parent Node

Definition at line 245 of file WsAbstractNode.h.

NodePropertiesPtr WsNode::m_properties
protected

The properties of the node

Definition at line 218 of file WsNode.h.

path WsAbstractNode::m_relPath
inherited

The relative path of the Node (ie the path starting from the rootPath

Definition at line 266 of file WsAbstractNode.h.

uintmax_t WsAbstractNode::m_size
inherited

The size of the file represented by the node on disk

Definition at line 270 of file WsAbstractNode.h.


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