支持特定于实现的对象元数据的最佳方法是什么? (虽然希望仍然是强类型)
为了保持简短(并且切中要点),我将列出三个简短的对象构造,然后解释我在这里想要完成的任务。
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);
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);
};
鉴于上述对象定义,我想要做的是将以下概念添加到 directory_object
和 filesystem_object
中:
- 特定于实现的 ACL
directory_object
和filesystem_object
- 实现特定的用户标签数据的条目(即对迭代树的特定实例的代码有意义的结构。)
给定上述信息,我怎样才能最好地实现这些目标?
PS这可能是未来的实现细节,但我最终将“远程”访问我的树实现(即这将在线程服务器中结束,因此此处提供的任何帮助都应该能够在那里实现< em>和这里。)
谢谢。
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);
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论