Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

emobject.h File Reference

#include <map>
#include <set>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <iterator>
#include "log.h"
#include "exception.h"
#include <iostream>
#include <cctype>

Include dependency graph for emobject.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  EMAN

Classes

class  EMAN::EMConsts
class  EMAN::EMObject
 EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType. More...
class  EMAN::TypeDict
 TypeDict is a dictionary to store <string, EMObject::ObjectType> pair. More...
class  EMAN::Dict
 Dict is a dictionary to store <string, EMObject> pair. More...
class  EMAN::Dict::iterator
 Non const iterator support for the Dict object This is just a wrapper, everything is inherited from the map<string,EMObject>::iterator so the interface is the same as you would expect i.e for ( Dict::iterator it = params.begin(); it != params.end(); ++it ). More...
class  EMAN::Dict::const_iterator
 Const iterator support for the Dict object This is just a wrapper, everything is inherited from the map<string,EMObject>::cons_iterator so the interface is the same as you would expect i.e for ( Dict::const_iterator it = params.begin(); it != params.end(); ++it ). More...
class  EMAN::Factory< T >
 Factory is used to store objects to create new instances. More...
class  EMAN::FactoryBase
 A class one may inherit from to ensure that the responsibilities of being incorporated into an EMAN2::Factory are met. More...

Defines

#define eman__object__h__   1
 
Id
emobject.h,v 1.94 2010/09/21 21:53:58 john Exp


Enumerations

enum  MapInfoType {
  NORMAL, ICOS2F_FIRST_OCTANT, ICOS2F_FULL, ICOS2F_HALF,
  ICOS3F_HALF, ICOS3F_FULL, ICOS5F_HALF, ICOS5F_FULL,
  ICOS_UNKNOWN
}

Functions

bool operator== (const EMObject &e1, const EMObject &e2)
bool operator!= (const EMObject &e1, const EMObject &e2)
bool operator== (const Dict &d1, const Dict &d2)
bool operator!= (const Dict &d1, const Dict &d2)
template<class T>
void dump_factory ()
template<class T>
map< string, vector< string > > dump_factory_list ()


Define Documentation

#define eman__object__h__   1
 

Id
emobject.h,v 1.94 2010/09/21 21:53:58 john Exp

Definition at line 37 of file emobject.h.


Enumeration Type Documentation

enum MapInfoType
 

Enumeration values:
NORMAL 
ICOS2F_FIRST_OCTANT 
ICOS2F_FULL 
ICOS2F_HALF 
ICOS3F_HALF 
ICOS3F_FULL 
ICOS5F_HALF 
ICOS5F_FULL 
ICOS_UNKNOWN 

Definition at line 97 of file emobject.h.

00097                          {
00098                 NORMAL,
00099                 ICOS2F_FIRST_OCTANT,
00100                 ICOS2F_FULL,
00101                 ICOS2F_HALF,
00102                 ICOS3F_HALF,
00103                 ICOS3F_FULL,
00104                 ICOS5F_HALF,
00105                 ICOS5F_FULL,
00106                 ICOS_UNKNOWN
00107         };


Function Documentation

template<class T>
void dump_factory  ) 
 

Definition at line 825 of file emobject.h.

References EMAN::TypeDict::dump().

00826         {
00827                 vector < string > item_names = Factory < T >::get_list();
00828 
00829                 for (size_t i = 0; i < item_names.size(); i++) {
00830                         T *item = Factory < T >::get(item_names[i]);
00831                         printf("%s :  %s\n", item->get_name().c_str(),item->get_desc().c_str());
00832                         TypeDict td = item->get_param_types();
00833                         td.dump();
00834                 }
00835         }

template<class T>
map<string, vector<string> > dump_factory_list  ) 
 

Definition at line 837 of file emobject.h.

References EMAN::TypeDict::get_desc(), EMAN::TypeDict::get_type(), EMAN::TypeDict::keys(), and EMAN::TypeDict::size().

00838         {
00839                 vector < string > item_names = Factory < T >::get_list();
00840                 map<string, vector<string> >    factory_list;
00841 
00842                 typename vector<string>::const_iterator p;
00843                 for(p = item_names.begin(); p !=item_names.end(); ++p) {
00844                         T *item = Factory<T>::get(*p);
00845 
00846                         string name = item->get_name();
00847 
00848                         vector<string> content;
00849                         content.push_back(item->get_desc());
00850                         TypeDict td = item->get_param_types();
00851                         vector<string> keys = td.keys();
00852                         for(unsigned int i=0; i<td.size(); ++i) {
00853                                 content.push_back(keys[i]);
00854                                 content.push_back( td.get_type(keys[i]) );
00855                                 content.push_back( td.get_desc(keys[i]) );
00856                         }
00857                         factory_list[name] = content;
00858                 }
00859 
00860                 return factory_list;
00861         }

