#include <emobject.h>
Public Member Functions | |
Dict () | |
Dict (const string &key1, EMObject val1) | |
Construct a Dict object from 1 key/value pair It's probably more conventional to intialize key/value pairs using operator[], but either approach is fine. | |
Dict (const string &key1, EMObject val1, const string &key2, EMObject val2) | |
Construct a Dict object from 2 key/value pairs. | |
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. | |
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. | |
Dict (const map< string, EMObject > &d) | |
Construct a Dict object from a map object Calls the generic algorithm "copy". | |
~Dict () | |
Destructor Performs no explicit action besides what the compiler automatically does. | |
Dict (const Dict &that) | |
Copy constructor Copies all elements in dict. | |
Dict & | operator= (const Dict &that) |
Assignment operator Copies all elements in dict. | |
vector< string > | keys () const |
Get a vector containing all of the (string) keys in this dictionary. | |
vector< EMObject > | values () const |
Get a vector containing copies of each of the EMObjects in this dictionary. | |
bool | has_key_ci (const string &key) const |
Ask the Dictionary if it as a particular key in a case insensitive way. | |
bool | has_key (const string &key) const |
Ask the Dictionary if it as a particular key. | |
size_t | size () const |
Ask the Dictionary for its size. | |
EMObject | get (const string &key) const |
Get the EMObject corresponding to the particular key Probably better to just use operator[]. | |
EMObject | get_ci (const string &key) const |
Get the EMObject corresponding to the particular key using case insensitivity. | |
void | put (const string &key, EMObject val) |
Put the value/key pair into the dictionary probably better to just use operator[]. | |
void | erase (const string &key) |
Remove a particular key. | |
void | clear () |
Clear all keys wraps map.clear(). | |
template<typename type> | |
type | set_default (const string &key, type val) |
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there was a function being written for every type). | |
Dict | copy_exclude_keys (const vector< string > &excluded_keys) const |
Dict | copy_exclusive_keys (const vector< string > &exclusive_keys) const |
Dict | copy_keys_in (const TypeDict &tdict) const |
EMObject & | operator[] (const string &key) |
EMObject | operator[] (const string &key) const |
iterator | begin (void) |
const_iterator | begin (void) const |
iterator | end (void) |
const_iterator | end (void) const |
iterator | find (const string &key) |
const_iterator | find (const string &key) const |
Private Attributes | |
map< string, EMObject > | dict |
Friends | |
bool | operator== (const Dict &d1, const Dict &d2) |
Friend declaration operator== namespace EMAN2 operator== accesses private variables. | |
bool | operator!= (const Dict &d1, const Dict &d2) |
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables. |
Typical ways to construct a Dict:
Dict d; d["lowpass"] = 12.23; float lowpass1 = d["lowpass"];
Dict d2("lowpass", 12.23);
You can iterate through a dict: for ( Dict::const_iterator it = params.begin(); it != params.end(); ++it ) { //do things to it } And similary use the Dict iterator as arguments to the generic algorithms that are feasible, such as copy.
You can find things in the iterator style: if( d.find("lowpass") != d.end() ) cout << "D has a lowpass key" << endl;\ Or like this if( d.has_key("lowpass") ) ...
A Dict has copy and assignment operators.
See the testing code in rt/emdata/test_emobject.cpp for prewritten testing code
Definition at line 389 of file emobject.h.
|
Definition at line 392 of file emobject.h. 00393 { 00394 }
|
|
Construct a Dict object from 1 key/value pair It's probably more conventional to intialize key/value pairs using operator[], but either approach is fine.
Definition at line 400 of file emobject.h. 00401 { 00402 dict[key1] = val1; 00403 }
|
|
Construct a Dict object from 2 key/value pairs.
Definition at line 407 of file emobject.h.
|
|
Construct a Dict object from 3 key/value pairs.
Definition at line 416 of file emobject.h.
|
|
Construct a Dict object from 4 key/value pairs.
Definition at line 427 of file emobject.h. 00431 { 00432 dict[key1] = val1; 00433 dict[key2] = val2; 00434 dict[key3] = val3; 00435 dict[key4] = val4; 00436 }
|
|
Construct a Dict object from a map object Calls the generic algorithm "copy".
Definition at line 441 of file emobject.h. References copy(). 00442 { 00443 copy(d.begin(), d.end(), inserter(dict, dict.begin())); 00444 // Or use 00445 // dict.insert(d.begin(), d.end()); 00446 }
|
|
Destructor Performs no explicit action besides what the compiler automatically does.
Definition at line 451 of file emobject.h. 00451 {}
|
|
Copy constructor Copies all elements in dict.
Definition at line 1070 of file emobject.cpp. 01071 {
01072 *this = that;
01073 }
|
|
Definition at line 1114 of file emobject.cpp. References dict. 01115 { 01116 return const_iterator( (map < string, EMObject >::const_iterator) dict.begin() ); 01117 }
|
|
Definition at line 1109 of file emobject.cpp. References dict. Referenced by EMAN::Transform::detect_problem_keys(), EMAN::FactoryBase::insert_params(), and operator=(). 01110 { 01111 return iterator( dict.begin() ); 01112 }
|
|
Clear all keys wraps map.clear().
Definition at line 551 of file emobject.h. Referenced by operator=(). 00552 { 00553 dict.clear(); 00554 }
|
|
Definition at line 568 of file emobject.h. References erase(), and has_key(). 00569 { 00570 Dict ret(*this); 00571 00572 for ( vector<string>::const_iterator it = excluded_keys.begin(); it != excluded_keys.end(); ++it ) { 00573 if (ret.has_key(*it)) ret.erase(*it); 00574 } 00575 00576 return ret; 00577 }
|
|
Definition at line 579 of file emobject.h. References end(). 00580 { 00581 Dict ret; 00582 for ( vector<string>::const_iterator it = exclusive_keys.begin(); it != exclusive_keys.end(); ++it ) { 00583 if (has_key(*it)) ret[*it] = (*this)[*it]; 00584 } 00585 00586 return ret; 00587 }
|
|
Definition at line 589 of file emobject.h. References EMAN::TypeDict::keys(). 00589 { 00590 vector<string> keys = tdict.keys(); 00591 return copy_exclusive_keys(keys); 00592 }
|
|
Definition at line 1130 of file emobject.cpp. References dict. 01131 { 01132 return const_iterator( (map < string, EMObject >::const_iterator)dict.end() ); 01133 }
|
|
|
Remove a particular key.
Definition at line 543 of file emobject.h. References key. Referenced by copy_exclude_keys(), EMAN::EMData::del_attr(), EMAN::EMData::read_binedimage(), EMAN::EMData::read_image(), and EMAN::EMData::set_attr_dict(). 00544 { 00545 dict.erase(key); 00546 }
|
|
Definition at line 1135 of file emobject.cpp. 01136 { 01137 return const_iterator( (map < string, EMObject >::const_iterator)dict.find(key) ); 01138 }
|
|
Definition at line 1120 of file emobject.cpp. 01121 { 01122 return iterator( dict.find(key) ); 01123 }
|
|
Get the EMObject corresponding to the particular key Probably better to just use operator[].
Definition at line 518 of file emobject.h. References key, LOGERR, and NotExistingObjectException. Referenced by EMAN::file_store::add_image(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::SigmaProcessor::set_params(), EMAN::RangeThresholdProcessor::set_params(), EMAN::ExpProcessor::set_params(), and EMAN::LinearXformProcessor::set_params(). 00519 { 00520 if( has_key(key) ) { 00521 return dict[key]; 00522 } 00523 else { 00524 LOGERR("No such key exist in this Dict"); 00525 throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict"); 00526 } 00527 }
|
|
Get the EMObject corresponding to the particular key using case insensitivity.
Definition at line 1192 of file emobject.cpp. References dict, key, NotExistingObjectException, and EMAN::Util::str_to_lower(). Referenced by EMAN::Transform::set_params(), EMAN::Transform::set_params_inverse(), and EMAN::Transform::set_rotation(). 01193 { 01194 string lower_key = Util::str_to_lower(key); 01195 01196 for (map < string, EMObject >::const_iterator it = dict.begin(); it != dict.end(); ++it ) { 01197 string lower = Util::str_to_lower(it->first); 01198 if (lower == lower_key) return it->second; 01199 } 01200 01201 throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict"); 01202 }
|
|
|
Ask the Dictionary if it as a particular key in a case insensitive way.
Definition at line 1204 of file emobject.cpp. References dict, key, and EMAN::Util::str_to_lower(). Referenced by EMAN::Transform::detect_problem_keys(), EMAN::Transform::set_params(), EMAN::Transform::set_params_inverse(), and EMAN::Transform::set_rotation(). 01205 { 01206 string lower_key = Util::str_to_lower(key); 01207 01208 for (map < string, EMObject >::const_iterator it = dict.begin(); it != dict.end(); ++it ) { 01209 string lower = Util::str_to_lower(it->first); 01210 if (lower == lower_key) return true; 01211 } 01212 return false; 01213 }
|
|
Get a vector containing all of the (string) keys in this dictionary.
Definition at line 465 of file emobject.h. Referenced by EMAN::EMUtil::dump_dict(), EMAN::TestUtil::dump_emdata(), EMAN::EMData::set_attr_dict(), and EMAN::TestUtil::test_dict(). 00466 { 00467 vector < string > result; 00468 00469 map < string, EMObject >::const_iterator p; 00470 for (p = dict.begin(); p != dict.end(); p++) { 00471 result.push_back(p->first); 00472 } 00473 00474 return result; 00475 }
|
|
Assignment operator Copies all elements in dict.
Definition at line 1075 of file emobject.cpp. References begin(), clear(), copy(), dict, and end(). 01076 { 01077 if ( this != &that ) 01078 { 01079 dict.clear(); 01080 copy(that.begin(), that.end(), inserter(dict, dict.begin())); 01081 // or use this 01082 // dict.insert( that.begin(), that.end()); 01083 } 01084 else 01085 { 01086 cerr << "Warning - attempted to assign a Dict object to itself. No action taken" << endl; 01087 } 01088 01089 return *this; 01090 }
|
|
Definition at line 609 of file emobject.h. 00610 { 00611 // if( has_key(key) ) return dict[key]; 00612 // else return EMObject(); 00613 return dict[key]; 00614 00615 // else { 00616 // LOGERR("No such key exist in this Dict"); 00617 // throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict"); 00618 // } 00619 }
|
|
Definition at line 594 of file emobject.h. 00595 { 00596 // static EMObject nullreturn; 00597 // if( has_key(key) ) return dict[key]; 00598 // else return nullreturn; 00599 00600 // if( has_key(key) ) { 00601 return dict[key]; 00602 // } 00603 // else { 00604 // LOGERR("No such key exist in this Dict"); 00605 // throw NotExistingObjectException("EMObject", "Nonexisting key (" + key + ") in Dict"); 00606 // } 00607 }
|
|
Put the value/key pair into the dictionary probably better to just use operator[].
Definition at line 536 of file emobject.h. Referenced by EMAN::SymSearchProcessor::process_inplace(). 00537 { 00538 dict[key] = val; 00539 }
|
|
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there was a function being written for every type).
Definition at line 560 of file emobject.h. References key. Referenced by EMAN::FourierWeightAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::TomoAverager::add_image(), EMAN::OrientationGenerator::add_orientation(), EMAN::Refine3DAlignerGrid::align(), EMAN::Refine3DAlignerQuaternion::align(), EMAN::SymAlignProcessorQuat::align(), EMAN::RefineAlignerCG::align(), EMAN::RefineAligner::align(), EMAN::SymAlignProcessor::align(), EMAN::RTFSlowExhaustiveAligner::align(), EMAN::RTFExhaustiveAligner::align(), EMAN::RotateFlipAlignerIterative::align(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAlignerPawel::align(), EMAN::RotateTranslateFlipScaleAlignerIterative::align(), EMAN::RotateTranslateFlipAlignerIterative::align(), EMAN::RotateTranslateFlipScaleAligner::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateScaleAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotateTranslateAlignerPawel::align(), EMAN::RotateTranslateScaleAlignerIterative::align(), EMAN::RotateTranslateAlignerIterative::align(), EMAN::RotationalAlignerIterative::align(), EMAN::RotationalAligner::align(), EMAN::TranslationalAligner::align(), EMAN::ScaleAligner::align(), EMAN::ScaleAlignerABS::align_using_base(), EMAN::FRCCmp::cmp(), EMAN::PhaseCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::QuadMinDotCmp::cmp(), EMAN::TomoFscCmp::cmp(), EMAN::TomoCccCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::CccCmp::cmp(), EMAN::LowpassAutoBProcessor::create_radial_func(), EMAN::WienerFourierReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::TomoAverager::finish(), EMAN::OptimumOrientationGenerator::gen_orientations(), EMAN::SaffOrientationGenerator::gen_orientations(), EMAN::EvenOrientationGenerator::gen_orientations(), EMAN::RandomOrientationGenerator::gen_orientations(), EMAN::EmanOrientationGenerator::gen_orientations(), EMAN::HSym::get_asym_unit_points(), EMAN::DSym::get_asym_unit_points(), EMAN::CSym::get_asym_unit_points(), EMAN::DSym::get_asym_unit_triangles(), EMAN::CSym::get_asym_unit_triangles(), EMAN::DSym::get_delimiters(), EMAN::CSym::get_delimiters(), EMAN::OptimumOrientationGenerator::get_orientations_tally(), EMAN::SaffOrientationGenerator::get_orientations_tally(), EMAN::EvenOrientationGenerator::get_orientations_tally(), EMAN::EmanOrientationGenerator::get_orientations_tally(), EMAN::HSym::get_sym(), EMAN::DSym::get_sym(), EMAN::CSym::get_sym(), EMAN::HSym::is_in_asym_unit(), EMAN::DSym::is_in_asym_unit(), EMAN::CSym::is_in_asym_unit(), EMAN::BinarySkeletonizerProcessor::process(), EMAN::ScaleTransformProcessor::process(), EMAN::IntTranslateProcessor::process(), EMAN::DirectionalSumProcessor::process(), EMAN::CtfSimProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::KmeansSegmentProcessor::process(), EMAN::ApplySymProcessor::process(), EMAN::DistanceSegmentProcessor::process(), EMAN::RotateInFSProcessor::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::TomoTiltAngleWeightProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::NSigmaClampingProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::ScaleTransformProcessor::process_inplace(), EMAN::IntTranslateProcessor::process_inplace(), EMAN::TestImageEllipse::process_inplace(), EMAN::TestImageHollowEllipse::process_inplace(), EMAN::TestImageCirclesphere::process_inplace(), EMAN::TestImageAxes::process_inplace(), EMAN::TestImageGradient::process_inplace(), EMAN::TestImageLineWave::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::StripeXYProcessor::process_inplace(), EMAN::PhaseToMassCenterProcessor::process_inplace(), EMAN::ToMassCenterProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::FFTResampleProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::ToMinvalProcessor::process_inplace(), EMAN::RecipCarefullyProcessor::set_params(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), EMAN::FourierReconstructor::setup_seed(), EMAN::RT3DSymmetryAligner::xform_align_nbest(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().
|
|
Ask the Dictionary for its size.
Definition at line 510 of file emobject.h. Referenced by ali3d_d(), apmd(), apmq(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), EMAN::Util::coveig_for_py(), EMAN::DoGFourierProcessor::create_radial_func(), EMAN::LoGFourierProcessor::create_radial_func(), EMAN::LinearRampProcessor::create_radial_func(), EMAN::LowpassAutoBProcessor::create_radial_func(), EMAN::Util::Crosrng_ew(), EMAN::Util::Crosrng_ms(), EMAN::Util::Crosrng_ms_delta(), EMAN::Util::Crosrng_ns(), EMAN::Util::Crosrng_psi(), EMAN::Util::Crosrng_sm_psi(), EMAN::Processor::EMFourierFilterFunc(), EMAN::Util::hans(), EMAN::Util::min_dist_four(), EMAN::Util::min_dist_real(), EMAN::Util::multiref_polar_ali_2d(), EMAN::Util::multiref_polar_ali_2d_delta(), EMAN::Util::multiref_polar_ali_2d_local(), EMAN::Util::multiref_polar_ali_2d_local_psi(), EMAN::Util::multiref_polar_ali_2d_nom(), EMAN::Util::multiref_polar_ali_2d_peaklist(), EMAN::Util::multiref_polar_ali_helical(), EMAN::Util::multiref_polar_ali_helical_90(), EMAN::Util::multiref_polar_ali_helical_90_local(), EMAN::Util::multiref_polar_ali_helical_local(), EMAN::RadialProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::Util::pw_extract(), EMAN::EMData::read_images(), EMAN::KMeansAnalyzer::reclassify(), EMAN::KMeansAnalyzer::reseed(), and EMAN::KMeansAnalyzer::update_centers(). 00511 { 00512 return dict.size(); 00513 }
|
|
Get a vector containing copies of each of the EMObjects in this dictionary.
Definition at line 479 of file emobject.h. Referenced by EMAN::EMUtil::dump_dict(), and EMAN::RealPixelProcessor::set_params(). 00480 { 00481 vector < EMObject > result; 00482 00483 map < string, EMObject >::const_iterator p; 00484 for (p = dict.begin(); p != dict.end(); p++) { 00485 result.push_back(p->second); 00486 } 00487 00488 return result; 00489 }
|
|
Friend declaration operator!= namespace EMAN2 operator!= accesses private variables.
|
|
Friend declaration operator== namespace EMAN2 operator== accesses private variables.
|
|
Definition at line 632 of file emobject.h. Referenced by begin(), end(), find(), get_ci(), has_key_ci(), operator=(), and EMAN::operator==(). |