iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ValidValuesSpecImpl.H
Go to the documentation of this file.
1 /*! @file
2  @author Randolph Voorhies
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 #ifndef INCLUDE_NRT_CORE_TYPING_DETAILS_VALIDVALUESSPECIMPL_H
37 #define INCLUDE_NRT_CORE_TYPING_DETAILS_VALIDVALUESSPECIMPL_H
38 
39 #include <sstream>
41 
42 // ######################################################################
43 // ######################################################################
44 // ######################################################################
45 template <class T> inline
47 { }
48 
49 template <class T> inline
51 { }
52 
53 // ######################################################################
54 // ######################################################################
55 // ######################################################################
56 template <class T> inline
58 { }
59 
60 template <class T> inline
62 { }
63 
64 template <class T> inline
66 { return true; }
67 
68 template <class T> inline
69 std::string const nrt::ValidValuesSpecNone<T>::str() const
70 { return "None:[]"; }
71 
72 // ######################################################################
73 // ######################################################################
74 // ######################################################################
75 template <class T> inline
76 nrt::ValidValuesSpecList<T>::ValidValuesSpecList(std::vector<T> const & valid_list) :
77  ValidValuesSpecBase<T>(), itsValidList(valid_list)
78 { }
79 
80 template <class T> inline
82 { }
83 
84 template <class T> inline
86 {
87  for (T const & v : itsValidList) if (val == v) return true;
88  return false;
89 }
90 
91 template <class T> inline
92 std::string const nrt::ValidValuesSpecList<T>::str() const
93 {
94  std::ostringstream os;
95  os << "List:[";
96  for (T const & v : itsValidList) os << v << '|';
97  os.seekp(-1, std::ios_base::end); os << ']';
98  return os.str();
99 }
100 
101 // ######################################################################
102 // ######################################################################
103 // ######################################################################
104 template <class T> inline
106  ValidValuesSpecBase<T>(), itsValidRange(valid_range)
107 { }
108 
109 template <class T> inline
111 { }
112 
113 template <class T> inline
115 {
116  return (val >= itsValidRange.min() && val <= itsValidRange.max());
117 }
118 
119 template <class T> inline
120 std::string const nrt::ValidValuesSpecRange<T>::str() const
121 {
122  std::ostringstream os;
123  os << "Range:[" << itsValidRange << ']';
124  return os.str();
125 }
126 
127 // ######################################################################
128 // ######################################################################
129 // ######################################################################
130 template <class T> inline
131 nrt::ValidValuesSpecRegex<T>::ValidValuesSpecRegex(boost::regex const & valid_regex) :
132  ValidValuesSpecBase<T>(), itsValidRegex(valid_regex)
133 { }
134 
135 template <class T> inline
137 { }
138 
139 template <class T> inline
141 {
142  std::string v; nrt::paramValToString(val, v);
143  return boost::regex_match(v, itsValidRegex);
144 }
145 
146 template <class T> inline
147 std::string const nrt::ValidValuesSpecRegex<T>::str() const
148 {
149  std::ostringstream os;
150  os << "Regex:[" << itsValidRegex.str() << ']';
151  return os.str();
152 }
153 
154 #endif // INCLUDE_NRT_CORE_TYPING_DETAILS_VALIDVALUESSPECIMPL_H
155