32#ifndef eman__object__h__
33#define eman__object__h__ 1
72 static const float I2G;
73 static const float I3G;
74 static const float I4G;
75 static const float I5G;
79 static const double pi;
170 EMObject(
const vector <string>& sarray);
171 EMObject(
const vector <Transform>& tarray);
191 operator bool ()
const;
192 operator short ()
const;
193 operator int ()
const;
194 operator unsigned int ()
const;
195 operator float ()
const;
196 operator double ()
const;
197 operator const char *()
const;
198 operator float * ()
const;
199 operator int * ()
const;
200 operator void * ()
const;
201 operator EMData *()
const;
202 operator XYData *()
const;
204 operator Ctf *()
const;
205 operator vector<int> ()
const;
206 operator vector<float> ()
const;
207 operator vector<string> ()
const;
208 operator vector<Transform> ()
const;
286 static map<ObjectType, string>
init();
317 vector<string> result;
320 result.push_back(p->first);
451 Dict(
const map<string, EMObject> &d)
477 vector<string> result;
479 for (
auto p =
dict.begin(); p !=
dict.end(); p++)
480 result.push_back(p->first);
489 vector<EMObject> result;
491 for (
auto p =
dict.begin(); p !=
dict.end(); p++)
492 result.push_back(p->second);
513 auto p =
dict.find(key);
514 return p !=
dict.end();
533 LOGERR(
"No such key exist in this Dict");
568 template <
typename type>
581 for (
auto it = excluded_keys.begin(); it != excluded_keys.end(); ++it )
591 for (
auto it = exclusive_keys.begin(); it != exclusive_keys.end(); ++it ) {
593 ret[*it] = (*this)[*it];
642 mutable map<string, EMObject>
dict;
659 iterator( map<string, EMObject>::iterator parent_it );
679 const_iterator(
const map<string, EMObject>::const_iterator parent_it);
689 const_iterator
begin()
const;
692 const_iterator
end()
const;
695 iterator
find(
const string& key );
696 const_iterator
find(
const string& key )
const;
701 bool operator==(
const Dict &d1,
const Dict& d2);
702 bool operator!=(
const Dict &d1,
const Dict& d2);
727 typedef T *(*InstanceType) ();
729 template <
class ClassType>
static void add();
730 static T *
get(
const string & instance_name);
731 static T *
get(
const string & instance_name,
const Dict & params);
739 template <
class ClassType>
void force_add();
757 template <
class ClassType >
760 string name = ClassType::NAME;
761 my_dict[name] = &ClassType::NEW;
766 template <
class ClassType >
771 string name = ClassType::NAME;
772 typename map < string, InstanceType >::iterator fi =
773 my_instance->my_dict.find(name);
775 if (fi == my_instance->my_dict.end()) {
776 my_instance->my_dict[name] = &ClassType::NEW;
784 typename map < string, InstanceType >::iterator fi =
785 my_instance->my_dict.find(instancename);
786 if (fi != my_instance->my_dict.end()) {
787 return my_instance->my_dict[instancename] ();
790 string lower = instancename;
791 for (
unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]);
793 fi = my_instance->my_dict.find(lower);
794 if (fi != my_instance->my_dict.end()) {
795 return my_instance->my_dict[lower] ();
806 typename map<string, InstanceType>::iterator fi =
807 my_instance->my_dict.find(instancename);
809 string lower = instancename;
810 if (fi == my_instance->my_dict.end()) {
811 for (
unsigned int i=0; i<lower.length(); i++)
812 lower[i]=tolower(lower[i]);
813 fi = my_instance->my_dict.find(lower);
816 if (fi != my_instance->my_dict.end()) {
817 T *i = my_instance->my_dict[lower] ();
819 const vector<string> para_keys = params.
keys();
821 const vector<string> valid_keys = i->get_param_types().keys();
822 for(
auto it=para_keys.begin(); it!=para_keys.end(); ++it) {
824 if( find(valid_keys.begin(), valid_keys.end(), *it) == valid_keys.end() ) {
829 i->set_params(params);
839 vector<string> result;
840 for (
auto p = my_instance->my_dict.begin(); p != my_instance->my_dict.end(); p++) {
841 result.push_back(p->first);
852 for (
size_t i = 0; i < item_names.size(); i++) {
854 printf(
"%s : %s\n", item->get_name().c_str(),item->get_desc().c_str());
855 TypeDict td = item->get_param_types();
864 map<string, vector<string> > factory_list;
866 for(
auto p = item_names.begin(); p !=item_names.end(); ++p) {
869 string name = item->get_name();
871 vector<string> content;
872 content.push_back(item->get_desc());
873 TypeDict td = item->get_param_types();
874 vector<string> keys = td.
keys();
875 for(
unsigned int i=0; i<td.
size(); ++i) {
876 content.push_back(keys[i]);
877 content.push_back( td.
get_type(keys[i]) );
878 content.push_back( td.
get_desc(keys[i]) );
880 factory_list[name] = content;
936 for (
auto it = new_params.
begin(); it != new_params.
end(); ++it )
938 if ( !permissable_params.
find_type(it->first) )
942 params[it->first] = it->second;
Aligner class defines image alignment method.
Analyzer class defines a way to take a List of images as input, and returns a new List of images.
Averager class defines a way to do averaging on a set of images.
Cmp class defines image comparison method.
Ctf is the base class for all CTF model.
Const iterator support for the Dict object This is just a wrapper, everything is inherited from the m...
const_iterator(const map< string, EMObject >::const_iterator parent_it)
std::bidirectional_iterator_tag iterator_category
const_iterator & operator=(const const_iterator &that)
pair< string, EMObject > value_type
virtual ~const_iterator()
Non const iterator support for the Dict object This is just a wrapper, everything is inherited from t...
iterator & operator=(const iterator &that)
pair< string, EMObject > value_type
iterator(map< string, EMObject >::iterator parent_it)
std::bidirectional_iterator_tag iterator_category
Dict is a dictionary to store <string, EMObject> pair.
void erase(const string &key)
Remove a particular key.
Dict(const string &key1, EMObject val1, const string &key2, EMObject val2)
Construct a Dict object from 2 key/value pairs.
bool has_key_ci(const string &key) const
Ask the Dictionary if it as a particular key in a case insensitive way.
friend bool operator!=(const Dict &d1, const Dict &d2)
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
Dict & operator=(const Dict &that)
Assignment operator Copies all elements in dict.
Dict copy_exclude_keys(const vector< string > &excluded_keys) const
Dict copy_exclusive_keys(const vector< string > &exclusive_keys) const
vector< EMObject > values() const
Get a vector containing copies of each of the EMObjects in this dictionary.
Dict(const string &key1, EMObject val1, const string &key2, EMObject val2, const string &key3, EMObject val3, const string &key4, EMObject val4)
Construct a Dict object from 4 key/value pairs.
EMObject & operator[](const string &key)
size_t size() const
Ask the Dictionary for its size.
Dict(const string &key1, EMObject val1)
Construct a Dict object from 1 key/value pair It's probably more conventional to intialize key/value ...
Dict copy_keys_in(const TypeDict &tdict) const
Dict(const string &key1, EMObject val1, const string &key2, EMObject val2, const string &key3, EMObject val3)
Construct a Dict object from 3 key/value pairs.
iterator find(const string &key)
friend bool operator==(const Dict &d1, const Dict &d2)
Friend declaration operator== namespace EMAN2 operator== accesses private variables.
Dict(const string &key1, EMObject val1, const string &key2, EMObject val2, const string &key3, EMObject val3, const string &key4, EMObject val4, const string &key5, EMObject val5)
Construct a Dict object from 5 key/value pairs.
map< string, EMObject > dict
void put(const string &key, EMObject val)
Put the value/key pair into the dictionary probably better to just use operator[].
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
vector< string > keys() const
Get a vector containing all of the (string) keys in this dictionary.
Dict(const map< string, EMObject > &d)
Construct a Dict object from a map object Calls the generic algorithm "copy".
EMObject get_ci(const string &key) const
Get the EMObject corresponding to the particular key using case insensitivity.
void clear()
Clear all keys wraps map.clear()
EMObject get(const string &key) const
Get the EMObject corresponding to the particular key Probably better to just use operator[].
~Dict()
Destructor Performs no explicit action besides what the compiler automatically does.
void update(const Dict &that)
Update replaces values from that into this without otherwise altering this.
static const double rad2deg
static const double deg2rad
EMData stores an image's data and defines core image processing routines.
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
vector< Transform > transformarray
EMObject & operator=(const EMObject &that)
Assigment operator copies pointer locations (emdata, xydata, transform) - does not take ownership dee...
string get_type_string() const
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes.
friend bool operator==(const EMObject &e1, const EMObject &e2)
Friend declaration operator== namespace EMAN2 operator== accesses private variables.
string to_str() const
Calls to_str( this->type)
bool is_null() const
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type ...
EMObject()
Constructors for each type More types could be added, but all of the accompanying functions would hav...
~EMObject()
Desctructor Does not free pointers.
friend bool operator!=(const EMObject &e1, const EMObject &e2)
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
static map< ObjectType, string > init()
void printInfo() const
A debug function that prints as much information as possibe to cout.
ObjectType get_type() const
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes.
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.
vector< string > strarray
static map< ObjectType, string > type_registry
A class one may inherit from to ensure that the responsibilities of being incorporated into an EMAN2:...
Dict copy_relevant_params(const FactoryBase *const that) const
void set_params(const Dict &new_params)
Set new parameters.
virtual string get_desc() const =0
Get a clear, concise description of this class.
Dict params
This is the dictionary the stores the parameters of the object.
void set_param(const string key, const EMObject val)
void insert_params(const Dict &new_params)
Insert parameters.
virtual TypeDict get_param_types() const =0
virtual string get_name() const =0
Get the unique name of this class (especially for factory based instantiation access)
Dict get_params() const
get a copy of the parameters of this class
Factory is used to store objects to create new instances.
static Factory< T > * my_instance
Factory(const Factory< T > &)
map< string, InstanceType > my_dict
static T * get(const string &instance_name)
static vector< string > get_list()
Typical usage of Processors are as follows:
Projector class defines a method to generate 2D projections from a 3D model.
Reconstructor class defines a way to do 3D recontruction.
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
map< string, string > type_dict
vector< string > keys() const
string get_type(const string &key)
void put(const string &key, EMObject::ObjectType o, const string &desc="")
bool find_type(const string &type)
string get_desc(const string &key)
map< string, string > desc_dict
string operator[](const string &key)
XYData defines a 1D (x,y) data set.
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
#define InvalidParameterException(desc)
#define NotExistingObjectException(objname, desc)
map< string, vector< string > > dump_factory_list()
bool operator!=(const EMObject &e1, const EMObject &e2)
bool operator==(const EMObject &e1, const EMObject &e2)