Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

Valuator_Struct_Tie.hxx

00001 
00002 // 
00003 // Copyright (C) 2006 James M. Lawrence.  All rights reserved.
00004 // 
00005 // software: esve-1.0.3
00006 // file: esve/components/dimn/Valuator_Struct_Tie.hxx
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions
00010 // are met:
00011 // 
00012 // 1. Redistributions of source code must retain the above copyright
00013 //    notice, this list of conditions and the following disclaimer.
00014 // 
00015 // 2. The origin of this software must not be misrepresented; you must
00016 //    not claim that you wrote the original software.  If you use this
00017 //    software in a product, an acknowledgment in the product 
00018 //    documentation would be appreciated but is not required.
00019 // 
00020 // 3. Altered source versions must be plainly marked as such, and must
00021 //    not be misrepresented as being the original software.
00022 // 
00023 // 4. The name of the author may not be used to endorse or promote
00024 //    products derived from this software without specific prior written
00025 //    permission.
00026 // 
00027 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY,
00028 // AND WITH NO CLAIM AS TO ITS SUITABILITY FOR ANY PURPOSE.  IN NO EVENT
00029 // SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM WHATSOEVER MADE IN CONNECTION
00030 // TO THIS SOFTWARE.
00031 // 
00033 
00034 #ifndef esve_components_dimn_Valuator_Struct_Tie_hxx
00035 #define esve_components_dimn_Valuator_Struct_Tie_hxx
00036 
00037 #include <esve/components/dimn/Valuator_Handler.hxx>
00038 #include <string>
00039 #include <map>
00040 
00041 namespace esve { namespace components { namespace dimn {
00042 
00043 template< typename T_Value > class Valuator_Creator ;
00044 
00045 //
00046 // @class Valuator_Struct_Tie esve/components/dimn/Valuator_Struct_Tie.hxx
00047 // @brief Tie valuators to a struct.
00048 //
00049 // Whenever a valuator changes, the corresponding data member is
00050 // updated.  The initial value is read from the data member.
00051 //
00052 // Make sure the tie is able to receive handle_valuator() messages.
00053 //
00054 
00055 template< typename T_Target,
00056           typename T_Value_Type >
00057 class Valuator_Struct_Tie
00058     : public Valuator_Handler<T_Value_Type>
00059 {
00060 private:
00061     typedef Valuator_Handler<T_Value_Type> super ;
00062 
00063     typedef T_Target m_Target ;
00064     typedef T_Value_Type m_Value_Type ;
00065 
00066     typedef m_Value_Type m_Target::* m_Member ;
00067     typedef std::map<Valuator<m_Value_Type>*, m_Member> m_Map ;
00068     typedef std::pair<Valuator<m_Value_Type>*, m_Member> m_Pair ;
00069     typedef typename m_Map::iterator m_Map_iterator ;
00070     typedef typename m_Map::const_iterator m_Map_const_iterator ;
00071 
00072     Valuator_Struct_Tie( const Valuator_Struct_Tie & ) ;
00073     Valuator_Struct_Tie & operator=( const Valuator_Struct_Tie & ) ;
00074 
00075     Valuator_Creator<m_Value_Type> & m_ui ;
00076     m_Target & m_target ;
00077     m_Map m_map ;
00078 
00079 public:
00080     typedef m_Target Target ;
00081     typedef m_Member Member ;
00082     typedef m_Value_Type Value_Type ;
00083 
00085     Valuator_Struct_Tie( Valuator_Creator<Value_Type> & ui,
00086                          Target & data ) ;
00087 
00089     Valuator<Value_Type> &
00090     create_valuator( Member, const std::string & name = "" ) ;
00091 
00093     void tie( Valuator<Value_Type> &, Member ) ;
00094 
00095     ~Valuator_Struct_Tie() ;
00096 
00097 protected:
00098     bool handle_valuator( const Valuator<Value_Type> & ) ;
00099 } ;
00100 
00101 }}} // namespace esve::components::dimn
00102 
00103 #include <esve/components/dimn/Valuator_Struct_Tie.template.cxx>
00104 
00105 #endif
00106 

Generated on Tue May 30 11:40:53 2006 for esve by doxygen 1.3.4