Cortex  10.0.0-a4
CompoundParameter.h
1 //
3 // Copyright (c) 2007-2013, 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_CORE_COMPOUNDPARAMETER_H
36 #define IE_CORE_COMPOUNDPARAMETER_H
37 
38 #include "IECore/Export.h"
39 #include "IECore/Parameter.h"
40 #include "IECore/CompoundObject.h"
41 
42 namespace IECore
43 {
44 
47 class IECORE_API CompoundParameter : public Parameter
48 {
49  public :
50 
51  IE_CORE_DECLARERUNTIMETYPED( CompoundParameter, Parameter );
52 
54  typedef std::map<InternedString, ParameterPtr> ParameterMap;
56  typedef std::vector<ParameterPtr> ParameterVector;
57 
61  CompoundParameter( const std::string &name = "", const std::string &description = "", ConstCompoundObjectPtr userData=nullptr, bool adoptChildPresets=true );
65  template<typename I>
66  CompoundParameter( const std::string &name, const std::string &description, I membersBegin, I membersEnd, ConstCompoundObjectPtr userData=nullptr, bool adoptChildPresets=true );
67 
70 
71  const Object *defaultValue() const override;
80  const PresetsContainer &getPresets() const override;
83  void setPresets( const PresetsContainer &presets ) override;
86  bool presetsOnly() const override;
89  bool valueValid( const Object *value, std::string *reason = nullptr ) const override;
93  void setValue( ObjectPtr value ) override;
97  Object *getValue() override;
99  const Object *getValue() const override;
101 
106 
107  void addParameter( ParameterPtr parameter );
112  template<typename I>
113  void addParameters( I begin, I end );
117  void insertParameter( ParameterPtr parameter, ConstParameterPtr other );
120  void removeParameter( ParameterPtr parameter );
123  void removeParameter( const std::string &name );
125  void clearParameters();
130  const ParameterMap &parameters() const;
134  const ParameterVector &orderedParameters() const;
138  template<typename T>
139  T *parameter( const std::string &name );
140  template<typename T>
141  const T *parameter( const std::string &name ) const;
145  bool parameterPath( const Parameter *child, std::vector<std::string> &path ) const;
148  void setParameterValue( const std::string &name, ObjectPtr value );
151  void setValidatedParameterValue( const std::string &name, ObjectPtr value );
155  Object *getParameterValue( const std::string &name );
159  Object *getValidatedParameterValue( const std::string &name );
161 
162  private :
163 
164  ParameterMap m_namesToParameters;
165  ParameterVector m_parameters;
166  bool m_adoptChildPresets;
167 
168 };
169 
170 IE_CORE_DECLAREPTR( CompoundParameter );
171 
172 } // namespace IECore
173 
174 #include "IECore/CompoundParameter.inl"
175 
176 #endif // IE_CORE_COMPOUNDPARAMETER_H
Definition: Parameter.h:53
std::vector< ParameterPtr > ParameterVector
A type to hold a vector of Parameters.
Definition: CompoundParameter.h:56
std::vector< Preset > PresetsContainer
A type to store a bunch of preset values for the Parameter.
Definition: Parameter.h:63
Definition: Object.h:104
Definition: CompoundParameter.h:47
std::map< InternedString, ParameterPtr > ParameterMap
A type to map from names to Parameters.
Definition: CompoundParameter.h:54
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43