MINT2
NamedParameter.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:55 GMT
3 #include "Mint/NamedParameter.h"
4 
5 using namespace MINT;
6 /*
7  not much to do - it's a template
8  and it likes to live in the header.
9  Specialiations go here, though.
10 */
11 
12 template<>
15  std::cout << "WARNING in MINT::NamedParameter<std::string>::operator-=:"
16  << "\n\t OPERATOR \"-=\" undefined for strings"
17  << "\n\t you tried: " << (std::string)(*this)
18  << " -= " << rhs
19  << std::endl;
20  return *this;
21 }
22 
23 template<>
26  std::cout << "WARNING in MINT::NamedParameter<std::string>::operator-=:"
27  << "\n\t OPERATOR \"*=\" undefined for strings"
28  << "\n\t you tried: " << (std::string)(*this)
29  << " *= " << rhs
30  << std::endl;
31  return *this;
32 }
33 
34 template<>
37  std::cout << "WARNING in MINT::NamedParameter<std::string>::operator-=:"
38  << "\n\t OPERATOR \"/=\" undefined for strings"
39  << "\n\t you tried: " << (std::string)(*this)
40  << " /= " << rhs
41  << std::endl;
42  return *this;
43 }
44 
45 
46 template<>
48  const std::vector<std::string>& vsl = line.parsedStrings();
49  if(vsl.size() < 2) return false; // first element is parameter name
50  if(vsl[0] != _name){
51  std::cout << "ERROR IN NamedParameter<string>::setFromParsedLine"
52  << " wrong parameter name. My name is " << _name
53  << " the line's first element is " << vsl[0]
54  << std::endl;
55  return false;
56  }
57  for(unsigned int i=1; i< vsl.size(); i++){
58  setVal(vsl[i], i-1);
59  }
60  return true;
61 }
62 
63 template<>
64 void MINT::NamedParameter<std::string>::print(std::ostream& os) const{
65  os << "\"" << name() << "\" ";
66  if(size()==0){
67  return;
68  }else{
69  for(int i=0; i< size(); i++){
70  os << "\"" << getVal(i) << "\" ";
71  if(i != size()) os << " ";
72  }
73  }
74 }
75 
77 //
const std::vector< std::string > & parsedStrings() const
virtual void print(std::ostream &os=std::cout) const
virtual bool setFromParsedLine(const ParsedParameterLine &line)
NamedParameter< T > & operator-=(const T &rhs)
NamedParameter< T > & operator/=(const T &rhs)
NamedParameter< T > & operator *=(const T &rhs)