ircproxy The Ultimate Cyborg |
#include <Bool.h>
Definition at line 64 of file Bool.h.
Public Member Functions | |
Bool (char const *name) | |
Construct a Bool with debug name name. | |
Bool (Bool const &b) | |
Copy constructor. | |
~Bool () | |
Destructor. | |
void | print_name (std::ostream &os) const |
For debugging purposes. Write the (debug) name of this object to os. | |
void | add_event_server (boost::shared_ptr< ExpressionEventServer > const &event_server) |
Add event server to notification list. | |
void | sub_event_server (ExpressionEventServer *event_server) |
Remove event server from notification list. | |
Bool & | operator= (bool b) |
Assign bool value. | |
Bool & | operator= (Bool const &b) |
Assign Bool value. | |
BoolExpression< false > | operator* (void) |
Dereference operator. Returns this object as expression. | |
bool | value (void) const |
Returns underlying bool value. | |
Private Member Functions | |
void | changed_to (bool b) |
Called when the underlying boolean changes value to b. | |
Private Attributes | |
bool | M_value |
Underlaying bool value. | |
bool | M_being_destructed |
True when this object is being destructed. | |
std::set< boost::shared_ptr < ExpressionEventServer > > | M_event_servers |
List of Expression event servers that are watching this Bool. | |
char const * | M_name |
For debugging purposes; a human readable name for this object. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, Bool const &b) |
Write Bool b to os. |
Bool::Bool | ( | char const * | name | ) | [inline] |
Bool::Bool | ( | Bool const & | b | ) | [inline] |
Copy constructor.
Definition at line 82 of file Bool.h.
00082 : M_value(b.M_value), M_being_destructed(false) 00083 #ifdef CWDEBUG 00084 , M_name(b.M_name) 00085 #endif 00086 { 00087 #ifdef CWDEBUG 00088 if (!b.M_event_servers.empty()) 00089 Dout(dc::warning, "Copy-constructing a Bool that is being used by one or more ExpressionEventServer's"); 00090 #endif 00091 }
Bool::~Bool | ( | ) |
Destructor.
Definition at line 35 of file Bool.cc.
References M_being_destructed, and M_event_servers.
00036 { 00037 M_being_destructed = true; 00038 for (std::set<boost::shared_ptr<ExpressionEventServer> >::iterator iter = M_event_servers.begin(); 00039 iter != M_event_servers.end(); ++iter) 00040 (*iter)->bool_destructed(); 00041 }
void Bool::print_name | ( | std::ostream & | os | ) | const [inline] |
For debugging purposes. Write the (debug) name of this object to os.
Definition at line 97 of file Bool.h.
Referenced by BoolExpression< inverted >::print_on().
00097 { os << M_name; }
void Bool::add_event_server | ( | boost::shared_ptr< ExpressionEventServer > const & | event_server | ) | [inline] |
Add event server to notification list.
Definition at line 101 of file Bool.h.
References M_event_servers.
Referenced by BoolExpression< inverted >::add_event_server().
00102 { 00103 // If this Bool appears multiple times in one expression, we come here more than once. 00104 // However, since M_event_servers is a set<>, only the first time the event_server is really added. 00105 M_event_servers.insert(event_server); 00106 }
void Bool::sub_event_server | ( | ExpressionEventServer * | event_server | ) | [inline] |
Remove event server from notification list.
Definition at line 109 of file Bool.h.
References M_being_destructed, and M_event_servers.
Referenced by BoolExpression< inverted >::sub_event_server_impl().
00110 { 00111 if (M_being_destructed) 00112 return; 00113 std::set<boost::shared_ptr<ExpressionEventServer> >::iterator iter = M_event_servers.begin(); 00114 while (iter != M_event_servers.end()) 00115 { 00116 if ((*iter).get() == event_server) 00117 break; 00118 ++iter; 00119 } 00120 // If this Bool appears multiple times in one expression, we come here more than once. 00121 if (iter != M_event_servers.end()) 00122 M_event_servers.erase(iter); 00123 }
Bool& Bool::operator= | ( | bool | b | ) | [inline] |
Assign bool value.
Definition at line 126 of file Bool.h.
References changed_to(), and M_value.
00127 { 00128 if (M_value != b) 00129 changed_to(b); 00130 return *this; 00131 }
Assign Bool value.
Definition at line 134 of file Bool.h.
References changed_to(), and M_value.
00135 { 00136 if (M_value != b.M_value) 00137 changed_to(b.M_value); 00138 return *this; 00139 }
BoolExpression<false> Bool::operator* | ( | void | ) | [inline] |
Dereference operator. Returns this object as expression.
Definition at line 142 of file Bool.h.
00142 { return BoolExpression<false>(*this); }
bool Bool::value | ( | void | ) | const [inline] |
Returns underlying bool value.
Definition at line 145 of file Bool.h.
References M_value.
Referenced by BoolExpression< inverted >::evaluate_impl().
00145 { return M_value; }
void Bool::changed_to | ( | bool | b | ) | [private] |
Called when the underlying boolean changes value to b.
Definition at line 23 of file Bool.cc.
References M_event_servers, and M_value.
Referenced by operator=().
00024 { 00025 // The call to bool_changed might cause the expression to trigger. 00026 // Once handled, the expression is released and therefore the ExpressionEventServer 00027 // is removed from the set<>. Therefore we need to advance iter before 00028 // calling bool_changed(). 00029 M_value = b; 00030 std::set<boost::shared_ptr<ExpressionEventServer> >::iterator iter = M_event_servers.begin(); 00031 while (iter != M_event_servers.end()) 00032 (*iter++)->bool_changed(); 00033 }
std::ostream& operator<< | ( | std::ostream & | os, | |
Bool const & | b | |||
) | [friend] |
bool Bool::M_value [private] |
Underlaying bool value.
Definition at line 66 of file Bool.h.
Referenced by changed_to(), operator<<(), operator=(), and value().
bool Bool::M_being_destructed [private] |
True when this object is being destructed.
Definition at line 67 of file Bool.h.
Referenced by sub_event_server(), and ~Bool().
std::set<boost::shared_ptr<ExpressionEventServer> > Bool::M_event_servers [private] |
List of Expression event servers that are watching this Bool.
Definition at line 68 of file Bool.h.
Referenced by add_event_server(), changed_to(), sub_event_server(), and ~Bool().
char const* Bool::M_name [private] |
For debugging purposes; a human readable name for this object.
Definition at line 70 of file Bool.h.
Referenced by operator<<().
Copyright © 2005-2007 Carlo Wood. All rights reserved. |
---|