Veda/PackLong_WithLimits.h

Go to the documentation of this file.
00001 /*! \file 
00002     \author victorien ferry & www.m4nkind.com
00003     \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING.
00004 */
00005 #ifndef COM_M4NKIND_PackLong_WithLimits_H
00006 #define COM_M4NKIND_PackLong_WithLimits_H
00007 
00008 #include "PackLong.h"
00009 
00010 /*!
00011     \class  PackLong_WithLimits
00012     \ingroup    BaseSerializableClass
00013     \brief   PackLong_WithLimits specialize PackLong to define a min and max value
00014             possible for this signed integer value. Specify these min,max after
00015             serialisation member registration. When compiled as non-editable,
00016             this class become a classic PackLong, nothing more is compiled.
00017 */
00018 
00019 #ifdef _ENGINE_EDITABLE_
00020 // if we are in editable mode:
00021 class PackLong_WithLimits : public PackLong
00022 {
00023 /*==================================================================
00024                                 PUBLIC
00025 ==================================================================*/
00026 public:
00027     /*!
00028         \brief  Constructor. 
00029     */
00030     PackLong_WithLimits(void);
00031     /*!
00032         \brief  Destructor. 
00033     */
00034     virtual ~PackLong_WithLimits(void);
00035 
00036     /*!
00037         \brief  Each BaseType's inherited classes must explicit an ID for their
00038                 class, or let use one of the super class at least through this virtual method.
00039                 This is needed by GUIs to detect the types of each sub-members, and shape
00040                 an interface for each Object according to their member list.
00041         \return a const character string, that must be unique and unchanged for all serializable base type.
00042     */
00043     virtual const char *GetClassID() const { return "PackLong_WithLimits"; };
00044 
00045     /*!
00046         \brief set the value of this type, which will be cut to teh defined limits.
00047         \param _value the value to set, which will be cut to teh defined limits.
00048     */
00049     virtual void Set( signed int _value );
00050 
00051     /*!
00052         \brief set the minimum and maximum values possible for this type.
00053          It has to be used at init. Doon't use it directly, use macro PACKLONG_WITHLIMITS_SETMINMAX()
00054          to be compatible with non editable compilation mode.
00055         \param _min the minimum value possible for this object.
00056         \param _max the maximum value possible for this object.
00057     */
00058     void    SetMinMax( signed int _min, signed int _max );
00059 
00060     /*!
00061         \brief get the minimum 
00062     */
00063     inline int GetMin(){return(m_Minimum);};    
00064     /*!
00065         \brief set the maximum values possible for this type.
00066     */
00067     inline int GetMax(){return(m_Maximum);};    
00068 
00069 /*==================================================================
00070                                 PROTECTED
00071 ==================================================================*/
00072 protected:
00073     signed int  m_Minimum;
00074     signed int  m_Maximum;
00075 };
00076 /*!
00077     \def    REGISTER_MEMBER_WITHLIMITS_SETMINMAX
00078 
00079     \brief  This macro is used for member registration to specify the limits possible for this member:
00080 */
00081 #define     REGISTER_MEMBER_WITHLIMITS_SETMINMAX(_object,_MemberName,_DefaultVal,_min,_max) \
00082 REGISTER_MEMBER(_object,_MemberName)\
00083 _object.SetMinMax( _min, _max );\
00084 _object.Set(_DefaultVal);
00085 #else
00086 /*==================================================================
00087                                 WHEN NON EDITABLE:
00088 ==================================================================*/
00089 // if we are in non-editable mode:
00090 typedef PackLong PackLong_WithLimits;
00091 /*!
00092     \def    REGISTER_MEMBER_WITHLIMITS_SETMINMAX
00093 
00094     \brief  This macro is used after member registration to specify the limits possible for this member.
00095             In non-editable mode, it does nothing.
00096 */
00097 
00098 #define     REGISTER_MEMBER_WITHLIMITS_SETMINMAX(_object,_MemberName,_DefaultVal,_min,_max) \
00099 REGISTER_MEMBER(_object,_MemberName)
00100 
00101 // end of editable mode test :
00102 #endif
00103 
00104 // end of file:
00105 #endif

      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/