FDM_CDR Class Reference
#include <fdm_cdr.h>
Inheritance diagram for FDM_CDR:

Public Member Functions | |
| FDM_CDR (FDM::Direction dir) | |
| FDM_CDR (ACE_InputCDR &istr) | |
| FDM_CDR (const ACE_Message_Block &msg, FDM::Direction dir) | |
| FDM_CDR (ACE_OutputCDR &ostr) | |
| ~FDM_CDR () | |
| void | set_message_block (const ACE_Message_Block &msg) |
| const ACE_Message_Block & | get_message_block () |
| void | clear () |
Static Public Member Functions | |
| template<class T> | |
| static bool | object_to_message_block (const T &obj, ACE_Message_Block &mb) |
| template<class T> | |
| static bool | message_block_to_object (T &obj, const ACE_Message_Block &mb_in) |
Protected Member Functions | |
| virtual bool | _io_object (bool &x) |
| virtual bool | _io_object (unsigned char &x) |
| virtual bool | _io_object (char &x) |
| virtual bool | _io_object (unsigned short &x) |
| virtual bool | _io_object (short &x) |
| virtual bool | _io_object (unsigned int &x) |
| virtual bool | _io_object (int &x) |
| virtual bool | _io_object (unsigned long &x) |
| virtual bool | _io_object (long &x) |
| virtual bool | _io_object (unsigned long long &x) |
| virtual bool | _io_object (long long &x) |
| virtual bool | _io_object (float &x) |
| virtual bool | _io_object (double &x) |
| virtual bool | _io_object (std::string &x) |
| template<class T> | |
| bool | cdr_peek_object (T &x) |
| virtual bool | _peek_object (unsigned int &x) |
| virtual bool | _peek_object (std::string &x) |
| virtual bool | _check_streams (size_t size) |
| virtual void | _begin_map () |
| virtual void | _begin_array () |
| virtual bool | _array_resizable_length (int &size) |
| virtual bool | _array_element () |
| virtual void | _end () |
| virtual bool | _map_field (const char *name) |
Protected Attributes | |
| ACE_InputCDR * | _istr |
| ACE_OutputCDR * | _ostr |
| bool | _owns_istr |
| bool | _owns_ostr |
Detailed Description
Definition at line 41 of file fdm_cdr.h.
Constructor & Destructor Documentation
| FDM_CDR::FDM_CDR | ( | FDM::Direction | dir | ) |
Definition at line 27 of file fdm_cdr.cc.
References _ostr, and _owns_ostr.
00027 : 00028 FDM_Stream(dir), _istr(NULL), _ostr(NULL), 00029 _owns_istr(false), _owns_ostr(false) 00030 { 00031 // If writing, create ostr now 00032 if(is_write()) { 00033 _ostr = new ACE_OutputCDR; 00034 _owns_ostr = true; 00035 } 00036 }
| FDM_CDR::FDM_CDR | ( | ACE_InputCDR & | istr | ) |
Definition at line 38 of file fdm_cdr.cc.
References _istr, and _owns_istr.
00038 : 00039 FDM_Stream(FDM::Read), _istr(NULL), _ostr(NULL), 00040 _owns_istr(false), _owns_ostr(false) 00041 { 00042 _istr = &istr; 00043 _owns_istr = false; 00044 }
| FDM_CDR::FDM_CDR | ( | const ACE_Message_Block & | msg, | |
| FDM::Direction | dir | |||
| ) |
Definition at line 46 of file fdm_cdr.cc.
References _istr, and _owns_istr.
00047 : 00048 FDM_Stream(dir), _istr(NULL), _ostr(NULL), 00049 _owns_istr(false), _owns_ostr(false) 00050 { 00051 assert(dir == FDM::Read); 00052 _istr = new ACE_InputCDR(&msg); 00053 _owns_istr = true; 00054 }
| FDM_CDR::FDM_CDR | ( | ACE_OutputCDR & | ostr | ) |
Definition at line 56 of file fdm_cdr.cc.
References _ostr, and _owns_ostr.
00056 : 00057 FDM_Stream(FDM::Write), _istr(NULL), _ostr(NULL), 00058 _owns_istr(false), _owns_ostr(false) 00059 { 00060 _ostr = &ostr; 00061 _owns_ostr = false; 00062 }
| FDM_CDR::~FDM_CDR | ( | ) |
Definition at line 64 of file fdm_cdr.cc.
References _istr, _ostr, _owns_istr, and _owns_ostr.
00065 { 00066 if(_owns_istr && _istr!=NULL) { 00067 delete _istr; 00068 } 00069 if(_owns_ostr && _ostr!=NULL) { 00070 delete _ostr; 00071 } 00072 }
Member Function Documentation
| void FDM_CDR::set_message_block | ( | const ACE_Message_Block & | msg | ) |
Definition at line 75 of file fdm_cdr.cc.
References _istr, and _owns_istr.
Referenced by FDM_CDR_File::_process_next_block().
00076 { 00077 assert(is_read()); 00078 if(_istr == NULL) { 00079 _istr = new ACE_InputCDR(&msg); 00080 _owns_istr = true; 00081 } 00082 else if(_owns_istr) { 00083 // We own it, delete and recreate 00084 delete _istr; 00085 _istr = new ACE_InputCDR(&msg); 00086 } 00087 else { 00088 // We don't own it, have to call reset 00089 _istr->reset(&msg, ACE_CDR_BYTE_ORDER); 00090 } 00091 }
| const ACE_Message_Block & FDM_CDR::get_message_block | ( | ) |
Definition at line 96 of file fdm_cdr.cc.
References _ostr.
Referenced by FDM_CDR_File::flush(), and CDR_Recycle_Functor::operator()().
00097 { 00098 assert(is_write() && _ostr!=NULL && _ostr->begin()!=NULL); 00099 return(*(_ostr->begin())); 00100 }
| void FDM_CDR::clear | ( | ) |
Definition at line 103 of file fdm_cdr.cc.
References _ostr.
Referenced by FDM_CDR_File::flush(), and CDR_Reset_Functor::operator()().
00104 { 00105 assert(is_write() && _ostr!=NULL); 00106 _ostr->reset(); 00107 // Clear the contents of the Data_Block to zero 00108 const ACE_Message_Block *msg = _ostr->begin(); 00109 ACE_OS::memset(((void *)msg->base()), 0, msg->capacity()); 00110 }
| static bool FDM_CDR::object_to_message_block | ( | const T & | obj, | |
| ACE_Message_Block & | mb | |||
| ) | [inline, static] |
| static bool FDM_CDR::message_block_to_object | ( | T & | obj, | |
| const ACE_Message_Block & | mb_in | |||
| ) | [inline, static] |
| bool FDM_CDR::_io_object | ( | bool & | x | ) | [protected, virtual] |
Definition at line 158 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
Referenced by _array_resizable_length(), FDM_CDR_File::_start_topform(), cdr_peek_object(), and FDM_CDR_File::summarize().
00159 { 00160 if(!_check_streams(sizeof(x))) { 00161 return(false); 00162 } 00163 if(is_read()) { 00164 ACE_CDR::Boolean b; 00165 if(_istr->read_boolean(b)) { 00166 x=b; 00167 return(_istr->good_bit()); 00168 } 00169 } 00170 else { 00171 _ostr->write_boolean(x); 00172 return (_ostr->good_bit()); 00173 } 00174 return(false); 00175 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | unsigned char & | x | ) | [protected, virtual] |
Definition at line 178 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00179 { 00180 if(!_check_streams(sizeof(x))) { 00181 return(false); 00182 } 00183 if(is_read()) { 00184 ACE_CDR::Octet b; 00185 if(_istr->read_octet(b)) { 00186 x=b; 00187 return(_istr->good_bit()); 00188 } 00189 } 00190 else { 00191 _ostr->write_octet(x); 00192 return (_ostr->good_bit()); 00193 } 00194 return(false); 00195 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | char & | x | ) | [protected, virtual] |
Definition at line 198 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00199 { 00200 if(!_check_streams(sizeof(x))) { 00201 return(false); 00202 } 00203 ACE_CDR::Char cx=x; 00204 if(is_read()) { 00205 (*_istr) >> cx; 00206 x = cx; 00207 return (_istr->good_bit()); 00208 } 00209 else if(is_write()) { 00210 (*_ostr) << cx; 00211 return (_ostr->good_bit()); 00212 } 00213 return(false); 00214 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | unsigned short & | x | ) | [protected, virtual] |
Definition at line 217 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00218 { 00219 if(!_check_streams(sizeof(x))) { 00220 return(false); 00221 } 00222 ACE_CDR::UShort cx=x; 00223 if(is_read()) { 00224 (*_istr) >> cx; 00225 x = cx; 00226 return (_istr->good_bit()); 00227 } 00228 else if(is_write()) { 00229 (*_ostr) << cx; 00230 return (_ostr->good_bit()); 00231 } 00232 return(false); 00233 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | short & | x | ) | [protected, virtual] |
Definition at line 236 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00237 { 00238 if(!_check_streams(sizeof(x))) { 00239 return(false); 00240 } 00241 ACE_CDR::Short cx=x; 00242 if(is_read()) { 00243 (*_istr) >> cx; 00244 x = cx; 00245 return (_istr->good_bit()); 00246 } 00247 else if(is_write()) { 00248 (*_ostr) << cx; 00249 return (_ostr->good_bit()); 00250 } 00251 return(false); 00252 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | unsigned int & | x | ) | [protected, virtual] |
Definition at line 255 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00256 { 00257 if(!_check_streams(sizeof(x))) { 00258 return(false); 00259 } 00260 ACE_CDR::ULong cx=x; 00261 if(is_read()) { 00262 (*_istr) >> cx; 00263 x = cx; 00264 return (_istr->good_bit()); 00265 } 00266 else if(is_write()) { 00267 (*_ostr) << cx; 00268 return (_ostr->good_bit()); 00269 } 00270 return(false); 00271 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | int & | x | ) | [protected, virtual] |
Definition at line 274 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00275 { 00276 if(!_check_streams(sizeof(x))) { 00277 return(false); 00278 } 00279 ACE_CDR::Long cx=x; 00280 if(is_read()) { 00281 (*_istr) >> cx; 00282 x = cx; 00283 return (_istr->good_bit()); 00284 } 00285 else if(is_write()) { 00286 (*_ostr) << cx; 00287 return (_ostr->good_bit()); 00288 } 00289 return(false); 00290 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | unsigned long & | x | ) | [protected, virtual] |
Definition at line 293 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00294 { 00295 if(!_check_streams(sizeof(x))) { 00296 return(false); 00297 } 00298 ACE_CDR::ULong cx=x; 00299 if(is_read()) { 00300 (*_istr) >> cx; 00301 x = cx; 00302 return (_istr->good_bit()); 00303 } 00304 else if(is_write()) { 00305 (*_ostr) << cx; 00306 return (_ostr->good_bit()); 00307 } 00308 return(false); 00309 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | long & | x | ) | [protected, virtual] |
Definition at line 312 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00313 { 00314 if(!_check_streams(sizeof(x))) { 00315 return(false); 00316 } 00317 ACE_CDR::Long cx=x; 00318 if(is_read()) { 00319 (*_istr) >> cx; 00320 x = cx; 00321 return (_istr->good_bit()); 00322 } 00323 else if(is_write()) { 00324 (*_ostr) << cx; 00325 return (_ostr->good_bit()); 00326 } 00327 return(false); 00328 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | unsigned long long & | x | ) | [protected, virtual] |
Definition at line 330 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00331 { 00332 #ifndef NONNATIVE_LONGLONG 00333 if(!_check_streams(sizeof(x))) { 00334 return(false); 00335 } 00336 ACE_CDR::ULongLong cx=x; 00337 if(is_read()) { 00338 (*_istr) >> cx; 00339 x = (unsigned long long)cx; 00340 return (_istr->good_bit()); 00341 } 00342 else if(is_write()) { 00343 (*_ostr) << cx; 00344 return (_ostr->good_bit()); 00345 } 00346 #endif 00347 return(false); 00348 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | long long & | x | ) | [protected, virtual] |
Definition at line 350 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00351 { 00352 #ifndef NONNATIVE_LONGLONG 00353 if(!_check_streams(sizeof(x))) { 00354 return(false); 00355 } 00356 ACE_CDR::LongLong cx=(ACE_CDR::LongLong)x; 00357 if(is_read()) { 00358 (*_istr) >> cx; 00359 x = (long long) cx; 00360 return (_istr->good_bit()); 00361 } 00362 else if(is_write()) { 00363 (*_ostr) << cx; 00364 return (_ostr->good_bit()); 00365 } 00366 #endif 00367 return(false); 00368 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | float & | x | ) | [protected, virtual] |
Definition at line 370 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00371 { 00372 if(!_check_streams(sizeof(x))) { 00373 return(false); 00374 } 00375 ACE_CDR::Float cx=x; 00376 if(is_read()) { 00377 (*_istr) >> cx; 00378 x = cx; 00379 return (_istr->good_bit()); 00380 } 00381 else if(is_write()) { 00382 (*_ostr) << cx; 00383 return (_ostr->good_bit()); 00384 } 00385 return(false); 00386 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | double & | x | ) | [protected, virtual] |
Definition at line 388 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00389 { 00390 if(!_check_streams(sizeof(x))) { 00391 return(false); 00392 } 00393 ACE_CDR::Double cx=x; 00394 if(is_read()) { 00395 (*_istr) >> cx; 00396 x = cx; 00397 return (_istr->good_bit()); 00398 } 00399 else if(is_write()) { 00400 (*_ostr) << cx; 00401 return (_ostr->good_bit()); 00402 } 00403 return(false); 00404 }
Here is the call graph for this function:

| bool FDM_CDR::_io_object | ( | std::string & | x | ) | [protected, virtual] |
Definition at line 132 of file fdm_cdr.cc.
References _check_streams(), _istr, and _ostr.
00133 { 00134 // TODO: This would fail on strings including zeros, look more closely... 00135 if(!_check_streams(100)) { 00136 return(false); 00137 } 00138 if(is_read()) { 00139 char *rstr; 00140 // This reads the string from the cdr stream, allocates 00141 // a buffer, and sets rstr to point to the new buffer 00142 if(_istr->read_string(rstr)) { 00143 // Copy the string into x 00144 x.assign(rstr); 00145 // Delete the buffer read_string gave us 00146 delete [] rstr; 00147 return(_istr->good_bit()); 00148 } 00149 } 00150 else { 00151 _ostr->write_string(x.c_str()); 00152 return (_ostr->good_bit()); 00153 } 00154 return(false); 00155 }
Here is the call graph for this function:

| bool FDM_CDR::cdr_peek_object | ( | T & | x | ) | [inline, protected] |
Definition at line 92 of file fdm_cdr.h.
References _check_streams(), _io_object(), and _istr.
Referenced by _peek_object().
00092 { 00093 if(!_check_streams(sizeof(x))) { 00094 return(false); 00095 } 00096 char *orig_ptr = _istr->rd_ptr(); 00097 bool ok = _io_object(x); 00098 char *final_ptr = _istr->rd_ptr(); 00099 _istr->skip_bytes(orig_ptr-final_ptr); 00100 assert(_istr->rd_ptr() == orig_ptr); 00101 return(ok); 00102 }
Here is the call graph for this function:

| virtual bool FDM_CDR::_peek_object | ( | unsigned int & | x | ) | [inline, protected, virtual] |
Definition at line 104 of file fdm_cdr.h.
References cdr_peek_object().
00104 { 00105 return(cdr_peek_object(x)); 00106 }
Here is the call graph for this function:

| virtual bool FDM_CDR::_peek_object | ( | std::string & | x | ) | [inline, protected, virtual] |
Definition at line 107 of file fdm_cdr.h.
References cdr_peek_object().
00107 { 00108 return(cdr_peek_object(x)); 00109 }
Here is the call graph for this function:

| bool FDM_CDR::_check_streams | ( | size_t | size | ) | [protected, virtual] |
Reimplemented in FDM_CDR_File.
Definition at line 113 of file fdm_cdr.cc.
References _istr, _ostr, and _owns_ostr.
Referenced by FDM_CDR_File::_check_streams(), _io_object(), and cdr_peek_object().
00114 { 00115 if(is_read() && _istr!=NULL) { 00116 return (_istr->good_bit()); 00117 } 00118 else if(is_write()) { 00119 if(_ostr==NULL) { 00120 // Haven't created one yet, create it now 00121 _ostr = new ACE_OutputCDR; 00122 _owns_ostr = true; 00123 } 00124 return (_ostr->good_bit()); 00125 } 00126 else { 00127 return(false); 00128 } 00129 }
| virtual void FDM_CDR::_begin_map | ( | ) | [inline, protected, virtual] |
| virtual void FDM_CDR::_begin_array | ( | ) | [inline, protected, virtual] |
| virtual bool FDM_CDR::_array_resizable_length | ( | int & | size | ) | [inline, protected, virtual] |
Definition at line 119 of file fdm_cdr.h.
References _io_object().
00119 { 00120 return(_io_object(size)); 00121 }
Here is the call graph for this function:

| virtual bool FDM_CDR::_array_element | ( | ) | [inline, protected, virtual] |
| virtual void FDM_CDR::_end | ( | ) | [inline, protected, virtual] |
| virtual bool FDM_CDR::_map_field | ( | const char * | name | ) | [inline, protected, virtual] |
Member Data Documentation
ACE_InputCDR* FDM_CDR::_istr [protected] |
Definition at line 135 of file fdm_cdr.h.
Referenced by _check_streams(), FDM_CDR_File::_end_topform(), _io_object(), cdr_peek_object(), FDM_CDR(), set_message_block(), and ~FDM_CDR().
ACE_OutputCDR* FDM_CDR::_ostr [protected] |
Definition at line 136 of file fdm_cdr.h.
Referenced by _check_streams(), _io_object(), clear(), FDM_CDR_File::close(), FDM_CDR(), get_message_block(), and ~FDM_CDR().
bool FDM_CDR::_owns_istr [protected] |
Definition at line 137 of file fdm_cdr.h.
Referenced by FDM_CDR(), set_message_block(), and ~FDM_CDR().
bool FDM_CDR::_owns_ostr [protected] |
Definition at line 138 of file fdm_cdr.h.
Referenced by _check_streams(), FDM_CDR(), and ~FDM_CDR().
The documentation for this class was generated from the following files: