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

MCTypeTraits.h

00001 #if !defined(MCTypeTraits_H_)
00002 #define MCTypeTraits_H_
00003 
00004 #ident "@(#)$Id: MCTypeTraits.h,v 1.5 2004/12/02 07:05:20 mike Exp $"
00005 
00006 /*
00007  * Copyright Miba Consulting Ltd. (c) 2000-2003
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022  *
00023  */
00024 
00025 #include "mcllib/MCTypes.h"
00026 
00027 /*
00028  * Provides support for optimizations
00029  * There are three optimizations
00030  * - optimize destructor
00031  * - optimize copy constructor 
00032  * - optimize assignment
00033  * If the optimization is set then the relevant operation can be avoided
00034  * Otherwise the operation must be performed. This is useful when using
00035  * placement new to allocate arrays of things which may or may not be
00036  * objects. To get better performance (e.g. if your copy constructor nothing)
00037  * then specialize MCTypeTraits.
00038  * The is_pod member determines if the type is a pod (plain-old-data) type
00039  */
00040 
00041 namespace mcllib
00042 {
00051     template<typename T>
00052     struct MCTypeTraits {
00054         typedef T underlying_type;
00055         enum {
00057             destruct_opt = 0,
00059             copy_opt = 0,
00061             assign_opt = 0,
00063             is_pod = 0
00064         };
00068         typedef const underlying_type& copy_param_type;
00072         typedef const underlying_type& copy_return_type;
00073     };
00074 
00079     template<>
00080     struct MCTypeTraits<bool> {
00081         typedef bool underlying_type;
00082         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00083         typedef underlying_type copy_param_type;
00084         typedef underlying_type copy_return_type;
00085     };
00086 
00091     template<>
00092     struct MCTypeTraits<mcllib::mcint8> {
00093         typedef mcllib::mcint8 underlying_type;
00094         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00095         typedef underlying_type copy_param_type;
00096         typedef underlying_type copy_return_type;
00097     };
00098 
00103     template<>
00104     struct MCTypeTraits<mcllib::mcuint8> {
00105         typedef mcllib::mcuint8 underlying_type;
00106         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00107         typedef underlying_type copy_param_type;
00108         typedef underlying_type copy_return_type;
00109     };
00110 
00115     template<>
00116     struct MCTypeTraits<mcllib::mcint16> {
00117         typedef mcllib::mcint16 underlying_type;
00118         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00119         typedef underlying_type copy_param_type;
00120         typedef underlying_type copy_return_type;
00121     };
00122 
00127     template<>
00128     struct MCTypeTraits<mcllib::mcuint16> {
00129         typedef mcllib::mcuint16 underlying_type;
00130         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00131         typedef underlying_type copy_param_type;
00132         typedef underlying_type copy_return_type;
00133     };
00134 
00139     template<>
00140     struct MCTypeTraits<mcllib::mcint32> {
00141         typedef mcllib::mcint32 underlying_type;
00142         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00143         typedef underlying_type copy_param_type;
00144         typedef underlying_type copy_return_type;
00145     };
00146 
00151     template<>
00152     struct MCTypeTraits<mcllib::mcuint32> {
00153         typedef mcllib::mcuint32 underlying_type;
00154         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00155         typedef underlying_type copy_param_type;
00156         typedef underlying_type copy_return_type;
00157     };
00158 
00163     template<>
00164     struct MCTypeTraits<mcllib::mcint64> {
00165         typedef mcllib::mcint64 underlying_type;
00166         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00167         typedef const underlying_type& copy_param_type;
00168         typedef const underlying_type& copy_return_type;
00169     };
00170 
00175     template<>
00176     struct MCTypeTraits<mcllib::mcuint64> {
00177         typedef mcllib::mcuint64 underlying_type;
00178         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00179         typedef const underlying_type& copy_param_type;
00180         typedef const underlying_type& copy_return_type;
00181     };
00182 
00187     template<>
00188     struct MCTypeTraits<mcllib::mcfloat32> {
00189         typedef mcllib::mcfloat32 underlying_type;
00190         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00191         typedef underlying_type copy_param_type;
00192         typedef underlying_type copy_return_type;
00193     };
00194 
00199     template<>
00200     struct MCTypeTraits<mcllib::mcfloat64> {
00201         typedef mcllib::mcfloat64 underlying_type;
00202         enum { destruct_opt = 1, copy_opt = 1, assign_opt = 1, is_pod = 1 };
00203         typedef const underlying_type& copy_param_type;
00204         typedef const underlying_type& copy_return_type;
00205     };
00206 
00207 };
00208 
00209 #endif

Generated on Wed Jan 12 19:05:48 2005 for MCLLIB by  doxygen 1.3.9.1