00001 #ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 00002 #define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 00003 00004 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 00005 #pragma once 00006 #endif 00007 00008 00009 #include "yaml-cpp-pm/noncopyable.h" 00010 #include "ptr_vector.h" 00011 #include <set> 00012 00013 namespace YAML_PM 00014 { 00015 class Node; 00016 00017 class NodeOwnership: private noncopyable 00018 { 00019 public: 00020 explicit NodeOwnership(NodeOwnership *pOwner = 0); 00021 ~NodeOwnership(); 00022 00023 Node& Create() { return m_pOwner->_Create(); } 00024 void MarkAsAliased(const Node& node) { m_pOwner->_MarkAsAliased(node); } 00025 bool IsAliased(const Node& node) const { return m_pOwner->_IsAliased(node); } 00026 00027 private: 00028 Node& _Create(); 00029 void _MarkAsAliased(const Node& node); 00030 bool _IsAliased(const Node& node) const; 00031 00032 private: 00033 ptr_vector<Node> m_nodes; 00034 std::set<const Node *> m_aliasedNodes; 00035 NodeOwnership *m_pOwner; 00036 }; 00037 } 00038 00039 #endif // NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66