Aegis  4.25.D505
/home/archives/aegis/branch.4/branch.25/delta28933.505/libaegis/introspector/boolean/by_method.h
Go to the documentation of this file.
00001 //
00002 // aegis - project change supervisor
00003 // Copyright (C) 2008 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License along
00016 // with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIBAEGIS_INTROSPECTOR_BOOLEAN_BY_METHOD_H
00020 #define LIBAEGIS_INTROSPECTOR_BOOLEAN_BY_METHOD_H
00021 
00022 #include <libaegis/introspector/boolean.h>
00023 
00031 template <class T>
00032 class introspector_boolean_by_method:
00033     public introspector_boolean
00034 {
00035 public:
00039     virtual ~introspector_boolean_by_method(){}
00040 
00041 private:
00053     introspector_boolean_by_method(T &a_object, void (T::*a_set)(bool),
00054             bool (T::*a_is_set)() const) :
00055         object(a_object),
00056         set(a_set),
00057         is_set(a_is_set)
00058     {
00059     }
00060 
00061 public:
00073     static pointer
00074     create(T &a_object, void (T::*a_set)(bool), bool (T::*a_is_set)()const)
00075     {
00076         return
00077             pointer
00078             (
00079                 new introspector_boolean_by_method(a_object, a_set, a_is_set)
00080             );
00081     }
00082 
00083 protected:
00084     // See base class for documentation.
00085     void
00086     enumeration(const nstring &name)
00087     {
00088         if (name == "true")
00089             (object.*set)(true);
00090         else if (name == "false")
00091             (object.*set)(false);
00092         else
00093             value_of_type_required();
00094     }
00095 
00096 private:
00101     T &object;
00102 
00107     void (T::*set)(bool);
00108 
00113     bool (T::*is_set)() const;
00114 
00118     introspector_boolean_by_method();
00119 
00123     introspector_boolean_by_method(const introspector_boolean_by_method &);
00124 
00128     introspector_boolean_by_method &operator=(
00129         const introspector_boolean_by_method &);
00130 };
00131 
00132 #endif // LIBAEGIS_INTROSPECTOR_BOOLEAN_BY_METHOD_H