ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/minimizers/MinimizerFactory.cpp
Revision: 1902
Committed: Wed Jan 5 17:35:19 2005 UTC (19 years, 5 months ago) by tim
File size: 1492 byte(s)
Log Message:
minimizer in progress

File Contents

# Content
1
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 std::cout << "register " << creator->getIdent() << std::endl;
12 return creatorMap_.insert(
13 CreatorMapType::value_type(creator->getIdent(), creator)).second;
14 }
15
16 bool MinimizerFactory::unregisterMinimizer(const std::string& id) {
17 return creatorMap_.erase(id) == 1;
18 }
19
20 Minimizer* MinimizerFactory::createMinimizer(const std::string& id, SimInfo* info) {
21 CreatorMapType::iterator i = creatorMap_.find(id);
22 if (i != creatorMap_.end()) {
23 //invoke functor to create object
24 return (i->second)->create(info);
25 } else {
26 return NULL;
27 }
28 }
29
30 std::vector<std::string> MinimizerFactory::getIdents() {
31 IdentVectorType idents;
32 CreatorMapType::iterator i;
33
34 for (i = creatorMap_.begin(); i != creatorMap_.end(); ++i) {
35 idents.push_back(i->first);
36 }
37
38 return idents;
39 }
40
41 std::ostream& operator <<(std::ostream& o, MinimizerFactory& factory) {
42 MinimizerFactory::IdentVectorType idents;
43 MinimizerFactory::IdentVectorIterator i;
44
45 idents = factory.getIdents();
46
47 o << "Avaliable type identifiers in this factory: " << std::endl;
48 for (i = idents.begin(); i != idents.end(); ++i) {
49 o << *i << std::endl;
50 }
51
52 return o;
53 }
54
55 }
56

Properties

Name Value
svn:executable *