#include <creaImageIOTreeDescriptor.h>
#include <creaImageIOTreeComparators.h>
+#include<boost/filesystem/operations.hpp>
#include <vector>
#include <map>
+
namespace creaImageIO
{
/// Returns the level of the node in the tree
virtual int GetLevel() const { return mParent->GetLevel()+1; }
+
/// Returns the parent of the node
Node* GetParent() const { return mParent; }
/// Remove the given children from the children list
int RemoveChildrenFromList(Node*);
-
+
+ /// Get the Attributes Map
AttributeMapType& GetAttributeMap() { return mAttributeMap; }
+
+ /// Get the Attributes Map
const AttributeMapType& GetAttributeMap() const { return mAttributeMap; }
+
+ /// Get the Attribute for a specific key
const std::string& GetAttribute(const std::string& k) const;
- const std::string& GetCleanAttribute(const std::string& k) const;
- const std::string& UnsafeGetAttribute(const std::string& k) const
- { return mAttributeMap.find(k)->second; }
+
+ /// Get the Attribute for a specific key without OS dependance (not implemented)
+ // TODO : backslash OS uniformity
+ const std::string& GetCleanAttribute(const std::string& k) const;
+
+ /// Set an Attribute for a specific key
void SetAttribute(const std::string& k, const std::string& v);
+
+ /// Set an Attribute for a specific key(unsafe mode)
void UnsafeSetAttribute(const std::string& k, const std::string& v)
{ mAttributeMap[k] = v; }
+ /// Get Descriptor for an Attribute
const AttributeDescriptor& GetAttributeDescriptor(const std::string& k)const;
- // { return GetTypeDescription().GetFieldDescription(k); }
-
-
- /// Returns true iff the KEY attributes of the node match those of the map provided
+
+ /// Returns true if the KEY attributes of the node match those of the map provided
bool Matches( const AttributeMapType& ) const;
/// Returns the node data casted into the type T
{ if (mData!=0) return dynamic_cast<T>(mData); return 0; }
/// Sets the node data. Deletes existing data if any.
- void SetData(NodeData* d) { if (mData) delete mData; mData = d; }
+ void SetData(boost::shared_ptr<NodeData> d) {mData.reset(); mData = d; }//{ if (mData) delete mData; mData = d; }
/// Sorts the children of the node
void SortChildren(const LexicographicalComparator&);
+ /// Print the node
virtual void Print() const;
+
+ /// Get the Label of the node
std::string GetLabel() const;
- /*
- int ImageGetRows() const;
- int ImageGetColumns() const;
- int ImageGetFrames() const;
- const std::string& ImageGetFullFileName() const { return UnsafeGetAttribute("FullFileName"); }
- */
+
private:
/// The parent of the node
/// The map of attributes
AttributeMapType mAttributeMap;
/// User data
- NodeData* mData;
+ boost::shared_ptr<NodeData> mData;
/// Are the children loaded ?
bool mChildrenLoaded;
/// The number of children