5 #ifndef __BASE_DEPENDENCY_H__
6 #define __BASE_DEPENDENCY_H__
8 #include <boost/intrusive/list.hpp>
9 #include <boost/iterator/iterator_facade.hpp>
12 template <
typename NodeType,
typename ObjectType>
15 template <
typename NodeType,
typename ObjectType>
22 ptr_->DependencyAdd(
this);
28 ptr_->DependencyRemove(
this);
34 ptr_->DependencyRemove(
this);
38 ptr_->DependencyAdd(
this);
44 ptr_->DependencyRemove(
this);
49 ObjectType *
get()
const {
59 boost::intrusive::list_member_hook<>
node_;
65 template <
typename NodeType,
typename ObjectType>
68 typedef boost::intrusive::member_hook<
70 boost::intrusive::list_member_hook<>,
72 typedef boost::intrusive::list<
75 template <
typename ValueType,
typename IteratorType>
77 IteratorBase<ValueType, IteratorType>, ValueType,
78 boost::forward_traversal_tag> {
87 return *(
iter_->self_);
92 typedef IteratorBase<NodeType, typename List::iterator>
iterator;
93 typedef IteratorBase<
const NodeType,
99 list_.push_back(*node);
107 while (!
list_.empty()) {
131 #define DEPENDENCY_LIST(NodeType, ObjectType, _Member) \
132 friend class DependencyRef<NodeType, ObjectType>; \
133 void DependencyAdd(DependencyRef<NodeType, ObjectType> *node) { \
136 void DependencyRemove(DependencyRef<NodeType, ObjectType> *node) { \
137 _Member.Remove(node); \
139 DependencyList<NodeType, ObjectType> _Member
DependencyRef(NodeType *self)
IteratorBase(const IteratorType &iter)
DependencyRef(NodeType *self, ObjectType *ptr)
void Remove(DependencyRef< NodeType, ObjectType > *node)
const_iterator end() const
boost::intrusive::list< DependencyRef< NodeType, ObjectType >, MemberHook > List
IteratorBase< const NodeType, typename List::const_iterator > const_iterator
void Add(DependencyRef< NodeType, ObjectType > *node)
DISALLOW_COPY_AND_ASSIGN(DependencyRef)
boost::intrusive::member_hook< DependencyRef< NodeType, ObjectType >, boost::intrusive::list_member_hook<>,&DependencyRef< NodeType, ObjectType >::node_ > MemberHook
DISALLOW_COPY_AND_ASSIGN(DependencyList)
friend class boost::iterator_core_access
ValueType & dereference() const
const_iterator begin() const
const List & list() const
ObjectType * operator->() const
boost::intrusive::list_member_hook node_
bool equal(const IteratorBase &rhs) const
IteratorBase< NodeType, typename List::iterator > iterator
void reset(ObjectType *ptr)