ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/minimizers/MinimizerFactory.cpp
Revision: 1912
Committed: Mon Jan 10 20:52:07 2005 UTC (21 years, 1 month ago) by tim
File size: 1426 byte(s)
Log Message:
zconstraint method is working now

File Contents

# User Rev Content
1 tim 1902
2     #include "minimizers/MinimizerFactory.hpp"
3     #include "minimizers/MinimizerCreator.hpp"
4    
5     namespace oopse {
6    
7     //initialize instance of MinimizerFactory
8     MinimizerFactory* MinimizerFactory::instance_ = NULL;
9    
10     bool MinimizerFactory::registerMinimizer(MinimizerCreator* creator) {
11     return creatorMap_.insert(
12     CreatorMapType::value_type(creator->getIdent(), creator)).second;
13     }
14    
15     bool MinimizerFactory::unregisterMinimizer(const std::string& id) {
16     return creatorMap_.erase(id) == 1;
17     }
18    
19     Minimizer* MinimizerFactory::createMinimizer(const std::string& id, SimInfo* info) {
20     CreatorMapType::iterator i = creatorMap_.find(id);
21     if (i != creatorMap_.end()) {
22     //invoke functor to create object
23     return (i->second)->create(info);
24     } else {
25     return NULL;
26     }
27     }
28    
29     std::vector<std::string> MinimizerFactory::getIdents() {
30     IdentVectorType idents;
31     CreatorMapType::iterator i;
32    
33     for (i = creatorMap_.begin(); i != creatorMap_.end(); ++i) {
34     idents.push_back(i->first);
35     }
36    
37     return idents;
38     }
39    
40     std::ostream& operator <<(std::ostream& o, MinimizerFactory& factory) {
41     MinimizerFactory::IdentVectorType idents;
42     MinimizerFactory::IdentVectorIterator i;
43    
44     idents = factory.getIdents();
45    
46     o << "Avaliable type identifiers in this factory: " << std::endl;
47     for (i = idents.begin(); i != idents.end(); ++i) {
48     o << *i << std::endl;
49     }
50    
51     return o;
52     }
53    
54     }
55    

Properties

Name Value
svn:executable *