ConfigFunctor.hh

Go to the documentation of this file.
00001 //Copyright 2013 Ben Loer
00002 //This file is part of the ConfigHandler library
00003 //It is released under the terms of the GNU General Public License v3
00004 
00011 #ifndef CONFIGFUNCTOR_h 
00012 #define CONFIGFUNCTOR_h 
00013 
00031 #include "ParameterIOimpl.hh"
00032 
00033 template <typename readfunc, typename writefunc>
00034 class ConfigFunctor : public VParameterNode{
00035 public:
00036   ConfigFunctor(const readfunc& r, const writefunc& w, 
00037                 const std::string& key="", const std::string& helptext="") : 
00038     VParameterNode(key, helptext), reader(r), writer(w) { _node_type=FUNCTION;}
00039   ~ConfigFunctor(){}
00040   
00041   std::istream& ReadFrom(std::istream& in, bool dummy=0){ return reader(in);}
00042   std::ostream& WriteTo(std::ostream& out, bool dummy1=0, int dummy=0) const
00043   { return writer(out);}
00044   
00045   ConfigFunctor<readfunc, writefunc>* Clone(const void* from, void* to) const
00046   { return new ConfigFunctor<readfunc, writefunc>(*this); }
00047 private:
00048   readfunc reader;
00049   writefunc writer;
00050 };
00051 
00053 struct ConfigFunctorDummyRead{
00054   std::istream& operator()(std::istream& in){ return in; }
00055 };
00057 struct ConfigFunctorDummyWrite{
00058   std::ostream& operator()(std::ostream& out) const{ return out; }
00059 };
00060 
00061 template<class T> struct DeprecatedParameter{
00062   std::istream& operator()(std::istream& in){ T t; return ParameterIOimpl::read(in,t); }
00063 };
00064 
00065 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1