00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WGESHADERPROPERTYDEFINEOPTIONS_H
00026 #define WGESHADERPROPERTYDEFINEOPTIONS_H
00027
00028 #include <string>
00029 #include <vector>
00030
00031 #include <boost/shared_ptr.hpp>
00032 #include "boost/tuple/tuple.hpp"
00033 #include <boost/signals2.hpp>
00034
00035 #include "../../common/WProperties.h"
00036 #include "../../common/WPropertyTypes.h"
00037 #include "../../common/exceptions/WPreconditionNotMet.h"
00038
00039 #include "WGEShaderDefineOptions.h"
00040
00041 template< typename PropType >
00042 class WGEShaderPropertyDefineOptionsIndexAdapter;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 template< typename PropType = WPropSelection, typename PropIndexAdapter = WGEShaderPropertyDefineOptionsIndexAdapter< PropType > >
00055 class WGEShaderPropertyDefineOptions: public WGEShaderDefineOptions
00056 {
00057 public:
00058
00059
00060
00061
00062 typedef boost::shared_ptr< WGEShaderPropertyDefineOptions > SPtr;
00063
00064
00065
00066
00067 typedef boost::shared_ptr< const WGEShaderPropertyDefineOptions > ConstSPtr;
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 WGEShaderPropertyDefineOptions( PropType prop, std::string first,
00086 std::string option2 = "", std::string option3 = "", std::string option4 = "", std::string option5 = "",
00087 std::string option6 = "", std::string option7 = "", std::string option8 = "", std::string option9 = "",
00088 std::string option10 = "" );
00089
00090
00091
00092
00093
00094
00095
00096
00097 WGEShaderPropertyDefineOptions( PropType prop, std::vector< std::string > options );
00098
00099
00100
00101
00102 virtual ~WGEShaderPropertyDefineOptions();
00103
00104
00105
00106
00107
00108
00109 PropType getProperty() const;
00110
00111 protected:
00112
00113 private:
00114
00115
00116
00117
00118 PropType m_property;
00119
00120
00121
00122
00123 boost::signals2::connection m_connection;
00124
00125
00126
00127
00128 void propUpdated();
00129 };
00130
00131
00132
00133
00134 namespace WGEShaderPropertyDefineOptionsTools
00135 {
00136
00137
00138
00139 typedef boost::tuple< std::string, std::string, std::string > NameDescriptionDefineTuple;
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 WGEShaderPropertyDefineOptions< WPropSelection >::SPtr createSelection( std::string propName, std::string propDescription,
00152 WProperties::SPtr propGroup,
00153 std::vector< NameDescriptionDefineTuple > defines );
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 template< typename PropType >
00163 class WGEShaderPropertyDefineOptionsIndexAdapter
00164 {
00165 public:
00166
00167
00168
00169 typedef typename WGEShaderPropertyDefineOptions< PropType >::IdxList IdxList;
00170
00171
00172
00173
00174
00175
00176
00177
00178 IdxList operator()( const typename PropType::element_type::ValueType& in ) const
00179 {
00180 return IdxList( 1, typename IdxList::value_type( in ) );
00181 }
00182 };
00183
00184
00185
00186
00187
00188
00189
00190 template<>
00191 class WGEShaderPropertyDefineOptionsIndexAdapter< WPropSelection >
00192 {
00193 public:
00194
00195
00196
00197 typedef WGEShaderPropertyDefineOptions< WPropSelection >::IdxList IdxList;
00198
00199
00200
00201
00202
00203
00204
00205
00206 IdxList operator()( const WPVBaseTypes::PV_SELECTION& in ) const
00207 {
00208 return in.getIndexList();
00209 }
00210 };
00211
00212 template< typename PropType, typename PropIndexAdapter >
00213 WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >::WGEShaderPropertyDefineOptions( PropType prop, std::string first,
00214 std::string option2, std::string option3, std::string option4, std::string option5,
00215 std::string option6, std::string option7, std::string option8, std::string option9,
00216 std::string option10 ):
00217 WGEShaderDefineOptions( first, option2, option3, option4, option5, option6, option7, option8, option9, option10 ),
00218 m_property( prop )
00219 {
00220
00221 m_connection = m_property->getValueChangeCondition()->subscribeSignal(
00222 boost::bind( &WGEShaderPropertyDefineOptions< PropType >::propUpdated, this )
00223 );
00224 propUpdated();
00225 }
00226
00227 template< typename PropType, typename PropIndexAdapter >
00228 WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >::WGEShaderPropertyDefineOptions( PropType prop, std::vector< std::string > options ):
00229 WGEShaderDefineOptions( options ),
00230 m_property( prop )
00231 {
00232
00233 m_connection = m_property->getValueChangeCondition()->subscribeSignal(
00234 boost::bind( &WGEShaderPropertyDefineOptions< PropType >::propUpdated, this )
00235 );
00236 propUpdated();
00237 }
00238
00239 template< typename PropType, typename PropIndexAdapter >
00240 WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >::~WGEShaderPropertyDefineOptions()
00241 {
00242
00243 }
00244
00245 template< typename PropType, typename PropIndexAdapter >
00246 void WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >::propUpdated()
00247 {
00248 PropIndexAdapter functor;
00249 setActivationList( functor( m_property->get() ) );
00250 }
00251
00252 template< typename PropType, typename PropIndexAdapter >
00253 PropType WGEShaderPropertyDefineOptions< PropType, PropIndexAdapter >::getProperty() const
00254 {
00255 return m_property;
00256 }
00257
00258 #endif // WGESHADERPROPERTYDEFINEOPTIONS_H
00259