16 #include <boost/lexical_cast.hpp>
40 int lsortNumber, rsortNumber;
42 std::string sortOrder = lhs.get()->getParent()->getProperties().get()->get(
"global",
"sort_order",
"asc");
45 lsortNumber = boost::lexical_cast<
int>(lhs->getProperty(
"global",
"sort_number",
"-1"));
46 rsortNumber = boost::lexical_cast<
int>(rhs->getProperty(
"global",
"sort_number",
"-1"));
47 if (lsortNumber == rsortNumber) {
48 if (sortOrder ==
"asc")
49 return lhs.get()->getName() < rhs.get()->getName() ;
50 return lhs.get()->getName() > rhs.get()->getName() ;
52 if (sortOrder ==
"asc")
53 return lsortNumber > rsortNumber;
54 return lsortNumber < rsortNumber;
55 }
catch (boost::bad_lexical_cast&) {
56 LOG(
ERROR) <<
"WsNode :: Cannot cast sort number, check config file values";
66 WsNode(
const path& fullPath,
const path& rootPath);
91 string getName(
const bool noExt =
false);
136 const vector<NodePtr>
getAll();
161 std::string
getProperty(
const std::string& section,
const std::string&
id,
const std::string& def,
bool recurse =
false);
202 void setSize(
const uintmax_t& size);
207 virtual const uintmax_t
getSize() = 0;
boost::shared_ptr< WsAbstractNode > NodePtr
NodePtr eatPath(const std::string &path)
resolves the path and returns the node reprenseted by this path The path should be starting from the ...
const string getDisplayName(const bool noExt=false)
returns the display name of the node
const time_t & getCreateDate()
WsAbstractNode::getCreateDate()
std::string getProperty(const std::string §ion, 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 ...
const path & getFullPath()
returns the full path of the node
Contains Abstract metods on nodes and variables.
void setModifyDate(const time_t &t)
sets the modification date of the file. This method does not change the actual modification date of t...
int addChildNode(NodePtr f)
add a Node to the combined vect WsAbstractNode::m_combinedVect
Represents a node on disk.
boost::mutex * m_mutexSort
const vector< NodePtr > getFiles()
returns the list of all the file contained in the directory represented by this
void sort()
sort the nodes using the sort number or the name if not provided
NodePropertiesPtr getProperties()
get the properties of the node If the properties are not set (no conf found, or node retrieved from s...
void setProperties(NodePropertiesPtr properties)
set the properties of the node. The properties are a WsAbstractProperties object. ...
const time_t & getModifyDate()
returns the modification date of the file reprenseted by the node
virtual bool isRegularFile()=0
returns true if Node is a WsFileNode, false otherwise
bool operator()(NodePtr lhs, NodePtr rhs)
const vector< NodePtr > getAll()
combine the vector of files and directories into a single one
int addChildDirectory(NodePtr f)
adds a node as a child directory The Directory is added to the WsAbstractNode::m_dirVect ...
NodePropertiesPtr m_properties
bool getDisplayInMenu()
returns true if the item should be displayed in the menu. This value is set in the configuration file...
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 ...
void setParent(NodePtr n)
sets the parent of the node represented by this
const path & getPath()
returns the relative path of the node
NodePtr getParent()
returns the parent node of this
boost::shared_ptr< WsNodeProperties > NodePropertiesPtr
string getName(const bool noExt=false)
returns the name of the node
void setSize(const uintmax_t &size)
sets the file size in the node. Typically called by WsFileSystemTree when building the FileSystemTree...
virtual bool isDirectory()=0
returns true if Node is a WsDirNode, false otherwise
const vector< NodePtr > getDirectories()
returns the list of all the file contained in the file reprensented by this
Compares two nodes and returns true or false depending on : If Sort order is asc in the node configur...
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 ...
NodePtr getNodeByName(const std::string &name)
Searches for the NodePtr reprenting the filename.
int addChildFile(NodePtr f)
adds a node as a child file The Directory is added to the WsAbstractNode::m_fileVect ...