Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / LF_Multi_Event.cpp
blob244ea609a55d1e8827f5d4612bef5fdbee9f9351
1 #include "tao/LF_Multi_Event.h"
2 #include "tao/Connection_Handler.h"
3 #include "ace/OS_Memory.h"
5 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 TAO_LF_Multi_Event::TAO_LF_Multi_Event ()
9 : TAO_LF_Event (),
10 events_ (nullptr),
11 winner_ (nullptr)
15 TAO_LF_Multi_Event::~TAO_LF_Multi_Event ()
17 while (this->events_ != nullptr)
19 Event_Node *n = this->events_->next_;
20 delete this->events_;
21 this->events_ = n;
25 int
26 TAO_LF_Multi_Event::bind (TAO_LF_Follower *follower)
28 if (this->TAO_LF_Event::bind(follower) == -1)
30 return -1;
33 for (Event_Node *n = this->events_; n != nullptr; n = n->next_)
34 if (n->ptr_->bind(follower) == -1)
36 return -1;
38 return 0;
41 int
42 TAO_LF_Multi_Event::unbind (TAO_LF_Follower *follower)
44 if (this->TAO_LF_Event::unbind (follower) == -1)
46 return -1;
49 for (Event_Node *n = this->events_; n != nullptr; n = n->next_)
50 if (n->ptr_->unbind (follower) == -1)
52 return -1;
54 return 0;
58 void
59 TAO_LF_Multi_Event::add_event (TAO_Connection_Handler *ev)
61 Event_Node *node = nullptr;
62 ACE_NEW (node, Event_Node);
63 node->next_ = this->events_;
64 node->ptr_ = ev;
66 this->events_ = node;
69 TAO_Connection_Handler*
70 TAO_LF_Multi_Event::winner ()
72 return this->winner_;
75 TAO_Transport *
76 TAO_LF_Multi_Event::base_transport ()
78 return (this->events_ == nullptr) ? nullptr : this->events_->ptr_->transport();
81 bool
82 TAO_LF_Multi_Event::successful_i () const
84 for (Event_Node *n = this->events_; n != nullptr; n = n->next_)
85 if (n->ptr_->successful_i())
87 this->winner_ = n->ptr_;
88 return true;
90 return false;
93 bool
94 TAO_LF_Multi_Event::error_detected_i () const
96 for (Event_Node *n = this->events_; n != nullptr; n = n->next_)
98 if (!n->ptr_->error_detected_i ())
100 return false;
103 return true;
106 void
107 TAO_LF_Multi_Event::state_changed_i (LFS_STATE )
111 bool
112 TAO_LF_Multi_Event::is_state_final () const
114 for (Event_Node *n = this->events_; n != nullptr; n = n->next_)
116 if (!n->ptr_->is_state_final ())
118 return false;
121 return true;
124 TAO_END_VERSIONED_NAMESPACE_DECL