What's the best method for supporting implementation-specific object metadata? (while hopefully still being stongly-typed)
In the interests of keeping this short (and on-point), I'm going to lay out three short object constructs and then explain what it is that I'm trying to accomplish here.
tree_object class-
class tree_object
{
protected:
std::string name_;
tree_object* root_;
uint32_t type_;
// tree_objec::tree_object();
tree_object(enum OBJECT_TYPE type);
// tree_objec::tree_object();
tree_object(std::string name, enum OBJECT_TYPE type = ENTITY);
// tree_objec::tree_object();
tree_object(std::string name, enum OBJECT_TYPE type, tree_object& parent)开发者_StackOverflow中文版;
public:
// default constructor.
tree_object();
// Attach me to some parent node.
virtual bool attach(tree_object& parent);
// Detach me from my current parent.
virtual bool detach(bool forced = false);
// Get object name
virtual operator std::string();
// Set object name
void operator=(std::string value);
// Get object type
virtual operator uint32_t();
};
directory_object-
class directory_object: public tree_object
{
// List of children
std::vector<tree_object> children;
public:
// Attach me to some parent node.
bool attach(tree_object& parent);
// Detach me from my current parent.
bool detach(bool forced = false);
directory_object(std::string element_name = "");
directory_object(std::string element_name, tree_object& parent);
directory_object(std::string element_name, directory_object& parent);
};
filesystem_object-
class filesystem_object: public tree_object
{
public:
// Attach me to some parent node.
bool attach(tree_object& parent);
// Detach me from my current parent.
bool detach(bool forced = false);
filesystem_object(std::string element_name = "");
filesystem_object(std::string element_name, tree_object& parent);
filesystem_object(std::string element_name, directory_object& parent);
};
Given the above object definitions, what I'm looking to do is add support for the following concepts to directory_object
and filesystem_object
:
- implementation-specific ACL entries for both
directory_object
andfilesystem_object
- implementation-specific user tag-data (i.e. a struct that means something to the code iterating a specific instance of the tree.)
Given the information above, how best would I be able to accomplish these goals?
P.S. This might be a future implementation detail, but I am eventually going to be accessing my tree implementation "remotely" (i.e. this is going to wind up in a threaded server, so any assistance provided here should be able to be implemented both there and here.)
Thanks.
精彩评论