Cortex  10.0.0-a4
FromMayaPlugConverter.h
1 //
3 // Copyright (c) 2007-2011, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IE_COREMAYA_FROMMAYAPLUGCONVERTER_H
36 #define IE_COREMAYA_FROMMAYAPLUGCONVERTER_H
37 
38 #include "IECoreMaya/FromMayaConverter.h"
39 
40 #include "IECore/Object.h"
41 
42 #include "maya/MPlug.h"
43 #include "maya/MFnNumericData.h"
44 #include "maya/MFnUnitAttribute.h"
45 
46 #include <map>
47 
48 namespace IECoreMaya
49 {
50 
51 IE_CORE_FORWARDDECLARE( FromMayaPlugConverter );
52 
56 {
57 
58  public :
59 
60  IE_CORE_DECLARERUNTIMETYPEDEXTENSION( FromMayaPlugConverter, FromMayaPlugConverterTypeId, FromMayaConverter );
61 
63  const MPlug &plug() const;
64 
70  static FromMayaConverterPtr create( const MPlug &plug, IECore::TypeId resultType=IECore::InvalidTypeId );
71 
72  protected :
73 
74  FromMayaPlugConverter( const MPlug &plug );
75 
78  template<class T>
80  {
81  public :
82  Description( MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter );
83  Description( MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter );
84  Description( MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter );
85  private :
86  static FromMayaPlugConverterPtr creator( const MPlug &object );
87  };
88 
89  private :
90 
91  typedef FromMayaPlugConverterPtr (*CreatorFn)( const MPlug &plug );
92  static void registerConverter( MFnNumericData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator );
93  static void registerConverter( MFnData::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator );
94  static void registerConverter( MFnUnitAttribute::Type fromType, IECore::TypeId resultType, bool isDefaultConverter, CreatorFn creator );
95 
96  typedef std::pair<MFnNumericData::Type, IECore::TypeId> NumericTypePair;
97  typedef std::map<NumericTypePair, CreatorFn> NumericTypesToFnsMap;
98  typedef std::map<MFnNumericData::Type, NumericTypesToFnsMap::const_iterator> NumericDefaultConvertersMap;
99  static NumericTypesToFnsMap &numericTypesToFns();
100  static NumericDefaultConvertersMap &numericDefaultConverters();
101 
102  typedef std::pair<MFnData::Type, IECore::TypeId> TypedTypePair;
103  typedef std::map<TypedTypePair, CreatorFn> TypedTypesToFnsMap;
104  typedef std::map<MFnData::Type, TypedTypesToFnsMap::const_iterator> TypedDefaultConvertersMap;
105  static TypedTypesToFnsMap &typedTypesToFns();
106  static TypedDefaultConvertersMap &typedDefaultConverters();
107 
108  typedef std::pair<MFnUnitAttribute::Type, IECore::TypeId> UnitTypePair;
109  typedef std::map<UnitTypePair, CreatorFn> UnitTypesToFnsMap;
110  typedef std::map<MFnUnitAttribute::Type, UnitTypesToFnsMap::const_iterator> UnitDefaultConvertersMap;
111  static UnitTypesToFnsMap &unitTypesToFns();
112  static UnitDefaultConvertersMap &unitDefaultConverters();
113 
114  MPlug m_plug;
115 
116 };
117 
118 } // namespace IECoreMaya
119 
120 #include "IECoreMaya/FromMayaPlugConverter.inl"
121 
122 #endif // IE_COREMAYA_FROMMAYAPLUGCONVERTER_H
Definition: FromMayaConverter.h:48
static FromMayaConverterPtr create(const MPlug &plug, IECore::TypeId resultType=IECore::InvalidTypeId)
TypeId
Definition: TypeIds.h:46
const MPlug & plug() const
The MPlug which will be converted by the convert() function.
The IECoreMaya namespace holds all the functionality of libIECoreMaya.
Definition: BoolParameterHandler.h:44
Definition: FromMayaPlugConverter.h:79
Definition: FromMayaPlugConverter.h:55