#include <EventTypeSeq.h>
Inheritance diagram for TAO_Notify_EventTypeSeq:
Public Member Functions | |
TAO_Notify_EventTypeSeq (void) | |
Constructor. | |
TAO_Notify_EventTypeSeq (const CosNotification::EventTypeSeq &event_type_seq) | |
TAO_Notify_EventTypeSeq (const TAO_Notify_EventTypeSeq &rhs) | |
TAO_Notify_EventTypeSeq & | operator= (const TAO_Notify_EventTypeSeq &rhs) |
void | add_and_remove (TAO_Notify_EventTypeSeq &added, TAO_Notify_EventTypeSeq &removed) |
Preprocess the types added and removed. | |
void | intersection (const TAO_Notify_EventTypeSeq &rhs, const TAO_Notify_EventTypeSeq &lhs) |
Populate this sequence with the intersection of rhs and lhs. | |
void | insert_seq (const CosNotification::EventTypeSeq &event_type_seq) |
insert_seq the contents of <event_type_seq> into this object. | |
void | remove_seq (const CosNotification::EventTypeSeq &event_type_seq) |
remove_seq the contents of <event_type_seq> from this object. | |
void | insert_seq (const TAO_Notify_EventTypeSeq &event_type_seq) |
insert_seq the contents of <event_type_seq> into this object. | |
void | remove_seq (const TAO_Notify_EventTypeSeq &event_type_seq) |
remove_seq the contents of <event_type_seq> from this object. | |
void | populate (CosNotification::EventTypeSeq &event_type) const |
Populate <event_type_seq> with the contents of this object. | |
void | populate_no_special (CosNotification::EventTypeSeq &event_type) const |
void | dump (void) const |
Print the contents. | |
virtual void | save_persistent (TAO_Notify::Topology_Saver &saver) |
virtual TAO_Notify::Topology_Object * | load_child (const ACE_CString &type, CORBA::Long id, const TAO_Notify::NVPList &attrs) |
Create a child of the appropriate type and return it. | |
Private Types | |
typedef ACE_Unbounded_Set< TAO_Notify_EventType > | inherited |
Private Member Functions | |
virtual void | release (void) |
The release method is called when the refcount reaches 0. |
Definition at line 33 of file EventTypeSeq.h.
typedef ACE_Unbounded_Set<TAO_Notify_EventType> TAO_Notify_EventTypeSeq::inherited [private] |
Definition at line 37 of file EventTypeSeq.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_EventTypeSeq::TAO_Notify_EventTypeSeq | ( | void | ) |
TAO_Notify_EventTypeSeq::TAO_Notify_EventTypeSeq | ( | const CosNotification::EventTypeSeq & | event_type_seq | ) |
Definition at line 20 of file EventTypeSeq.cpp.
References insert_seq().
00021 { 00022 this->insert_seq (event_type_seq); 00023 }
TAO_Notify_EventTypeSeq::TAO_Notify_EventTypeSeq | ( | const TAO_Notify_EventTypeSeq & | rhs | ) |
Definition at line 32 of file EventTypeSeq.cpp.
00033 : TAO_Notify_Object () 00034 , TAO_Notify::Topology_Savable () 00035 , ACE_Unbounded_Set <TAO_Notify_EventType> (rhs) 00036 , TAO_Notify::Topology_Object () 00037 { 00038 }
void TAO_Notify_EventTypeSeq::add_and_remove | ( | TAO_Notify_EventTypeSeq & | added, | |
TAO_Notify_EventTypeSeq & | removed | |||
) |
Preprocess the types added and removed.
Definition at line 126 of file EventTypeSeq.cpp.
References ACE_Unbounded_Set_Ex< T, C >::find(), ACE_Unbounded_Set_Ex< TAO_Notify_EventType, ACE_Unbounded_Set_Default_Comparator< TAO_Notify_EventType > >::insert(), ACE_Unbounded_Set_Ex< T, C >::insert(), insert_seq(), intersection(), ACE_Unbounded_Set_Ex< T, C >::is_empty(), remove_seq(), ACE_Unbounded_Set_Ex< TAO_Notify_EventType, ACE_Unbounded_Set_Default_Comparator< TAO_Notify_EventType > >::reset(), ACE_Unbounded_Set_Ex< T, C >::reset(), and TAO_Notify_EventType::special().
Referenced by TAO_Notify_SupplierAdmin::offer_change(), TAO_Notify_ProxyConsumer_T< SERVANT_TYPE >::offer_change(), TAO_Notify_ProxySupplier_T< SERVANT_TYPE >::subscription_change(), and TAO_Notify_ConsumerAdmin::subscription_change().
00127 { 00128 const TAO_Notify_EventType& special = TAO_Notify_EventType::special (); 00129 00130 if (this->find (special) == 0) // If this object has the special type. 00131 { 00132 if (seq_added.find (special) == 0) // if the seq. being added has the special type, you cannot be adding or removing anythings. * overrides. 00133 { 00134 seq_added.reset (); // remove everything from the sequence bening added. 00135 seq_remove.reset (); // remove everything form whats being removed. 00136 } 00137 else // sequence being added does not have * 00138 { 00139 if (!seq_added.is_empty ()) // if sequence being added is non empty 00140 { 00141 this->reset (); // take away the * from this object. 00142 this->insert_seq (seq_added); // insert the sequence being added as the new list of types. 00143 00144 seq_remove.reset (); // reset all that is being removed. 00145 seq_remove.insert (special); // remove * 00146 } 00147 else // nothing is being added 00148 { 00149 if (seq_remove.find (special) == 0) // we're removing everything 00150 { 00151 this->reset (); 00152 seq_remove.reset (); // reset all that is being removed. 00153 seq_remove.insert (special); // remove * 00154 } 00155 else if (!seq_remove.is_empty ()) 00156 { 00157 // if we're currently subscribed for everything and did not added anything, we can't remove something. 00158 seq_remove.reset (); 00159 } 00160 } 00161 } 00162 } 00163 else // if this object does not have the special type. 00164 { 00165 if (seq_added.find (special) == 0) // but the seq. being added has the special type, 00166 { 00167 if (seq_remove.find (special) == 0) // and you're removing * as well 00168 { 00169 seq_added.reset (); // ignore the request 00170 seq_remove.reset (); // ignore the request 00171 } 00172 else // seq being removed does not have the special type 00173 { 00174 seq_remove.reset (); // everything that we're subscribed for is being removed. 00175 seq_remove.insert_seq (*this); 00176 00177 this->reset (); // insert the special in this object. 00178 this->insert (special); 00179 00180 seq_added.reset (); // also clear our set and add only * 00181 seq_added.insert (special); 00182 } 00183 } 00184 else // seq being added does not have special. 00185 { 00186 if (seq_remove.find (special) == 0) // but we're removing everything. 00187 { 00188 seq_remove.reset (); // move all that we have currently to removed. 00189 seq_remove.insert_seq (*this); 00190 } 00191 00192 // so now there are no specials anywhere.. 00193 { 00194 //= First remove the duplicates in the added and removes lists. 00195 // compute the intersection. 00196 00197 TAO_Notify_EventTypeSeq common; 00198 common.intersection (seq_added, seq_remove); 00199 00200 // remove the common elements from both the lists so Added {BCDK} and Removed {CDEA} will yield Added {BK} and Removed {EA} 00201 seq_added.remove_seq (common); 00202 seq_remove.remove_seq (common); 00203 00204 // If we're already subscribed for an element we should not subscribe again (duplicate events). 00205 // so if we currently subscribe for ABC and we Added {BK} we should now get ABCK as current subscription and Added {K} 00206 common.reset (); 00207 common.intersection (*this, seq_added); 00208 // remove the common elements from the added list. i,e. doent ask to add what we're already added for. 00209 seq_added.remove_seq (common); 00210 // update the current subscription. 00211 this->insert_seq (seq_added); 00212 00213 00214 // Similarly for removed.. if we're removing EA and now our current list looks like ABC we should emd up with 00215 // current subscription BC and Removed {A} 00216 common.reset (); 00217 common.intersection (*this, seq_remove); 00218 00219 seq_remove.reset (); 00220 seq_remove.insert_seq (common); // only remove what we currently have. 00221 00222 this->remove_seq (seq_remove); 00223 } 00224 } 00225 } 00226 }
void TAO_Notify_EventTypeSeq::dump | ( | void | ) | const |
Print the contents.
Reimplemented from ACE_Unbounded_Set_Ex< TAO_Notify_EventType, ACE_Unbounded_Set_Default_Comparator< TAO_Notify_EventType > >.
Definition at line 249 of file EventTypeSeq.cpp.
References ACE_DEBUG, TAO_Notify_EventType::dump(), and LM_DEBUG.
00250 { 00251 TAO_Notify_EventTypeSeq::CONST_ITERATOR iter (*this); 00252 00253 TAO_Notify_EventType* event_type; 00254 00255 for (iter.first (); iter.next (event_type); iter.advance ()) 00256 { 00257 event_type->dump (); 00258 ACE_DEBUG ((LM_DEBUG, ", ")); 00259 } 00260 }
void TAO_Notify_EventTypeSeq::insert_seq | ( | const TAO_Notify_EventTypeSeq & | event_type_seq | ) |
insert_seq the contents of <event_type_seq> into this object.
Definition at line 104 of file EventTypeSeq.cpp.
00105 { 00106 TAO_Notify_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); 00107 00108 TAO_Notify_EventType* event_type; 00109 00110 for (iter.first (); iter.next (event_type); iter.advance ()) 00111 inherited::insert (*event_type); 00112 }
void TAO_Notify_EventTypeSeq::insert_seq | ( | const CosNotification::EventTypeSeq & | event_type_seq | ) |
insert_seq the contents of <event_type_seq> into this object.
Definition at line 80 of file EventTypeSeq.cpp.
Referenced by add_and_remove(), and TAO_Notify_EventTypeSeq().
00081 { 00082 TAO_Notify_EventType event_type; 00083 00084 for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) 00085 { 00086 event_type = event_type_seq[i]; 00087 inherited::insert (event_type); 00088 } 00089 }
void TAO_Notify_EventTypeSeq::intersection | ( | const TAO_Notify_EventTypeSeq & | rhs, | |
const TAO_Notify_EventTypeSeq & | lhs | |||
) |
Populate this sequence with the intersection of rhs and lhs.
Definition at line 229 of file EventTypeSeq.cpp.
Referenced by add_and_remove(), and TAO_Notify_Peer::dispatch_updates().
00230 { 00231 // linear search. 00232 TAO_Notify_EventTypeSeq::CONST_ITERATOR rhs_iter (rhs); 00233 TAO_Notify_EventType* rhs_event_type; 00234 00235 TAO_Notify_EventTypeSeq::CONST_ITERATOR lhs_iter (lhs); 00236 TAO_Notify_EventType* lhs_event_type; 00237 00238 for (rhs_iter.first (); rhs_iter.next (rhs_event_type); rhs_iter.advance ()) 00239 { 00240 for (lhs_iter.first (); lhs_iter.next (lhs_event_type); lhs_iter.advance ()) 00241 { 00242 if (*rhs_event_type == *lhs_event_type) // if both are same add to this object. 00243 this->insert (*rhs_event_type); 00244 } 00245 } 00246 }
TAO_Notify::Topology_Object * TAO_Notify_EventTypeSeq::load_child | ( | const ACE_CString & | type, | |
CORBA::Long | id, | |||
const TAO_Notify::NVPList & | attrs | |||
) | [virtual] |
Create a child of the appropriate type and return it.
Use "type" as passed in to determine what kind of child (supporting the Topology_Object interface) to create and return. Inform it of its new ID.
Reimplemented from TAO_Notify::Topology_Object.
Definition at line 291 of file EventTypeSeq.cpp.
References ACE_DEBUG, ACE_TEXT(), DEBUG_LEVEL, TAO_Notify_EventType::init(), ACE_Unbounded_Set_Ex< TAO_Notify_EventType, ACE_Unbounded_Set_Default_Comparator< TAO_Notify_EventType > >::insert(), and LM_DEBUG.
00293 { 00294 ACE_UNUSED_ARG (id); 00295 TAO_Notify::Topology_Object *result = this; 00296 TAO_Notify_EventType et; 00297 00298 if ((type == "subscription") && et.init(attrs)) 00299 { 00300 if (DEBUG_LEVEL) ACE_DEBUG ((LM_DEBUG, 00301 ACE_TEXT ("(%P|%t) Event_Type reload subscription\n") 00302 )); 00303 inherited::insert(et); 00304 } 00305 return result; 00306 }
TAO_Notify_EventTypeSeq & TAO_Notify_EventTypeSeq::operator= | ( | const TAO_Notify_EventTypeSeq & | rhs | ) |
Definition at line 26 of file EventTypeSeq.cpp.
00027 { 00028 ACE_Unbounded_Set <TAO_Notify_EventType>::operator = (rhs); 00029 return *this; 00030 }
void TAO_Notify_EventTypeSeq::populate | ( | CosNotification::EventTypeSeq & | event_type | ) | const |
Populate <event_type_seq> with the contents of this object.
Definition at line 41 of file EventTypeSeq.cpp.
References TAO_Notify_EventType::native().
Referenced by TAO_Notify_Proxy::obtain_types().
00042 { 00043 event_type_seq.length (static_cast<CORBA::ULong> (this->size ())); 00044 00045 inherited::CONST_ITERATOR iter (*this); 00046 00047 TAO_Notify_EventType* event_type = 0; 00048 00049 CORBA::ULong i = 0; 00050 for (iter.first (); iter.next (event_type); iter.advance (), ++i) 00051 event_type_seq[i] = event_type->native (); 00052 }
void TAO_Notify_EventTypeSeq::populate_no_special | ( | CosNotification::EventTypeSeq & | event_type | ) | const |
Populate <event_type_seq> with the contents of this object. Excludes the special event type. This is used to avoid sending * type updates to proxys.
Definition at line 55 of file EventTypeSeq.cpp.
References TAO_Notify_EventType::is_special(), TAO_Notify_EventType::native(), and TAO_Notify_EventType::special().
Referenced by TAO_Notify_Peer::dispatch_updates().
00056 { 00057 // If the special exists in us, don't include it. 00058 const TAO_Notify_EventType& special = TAO_Notify_EventType::special (); 00059 00060 if (this->find (special) == 0) 00061 { 00062 event_type_seq.length (static_cast<CORBA::ULong> (this->size () - 1)); 00063 } 00064 else 00065 event_type_seq.length (static_cast<CORBA::ULong> (this->size ())); 00066 00067 inherited::CONST_ITERATOR iter (*this); 00068 00069 TAO_Notify_EventType* event_type = 0; 00070 00071 CORBA::ULong i = 0; 00072 for (iter.first (); iter.next (event_type); iter.advance (), ++i) 00073 { 00074 if (event_type->is_special () == 0) // if its not the special event type. 00075 event_type_seq[i] = event_type->native (); 00076 } 00077 }
void TAO_Notify_EventTypeSeq::release | ( | void | ) | [private, virtual] |
The release method is called when the refcount reaches 0.
Implements TAO_Notify_Refcountable.
Definition at line 309 of file EventTypeSeq.cpp.
void TAO_Notify_EventTypeSeq::remove_seq | ( | const TAO_Notify_EventTypeSeq & | event_type_seq | ) |
remove_seq the contents of <event_type_seq> from this object.
Definition at line 115 of file EventTypeSeq.cpp.
00116 { 00117 TAO_Notify_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); 00118 00119 TAO_Notify_EventType* event_type; 00120 00121 for (iter.first (); iter.next (event_type); iter.advance ()) 00122 inherited::remove (*event_type); 00123 }
void TAO_Notify_EventTypeSeq::remove_seq | ( | const CosNotification::EventTypeSeq & | event_type_seq | ) |
remove_seq the contents of <event_type_seq> from this object.
Definition at line 92 of file EventTypeSeq.cpp.
Referenced by add_and_remove(), and TAO_Notify_Peer::dispatch_updates().
00093 { 00094 TAO_Notify_EventType event_type; 00095 00096 for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) 00097 { 00098 event_type = event_type_seq[i]; 00099 inherited::remove (event_type); 00100 } 00101 }
void TAO_Notify_EventTypeSeq::save_persistent | ( | TAO_Notify::Topology_Saver & | saver | ) | [virtual] |
Save our state to a Topology_Saver.
Use the methods of a Topology_Saver to store all information we want persisted. This function is called by our parent, which gives us a saver to use. In turn, we must call this function on all of our children. The implementation should look like: bool change = this->self_changed_; this->self_changed_ = false; this->children_changed_ = false; if (is_persistent ()) { bool want_all_children = saver.begin_object( this->id(), type, attrs, change); for all children { if (want_all_children || child.is_changed()) { child.save_persistent(saver); } } for all deleted children { saver.delete_child(child_type, child_id); } saver.end_object(this->id(), type); )
Implements TAO_Notify::Topology_Savable.
Definition at line 264 of file EventTypeSeq.cpp.
References TAO_Notify::Topology_Saver::begin_object(), TAO_Notify::Topology_Object::children_changed_, TAO_Notify::Topology_Saver::end_object(), TAO_Notify_EventType::save_persistent(), and TAO_Notify::Topology_Object::self_changed_.
00265 { 00266 bool changed = this->self_changed_; 00267 this->self_changed_ = false; 00268 this->children_changed_ = false; 00269 TAO_Notify::NVPList attrs; 00270 00271 TAO_Notify_EventTypeSeq::ITERATOR iter (*this); 00272 TAO_Notify_EventType* event_type; 00273 00274 if (this->size() != 0) 00275 { 00276 saver.begin_object(0, "subscriptions", attrs, changed); 00277 for (iter.first (); iter.next (event_type) != 0; iter.advance ()) 00278 { 00279 event_type->save_persistent(saver); 00280 } 00281 // todo: 00282 // for all deleted children 00283 // { 00284 // saver.delete_child(child_type, child_id); 00285 // } 00286 saver.end_object(0, "subscriptions"); 00287 } 00288 }