EMAN2
|
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType. More...
#include <emobject.h>
Public Types | |
enum | ObjectType { UNKNOWN , BOOL , SHORT , UNSIGNEDINT , INT , FLOAT , DOUBLE , STRING , EMDATA , XYDATA , INTARRAY , FLOATARRAY , STRINGARRAY , TRANSFORM , CTF , FLOAT_POINTER , INT_POINTER , VOID_POINTER , TRANSFORMARRAY } |
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. More... | |
EMObject (bool boolean) | |
EMObject (short) | |
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 vector< Transform > &tarray) | |
EMObject (const EMObject &that) | |
Copy constructor. More... | |
EMObject & | operator= (const EMObject &that) |
Assigment operator copies pointer locations (emdata, xydata, transform) - does not take ownership deep copies all non pointer objects. More... | |
~EMObject () | |
Desctructor Does not free pointers. More... | |
operator bool () const | |
Conversion operators. More... | |
operator short () const | |
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< int > () const | |
operator vector< float > () const | |
operator vector< string > () const | |
operator vector< Transform > () 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. More... | |
string | to_str () const |
Calls to_str( this->type) More... | |
ObjectType | get_type () const |
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes. More... | |
string | get_type_string () const |
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes. More... | |
void | force_CTF () |
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. More... | |
Static Public Member Functions | |
static string | get_object_type_name (ObjectType t) |
Get an ObjectType as a string statically Can be accessed without the instantiation of a class object. More... | |
Private Member Functions | |
void | printInfo () const |
A debug function that prints as much information as possibe to cout. More... | |
Static Private Member Functions | |
static map< ObjectType, string > | init () |
Private Attributes | |
union { | |
bool b | |
short si | |
int n | |
unsigned int ui | |
float f | |
double d | |
float * fp | |
int * ip | |
void * vp | |
EMData * emdata | |
XYData * xydata | |
}; | |
string | str |
vector< int > | iarray |
vector< float > | farray |
vector< string > | strarray |
vector< Transform > | transformarray |
ObjectType | type |
Static Private Attributes | |
static map< ObjectType, string > | type_registry = init() |
Friends | |
bool | operator== (const EMObject &e1, const EMObject &e2) |
Friend declaration operator== namespace EMAN2 operator== accesses private variables. More... | |
bool | operator!= (const EMObject &e1, const EMObject &e2) |
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables. More... | |
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
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 122 of file emobject.h.
Enumerator | |
---|---|
UNKNOWN | |
BOOL | |
SHORT | |
UNSIGNEDINT | |
INT | |
FLOAT | |
DOUBLE | |
STRING | |
EMDATA | |
XYDATA | |
INTARRAY | |
FLOATARRAY | |
STRINGARRAY | |
TRANSFORM | |
CTF | |
FLOAT_POINTER | |
INT_POINTER | |
VOID_POINTER | |
TRANSFORMARRAY |
Definition at line 125 of file emobject.h.
EMObject::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.
Definition at line 131 of file emobject.cpp.
EMObject::EMObject | ( | bool | boolean | ) |
Definition at line 140 of file emobject.cpp.
EMObject::EMObject | ( | short | sint | ) |
Definition at line 149 of file emobject.cpp.
EMObject::EMObject | ( | int | num | ) |
Definition at line 158 of file emobject.cpp.
EMObject::EMObject | ( | unsigned int | num | ) |
Definition at line 167 of file emobject.cpp.
EMObject::EMObject | ( | float | ff | ) |
Definition at line 176 of file emobject.cpp.
References f, and EMAN::Util::goodf().
EMObject::EMObject | ( | double | dd | ) |
EMObject::EMObject | ( | const char * | s | ) |
Definition at line 208 of file emobject.cpp.
EMObject::EMObject | ( | const string & | s | ) |
Definition at line 217 of file emobject.cpp.
EMObject::EMObject | ( | float * | fp | ) |
Definition at line 226 of file emobject.cpp.
EMObject::EMObject | ( | int * | ip | ) |
Definition at line 235 of file emobject.cpp.
EMObject::EMObject | ( | void * | vp | ) |
Definition at line 244 of file emobject.cpp.
EMObject::EMObject | ( | EMData * | em | ) |
Definition at line 253 of file emobject.cpp.
EMObject::EMObject | ( | XYData * | xy | ) |
Definition at line 262 of file emobject.cpp.
EMObject::EMObject | ( | Transform * | t | ) |
Definition at line 271 of file emobject.cpp.
EMObject::EMObject | ( | Ctf * | ctf | ) |
Definition at line 280 of file emobject.cpp.
EMObject::EMObject | ( | const vector< int > & | v | ) |
Definition at line 289 of file emobject.cpp.
EMObject::EMObject | ( | const vector< float > & | v | ) |
Definition at line 298 of file emobject.cpp.
EMObject::EMObject | ( | const vector< string > & | sarray | ) |
Definition at line 307 of file emobject.cpp.
EMObject::EMObject | ( | const vector< Transform > & | tarray | ) |
Definition at line 316 of file emobject.cpp.
EMObject::EMObject | ( | const EMObject & | that | ) |
Copy constructor.
copies pointer locations - does not take ownership deep copies all non pointer objects
Definition at line 879 of file emobject.cpp.
EMObject::~EMObject | ( | ) |
Desctructor Does not free pointers.
Definition at line 124 of file emobject.cpp.
|
inline |
|
static |
Get an ObjectType as a string statically Can be accessed without the instantiation of a class object.
Definition at line 761 of file emobject.cpp.
References LOGERR, NotExistingObjectException, and type_registry.
Referenced by get_type_string(), and EMAN::TypeDict::put().
|
inline |
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes.
Definition at line 224 of file emobject.h.
References type.
Referenced by EMAN::Transform::set_params(), and EMAN::Transform::set_params_inverse().
|
inline |
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes.
Definition at line 230 of file emobject.h.
References get_object_type_name(), and type.
|
staticprivate |
Definition at line 78 of file emobject.cpp.
References BOOL, CTF, DOUBLE, EMDATA, FLOAT, FLOAT_POINTER, FLOATARRAY, INT, INT_POINTER, INTARRAY, SHORT, STRING, STRINGARRAY, TRANSFORM, TRANSFORMARRAY, UNKNOWN, UNSIGNEDINT, VOID_POINTER, and XYDATA.
bool EMObject::is_null | ( | ) | const |
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type is UNKNOWN.
Definition at line 679 of file emobject.cpp.
Referenced by EMAN::EMUtil::dump_dict().
EMObject::operator bool | ( | ) | const |
EMObject::operator const char * | ( | ) | const |
EMObject::operator Ctf * | ( | ) | const |
Definition at line 611 of file emobject.cpp.
References EMAN::Ctf::from_string().
EMObject::operator double | ( | ) | const |
EMObject::operator EMData * | ( | ) | const |
EMObject::operator float | ( | ) | const |
EMObject::operator float * | ( | ) | const |
EMObject::operator int | ( | ) | const |
EMObject::operator int * | ( | ) | const |
EMObject::operator short | ( | ) | const |
EMObject::operator Transform * | ( | ) | const |
Definition at line 598 of file emobject.cpp.
References EMAN::Transform::set_matrix(), and TypeException.
EMObject::operator unsigned int | ( | ) | const |
EMObject::operator vector< float > | ( | ) | const |
EMObject::operator vector< int > | ( | ) | const |
Definition at line 631 of file emobject.cpp.
References TypeException.
EMObject::operator vector< string > | ( | ) | const |
EMObject::operator vector< Transform > | ( | ) | const |
EMObject::operator void * | ( | ) | const |
Definition at line 522 of file emobject.cpp.
References TypeException.
EMObject::operator XYData * | ( | ) | const |
Assigment operator copies pointer locations (emdata, xydata, transform) - does not take ownership deep copies all non pointer objects.
Definition at line 893 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, SHORT, si, str, strarray, STRING, STRINGARRAY, TRANSFORM, TRANSFORMARRAY, transformarray, type, ui, UNKNOWN, UNSIGNEDINT, VOID_POINTER, vp, XYDATA, and xydata.
|
private |
A debug function that prints as much information as possibe to cout.
Definition at line 112 of file emobject.cpp.
References to_str(), type, and type_registry.
string EMObject::to_str | ( | ) | const |
Calls to_str( this->type)
Definition at line 684 of file emobject.cpp.
References to_str(), and type.
Referenced by EMAN::EMUtil::dump_dict(), printInfo(), and to_str().
string EMObject::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.
Definition at line 689 of file emobject.cpp.
References b, BOOL, CTF, d, DOUBLE, EMDATA, f, FLOAT, FLOAT_POINTER, FLOATARRAY, INT, INT_POINTER, INTARRAY, LOGERR, n, NotExistingObjectException, SHORT, si, str, STRING, STRINGARRAY, TRANSFORM, TRANSFORMARRAY, ui, UNKNOWN, UNSIGNEDINT, VOID_POINTER, and XYDATA.
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
Friend declaration operator== namespace EMAN2 operator== accesses private variables.
union { ... } EMAN::EMObject::@1 |
bool EMAN::EMObject::b |
Definition at line 260 of file emobject.h.
Referenced by operator=(), EMAN::operator==(), and to_str().
double EMAN::EMObject::d |
Definition at line 265 of file emobject.h.
Referenced by EMObject(), operator=(), EMAN::operator==(), and to_str().
EMData* EMAN::EMObject::emdata |
Definition at line 269 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
float EMAN::EMObject::f |
Definition at line 264 of file emobject.h.
Referenced by EMObject(), operator=(), EMAN::operator==(), and to_str().
|
private |
Definition at line 275 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
float* EMAN::EMObject::fp |
Definition at line 266 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
|
private |
Definition at line 274 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
int* EMAN::EMObject::ip |
Definition at line 267 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
int EMAN::EMObject::n |
Definition at line 262 of file emobject.h.
Referenced by operator=(), EMAN::operator==(), and to_str().
short EMAN::EMObject::si |
Definition at line 261 of file emobject.h.
Referenced by operator=(), EMAN::operator==(), and to_str().
|
private |
Definition at line 273 of file emobject.h.
Referenced by operator=(), EMAN::operator==(), and to_str().
|
private |
Definition at line 276 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
|
private |
Definition at line 277 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
|
private |
Definition at line 278 of file emobject.h.
Referenced by force_CTF(), get_type(), get_type_string(), is_null(), operator=(), EMAN::operator==(), printInfo(), and to_str().
|
staticprivate |
Definition at line 287 of file emobject.h.
Referenced by get_object_type_name(), and printInfo().
unsigned int EMAN::EMObject::ui |
Definition at line 263 of file emobject.h.
Referenced by operator=(), EMAN::operator==(), and to_str().
void* EMAN::EMObject::vp |
Definition at line 268 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().
XYData* EMAN::EMObject::xydata |
Definition at line 270 of file emobject.h.
Referenced by operator=(), and EMAN::operator==().