#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("filter.lowpass.gauss", Dict("cufoff_freq", EMObject(12));
Definition at line 713 of file emobject.h.
|
Definition at line 716 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 754 of file emobject.h. 00755 { 00756 init(); 00757 00758 string name = ClassType::NAME; 00759 typename map < string, InstanceType >::iterator fi = 00760 my_instance->my_dict.find(name); 00761 00762 if (fi == my_instance->my_dict.end()) { 00763 my_instance->my_dict[name] = &ClassType::NEW; 00764 } 00765 }
|
|
Definition at line 745 of file emobject.h. 00746 { 00747 string name = ClassType::NAME; 00748 my_dict[name] = &ClassType::NEW; 00749 }
|
|
|
|
Definition at line 787 of file emobject.h. References InvalidParameterException, EMAN::TypeDict::keys(), and NotExistingObjectException. 00789 { 00790 init(); 00791 00792 typename map < string, InstanceType >::iterator fi = 00793 my_instance->my_dict.find(instancename); 00794 00795 string lower = instancename; 00796 if (fi == my_instance->my_dict.end()) { 00797 for (unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]); 00798 fi = my_instance->my_dict.find(lower); 00799 } 00800 00801 if (fi != my_instance->my_dict.end()) { 00802 T *i = my_instance->my_dict[lower] (); 00803 00804 const vector<string> para_keys = params.keys(); 00805 // std::cout << "the number of keys is " << para_keys.size() << std::endl; // PRB May 19th 00806 const vector<string> valid_keys = i->get_param_types().keys(); 00807 typename vector<string>::const_iterator it; 00808 for(it=para_keys.begin(); it!=para_keys.end(); ++it) { 00809 // std::cout << "the iterator is " << *it << std::endl; // PRB May 19th 00810 if( find(valid_keys.begin(), valid_keys.end(), *it) == valid_keys.end() ) { 00811 throw InvalidParameterException(*it); 00812 } 00813 } 00814 00815 i->set_params(params); 00816 return i; 00817 } 00818 00819 00820 throw NotExistingObjectException(instancename, "No such an instance existing"); 00821 }
|
|
Definition at line 767 of file emobject.h. References NotExistingObjectException. Referenced by ali3d_d(), EMAN::SymAlignProcessor::align(), EMAN::BackProjectionReconstructor::finish(), EMAN::Transform::get_nsym(), EMAN::Transform::get_sym(), EMAN::Transform::get_sym_proj(), EMAN::Symmetry3D::get_symmetries(), EMAN::group_processors(), EMAN::FourierReconstructor::load_inserter(), EMAN::ApplySymProcessor::process(), EMAN::AutoMaskAsymUnit::process_inplace(), recons3d_4nn(), and EMAN::RT3DSphereAligner::xform_align_nbest(). 00768 { 00769 init(); 00770 typename map < string, InstanceType >::iterator fi = 00771 my_instance->my_dict.find(instancename); 00772 if (fi != my_instance->my_dict.end()) { 00773 return my_instance->my_dict[instancename] (); 00774 } 00775 00776 string lower = instancename; 00777 for (unsigned int i=0; i<lower.length(); i++) lower[i]=tolower(lower[i]); 00778 00779 fi = my_instance->my_dict.find(lower); 00780 if (fi != my_instance->my_dict.end()) { 00781 return my_instance->my_dict[lower] (); 00782 } 00783 00784 throw NotExistingObjectException(instancename, "The named object doesn't exist"); 00785 }
|
|
Definition at line 823 of file emobject.h. Referenced by EMAN::group_processors(). 00823 { 00824 init(); 00825 vector < string > result; 00826 typename map < string, InstanceType >::const_iterator p; 00827 for (p = my_instance->my_dict.begin(); p != my_instance->my_dict.end(); p++) { 00828 result.push_back(p->first); 00829 } 00830 00831 return result; 00832 }
|
|
Definition at line 736 of file emobject.h. 00737 { 00738 if (!my_instance) { 00739 my_instance = new Factory < T > (); 00740 } 00741 }
|
|
Definition at line 731 of file emobject.h. |
|
Definition at line 734 of file emobject.h. |