ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/types/DataHolder.hpp
(Generate patch)

Comparing trunk/OOPSE-4/src/types/DataHolder.hpp (file contents):
Revision 2717 by gezelter, Mon Apr 17 21:49:12 2006 UTC vs.
Revision 3173 by gezelter, Fri Jul 13 18:10:52 2007 UTC

# Line 54 | Line 54 | namespace oopse {
54   #include "utils/OOPSEException.hpp"
55   #include "utils/StringUtils.hpp"
56   namespace oopse {
57 <
58 < class DataHolder {
59 <    public:
60 <        DataHolder() {}
61 <        virtual ~DataHolder() {}
62 <        
63 <        template<class T>
64 <        void assign(const std::string& keyword, T val) {
65 <             ParamMap::iterator i =parameters_.find(keyword);
66 <              if (i != parameters_.end()) {
67 <                   bool result = i->second->setData(val);
68 <                   if (!result ) {
69 <                     std::stringstream ss;
70 <                  ss <<   "Error in parsing " << keyword << ": expected " << i->second->getParamType() <<"\n";
71 <                      throw OOPSEException(ss.str());
72 <                    }
73 <              }else if (deprecatedKeywords_.find(keyword) != deprecatedKeywords_.end()){
74 <                     std::cout << keyword << " has been deprecated in OOPSE 3.  Please update your .md file.\n";
75 <              }else {
76 <                     std::stringstream ss;
77 <                     ss << keyword << " is not a recognized keyword.\n";
78 <                     throw OOPSEException(ss.str());
79 <              }
57 >  
58 >  class DataHolder {
59 >  public:
60 >    DataHolder() {}
61 >    virtual ~DataHolder() {}
62 >    
63 >    template<class T>
64 >    void assign(const std::string& keyword, T val) {
65 >      ParamMap::iterator i =parameters_.find(keyword);
66 >      if (i != parameters_.end()) {
67 >        bool result = i->second->setData(val);
68 >        if (!result ) {
69 >          std::stringstream ss;
70 >          ss <<   "Error in parsing " << keyword << ": expected " <<
71 >            i->second->getParamType() <<"\n";
72 >          throw OOPSEException(ss.str());
73          }
74 <
75 <        virtual void validate() {
76 <          ParamMap::iterator i;
77 <          for (i = parameters_.begin(); i != parameters_.end(); ++i) {
78 <            if (!i->second->isOptional() && i->second->empty()) {
79 <                std::stringstream ss;
80 <                ss <<  i->second->getKeyword()  << " must be set.\n";
81 <                throw OOPSEException(ss.str());
82 <            }
83 <          }
74 >      } else if (deprecatedKeywords_.find(keyword) !=
75 >                 deprecatedKeywords_.end()){
76 >        std::cout << keyword <<
77 >          " has been deprecated in OOPSE 3.  Please update your .md file.\n";
78 >      } else {
79 >        std::stringstream ss;
80 >        ss << keyword << " is not a recognized keyword.\n";
81 >        throw OOPSEException(ss.str());
82 >      }
83 >    }
84 >    
85 >    virtual void validate() {
86 >      ParamMap::iterator i;
87 >      for (i = parameters_.begin(); i != parameters_.end(); ++i) {
88 >        if (!i->second->isOptional() && i->second->empty()) {
89 >          std::stringstream ss;
90 >          ss <<  i->second->getKeyword()  << " must be set.\n";
91 >          throw OOPSEException(ss.str());
92          }
93 +      }
94 +    }
95      
96 <    protected:
97 <        typedef std::map<std::string, ParameterBase*> ParamMap;
98 <        
99 <        ParamMap parameters_;        
100 <        std::set<std::string> deprecatedKeywords_;
101 <        
102 <    private:
103 <        DataHolder(const DataHolder&);
104 <        DataHolder& operator=(const DataHolder&);
105 < };
106 <
96 >  protected:
97 >    typedef std::map<std::string, ParameterBase*> ParamMap;
98 >    
99 >    ParamMap parameters_;        
100 >    std::set<std::string> deprecatedKeywords_;
101 >    
102 >  private:
103 >    DataHolder(const DataHolder&);
104 >    DataHolder& operator=(const DataHolder&);
105 >  };
106 >  
107   }
108   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines