Parameters.h
Go to the documentation of this file.
00001 /*
00002  * Parameters.h
00003  *
00004  *  Created on: Oct 27, 2013
00005  *      Author: blackpc
00006  */
00007 
00008 #ifndef PARAMETERS_H_
00009 #define PARAMETERS_H_
00010 
00011 #include <iostream>
00012 #include <inttypes.h>
00013 #include <map>
00014 #include <yaml-cpp/yaml.h>
00015 #include <boost/shared_ptr.hpp>
00016 #include <boost/lexical_cast.hpp>
00017 
00018 using namespace std;
00019 
00020 typedef boost::shared_ptr<vector<string> > ParametersVectorPtr;
00021 
00022 
00023 class YamlPtr {
00024 public:
00025         YamlPtr(std::auto_ptr<YAML::Node> nodePtr) : _yamlNode(nodePtr) { }
00026         YamlPtr(const YamlPtr& yamlPtr) { this->_yamlNode = yamlPtr._yamlNode; }
00027         YamlPtr& operator=(const YamlPtr& yamlPtr) { this->_yamlNode = yamlPtr._yamlNode; return *this; }
00028 
00029         YAML::Node* get() { return _yamlNode.get(); }
00030 
00031         template <typename T> const T to() const { return _yamlNode->to<T>(); }
00032 
00033         template <typename T>
00034         inline const YAML::Node& operator [] (const T& key) const { return (*_yamlNode)[key]; }
00035         inline const YAML::Node& operator [] (const char *key) const { return (*_yamlNode)[key]; }
00036         inline const YAML::Node& operator [] (char *key) const { return (*_yamlNode)[key]; }
00037         size_t size() { return _yamlNode->size(); }
00038 
00039         string str() const {
00040                 YAML::Emitter emitter;
00041                 emitter << *_yamlNode;
00042                 return emitter.c_str();
00043         }
00044 
00045 private:
00046         mutable std::auto_ptr<YAML::Node> _yamlNode;
00047 };
00048 
00049 typedef YamlPtr Yaml;
00050 
00051 class Parameters {
00052 public:
00053 
00054         Parameters() {
00055                 _parameters = boost::shared_ptr<vector<string> >(new vector<string>());
00056         }
00057 
00058         Parameters(vector<string> parameters) {
00059                 _parameters = boost::shared_ptr<vector<string> >(new vector<string>(parameters));
00060         }
00061 
00062         Parameters(ParametersVectorPtr parameters) {
00063                 _parameters = parameters;
00064         }
00065 
00066         size_t size() { return _parameters->size(); }
00067 
00068         template<typename T> T get(uint32_t index) { return T(); }
00069         template<typename T> void set(const T& value) { _parameters->push_back(boost::lexical_cast<string>(value)); }
00070 
00071 private:
00072         ParametersVectorPtr _parameters;
00073 };
00074 
00075 
00076 
00077 #endif /* PARAMETERS_H_ */


scriptable_monitor
Author(s):
autogenerated on Wed Aug 26 2015 16:21:30