Changeset 489 for XIOS/trunk/src/node/variable.cpp
- Timestamp:
- 09/22/14 14:17:33 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/variable.cpp
r477 r489 7 7 #include "xmlioserver_spl.hpp" 8 8 #include "type.hpp" 9 #include "context.hpp" 10 #include "context_client.hpp" 9 11 #include <boost/algorithm/string.hpp> 10 12 … … 48 50 { 49 51 return (this->content); 52 } 53 54 void CVariable::setContent(const StdString& contentStr) 55 { 56 this->content = contentStr; 50 57 } 51 58 … … 61 68 oss << "</" << CVariable::GetName() << " >"; 62 69 return (oss.str()); 63 } 64 70 } 71 65 72 CVariable::EVarType CVariable::getVarType(void) const 66 73 { 67 74 EVarType ret ; 68 75 69 76 if (type.isEmpty()) ret=t_undefined ; 70 77 else … … 83 90 return ret ; 84 91 } 85 92 93 /* 94 *\brief Sending value of a variable with its id from client to server 95 * 96 */ 97 void CVariable::sendValue() 98 { 99 CContext* context=CContext::getCurrent() ; 100 if (!context->hasServer) 101 { 102 CContextClient* client=context->client ; 103 104 CEventClient event(this->getType(),EVENT_ID_VARIABLE_VALUE) ; 105 if (client->isServerLeader()) 106 { 107 CMessage msg ; 108 msg<<this->getId() ; 109 msg<<content ; 110 event.push(client->getServerLeader(),1,msg) ; 111 client->sendEvent(event) ; 112 } 113 else client->sendEvent(event) ; 114 } 115 } 116 117 /* 118 *\brief Receive value of a variable with its id from client to server 119 * 120 */ 121 void CVariable::recvValue(CEventServer& event) 122 { 123 CBufferIn* buffer=event.subEvents.begin()->buffer; 124 string id; 125 *buffer>>id ; 126 get(id)->recvValue(*buffer); 127 } 128 129 130 /* 131 *\brief Receive value of a variable with its id from client to server 132 * 133 */ 134 void CVariable::recvValue(CBufferIn& buffer) 135 { 136 string str ; 137 buffer>>str; 138 setContent(str); 139 } 140 141 bool CVariable::dispatchEvent(CEventServer& event) 142 { 143 if (SuperClass::dispatchEvent(event)) return true ; 144 else 145 { 146 switch(event.type) 147 { 148 case EVENT_ID_VARIABLE_VALUE : 149 recvValue(event) ; 150 return true ; 151 break ; 152 153 default : 154 ERROR("bool CVariable::dispatchEvent(CEventServer& event)",<<"Unknown Event") ; 155 return false ; 156 } 157 } 158 } 159 86 160 /* 87 161 void CVariable::toBinary(StdOStream & os) const
Note: See TracChangeset
for help on using the changeset viewer.