VParameterNode.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 VPARAMETERNODE_h
00012 #define VPARAMETERNODE_h
00013 #include  <iostream>
00014 
00022 class VParameterNode{
00023 public:
00025   VParameterNode(const std::string key="", const std::string helptext="") : 
00026     _default_key(key), _node_type(VIRTUAL) , _helptext(helptext),
00027     hasread(true), haswrite(true) {}
00029   virtual ~VParameterNode() {}
00030   
00032   virtual bool SaveToFile(const char* fname, bool showhelp=false);
00034   virtual bool ReadFromFile(const char* fname, const std::string& key="",
00035                             bool suppress_errs=false);
00037   virtual std::istream& ReadFrom( std::istream& in, bool single=false)=0;
00039   virtual std::istream& ReadFromByKey( std::istream& in, 
00040                                        const std::string& key,
00041                                        bool suppress_errs=false);
00043   virtual std::ostream& WriteTo( std::ostream& out , bool showhelp=false, 
00044                                  int indent=0) const =0;
00046   const std::string& GetDefaultKey() const { return _default_key; }
00048   void SetDefaultKey(const std::string& key){ _default_key = key; }
00050   int GetNodeType(){ return _node_type; }
00052   virtual int PrintHelp(const std::string& myname="") const;
00053   
00055   const std::string& GetHelpText(){ return _helptext; }
00057   void SetHelpText(const std::string& newtext){ _helptext = newtext; }
00058   
00060   virtual VParameterNode* Clone(const void* from, void* to) const =0;
00061 
00062 protected:
00066   enum NODE_TYPES {VIRTUAL=0, PARAMETER=1, PARAMETER_LIST=2, FUNCTION=3};
00067   std::string _default_key;  
00068   int _node_type; 
00069   std::string _helptext; 
00070 public:
00071   bool hasread; 
00072   bool haswrite; 
00073 };
00074 
00075 //inline the redirect overloads
00077 inline std::istream& operator>>(std::istream& in, VParameterNode& p)
00078 {
00079   return p.ReadFrom(in);
00080 }
00081 
00083 inline std::ostream& operator<<(std::ostream& out, const VParameterNode& p)
00084 {
00085   return p.WriteTo(out);
00086 }
00087 
00088 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1