00001 // -*- C++ -*- 00002 00003 /** 00004 * @file ESF_Proxy_RB_Tree.h 00005 * 00006 * $Id: ESF_Proxy_RB_Tree.h 90386 2010-06-02 13:52:08Z vzykov $ 00007 * 00008 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00009 * 00010 * http://doc.ece.uci.edu/~coryan/EC/index.html 00011 */ 00012 00013 #ifndef TAO_ESF_PROXY_RB_TREE_H 00014 #define TAO_ESF_PROXY_RB_TREE_H 00015 00016 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00017 # pragma once 00018 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00019 00020 #include /**/ "tao/Versioned_Namespace.h" 00021 00022 #include "ace/RB_Tree.h" 00023 #include "ace/Null_Mutex.h" 00024 00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 /// Iterator class for a ACE_ESF_RB_Tree 00028 template<class PROXY> 00029 class TAO_ESF_Proxy_RB_Tree_Iterator 00030 { 00031 public: 00032 typedef ACE_RB_Tree_Iterator<PROXY *, 00033 int, 00034 ACE_Less_Than<PROXY*>, 00035 ACE_Null_Mutex> 00036 Implementation; 00037 00038 TAO_ESF_Proxy_RB_Tree_Iterator (const Implementation &i); 00039 00040 bool operator == (const TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> &rhs) const; 00041 bool operator != (const TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> &rhs) const; 00042 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY>& operator++ (void); 00043 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> operator++ (int); 00044 PROXY *operator *(void); 00045 00046 private: 00047 Implementation impl_; 00048 }; 00049 00050 // **************************************************************** 00051 00052 /// Concrete Proxy collection based on ACE_RB_Tree 00053 /** 00054 * The Event Service Framework provides several alternatives for the 00055 * underlying proxy collections. 00056 * This version is based on Red-Black trees that offer good insertion, 00057 * removal and lookup performance, but the iteration is slightly 00058 * degraded. 00059 */ 00060 template<class PROXY> 00061 class TAO_ESF_Proxy_RB_Tree 00062 { 00063 public: 00064 /// A typedef for the underlying implementaiton class 00065 typedef ACE_RB_Tree<PROXY*,int,ACE_Less_Than<PROXY*>,ACE_Null_Mutex> Implementation; 00066 00067 /// A typedef for the underlying iterator 00068 typedef TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> Iterator; 00069 00070 /// Constructor 00071 TAO_ESF_Proxy_RB_Tree (void); 00072 00073 /// Return the first element in the collection, or end() if there 00074 /// are none 00075 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> begin (void); 00076 00077 /// Return one past the last element in the collection 00078 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> end (void); 00079 00080 /// Return the number of elements in the collection 00081 size_t size (void) const; 00082 00083 /// Insert a new element to the collection 00084 void connected (PROXY *); 00085 00086 /// Insert a new element that could be there already. 00087 void reconnected (PROXY *); 00088 /// Remove an element from the collection 00089 void disconnected (PROXY *); 00090 00091 /// Shutdown the collection, i.e. remove all elements and release 00092 /// resources 00093 void shutdown (void); 00094 00095 private: 00096 /// The underlying implementation object 00097 Implementation impl_; 00098 }; 00099 00100 TAO_END_VERSIONED_NAMESPACE_DECL 00101 00102 #if defined (__ACE_INLINE__) 00103 #include "orbsvcs/ESF/ESF_Proxy_RB_Tree.inl" 00104 #endif /* __ACE_INLINE__ */ 00105 00106 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00107 #include "orbsvcs/ESF/ESF_Proxy_RB_Tree.cpp" 00108 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00109 00110 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00111 #pragma implementation ("ESF_Proxy_RB_Tree.cpp") 00112 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00113 00114 #endif /* TAO_ESF_PROXY_RB_TREE_H */