#include <emobject.h>
Collaboration diagram for EMAN::EMObject:
Public Types | |
enum | ObjectType { UNKNOWN, BOOL, UNSIGNEDINT, INT, FLOAT, DOUBLE, STRING, EMDATA, XYDATA, INTARRAY, FLOATARRAY, STRINGARRAY, TRANSFORM, CTF, FLOAT_POINTER, INT_POINTER, VOID_POINTER } |
Public Member Functions | |
EMObject () | |
Constructors for each type More types could be added, but all of the accompanying functions would have to be altered to ensure correct functioning. | |
EMObject (bool boolean) | |
EMObject (int num) | |
EMObject (unsigned int num) | |
EMObject (float ff) | |
EMObject (double dd) | |
EMObject (const char *s) | |
EMObject (const string &s) | |
EMObject (float *fp) | |
EMObject (int *ip) | |
EMObject (void *vp) | |
EMObject (EMData *em) | |
EMObject (XYData *xy) | |
EMObject (Transform *t) | |
EMObject (Ctf *ctf) | |
EMObject (const vector< int > &v) | |
EMObject (const vector< float > &v) | |
EMObject (const vector< string > &sarray) | |
EMObject (const EMObject &that) | |
Copy constructor. | |
EMObject & | operator= (const EMObject &that) |
Assigment operator copies pointer locations (emdata, xydata, transform3d) - does not take ownership deep copies all non pointer objects. | |
~EMObject () | |
Desctructor Does not free pointers. | |
operator bool () const | |
Conversion operators. | |
operator int () const | |
operator unsigned int () const | |
operator float () const | |
operator double () const | |
operator const char * () const | |
operator float * () const | |
operator int * () const | |
operator void * () const | |
operator EMData * () const | |
operator XYData * () const | |
operator Transform * () const | |
operator Ctf * () const | |
operator vector () const | |
operator vector () const | |
operator vector () const | |
bool | is_null () const |
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type is UNKNOWN. | |
string | to_str () const |
Calls to_str( this->type). | |
ObjectType | get_type () const |
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes. | |
string | get_type_string () const |
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes. | |
string | to_str (ObjectType type) const |
Write the EMObject's value to a string Literally copies into a string, except for the case where the type is boolen where it writes true of false, as opposed to 1 or 0. | |
Static Public Member Functions | |
string | get_object_type_name (ObjectType t) |
Get an ObjectType as a string statically Can be accessed without the instantiation of a class object. | |
Private Member Functions | |
void | printInfo () const |
A debug function that prints as much information as possibe to cout. | |
Static Private Member Functions | |
map< ObjectType, string > | init () |
Private Attributes | |
string | str |
vector< int > | iarray |
vector< float > | farray |
vector< string > | strarray |
ObjectType | type |
bool | b |
int | n |
unsigned int | ui |
float | f |
double | d |
float * | fp |
int * | ip |
void * | vp |
EMData * | emdata |
XYData * | xydata |
Static Private Attributes | |
map< ObjectType, string > | type_registry = init() |
Friends | |
bool | operator== (const EMObject &e1, const EMObject &e2) |
Friend declaration operator== namespace EMAN2 operator== accesses private variables. | |
bool | operator!= (const EMObject &e1, const EMObject &e2) |
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables. |
Each type is typically used as follows ('int' is the example):
int a = 12; EMObject o(a); EMObject o2 = a; // implicit converter from int to EMObject. int a1 = o; // implicit converter from EMObject to int.
EMObjects may store pointers but they currently do not assume ownership - that is, the memory associated with a pointer is never freed by an EMObject.
This type of class design is sometimes referred to as the Variant pattern.
See the testing code in rt/emdata/test_emobject.cpp for prewritten testing code
Definition at line 125 of file emobject.h.
|
Definition at line 128 of file emobject.h. 00128 { 00129 UNKNOWN, 00130 BOOL, 00131 UNSIGNEDINT, 00132 INT, 00133 FLOAT, 00134 DOUBLE, 00135 STRING, 00136 EMDATA, 00137 XYDATA, 00138 INTARRAY, 00139 FLOATARRAY, 00140 STRINGARRAY, 00141 TRANSFORM, 00142 CTF, 00143 FLOAT_POINTER, 00144 INT_POINTER, 00145 VOID_POINTER 00146 };
|
|
Constructors for each type More types could be added, but all of the accompanying functions would have to be altered to ensure correct functioning.
Definition at line 133 of file emobject.cpp. 00133 : 00134 d(0), type(UNKNOWN) 00135 { 00136 #ifdef MEMDEBUG 00137 allemobjlist.insert(this); 00138 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00139 #endif 00140 }
|
|
Definition at line 142 of file emobject.cpp. References b. 00142 : 00143 b(boolean), type(BOOL) 00144 { 00145 #ifdef MEMDEBUG 00146 allemobjlist.insert(this); 00147 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00148 #endif 00149 }
|
|
Definition at line 151 of file emobject.cpp. 00151 : 00152 n(num), type(INT) 00153 { 00154 #ifdef MEMDEBUG 00155 allemobjlist.insert(this); 00156 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00157 #endif 00158 }
|
|
Definition at line 160 of file emobject.cpp. 00160 : 00161 ui(num), type(UNSIGNEDINT) 00162 { 00163 #ifdef MEMDEBUG 00164 allemobjlist.insert(this); 00165 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00166 #endif 00167 }
|
|
Definition at line 169 of file emobject.cpp. References f, and EMAN::Util::goodf(). 00169 : 00170 type(FLOAT) 00171 { 00172 00173 #ifdef MEMDEBUG 00174 allemobjlist.insert(this); 00175 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00176 #endif 00177 if(Util::goodf(&ff)) { 00178 f = ff; 00179 } 00180 else{ 00181 f = 0.0f; 00182 } 00183 }
|
|
Definition at line 185 of file emobject.cpp. References d, and EMAN::Util::goodf(). 00185 : 00186 type(DOUBLE) 00187 { 00188 00189 #ifdef MEMDEBUG 00190 allemobjlist.insert(this); 00191 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00192 #endif 00193 if(Util::goodf(&dd)) { 00194 d = dd; 00195 } 00196 else{ 00197 d = 0.0; 00198 } 00199 }
|
|
Definition at line 201 of file emobject.cpp. 00201 : 00202 str(s), type(STRING) 00203 { 00204 #ifdef MEMDEBUG 00205 allemobjlist.insert(this); 00206 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00207 #endif 00208 }
|
|
Definition at line 210 of file emobject.cpp. 00210 : 00211 str(s), type(STRING) 00212 { 00213 #ifdef MEMDEBUG 00214 allemobjlist.insert(this); 00215 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00216 #endif 00217 }
|
|
Definition at line 219 of file emobject.cpp. 00219 : 00220 fp(f), type(FLOAT_POINTER) 00221 { 00222 #ifdef MEMDEBUG 00223 allemobjlist.insert(this); 00224 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00225 #endif 00226 }
|
|
Definition at line 228 of file emobject.cpp. 00228 : 00229 ip(i), type(INT_POINTER) 00230 { 00231 #ifdef MEMDEBUG 00232 allemobjlist.insert(this); 00233 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00234 #endif 00235 }
|
|
Definition at line 237 of file emobject.cpp. 00237 : 00238 vp(v), type(VOID_POINTER) 00239 { 00240 #ifdef MEMDEBUG 00241 allemobjlist.insert(this); 00242 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00243 #endif 00244 }
|
|
Definition at line 246 of file emobject.cpp. 00246 : 00247 emdata(em), type(EMDATA) 00248 { 00249 #ifdef MEMDEBUG 00250 allemobjlist.insert(this); 00251 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00252 #endif 00253 }
|
|
Definition at line 255 of file emobject.cpp. 00255 : 00256 xydata(xy), type(XYDATA) 00257 { 00258 #ifdef MEMDEBUG 00259 allemobjlist.insert(this); 00260 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00261 #endif 00262 }
|
|
Definition at line 264 of file emobject.cpp. References t. 00264 : 00265 farray(t->get_matrix()), type(TRANSFORM) 00266 { 00267 #ifdef MEMDEBUG 00268 allemobjlist.insert(this); 00269 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00270 #endif 00271 }
|
|
Definition at line 273 of file emobject.cpp. 00273 : 00274 str(ctf->to_string()), type(CTF) 00275 { 00276 #ifdef MEMDEBUG 00277 allemobjlist.insert(this); 00278 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00279 #endif 00280 }
|
|
Definition at line 282 of file emobject.cpp. References v. 00282 : 00283 iarray(v), type(INTARRAY) 00284 { 00285 #ifdef MEMDEBUG 00286 allemobjlist.insert(this); 00287 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00288 #endif 00289 }
|
|
Definition at line 291 of file emobject.cpp. References v. 00291 : 00292 farray(v), type(FLOATARRAY) 00293 { 00294 #ifdef MEMDEBUG 00295 allemobjlist.insert(this); 00296 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00297 #endif 00298 }
|
|
Definition at line 300 of file emobject.cpp. 00300 : 00301 strarray(sarray), type(STRINGARRAY) 00302 { 00303 #ifdef MEMDEBUG 00304 allemobjlist.insert(this); 00305 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00306 #endif 00307 }
|
|
Copy constructor. copies pointer locations - does not take ownership deep copies all non pointer objects Definition at line 865 of file emobject.cpp. 00866 { 00867 // init isn't necessary because that must have already called it! 00868 *this = that; 00869 #ifdef MEMDEBUG 00870 allemobjlist.insert(this); 00871 printf(" +(%6d) %p\n",(int)allemobjlist.size(),this); 00872 #endif 00873 }
|
|
Desctructor Does not free pointers.
Definition at line 126 of file emobject.cpp. 00126 { 00127 #ifdef MEMDEBUG 00128 allemobjlist.erase(this); 00129 printf(" -(%6d) %p\n",(int)allemobjlist.size(),this); 00130 #endif 00131 }
|
|
Get an ObjectType as a string statically Can be accessed without the instantiation of a class object.
Definition at line 698 of file emobject.cpp. References LOGERR, NotExistingObjectException, t, and type_registry. Referenced by operator bool(), operator const char *(), operator double(), operator EMData *(), operator float(), operator float *(), operator int(), operator int *(), operator Transform *(), operator unsigned int(), operator vector(), operator void *(), and operator XYData *(). 00699 { 00700 #ifdef _WIN32 00701 if (t == BOOL) { 00702 return "BOOL"; 00703 }else 00704 if ( t == INT){ 00705 return "INT"; 00706 }else 00707 if ( t == UNSIGNEDINT){ 00708 return "UNSIGNEDINT"; 00709 } else 00710 if ( t == FLOAT){ 00711 return "FLOAT"; 00712 } else 00713 if ( t == DOUBLE){ 00714 return "DOUBLE"; 00715 }else 00716 if ( t == STRING){ 00717 return "STRING"; 00718 }else 00719 if ( t == EMDATA){ 00720 return "EMDATA"; 00721 } 00722 else 00723 if ( t == XYDATA){ 00724 return "XYDATA"; 00725 }else 00726 if ( t == INTARRAY){ 00727 return "INTARRAY"; 00728 }else 00729 if ( t == FLOATARRAY){ 00730 return "FLOATARRAY"; 00731 } else 00732 if ( t == STRINGARRAY){ 00733 return "STRINGARRAY"; 00734 }else 00735 if ( t == TRANSFORM){ 00736 return "TRANSFORM"; 00737 }else 00738 if ( t == CTF){ 00739 return "CTF"; 00740 }else 00741 if ( t == FLOAT_POINTER){ 00742 return "FLOAT_POINTER"; 00743 }else 00744 if ( t == INT_POINTER){ 00745 return "INT_POINTER"; 00746 }else 00747 if ( t == UNKNOWN){ 00748 return "UNKNOWN"; 00749 } else 00750 if ( t == VOID_POINTER){ 00751 return "VOID_POINTER"; 00752 } 00753 else { 00754 LOGERR("No such EMObject defined"); 00755 throw NotExistingObjectException("EMObject", "unknown type"); 00756 } 00757 00758 #else 00759 00760 if ( type_registry.find(t) != type_registry.end() ) 00761 return type_registry[t]; 00762 else 00763 LOGERR("No such EMObject defined"); 00764 throw NotExistingObjectException("EMObject", "unknown type"); 00765 #endif //_WIN32 00766 }
|
|
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes.
Definition at line 221 of file emobject.h. Referenced by EMAN::EMData::set_attr_python(), EMAN::Transform::set_params(), and EMAN::Transform::set_params_inverse(). 00221 { return type; }
|
|
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes.
Definition at line 227 of file emobject.h. 00227 { return get_object_type_name(type); }
|
|
Definition at line 82 of file emobject.cpp. Referenced by EMAN::EMUtil::getRenderMinMax(). 00083 { 00084 map< EMObject::ObjectType, string> mymap; 00085 static bool first_construction = true; 00086 if ( first_construction ) 00087 { 00088 // Initialize the the type registry once and for all 00089 mymap[BOOL] = "BOOL"; 00090 mymap[INT] = "INT"; 00091 mymap[UNSIGNEDINT] = "UNSIGNEDINT"; 00092 mymap[FLOAT] = "FLOAT"; 00093 mymap[DOUBLE] = "DOUBLE"; 00094 mymap[STRING] = "STRING"; 00095 mymap[EMDATA] = "EMDATA"; 00096 mymap[XYDATA] = "XYDATA"; 00097 mymap[INTARRAY] = "INTARRAY"; 00098 mymap[FLOATARRAY] = "FLOATARRAY"; 00099 mymap[STRINGARRAY] = "STRINGARRAY"; 00100 mymap[TRANSFORM] = "TRANFORM"; 00101 mymap[CTF] = "CTF"; 00102 mymap[FLOAT_POINTER] = "FLOAT_POINTER"; 00103 mymap[INT_POINTER] = "INT_POINTER"; 00104 mymap[UNKNOWN] = "UNKNOWN"; 00105 mymap[VOID_POINTER] = "VOID_POINTER"; 00106 first_construction = false; 00107 } 00108 00109 return mymap; 00110 }
|
|
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type is UNKNOWN.
Definition at line 622 of file emobject.cpp. References type. Referenced by EMAN::EMUtil::dump_dict(). 00623 { 00624 return (type == UNKNOWN); 00625 }
|
|
Conversion operators.
Definition at line 309 of file emobject.cpp. References d, emdata, f, fp, get_object_type_name(), ip, n, type, TypeException, ui, vp, and xydata. 00310 { 00311 if (type == BOOL) { 00312 return b; 00313 } 00314 else if (type == INT) { 00315 return n != 0; 00316 } 00317 else if (type == UNSIGNEDINT) { 00318 return ui != 0; 00319 } 00320 else if (type == FLOAT) { 00321 return f != 0; 00322 } 00323 else if (type == DOUBLE) { 00324 return d != 0; 00325 } 00326 else if (type == EMDATA) { 00327 return emdata != 0; 00328 } 00329 else if (type == XYDATA) { 00330 return xydata != 0; 00331 } 00332 else if (type == FLOAT_POINTER) { 00333 return fp != 0; 00334 } 00335 else if (type == INT_POINTER) { 00336 return ip != 0; 00337 } 00338 else if (type == VOID_POINTER) { 00339 return vp != 0; 00340 } 00341 // else if (type == TRANSFORM) { 00342 // return transform != 0; 00343 // } 00344 // It seemed unconventional to return a boolean for the stl objects 00345 else { 00346 if (type != UNKNOWN) { 00347 throw TypeException("Cannot convert to bool this data type ", 00348 get_object_type_name(type)); 00349 } 00350 } 00351 return 0; 00352 }
|
|
Definition at line 488 of file emobject.cpp. References get_object_type_name(), str, STRING, type, and TypeException. 00489 { 00490 if (type != STRING && type != CTF) { 00491 stringstream ss; 00492 string return_string; 00493 if ( type == INT ) 00494 { 00495 ss << n; 00496 ss >> return_string; 00497 return return_string.c_str(); 00498 } 00499 if ( type == UNSIGNEDINT ) 00500 { 00501 ss << ui; 00502 ss >> return_string; 00503 return return_string.c_str(); 00504 } 00505 else 00506 if ( type == FLOAT ) 00507 { 00508 ss << f; 00509 ss >> return_string; 00510 return return_string.c_str(); 00511 } 00512 else 00513 if ( type == DOUBLE ) 00514 { 00515 ss << d; 00516 ss >> return_string; 00517 return return_string.c_str(); 00518 } 00519 else if (type != UNKNOWN) { 00520 throw TypeException("Cannot convert to string from this data type", 00521 get_object_type_name(type)); 00522 } 00523 00524 return ""; 00525 } 00526 return str.c_str(); 00527 }
|
|
Definition at line 566 of file emobject.cpp. References EMAN::Ctf::from_string(), and str. 00567 { 00568 /* if(type != CTF) { 00569 if(type != CTF) { 00570 throw TypeException("Cannot convert to TRANSFORM* from this data type", 00571 get_object_type_name(type)); 00572 } 00573 }*/ 00574 Ctf * ctf = 0; 00575 if(str[0] == 'O') { 00576 ctf = new EMAN1Ctf(); 00577 ctf->from_string(str); 00578 } 00579 else if(str[0] == 'E') { 00580 ctf = new EMAN2Ctf(); 00581 ctf->from_string(str); 00582 } 00583 return ctf; 00584 }
|
|
Definition at line 421 of file emobject.cpp. References b, get_object_type_name(), type, and TypeException. 00422 { 00423 if (type == BOOL) { 00424 return b?1.0:0.0; 00425 } 00426 else if (type == DOUBLE) { 00427 return d; 00428 } 00429 else if (type == INT) { 00430 return (double) n; 00431 } 00432 else if (type == UNSIGNEDINT) { 00433 return (double) ui; 00434 } 00435 else if (type == FLOAT) { 00436 return (double) f; 00437 } 00438 else { 00439 if (type != UNKNOWN) { 00440 throw TypeException("Cannot convert to double from this data type", 00441 get_object_type_name(type)); 00442 } 00443 } 00444 return 0; 00445 }
|
|
Definition at line 529 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00530 { 00531 if (type != EMDATA) { 00532 if (type != UNKNOWN) { 00533 throw TypeException("Cannot convert to EMData* from this data type", 00534 get_object_type_name(type)); 00535 } 00536 return 0; 00537 } 00538 return emdata; 00539 }
|
|
Definition at line 394 of file emobject.cpp. References b, get_object_type_name(), type, and TypeException. 00395 { 00396 if (type == BOOL) { 00397 return b?1.0f:0.0f; 00398 } 00399 else if (type == FLOAT) { 00400 return f; 00401 } 00402 else if (type == INT) { 00403 return (float) n; 00404 } 00405 else if (type == UNSIGNEDINT) { 00406 return (float) ui; 00407 } 00408 else if (type == DOUBLE) { 00409 return (float) d; 00410 } 00411 else { 00412 if (type != UNKNOWN) { 00413 throw TypeException("Cannot convert to float from this data type", 00414 get_object_type_name(type)); 00415 } 00416 } 00417 00418 return 0; 00419 }
|
|
Definition at line 462 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00463 { 00464 if (type != FLOAT_POINTER) 00465 { 00466 if (type != UNKNOWN) 00467 throw TypeException("Cannot convert to float pointer from this data type", 00468 get_object_type_name(type)); 00469 00470 return 0; 00471 } 00472 00473 return fp; 00474 }
|
|
Definition at line 354 of file emobject.cpp. References b, get_object_type_name(), type, and TypeException. 00355 { 00356 if (type == INT) { 00357 return n; 00358 } 00359 else if (type == UNSIGNEDINT) { 00360 return (int) ui; 00361 } 00362 else if (type == FLOAT) { 00363 return (int) f; 00364 } 00365 else if (type == DOUBLE) { 00366 return (int) d; 00367 } 00368 else if (type == BOOL) { 00369 return b?1:0; 00370 } 00371 else { 00372 if (type != UNKNOWN) { 00373 throw TypeException("Cannot convert to int this data type ", 00374 get_object_type_name(type)); 00375 } 00376 } 00377 return 0; 00378 }
|
|
Definition at line 447 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00448 { 00449 if (type != INT_POINTER) 00450 { 00451 if (type != UNKNOWN) 00452 throw TypeException("Cannot convert to float pointer from this data type", 00453 get_object_type_name(type)); 00454 00455 return 0; 00456 } 00457 00458 return ip; 00459 }
|
|
Definition at line 553 of file emobject.cpp. References farray, get_object_type_name(), EMAN::Transform::set_matrix(), type, and TypeException. 00554 { 00555 if(type != TRANSFORM) { 00556 if(type != UNKNOWN) { 00557 throw TypeException("Cannot convert to TRANSFORM* from this data type", 00558 get_object_type_name(type)); 00559 } 00560 } 00561 Transform * transform = new Transform(); 00562 transform->set_matrix(farray); 00563 return transform; 00564 }
|
|
Definition at line 380 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00381 { 00382 if (type == UNSIGNEDINT) { 00383 return (unsigned int) ui; 00384 } 00385 else { 00386 if (type != UNKNOWN) { 00387 throw TypeException("Cannot convert to int this data type ", 00388 get_object_type_name(type)); 00389 } 00390 } 00391 return 0; 00392 }
|
|
|
|
|
|
Definition at line 586 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00587 { 00588 if( type != INTARRAY ) 00589 { 00590 if( type != UNKNOWN ) { 00591 throw TypeException("Cannot convert to vector<int> from this data type", get_object_type_name(type) ); 00592 } 00593 return vector<int>(); 00594 } 00595 return iarray; 00596 }
|
|
Definition at line 477 of file emobject.cpp. References get_object_type_name(), type, TypeException, and vp. 00478 { 00479 if (type == VOID_POINTER) return vp; 00480 else if (type == FLOAT_POINTER) return (void *)fp; 00481 else if (type == INT_POINTER) return (void *)ip; 00482 else if (type == EMDATA) return (void *) emdata; 00483 else if (type == XYDATA) return (void *) xydata; 00484 // else if (type == TRANSFORM) return (void *) transform; 00485 else throw TypeException("Cannot convert to void pointer from this data type", get_object_type_name(type)); 00486 }
|
|
Definition at line 541 of file emobject.cpp. References get_object_type_name(), type, and TypeException. 00542 { 00543 if (type != XYDATA) { 00544 if (type != UNKNOWN) { 00545 throw TypeException("Cannot convert to XYData* from this data type", 00546 get_object_type_name(type)); 00547 } 00548 return 0; 00549 } 00550 return xydata; 00551 }
|
|
Assigment operator copies pointer locations (emdata, xydata, transform3d) - does not take ownership deep copies all non pointer objects.
Definition at line 879 of file emobject.cpp. References b, BOOL, CTF, d, DOUBLE, emdata, EMDATA, f, farray, FLOAT, FLOAT_POINTER, FLOATARRAY, fp, iarray, INT, INT_POINTER, INTARRAY, ip, LOGERR, n, NotExistingObjectException, str, strarray, STRING, STRINGARRAY, TRANSFORM, type, ui, UNKNOWN, UNSIGNEDINT, VOID_POINTER, vp, vp, xydata, and XYDATA. 00880 { 00881 00882 // This test breaks assignment when either the current or assigned values are (float)nan 00883 // it's also somewhat inherently stupid, since testing for equivalence may cost as much 00884 // as assignment. 00885 // if ( *this != that ) 00886 { 00887 // First store the type of the input, At first I forgot to do this and it was a very 00888 // difficult bug to track down 00889 type = that.type; 00890 00891 // if ( type != this_type ) throw 00892 00893 00894 switch (type) 00895 { 00896 case BOOL: 00897 b = that.b; 00898 break; 00899 case INT: 00900 n = that.n; 00901 break; 00902 case UNSIGNEDINT: 00903 ui = that.ui; 00904 break; 00905 case FLOAT: 00906 f = that.f; 00907 break; 00908 case DOUBLE: 00909 d = that.d; 00910 break; 00911 case CTF: 00912 case STRING: 00913 str = that.str; 00914 break; 00915 case FLOAT_POINTER: 00916 // Warning - Pointer address copy. 00917 fp = that.fp; 00918 break; 00919 case INT_POINTER: 00920 // Warning - Pointer address copy. 00921 ip = that.ip; 00922 break; 00923 case VOID_POINTER: 00924 // Warning - Pointer address copy. 00925 vp = that.vp; 00926 break; 00927 case EMDATA: 00928 // Warning - Pointer address copy. 00929 emdata = that.emdata; 00930 break; 00931 case XYDATA: 00932 // Warning - Pointer address copy. 00933 xydata = that.xydata; 00934 break; 00935 case TRANSFORM: 00936 case FLOATARRAY: 00937 farray = that.farray; 00938 break; 00939 case INTARRAY: 00940 iarray = that.iarray; 00941 break; 00942 case STRINGARRAY: 00943 strarray = that.strarray; 00944 break; 00945 case UNKNOWN: 00946 // This is possible, nothing should happen 00947 // The EMObject's default constructor has been called and 00948 // as yet has no type - doing nothing is exactly as the 00949 // the assignment operator should work. 00950 break; 00951 default: 00952 LOGERR("No such EMObject defined"); 00953 throw NotExistingObjectException("EMObject", "unknown type"); 00954 break; 00955 } 00956 } 00957 // else 00958 // { 00959 // cerr << "Warning - attempt to assign EMObject onto itself. No action taken" << endl; 00960 // cerr << "My type is " << get_object_type_name(type) << endl; 00961 // } 00962 00963 return *this; 00964 }
|
|
A debug function that prints as much information as possibe to cout.
Definition at line 114 of file emobject.cpp. References to_str(), type, and type_registry. 00115 { 00116 cout << "The address of my type is " << &type << endl; 00117 cout << " Now printing the enumerated values in type_registry " << endl; 00118 for( map< ObjectType, string>::const_iterator it = type_registry.begin(); it != type_registry.end(); ++it ) 00119 { 00120 cout << it->first << " " << it->second << endl; 00121 } 00122 cout << "My type is " << to_str(type) << " and its enumerated value is " << type << endl; 00123 cout << "The address of the static type registry is " << &type_registry <<", it should be same for all EMObjects" << endl; 00124 }
|
|
Write the EMObject's value to a string Literally copies into a string, except for the case where the type is boolen where it writes true of false, as opposed to 1 or 0.
Definition at line 632 of file emobject.cpp. References d, f, LOGERR, n, NotExistingObjectException, and ui. 00633 { 00634 if (argtype == STRING) { 00635 return str; 00636 } 00637 else { 00638 char tmp_str[32]; 00639 if (argtype == BOOL) { 00640 if (b) 00641 sprintf(tmp_str, "true"); 00642 else 00643 sprintf(tmp_str, "false"); 00644 } 00645 else if (argtype == INT) { 00646 sprintf(tmp_str, "%d", n); 00647 } 00648 else if (argtype == UNSIGNEDINT) { 00649 sprintf(tmp_str, "%d", ui); 00650 } 00651 else if (argtype == FLOAT) { 00652 sprintf(tmp_str, "%f", f); 00653 } 00654 else if (argtype == DOUBLE) { 00655 sprintf(tmp_str, "%f", d); 00656 } 00657 else if (argtype == EMDATA) { 00658 sprintf(tmp_str, "EMDATA"); 00659 } 00660 else if (argtype == FLOAT_POINTER) { 00661 sprintf(tmp_str, "FLOAT_POINTER"); 00662 } 00663 else if (argtype == INT) { 00664 sprintf(tmp_str, "INT_POINTER"); 00665 } 00666 else if (argtype == VOID_POINTER) { 00667 sprintf(tmp_str, "VOID_POINTER"); 00668 } 00669 else if (argtype == XYDATA) { 00670 sprintf(tmp_str, "XYDATA"); 00671 } 00672 else if (argtype == INTARRAY) { 00673 sprintf(tmp_str, "INTARRAY"); 00674 } 00675 else if (argtype == FLOATARRAY) { 00676 sprintf(tmp_str, "FLOATARRAY"); 00677 } 00678 else if (argtype == STRINGARRAY) { 00679 sprintf(tmp_str, "STRINGARRAY"); 00680 } 00681 else if (argtype == TRANSFORM) { 00682 sprintf(tmp_str, "TRANSFORMD"); 00683 } 00684 else if (argtype == CTF) { 00685 sprintf(tmp_str, "CTF"); 00686 } 00687 else if (argtype == UNKNOWN) { 00688 sprintf(tmp_str, "UNKNOWN"); 00689 } 00690 else { 00691 LOGERR("No such EMObject defined"); 00692 throw NotExistingObjectException("EMObject", "unknown type"); 00693 } 00694 return string(tmp_str); 00695 } 00696 }
|
|
Calls to_str( this->type).
Definition at line 627 of file emobject.cpp. References type. Referenced by EMAN::EMUtil::dump_dict(), and printInfo(). 00628 { 00629 return to_str(type); 00630 }
|
|
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
|
|
Friend declaration operator== namespace EMAN2 operator== accesses private variables.
|
|
Definition at line 255 of file emobject.h. Referenced by operator double(), operator float(), operator int(), operator=(), and EMAN::operator==(). |
|
Definition at line 259 of file emobject.h. Referenced by EMObject(), operator bool(), operator=(), EMAN::operator==(), and to_str(). |
|
Definition at line 263 of file emobject.h. Referenced by operator bool(), operator=(), and EMAN::operator==(). |
|
|
Definition at line 269 of file emobject.h. Referenced by operator Transform *(), operator=(), and EMAN::operator==(). |
|
Definition at line 260 of file emobject.h. Referenced by operator bool(), operator=(), and EMAN::operator==(). |
|
Definition at line 268 of file emobject.h. Referenced by operator=(), and EMAN::operator==(). |
|
Definition at line 261 of file emobject.h. Referenced by operator bool(), operator=(), and EMAN::operator==(). |
|
Definition at line 256 of file emobject.h. Referenced by operator bool(), operator=(), EMAN::operator==(), and to_str(). |
|
Definition at line 267 of file emobject.h. Referenced by operator const char *(), operator Ctf *(), operator=(), and EMAN::operator==(). |
|
Definition at line 270 of file emobject.h. Referenced by operator=(), and EMAN::operator==(). |
|
Definition at line 271 of file emobject.h. Referenced by is_null(), operator bool(), operator const char *(), operator double(), operator EMData *(), operator float(), operator float *(), operator int(), operator int *(), operator Transform *(), operator unsigned int(), operator vector(), operator void *(), operator XYData *(), operator=(), EMAN::operator==(), printInfo(), and to_str(). |
|
Definition at line 79 of file emobject.cpp. Referenced by get_object_type_name(), and printInfo(). |
|
Definition at line 257 of file emobject.h. Referenced by operator bool(), operator=(), EMAN::operator==(), and to_str(). |
|
Definition at line 262 of file emobject.h. Referenced by operator=(), and EMAN::operator==(). |
|
Definition at line 264 of file emobject.h. Referenced by operator bool(), operator=(), and EMAN::operator==(). |