bool EMAN::operator!= const Dict d1,
const Dict d2
 

Definition at line 1007 of file emobject.cpp.

01008 {
01009         return !(d1 == d2);
01010 }

bool EMAN::operator!= const EMObject e1,
const EMObject e2
 

Definition at line 859 of file emobject.cpp.

00860 {
00861         return !(e1 == e2);
00862 }

bool EMAN::operator== const Dict d1,
const Dict d2
 

Definition at line 1001 of file emobject.cpp.

References EMAN::Dict::dict.

01002 {
01003         // Just make use of map's version of operator==
01004         return (d1.dict == d2.dict);
01005 }

bool EMAN::operator== const EMObject e1,
const EMObject e2
 

Definition at line 768 of file emobject.cpp.

References EMAN::EMObject::b, EMAN::EMObject::d, EMAN::EMObject::emdata, EMAN::EMObject::f, EMAN::EMObject::farray, EMAN::EMObject::fp, EMAN::EMObject::iarray, EMAN::EMObject::ip, EMAN::EMObject::n, EMAN::EMObject::str, EMAN::EMObject::strarray, EMAN::EMObject::type, EMAN::EMObject::ui, EMAN::EMObject::vp, and EMAN::EMObject::xydata.

00769 {
00770 
00771         if (e1.type != e2.type) {
00772                 return false;
00773         }
00774 
00775         switch (e1.type) {
00776         case  EMObject::BOOL:
00777                 return (e1.b == e2.b);
00778         break;
00779         case  EMObject::INT:
00780                 return (e1.n == e2.n);
00781         break;
00782         case  EMObject::UNSIGNEDINT:
00783                 return (e1.ui == e2.ui);
00784         break;
00785         case  EMObject::FLOAT:
00786                 return (e1.f == e2.f);
00787         break;
00788         case  EMObject::DOUBLE:
00789                 return (e1.d == e2.d);
00790         break;
00791         case EMObject::CTF:
00792         case  EMObject::STRING:
00793                 return (e1.str == e2.str);
00794         break;
00795         case  EMObject::FLOAT_POINTER:
00796                 return (e1.fp == e2.fp);
00797         break;
00798         case  EMObject::INT_POINTER:
00799                 return (e1.ip == e2.ip);
00800         break;
00801         case  EMObject::VOID_POINTER:
00802                 return (e1.vp == e2.vp);
00803         break;
00804         case  EMObject::EMDATA:
00805                 return (e1.emdata == e2.emdata);
00806         break;
00807         case  EMObject::XYDATA:
00808                 return (e1.xydata == e2.xydata);
00809         break;
00810         case  EMObject::TRANSFORM:
00811         case  EMObject::FLOATARRAY:
00812                 if (e1.farray.size() == e2.farray.size()) {
00813                         for (size_t i = 0; i < e1.farray.size(); i++) {
00814                                 if (e1.farray[i] != e2.farray[i]) {
00815                                         return false;
00816                                 }
00817                         }
00818                         return true;
00819                 }
00820                 else {
00821                         return false;
00822                 }
00823         break;
00824         case  EMObject::INTARRAY:
00825                 if (e1.iarray.size() == e2.iarray.size()) {
00826                         for (size_t i = 0; i < e1.iarray.size(); i++) {
00827                                 if (e1.iarray[i] != e2.iarray[i]) {
00828                                         return false;
00829                                 }
00830                         }
00831                         return true;
00832                 }
00833         break;
00834         case  EMObject::STRINGARRAY:
00835                 if (e1.strarray.size() == e2.strarray.size()) {
00836                         for (size_t i = 0; i < e1.strarray.size(); i++) {
00837                                 if (e1.strarray[i] != e2.strarray[i]) {
00838                                         return false;
00839                                 }
00840                         }
00841                         return true;
00842                 }
00843                 else {
00844                         return false;
00845                 }
00846         break;
00847         case  EMObject::UNKNOWN:
00848                 // UNKNOWN really means "no type" and if two objects both have
00849                 // type UNKNOWN they really are the same
00850                 return (e1.type == e2.type);
00851         break;
00852         default:
00853                 return false;
00854         break;
00855         }
00856         return false;
00857 }


Generated on Thu Dec 9 13:46:12 2010 for EMAN2 by  doxygen 1.3.9.1