00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <vector>
00021 #include <ostream>
00022 #include <openmbvcppinterface/group.h>
00023
00024 #ifndef _OPENMBV_SIMPLEPARAMETER_H_
00025 #define _OPENMBV_SIMPLEPARAMETER_H_
00026
00027 namespace OpenMBV {
00028
00029 typedef SimpleParameter<double> ScalarParameter;
00030 typedef SimpleParameter<std::vector<double> > VectorParameter;
00031 typedef SimpleParameter<std::vector<std::vector<double> > > MatrixParameter;
00032
00033 template<class T>
00034 class SimpleParameter {
00035 friend class Object;
00036 protected:
00037 T value;
00038 std::string paramStr;
00039 bool addParameter;
00040 SimpleParameter(const std::string& paramStr_) : value(T()), paramStr(paramStr_), addParameter(false) {}
00041 public:
00042 SimpleParameter(const T& value_) : value(value_), paramStr(""), addParameter(true) {}
00043 SimpleParameter(const std::string& paramStr_, const T& value_) : value(value_), paramStr(paramStr_), addParameter(true) {}
00044 friend std::ostream& operator<<(std::ostream &os, const SimpleParameter<T> p) {
00045 if(p.paramStr=="")
00046 os<<p.value;
00047 else
00048 os<<p.paramStr;
00049 return os;
00050 };
00051 std::string getParamStr() const { return paramStr; }
00052 T getValue() const { return value; }
00053 bool getAddParameter() { return addParameter; }
00054 };
00055
00056 template<class T>
00057 std::ostream& operator<<(std::ostream &os, const std::vector<T> p) {
00058 os<<"[";
00059 for(size_t i=0; i<p.size()-1; i++)
00060 os<<p[i]<<";";
00061 os<<p[p.size()-1]<<"]";
00062 return os;
00063 }
00064
00065 }
00066
00067 #endif