rc_fallback_interface.h

Go to the documentation of this file.
00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0:
00002 /*
00003  * Copyright (C) 2007, Technical Computer Science Group,
00004  *                     University of Bonn
00005  *
00006  * This file is part of the ReChannel library.
00007  *
00008  * The ReChannel library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be
00014  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this library; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022  *
00023  * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke.
00024  *          {raabe, felke}@cs.uni-bonn.de
00025  */
00037 #ifndef RC_FALLBACK_INTERFACE_H_
00038 #define RC_FALLBACK_INTERFACE_H_
00039 
00040 #include <boost/type_traits/is_empty.hpp>
00041 //#include "ReChannel/util/rc_report.h"
00042 
00043 namespace ReChannel {
00044 
00048 template<class T>
00049 inline
00050 T rc_undefined_value()
00051 {
00052     return T();
00053 }
00054 
00058 template<class IF>
00059 class rc_fallback_interface
00060 {
00061     // must be an empty class
00062 };
00063 
00067 template<
00068     class IF, bool IF_EXISTS =
00069     !(boost::is_empty<rc_fallback_interface<IF> >::value)
00070 >
00071 class rc_fallback_interface_factory;
00072 
00076 template<class IF>
00077 class rc_fallback_interface_factory<IF, true>
00078 {
00079 public:
00080     static inline IF* create()
00081         { return (IF*)(new rc_fallback_interface<IF>()); }
00082 
00083 private:
00084     rc_fallback_interface_factory() {} //disabled
00085 };
00086 
00090 template<class IF>
00091 class rc_fallback_interface_factory<IF, false>
00092 {
00093 public:
00094     static inline IF* create()
00095         { return 0; }
00096 
00097 private:
00098     rc_fallback_interface_factory() {} //disabled
00099 };
00100 
00101 } // namespace ReChannel
00102 
00103 #define RC_UNDEFINED_VALUE(value_type, value) \
00104     namespace ReChannel { \
00105         template<> \
00106         inline value_type rc_undefined_value<value_type >() \
00107             { return (value); } \
00108     }
00109 
00110 #define RC_FALLBACK_INTERFACE(interface_type) \
00111     template<> \
00112     struct rc_fallback_interface<interface_type> \
00113         : virtual public interface_type
00114 
00115 #define RC_FALLBACK_INTERFACE_TEMPLATE(interface_type) \
00116     struct rc_fallback_interface<interface_type > \
00117         : virtual public interface_type
00118 
00119 #define RC_FALLBACK_INTERFACE_CTOR(interface_type) \
00120     rc_fallback_interface()
00121 
00122 #define RC_FALLBACK_INTERFACE_TEMPLATE_CTOR(interface_type) \
00123     RC_FALLBACK_INTERFACE_CTOR(interface_type)
00124 
00125 #endif // RC_FALLBACK_INTERFACE_H_
00126 
00127 //
00128 // $Id: rc_fallback_interface.h,v 1.3 2007/12/06 11:46:32 felke Exp $
00129 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/rc_fallback_interface.h,v $
00130 //

Generated on Tue Jan 1 23:13:34 2008 for ReChannel by  doxygen 1.5.3