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

RepDef.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       RepDef.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose: Provides a set of macros to define data and pointer classes.
00019   See class RepPtrStore in Rep.h.
00020 
00021 /-*/
00022 #ifndef RepDef_h
00023 #define RepDef_h
00024 
00025 #include <y2util/Rep.h>
00026 
00028 //
00029 // NOTE: Data classes must inherit class Rep:
00030 //
00031 // class CLNAME : public Rep {
00032 //   REP_BODY(CLNAME);
00033 //   ...
00034 // };
00035 //
00037 
00038 #define REP_BODY(NAME)         GEN_REP_BODY( NAME, #NAME )
00039 
00041 
00042 #define GEN_REP_BODY(CLNAME,STRNAME)                    \
00043   CLNAME( const CLNAME & );            /* no copy */    \
00044   CLNAME & operator=(const CLNAME & ); /* no assign */  \
00045   public:                                               \
00046     virtual const char * repName() const                \
00047       { return STRNAME; }                               \
00048     virtual size_t mem_size () const { return sizeof (CLNAME); }\
00049   private:
00050 
00052 
00053 #define DEFINE_BASE_POINTER(NAME)                               \
00054   class NAME;                                                   \
00055   typedef Ptr<NAME>      NAME##Ptr;                             \
00056   typedef constPtr<NAME> const##NAME##Ptr;                      \
00057   extern template class RepPtrStore<NAME>;                      \
00058   extern template class RepPtrStore<const NAME>;
00059 
00060 #define DEFINE_DERIVED_POINTER(NAME,BASE)                       \
00061   class NAME;                                                   \
00062   typedef Ptr<NAME,BASE>      NAME##Ptr;                        \
00063   typedef constPtr<NAME,BASE> const##NAME##Ptr;                 \
00064   extern template class RepPtrStore<NAME,BASE>;                 \
00065   extern template class RepPtrStore<const NAME,const BASE>;
00066 
00068 
00069 #define IMPL_BASE_POINTER(NAME)                                 \
00070 template class RepPtrStore<NAME>;                               \
00071 template class RepPtrStore<const NAME>;
00072 
00073 #define IMPL_DERIVED_POINTER(NAME,BASE)                         \
00074 template class RepPtrStore<NAME,BASE>;                          \
00075 template class RepPtrStore<const NAME,const BASE>;
00076 
00078 
00079 #endif // RepDef_h

Generated on Thu Feb 23 23:56:10 2006 for liby2util by doxygen 1.3.6