#include <emobject.h>
Public Types | |
typedef T *(* | InstanceType )() |
Public Member Functions | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Factory () | |
template<> | |
Symmetry3D * | get (const string &instancename) |
template<> | |
Factory () | |
Static Public Member Functions | |
template<class ClassType> | |
void | add () |
T * | get (const string &instance_name) |
T * | get (const string &instance_name, const Dict ¶ms) |
vector< string > | get_list () |
Private Member Functions | |
Factory () | |
Factory (const Factory< T > &) | |
~Factory () | |
template<class ClassType> | |
void | force_add () |
Static Private Member Functions | |
void | init () |
Private Attributes | |
map< string, InstanceType > | my_dict |
Static Private Attributes | |
Factory< T > * | my_instance = 0 |
It is a singleton template. Typical usages are as follows:
1. How to define a new factory (e.g. Processor Factory):
template<> Factory<Processor>::Factory() { force_add(&AbsoluateValueProcessor::NEW); force_add(&BooleanProcessor::NEW); }
2. How to use a Factory (e.g. Processor Factory):
Processor *f1 = Factory<Processor>::get("math.absvalue"); Processor *f2 = Factory<Processor>::get("eman1.filter.lowpass.gaussian", Dict("lowpass", EMObject(12));
Definition at line 701 of file emobject.h.
|
Definition at line 704 of file emobject.h. |
|
|
|
|
|
|
|
|
|
Definition at line 57 of file analyzer.cpp. 00058 { 00059 force_add<PCAsmall>(); 00060 force_add<PCAlarge>(); 00061 force_add<varimax>(); 00062 force_add<KMeansAnalyzer>(); 00063 force_add<SVDAnalyzer>(); 00064 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 742 of file emobject.h. 00743 { 00744 init(); 00745 00746 string name = ClassType::NAME; 00747 typename map < string, InstanceType >::iterator fi = 00748 my_instance->my_dict.find(name); 00749 00750 if (fi == my_instance->my_dict.end()) { 00751 my_instance->my_dict[name] = &ClassType::NEW; 00752 } 00753 }
|
|
Definition at line 733 of file emobject.h. 00734 { 00735 string name = ClassType::NAME; 00736 my_dict[name] = &ClassType::NEW; 00737 }
|
|
|
|
Definition at line 775 of file emobject.h. References InvalidParameterException, EMAN::TypeDict::keys(), and NotExistingObjectException. 00777 { 00778 init(); 00779 00780 typename map < string, InstanceType >::iterator fi = 00781 my_instance->my_dict.find(instancename); 00782 00783 string lower = instancename; 00784 if (fi == my_instance->my_dict.end()) { 00785 for (unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]); 00786 fi = my_instance->my_dict.find(lower); 00787 } 00788 00789 if (fi != my_instance->my_dict.end()) { 00790 T *i = my_instance->my_dict[lower] (); 00791 00792 const vector<string> para_keys = params.keys(); 00793 // std::cout << "the number of keys is " << para_keys.size() << std::endl; // PRB May 19th 00794 const vector<string> valid_keys = i->get_param_types().keys(); 00795 typename vector<string>::const_iterator it; 00796 for(it=para_keys.begin(); it!=para_keys.end(); ++it) { 00797 // std::cout << "the iterator is " << *it << std::endl; // PRB May 19th 00798 if( find(valid_keys.begin(), valid_keys.end(), *it) == valid_keys.end() ) { 00799 throw InvalidParameterException(*it); 00800 } 00801 } 00802 00803 i->set_params(params); 00804 return i; 00805 } 00806 00807 00808 throw NotExistingObjectException(instancename, "No such an instance existing"); 00809 }
|
|
Definition at line 755 of file emobject.h. References NotExistingObjectException. Referenced by ali3d_d(), EMAN::BackProjectionReconstructor::finish(), EMAN::Transform::get_nsym(), EMAN::Transform::get_sym(), EMAN::Symmetry3D::get_symmetries(), EMAN::group_processors(), EMAN::FourierReconstructor::load_inserter(), EMAN::AutoMaskAsymUnit::process_inplace(), recons3d_4nn(), and EMAN::RT3DSphereAligner::xform_align_nbest(). 00756 { 00757 init(); 00758 typename map < string, InstanceType >::iterator fi = 00759 my_instance->my_dict.find(instancename); 00760 if (fi != my_instance->my_dict.end()) { 00761 return my_instance->my_dict[instancename] (); 00762 } 00763 00764 string lower = instancename; 00765 for (unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]); 00766 00767 fi = my_instance->my_dict.find(lower); 00768 if (fi != my_instance->my_dict.end()) { 00769 return my_instance->my_dict[lower] (); 00770 } 00771 00772 throw NotExistingObjectException(instancename, "The named object doesn't exist"); 00773 }
|
|
Definition at line 811 of file emobject.h. Referenced by EMAN::group_processors(). 00811 { 00812 init(); 00813 vector < string > result; 00814 typename map < string, InstanceType >::const_iterator p; 00815 for (p = my_instance->my_dict.begin(); p != my_instance->my_dict.end(); p++) { 00816 result.push_back(p->first); 00817 } 00818 00819 return result; 00820 }
|
|
Definition at line 724 of file emobject.h. 00725 { 00726 if (!my_instance) { 00727 my_instance = new Factory < T > (); 00728 } 00729 }
|
|
Definition at line 719 of file emobject.h. |
|
Definition at line 722 of file emobject.h. |