EMAN2
emobject.h
Go to the documentation of this file.
1/*
2 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2007 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef eman__object__h__
33#define eman__object__h__ 1
34
35#include <map>
36using std::map;
37
38#include <set>
39using std::set;
40
41#include <vector>
42using std::vector;
43
44#include <string>
45using std::string;
46
47#include <utility>
48using std::pair;
49
50#include <algorithm>
51// using copy
52
53#include <iterator>
54
55// debug
56#include <cstdio>
57#include <iostream>
58using std::cout;
59using std::endl;
60
61#include <cctype> // tolower
62#include <algorithm> //tolower
63#include "log.h"
64#include "exception.h"
65
66// #include "transform.h" // Trnasform3D::EulerType
67
68namespace EMAN
69{
70 class EMConsts {
71 public:
72 static const float I2G; // 2 interpolation
73 static const float I3G; // used for 3 and 5x5x5 interpolation
74 static const float I4G; // used for 4 interpolation
75 static const float I5G; // used for 5x5x5 interpolation
76
77 static const double rad2deg; // radians to degree constant factor
78 static const double deg2rad; // degrees to radians constant factor
79 static const double pi; // degrees to radians constant factor
80 };
81
82 class EMData;
83 class XYData;
84 class Aligner;
85 class Averager;
86 class Cmp;
87 class Processor;
88 class Projector;
89 class Reconstructor;
90 class Analyzer;
91 class Transform;
92 class Ctf;
93
104 };
105
123 {
124 public:
145 };
146
147
152 EMObject();
153 EMObject(bool boolean);
154 EMObject(short);
155 EMObject(int num);
156 EMObject(unsigned int num);
157 EMObject(float ff);
158 EMObject(double dd);
159 EMObject(const char *s);
160 EMObject(const string & s);
161 EMObject(float * fp);
162 EMObject(int * ip);
163 EMObject(void * vp);
164 EMObject(EMData * em);
165 EMObject(XYData * xy);
166 EMObject(Transform * t);
167 EMObject(Ctf * ctf);
168 EMObject(const vector< int >& v);
169 EMObject(const vector<float>& v);
170 EMObject(const vector <string>& sarray);
171 EMObject(const vector <Transform>& tarray);
172
177 EMObject(const EMObject& that);
178
183 EMObject& operator=(const EMObject& that);
184
188 ~EMObject();
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;
203 operator Transform *() 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;
209
214 bool is_null() const;
215
218 string to_str() const;
219
224 ObjectType get_type() const { return type; }
225
230 string get_type_string() const { return get_object_type_name(type); }
231
232 // This forces a string to be a CTF object instead
233 void force_CTF() { type=CTF; }
234
240 string to_str(ObjectType type) const;
241
245 static string get_object_type_name(ObjectType t);
246
250 friend bool operator==(const EMObject &e1, const EMObject & e2);
251
255 friend bool operator!=(const EMObject &e1, const EMObject & e2);
256
257 private:
258 union
259 {
260 bool b;
261 short si;
262 int n;
263 unsigned int ui;
264 float f;
265 double d;
266 float * fp;
267 int * ip;
268 void * vp;
271 };
272
273 string str;
274 vector <int> iarray;
275 vector <float> farray;
276 vector <string> strarray;
277 vector <Transform> transformarray;
279
282 void printInfo() const;
283
284// void init();
285
286 static map<ObjectType, string> init();
287 static map<ObjectType, string> type_registry;
288 };
289
290 bool operator==(const EMObject &e1, const EMObject & e2);
291 bool operator!=(const EMObject &e1, const EMObject & e2);
292
305 {
306 public:
308 {
309 }
310
312 {
313 }
314
315 vector<string> keys() const
316 {
317 vector<string> result;
318
319 for (auto p = type_dict.begin(); p != type_dict.end(); p++)
320 result.push_back(p->first);
321
322 return result;
323 }
324
325 size_t size() const
326 {
327 return type_dict.size();
328 }
329
330 void put(const string& key, EMObject::ObjectType o, const string& desc = "")
331 {
333 desc_dict[key] = desc;
334 }
335
336 string get_type(const string& key)
337 {
338 return type_dict[key];
339 }
340
341 string get_desc(const string& key)
342 {
343 return desc_dict[key];
344 }
345
346 string operator[] (const string & key)
347 {
348 return type_dict[key];
349 }
350
351 void dump();
352
353 inline bool find_type( const string& type ) { return type_dict.find(type) != type_dict.end(); }
354
355 private:
356 map<string, string> type_dict;
357 map<string, string> desc_dict;
358 };
359
360
384 class Dict
385 {
386 public:
388 {
389 }
390
395 Dict(const string & key1, EMObject val1)
396 {
397 dict[key1] = val1;
398 }
399
402 Dict(const string & key1, EMObject val1,
403 const string & key2, EMObject val2)
404 {
405 dict[key1] = val1;
406 dict[key2] = val2;
407 }
408
411 Dict(const string & key1, EMObject val1,
412 const string & key2, EMObject val2,
413 const string & key3, EMObject val3)
414 {
415 dict[key1] = val1;
416 dict[key2] = val2;
417 dict[key3] = val3;
418 }
419
422 Dict(const string & key1, EMObject val1,
423 const string & key2, EMObject val2,
424 const string & key3, EMObject val3,
425 const string & key4, EMObject val4)
426 {
427 dict[key1] = val1;
428 dict[key2] = val2;
429 dict[key3] = val3;
430 dict[key4] = val4;
431 }
432
435 Dict(const string & key1, EMObject val1,
436 const string & key2, EMObject val2,
437 const string & key3, EMObject val3,
438 const string & key4, EMObject val4,
439 const string & key5, EMObject val5)
440 {
441 dict[key1] = val1;
442 dict[key2] = val2;
443 dict[key3] = val3;
444 dict[key4] = val4;
445 dict[key5] = val5;
446 }
447
451 Dict(const map<string, EMObject> &d)
452 {
453 copy(d.begin(), d.end(), inserter(dict, dict.begin()));
454 // Or use
455 // dict.insert(d.begin(), d.end());
456 }
457
461 ~Dict() {}
462
466 Dict( const Dict& that);
467
471 Dict& operator=(const Dict& that);
472
475 vector<string> keys()const
476 {
477 vector<string> result;
478
479 for (auto p = dict.begin(); p != dict.end(); p++)
480 result.push_back(p->first);
481
482 return result;
483 }
484
487 vector<EMObject> values()const
488 {
489 vector<EMObject> result;
490
491 for (auto p = dict.begin(); p != dict.end(); p++)
492 result.push_back(p->second);
493
494 return result;
495 }
496
500 void update(const Dict& that);
501
502
506 bool has_key_ci(const string & key) const;
507
511 bool has_key(const string & key) const
512 {
513 auto p = dict.find(key);
514 return p != dict.end();
515 }
516
519 size_t size() const
520 {
521 return dict.size();
522 }
523
527 EMObject get(const string & key) const
528 {
529 if( has_key(key) ) {
530 return dict[key];
531 }
532 else {
533 LOGERR("No such key exist in this Dict");
534 throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict");
535 }
536 }
537
541 EMObject get_ci(const string & key) const;
545 void put(const string & key, EMObject val)
546 {
547 dict[key] = val;
548 }
549
552 void erase(const string & key)
553 {
554 dict.erase(key);
555 }
556
560 void clear()
561 {
562 dict.clear();
563 }
564
568 template <typename type>
569 type set_default(const string & key, type val)
570 {
571 if (!has_key(key)) {
572 dict[key] = val;
573 }
574 return dict[key];
575 }
576
577 Dict copy_exclude_keys(const vector<string>& excluded_keys) const
578 {
579 Dict ret(*this);
580
581 for (auto it = excluded_keys.begin(); it != excluded_keys.end(); ++it )
582 if (ret.has_key(*it))
583 ret.erase(*it);
584
585 return ret;
586 }
587
588 Dict copy_exclusive_keys(const vector<string>& exclusive_keys) const
589 {
590 Dict ret;
591 for (auto it = exclusive_keys.begin(); it != exclusive_keys.end(); ++it ) {
592 if (has_key(*it))
593 ret[*it] = (*this)[*it];
594 }
595
596 return ret;
597 }
598
599 Dict copy_keys_in( const TypeDict& tdict ) const {
600 vector<string> keys = tdict.keys();
602 }
603
604 EMObject & operator[] (const string & key)
605 {
606// static EMObject nullreturn;
607// if( has_key(key) ) return dict[key];
608// else return nullreturn;
609
610// if( has_key(key) ) {
611 return dict[key];
612// }
613// else {
614// LOGERR("No such key exist in this Dict");
615// throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict");
616// }
617 }
618
619 EMObject operator[] (const string & key) const
620 {
621// if( has_key(key) ) return dict[key];
622// else return EMObject();
623 return dict[key];
624
625// else {
626// LOGERR("No such key exist in this Dict");
627// throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict");
628// }
629 }
630
634 friend bool operator==(const Dict& d1, const Dict& d2);
635
639 friend bool operator!=(const Dict& d1, const Dict& d2);
640
641 private:
642 mutable map<string, EMObject> dict;
643
644 public:
652 class iterator : public map<string, EMObject>::iterator
653 {
654 public:
655 typedef std::bidirectional_iterator_tag iterator_category;
656 typedef pair<string, EMObject> value_type;
657
658 public:
659 iterator( map<string, EMObject>::iterator parent_it );
660 virtual ~iterator(){}
661
662 iterator( const iterator& that );
663 iterator& operator=( const iterator& that );
664 };
665
673 class const_iterator : public map<string, EMObject>::const_iterator
674 {
675 public:
676 typedef std::bidirectional_iterator_tag iterator_category;
677 typedef pair<string, EMObject> value_type; // Note that value_type should NOT be const even though the container elements are const
678 public:
679 const_iterator( const map<string, EMObject>::const_iterator parent_it);
680 virtual ~const_iterator(){}
681 const_iterator( const Dict::iterator& it );
682
683 const_iterator( const const_iterator& that );
685 };
686
687 // Iterator support
688 iterator begin();
689 const_iterator begin() const;
690
691 iterator end();
692 const_iterator end() const;
693
694 // Wraps map.find(const string& key)
695 iterator find( const string& key );
696 const_iterator find( const string& key ) const;
697 };
698
699 // These operators were originally added for the purposes of making testing code but might come in handy for other things
700 // operator== simply wraps map<string, EMObject>::operator==
701 bool operator==(const Dict &d1, const Dict& d2);
702 bool operator!=(const Dict &d1, const Dict& d2);
703
704
723 template <class T>
725 {
726 public:
727 typedef T *(*InstanceType) ();
728
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);
732 static vector<string> get_list();
733
734 private:
738 static void init();
739 template <class ClassType> void force_add();
740
742 map<string, InstanceType> my_dict;
743 };
744
745 template <class T>
747
748 template <class T>
750 {
751 if (!my_instance) {
752 my_instance = new Factory<T>();
753 }
754 }
755
756 template <class T>
757 template <class ClassType >
759 {
760 string name = ClassType::NAME;
761 my_dict[name] = &ClassType::NEW;
762 }
763
764
765 template <class T>
766 template <class ClassType >
768 {
769 init();
770
771 string name = ClassType::NAME;
772 typename map < string, InstanceType >::iterator fi =
773 my_instance->my_dict.find(name);
774
775 if (fi == my_instance->my_dict.end()) {
776 my_instance->my_dict[name] = &ClassType::NEW;
777 }
778 }
779
780 template <class T>
781 T* Factory<T>::get(const string & instancename)
782 {
783 init();
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] ();
788 }
789
790 string lower = instancename;
791 for (unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]);
792
793 fi = my_instance->my_dict.find(lower);
794 if (fi != my_instance->my_dict.end()) {
795 return my_instance->my_dict[lower] ();
796 }
797
798 throw NotExistingObjectException(instancename, "The named object doesn't exist");
799 }
800
801 template <class T>
802 T* Factory<T>::get(const string & instancename, const Dict & params)
803 {
804 init();
805
806 typename map<string, InstanceType>::iterator fi =
807 my_instance->my_dict.find(instancename);
808
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);
814 }
815
816 if (fi != my_instance->my_dict.end()) {
817 T *i = my_instance->my_dict[lower] ();
818
819 const vector<string> para_keys = params.keys();
820// std::cout << "the number of keys is " << para_keys.size() << std::endl; // PRB May 19th
821 const vector<string> valid_keys = i->get_param_types().keys();
822 for(auto it=para_keys.begin(); it!=para_keys.end(); ++it) {
823// std::cout << "the iterator is " << *it << std::endl; // PRB May 19th
824 if( find(valid_keys.begin(), valid_keys.end(), *it) == valid_keys.end() ) {
825 throw InvalidParameterException(*it);
826 }
827 }
828
829 i->set_params(params);
830 return i;
831 }
832
833 throw NotExistingObjectException(instancename, "No such an instance existing");
834 }
835
836 template <class T>
837 vector<string> Factory<T>::get_list() {
838 init();
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);
842 }
843
844 return result;
845 }
846
847 template <class T>
849 {
850 auto item_names = Factory<T>::get_list();
851
852 for (size_t i = 0; i < item_names.size(); i++) {
853 T* item = Factory<T>::get(item_names[i]);
854 printf("%s : %s\n", item->get_name().c_str(),item->get_desc().c_str());
855 TypeDict td = item->get_param_types();
856 td.dump();
857 }
858 }
859
860 template <class T>
861 map<string, vector<string> > dump_factory_list()
862 {
863 vector<string> item_names = Factory<T>::get_list();
864 map<string, vector<string> > factory_list;
865
866 for(auto p = item_names.begin(); p !=item_names.end(); ++p) {
867 T* item = Factory<T>::get(*p);
868
869 string name = item->get_name();
870
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]) );
879 }
880 factory_list[name] = content;
881 }
882
883 return factory_list;
884 }
885
893 {
894 public:
896 virtual ~FactoryBase() {};
897
901 virtual string get_name() const = 0;
902
906 virtual string get_desc() const = 0;
907
911 Dict get_params() const { return params; }
912
916 void set_params(const Dict & new_params)
917 {
918 params.clear();
919 insert_params(new_params);
920 }
921
922 inline void set_param(const string key,const EMObject val) { params[key]=val; }
923
926 virtual TypeDict get_param_types() const = 0;
927
931 void insert_params(const Dict & new_params)
932 {
933 // this is really inserting OR individually replacing...
934 // the old data will be kept if it is not written over
935 TypeDict permissable_params = get_param_types();
936 for (auto it = new_params.begin(); it != new_params.end(); ++it )
937 {
938 if ( !permissable_params.find_type(it->first) )
939 {
940 throw InvalidParameterException(it->first);
941 }
942 params[it->first] = it->second;
943 }
944 }
945
946 Dict copy_relevant_params(const FactoryBase* const that) const
947 {
948 return params.copy_keys_in(that->get_param_types());
949 }
950
951 protected:
953 mutable Dict params;
954 };
955}
956
957#endif
Aligner class defines image alignment method.
Definition: aligner.h:81
Analyzer class defines a way to take a List of images as input, and returns a new List of images.
Definition: analyzer.h:57
Averager class defines a way to do averaging on a set of images.
Definition: averager.h:93
Cmp class defines image comparison method.
Definition: cmp.h:82
Ctf is the base class for all CTF model.
Definition: ctf.h:60
Const iterator support for the Dict object This is just a wrapper, everything is inherited from the m...
Definition: emobject.h:674
const_iterator(const map< string, EMObject >::const_iterator parent_it)
Definition: emobject.cpp:1104
std::bidirectional_iterator_tag iterator_category
Definition: emobject.h:676
const_iterator & operator=(const const_iterator &that)
Definition: emobject.cpp:1119
pair< string, EMObject > value_type
Definition: emobject.h:677
Non const iterator support for the Dict object This is just a wrapper, everything is inherited from t...
Definition: emobject.h:653
iterator & operator=(const iterator &that)
Definition: emobject.cpp:1091
virtual ~iterator()
Definition: emobject.h:660
pair< string, EMObject > value_type
Definition: emobject.h:656
iterator(map< string, EMObject >::iterator parent_it)
Definition: emobject.cpp:1079
std::bidirectional_iterator_tag iterator_category
Definition: emobject.h:655
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
void erase(const string &key)
Remove a particular key.
Definition: emobject.h:552
Dict(const string &key1, EMObject val1, const string &key2, EMObject val2)
Construct a Dict object from 2 key/value pairs.
Definition: emobject.h:402
bool has_key_ci(const string &key) const
Ask the Dictionary if it as a particular key in a case insensitive way.
Definition: emobject.cpp:1140
friend bool operator!=(const Dict &d1, const Dict &d2)
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
iterator end()
Definition: emobject.cpp:1061
Dict & operator=(const Dict &that)
Assignment operator Copies all elements in dict.
Definition: emobject.cpp:1004
Dict copy_exclude_keys(const vector< string > &excluded_keys) const
Definition: emobject.h:577
Dict copy_exclusive_keys(const vector< string > &exclusive_keys) const
Definition: emobject.h:588
vector< EMObject > values() const
Get a vector containing copies of each of the EMObjects in this dictionary.
Definition: emobject.h:487
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.
Definition: emobject.h:422
EMObject & operator[](const string &key)
Definition: emobject.h:604
size_t size() const
Ask the Dictionary for its size.
Definition: emobject.h:519
Dict(const string &key1, EMObject val1)
Construct a Dict object from 1 key/value pair It's probably more conventional to intialize key/value ...
Definition: emobject.h:395
iterator begin()
Definition: emobject.cpp:1045
Dict copy_keys_in(const TypeDict &tdict) const
Definition: emobject.h:599
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.
Definition: emobject.h:411
iterator find(const string &key)
Definition: emobject.cpp:1056
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.
Definition: emobject.h:435
map< string, EMObject > dict
Definition: emobject.h:642
void put(const string &key, EMObject val)
Put the value/key pair into the dictionary probably better to just use operator[].
Definition: emobject.h:545
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...
Definition: emobject.h:569
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
vector< string > keys() const
Get a vector containing all of the (string) keys in this dictionary.
Definition: emobject.h:475
Dict(const map< string, EMObject > &d)
Construct a Dict object from a map object Calls the generic algorithm "copy".
Definition: emobject.h:451
EMObject get_ci(const string &key) const
Get the EMObject corresponding to the particular key using case insensitivity.
Definition: emobject.cpp:1128
void clear()
Clear all keys wraps map.clear()
Definition: emobject.h:560
EMObject get(const string &key) const
Get the EMObject corresponding to the particular key Probably better to just use operator[].
Definition: emobject.h:527
~Dict()
Destructor Performs no explicit action besides what the compiler automatically does.
Definition: emobject.h:461
void update(const Dict &that)
Update replaces values from that into this without otherwise altering this.
Definition: emobject.cpp:1032
static const double rad2deg
Definition: emobject.h:77
static const float I5G
Definition: emobject.h:75
static const double deg2rad
Definition: emobject.h:78
static const float I4G
Definition: emobject.h:74
static const float I3G
Definition: emobject.h:73
static const double pi
Definition: emobject.h:79
static const float I2G
Definition: emobject.h:72
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
Definition: emobject.h:123
vector< Transform > transformarray
Definition: emobject.h:277
EMObject & operator=(const EMObject &that)
Assigment operator copies pointer locations (emdata, xydata, transform) - does not take ownership dee...
Definition: emobject.cpp:893
string get_type_string() const
Get the ObjectType as a string This is an enumerated type first declared in the class EMObjectTypes.
Definition: emobject.h:230
string str
Definition: emobject.h:273
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)
Definition: emobject.cpp:684
bool is_null() const
Checks to see if the EMObject is interpretable This basically equates to checking to see if the type ...
Definition: emobject.cpp:679
EMObject()
Constructors for each type More types could be added, but all of the accompanying functions would hav...
Definition: emobject.cpp:131
ObjectType type
Definition: emobject.h:278
~EMObject()
Desctructor Does not free pointers.
Definition: emobject.cpp:124
friend bool operator!=(const EMObject &e1, const EMObject &e2)
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
static map< ObjectType, string > init()
Definition: emobject.cpp:78
void force_CTF()
Definition: emobject.h:233
EMData * emdata
Definition: emobject.h:269
void printInfo() const
A debug function that prints as much information as possibe to cout.
Definition: emobject.cpp:112
unsigned int ui
Definition: emobject.h:263
ObjectType get_type() const
Get the ObjectType This is an enumerated type first declared in the class EMObjectTypes.
Definition: emobject.h:224
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.
Definition: emobject.cpp:761
vector< string > strarray
Definition: emobject.h:276
vector< float > farray
Definition: emobject.h:275
vector< int > iarray
Definition: emobject.h:274
float * fp
Definition: emobject.h:266
XYData * xydata
Definition: emobject.h:270
static map< ObjectType, string > type_registry
Definition: emobject.h:287
A class one may inherit from to ensure that the responsibilities of being incorporated into an EMAN2:...
Definition: emobject.h:893
Dict copy_relevant_params(const FactoryBase *const that) const
Definition: emobject.h:946
void set_params(const Dict &new_params)
Set new parameters.
Definition: emobject.h:916
virtual ~FactoryBase()
Definition: emobject.h:896
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.
Definition: emobject.h:953
void set_param(const string key, const EMObject val)
Definition: emobject.h:922
void insert_params(const Dict &new_params)
Insert parameters.
Definition: emobject.h:931
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
Definition: emobject.h:911
Factory is used to store objects to create new instances.
Definition: emobject.h:725
static void init()
Definition: emobject.h:749
static Factory< T > * my_instance
Definition: emobject.h:741
Factory(const Factory< T > &)
map< string, InstanceType > my_dict
Definition: emobject.h:742
static T * get(const string &instance_name)
Definition: emobject.h:781
static void add()
Definition: emobject.h:767
static vector< string > get_list()
Definition: emobject.h:837
void force_add()
Definition: emobject.h:758
Typical usage of Processors are as follows:
Definition: processor.h:90
Projector class defines a method to generate 2D projections from a 3D model.
Definition: projector.h:78
Reconstructor class defines a way to do 3D recontruction.
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
map< string, string > type_dict
Definition: emobject.h:356
vector< string > keys() const
Definition: emobject.h:315
string get_type(const string &key)
Definition: emobject.h:336
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330
bool find_type(const string &type)
Definition: emobject.h:353
string get_desc(const string &key)
Definition: emobject.h:341
size_t size() const
Definition: emobject.h:325
map< string, string > desc_dict
Definition: emobject.h:357
string operator[](const string &key)
Definition: emobject.h:346
XYData defines a 1D (x,y) data set.
Definition: xydata.h:47
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
vector< pair< float, int > > vp
#define InvalidParameterException(desc)
Definition: exception.h:361
#define NotExistingObjectException(objname, desc)
Definition: exception.h:130
#define LOGERR
Definition: log.h:51
E2Exception class.
Definition: aligner.h:40
map< string, vector< string > > dump_factory_list()
Definition: emobject.h:861
bool operator!=(const EMObject &e1, const EMObject &e2)
Definition: emobject.cpp:873
MapInfoType
Definition: emobject.h:94
@ ICOS3F_FULL
Definition: emobject.h:100
@ ICOS2F_HALF
Definition: emobject.h:98
@ ICOS_UNKNOWN
Definition: emobject.h:103
@ ICOS2F_FIRST_OCTANT
Definition: emobject.h:96
@ ICOS5F_HALF
Definition: emobject.h:101
@ ICOS5F_FULL
Definition: emobject.h:102
@ ICOS3F_HALF
Definition: emobject.h:99
@ NORMAL
Definition: emobject.h:95
@ ICOS2F_FULL
Definition: emobject.h:97
void dump_factory()
Definition: emobject.h:848
bool operator==(const EMObject &e1, const EMObject &e2)
Definition: emobject.cpp:770