Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

CClassType.hh

Go to the documentation of this file.
00001 #ifndef RFL_CCLASSTYPE_HH
00002 #define RFL_CCLASSTYPE_HH
00003 /* C++ Reflection & Serice Library
00004  * Copyright (C) 2003  Marcus Perlick
00005  * mailto: riffraff@users.sf.net
00006  * 
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  * 
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  *
00022  * This file is part of the "C++ Reflection & Serice Library" */
00023 
00024 #include <new>
00025 
00026 #include "align.hh"
00027 #include "baseoffset.hh"
00028 #include "ClassType.hh"
00029 
00030 namespace rfl {
00031 
00032 #define RFL_POD_CCLASS 0,0,0,0,0,0,0
00033 
00034   template<typename T>
00035   class CClassType : public ClassType {
00036   public:
00037     
00038     CClassType( const char* name,
00039                 void(*create)(const Type*,void*),
00040                 void(*cCreate)(const Type*,void*,const void*),
00041                 void(*destroy)(const Type*,void*),
00042                 void(*assign)(const Type*,void*,const void*),
00043                 void*(*newObj)(const Type*),
00044                 void*(*newCopy)(const Type*,const void*),
00045                 void(*delObj)(const Type*,void*) ) :
00046       ClassType( name, sizeof(T), AlignmentOf<T>::is(), 0, &typeid(T),
00047                  create, cCreate, destroy, assign, newObj, newCopy, delObj )
00048     {}
00049 
00050     template<typename B>
00051     void addBaseClass( const CClassType<B>& baseClass );
00052     
00053     template<typename M>
00054     void addMember( const char* name, 
00055                     const Type& type,
00056                     M T::* member );
00057     
00058   };
00059 
00060   template<typename T>
00061   template<typename M>
00062   void 
00063   CClassType<T>::addMember( const char* name, 
00064                             const Type& type,
00065                             M T::* member )
00066   {
00067     Member tmp = { name, &type, (std::size_t)member };
00068     mbrs_.push_back( tmp );
00069     elmNo_ = mbrs_.size();
00070   }
00071 
00072   template<typename T>
00073   template<typename B>
00074   void
00075   CClassType<T>::addBaseClass( const CClassType<B>& baseClass )
00076   {
00077     OffsetOf<B>::template inClass<T>();
00078     BaseClass tmp = { &baseClass, 0 };
00079     bases_.push_back( tmp );
00080   }
00081 
00082 } // namespace rfl
00083 #endif // RFL_CCLASSTYPE_HH

Generated on Thu Dec 18 11:32:54 2003 for Reflection&ServiceLibrary by doxygen 1.3.2