ExtendedEventChannel.h
Go to the documentation of this file.00001 /******************************************************************************* 00002 * 00003 * Copyright (c) 2008-2010 Michael Schulze <mschulze@ivs.cs.uni-magdeburg.de> 00004 * Copyright (c) 2010 Marcus Förster <marcusfoerster1@gmx.de> 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in 00016 * the documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * * Neither the name of the copyright holders nor the names of 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00028 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00029 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00030 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00031 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00032 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00033 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * 00037 * $Id$ 00038 * 00039 ******************************************************************************/ 00040 00041 #ifndef __ExtendedEventChannel_h__ 00042 #define __ExtendedEventChannel_h__ 00043 00044 #include "mw/common/Subject.h" 00045 00046 #include "boost/mpl/eval_if.hpp" 00047 #include "boost/mpl/vector.hpp" 00048 #include "mw/attributes/AttributeSet.h" 00049 #include "mw/attributes/detail/RequirementChecker.h" 00050 #include "config/type_traits/contains_type.h" 00051 00052 #include "assert/staticwarning.h" 00053 00054 IF_CONTAINS_TYPE_(attributeProvision); 00055 00056 namespace famouso { 00057 namespace mw { 00058 namespace api { 00059 00084 template <typename EC, typename Requirement, bool compileError = true> 00085 class ExtendedEventChannel : public EC { 00086 public: 00094 ExtendedEventChannel(const Subject& subject) : EC(subject) { } 00095 00096 private: 00097 // The event channel handler which is provided by the given 00098 // event channel 00099 typedef typename EC::eventChannelHandler ECH; 00100 00101 // Find out if the event channel handler defined a provision 00102 static const bool echHasProvision = 00103 if_contains_type_attributeProvision<ECH>::value; 00104 00105 // Issue a warning if it did not 00106 FAMOUSO_STATIC_ASSERT_WARNING( 00107 echHasProvision, 00108 no_provision_defined_by_event_channel_handler, 00109 (EC) 00110 ); 00111 00112 // Dummy struct for wrapping an empty provision (in the case that 00113 // the handler did not define a provision) 00114 struct EmptyProvisionProvider { 00115 typedef attributes::AttributeSet< 00116 boost::mpl::vector<> 00117 > attributeProvision; 00118 00119 typedef EmptyProvisionProvider type; 00120 }; 00121 00122 // Attribute provision of the given event channel handler (or an 00123 // an empty provision if the handler did not define any) 00124 typedef typename boost::mpl::eval_if_c< 00125 echHasProvision, 00126 ECH, 00127 EmptyProvisionProvider 00128 >::type::attributeProvision echProvision; 00129 00130 // The requirement of this event channel given by the attribute set above 00131 typedef Requirement ecRequirement; 00132 00133 // The type which checks the provision of the ECH against the given 00134 // requirement (This one does the actual work) 00135 typedef typename attributes::detail::RequirementChecker< 00136 echProvision, 00137 ecRequirement, 00138 compileError 00139 >::type checker; 00140 }; 00141 00142 } // namespace api 00143 } // namespace mw 00144 } // namespace famouso 00145 00146 #endif /* __PublisherEventChannel_h__ */