00001 // -*- C++ -*- 00002 00003 /** 00004 * @file ESF_Proxy_RB_Tree.h 00005 * 00006 * $Id: ESF_Proxy_RB_Tree.h 76589 2007-01-25 18:04:11Z elliott_c $ 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 "ace/RB_Tree.h" 00021 00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00023 00024 /// Iterator class for a ACE_ESF_RB_Tree 00025 template<class PROXY> 00026 class TAO_ESF_Proxy_RB_Tree_Iterator 00027 { 00028 public: 00029 typedef ACE_RB_Tree_Iterator<PROXY *, 00030 int, 00031 ACE_Less_Than<PROXY*>, 00032 ACE_Null_Mutex> 00033 Implementation; 00034 00035 TAO_ESF_Proxy_RB_Tree_Iterator (const Implementation &i); 00036 00037 bool operator == (const TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> &rhs) const; 00038 bool operator != (const TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> &rhs) const; 00039 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY>& operator++ (void); 00040 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> operator++ (int); 00041 PROXY *operator *(void); 00042 00043 private: 00044 Implementation impl_; 00045 }; 00046 00047 // **************************************************************** 00048 00049 /// Concrete Proxy collection based on ACE_RB_Tree 00050 /** 00051 * The Event Service Framework provides several alternatives for the 00052 * underlying proxy collections. 00053 * This version is based on Red-Black trees that offer good insertion, 00054 * removal and lookup performance, but the iteration is slightly 00055 * degraded. 00056 */ 00057 template<class PROXY> 00058 class TAO_ESF_Proxy_RB_Tree 00059 { 00060 public: 00061 /// A typedef for the underlying implementaiton class 00062 typedef ACE_RB_Tree<PROXY*,int,ACE_Less_Than<PROXY*>,ACE_Null_Mutex> Implementation; 00063 00064 /// A typedef for the underlying iterator 00065 typedef TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> Iterator; 00066 00067 /// Constructor 00068 TAO_ESF_Proxy_RB_Tree (void); 00069 00070 /// Return the first element in the collection, or end() if there 00071 /// are none 00072 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> begin (void); 00073 00074 /// Return one past the last element in the collection 00075 TAO_ESF_Proxy_RB_Tree_Iterator<PROXY> end (void); 00076 00077 /// Return the number of elements in the collection 00078 size_t size (void) const; 00079 00080 /// Insert a new element to the collection 00081 void connected (PROXY *); 00082 00083 /// Insert a new element that could be there already. 00084 void reconnected (PROXY *); 00085 /// Remove an element from the collection 00086 void disconnected (PROXY *); 00087 00088 /// Shutdown the collection, i.e. remove all elements and release 00089 /// resources 00090 void shutdown (void); 00091 00092 private: 00093 /// The underlying implementation object 00094 Implementation impl_; 00095 }; 00096 00097 TAO_END_VERSIONED_NAMESPACE_DECL 00098 00099 #if defined (__ACE_INLINE__) 00100 #include "orbsvcs/ESF/ESF_Proxy_RB_Tree.inl" 00101 #endif /* __ACE_INLINE__ */ 00102 00103 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00104 #include "orbsvcs/ESF/ESF_Proxy_RB_Tree.cpp" 00105 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00106 00107 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00108 #pragma implementation ("ESF_Proxy_RB_Tree.cpp") 00109 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00110 00111 #endif /* TAO_ESF_PROXY_RB_TREE_H */