Cortex
10.0.0-a4
|
#include <CompoundParameter.h>
Public Types | |
typedef std::map< InternedString, ParameterPtr > | ParameterMap |
A type to map from names to Parameters. | |
typedef std::vector< ParameterPtr > | ParameterVector |
A type to hold a vector of Parameters. | |
![]() | |
typedef std::pair< std::string, ObjectPtr > | Preset |
typedef std::vector< Preset > | PresetsContainer |
A type to store a bunch of preset values for the Parameter. | |
![]() | |
typedef RefCounted | BaseClass |
A typedef for the class this class derives from. All RunTimeTyped classes define this typedef. | |
![]() | |
typedef size_t | RefCount |
Public Member Functions | |
IE_CORE_DECLARERUNTIMETYPED (CompoundParameter, Parameter) | |
CompoundParameter (const std::string &name="", const std::string &description="", ConstCompoundObjectPtr userData=nullptr, bool adoptChildPresets=true) | |
template<typename I > | |
CompoundParameter (const std::string &name, const std::string &description, I membersBegin, I membersEnd, ConstCompoundObjectPtr userData=nullptr, bool adoptChildPresets=true) | |
Parameter method overrides. | |
const Object * | defaultValue () const override |
const PresetsContainer & | getPresets () const override |
void | setPresets (const PresetsContainer &presets) override |
bool | presetsOnly () const override |
bool | valueValid (const Object *value, std::string *reason=nullptr) const override |
void | setValue (ObjectPtr value) override |
Object * | getValue () override |
const Object * | getValue () const override |
As above. | |
Child Parameter access | |
These functions provide access to the child parameters held by the CompoundParameter. | |
void | addParameter (ParameterPtr parameter) |
template<typename I > | |
void | addParameters (I begin, I end) |
void | insertParameter (ParameterPtr parameter, ConstParameterPtr other) |
void | removeParameter (ParameterPtr parameter) |
void | removeParameter (const std::string &name) |
void | clearParameters () |
Removes all child parameters. | |
const ParameterMap & | parameters () const |
const ParameterVector & | orderedParameters () const |
template<typename T > | |
T * | parameter (const std::string &name) |
template<typename T > | |
const T * | parameter (const std::string &name) const |
bool | parameterPath (const Parameter *child, std::vector< std::string > &path) const |
void | setParameterValue (const std::string &name, ObjectPtr value) |
void | setValidatedParameterValue (const std::string &name, ObjectPtr value) |
Object * | getParameterValue (const std::string &name) |
Object * | getValidatedParameterValue (const std::string &name) |
![]() | |
IE_CORE_DECLARERUNTIMETYPED (Parameter, RunTimeTyped) | |
Parameter (const std::string &name, const std::string &description, ObjectPtr defaultValue, const PresetsContainer &presets=PresetsContainer(), bool presetsOnly=false, ConstCompoundObjectPtr userData=nullptr) | |
const std::string & | name () const |
Returns the name of this parameter. | |
const InternedString & | internedName () const |
const std::string & | description () const |
Returns the description for this parameter. | |
CompoundObject * | userData () |
Returns the userdata. This can be modified freely. | |
const CompoundObject * | userData () const |
Read only version of the above. | |
bool | valueValid (std::string *reason=nullptr) const |
Calls valueValid( getValue(), reason ) | |
void | validate () const |
void | validate (const Object *value) const |
void | setValidatedValue (ObjectPtr value) |
void | setValue (const std::string &presetName) |
Object * | getValidatedValue () |
const Object * | getValidatedValue () const |
template<typename T > | |
T * | getTypedValue () |
Convenience function returning runTimeCast<T>( getValue() ). | |
template<typename T > | |
const T * | getTypedValue () const |
Convenience function returning runTimeCast<T>( getValue() ). | |
template<typename T > | |
T * | getTypedValidatedValue () |
template<typename T > | |
const T * | getTypedValidatedValue () const |
std::string | getCurrentPresetName () const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RunTimeTyped) | |
virtual TypeId | typeId () const |
virtual const char * | typeName () const |
virtual bool | isInstanceOf (TypeId typeId) const |
virtual bool | isInstanceOf (const char *typeName) const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RefCounted) | |
void | addRef () const |
Add a reference to the current object. | |
void | removeRef () const |
Remove a reference from the current object. | |
RefCount | refCount () const |
Returns the current reference count. | |
Additional Inherited Members | |
![]() | |
static TypeId | staticTypeId () |
Returns the TypeId for this class, without needing an instance. | |
static const char * | staticTypeName () |
Returns the type name for this class, without needing an instance. | |
static TypeId | baseTypeId () |
static const char * | baseTypeName () |
static bool | inheritsFrom (TypeId typeId) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (const char *typeName) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (TypeId type, TypeId baseType) |
Returns true if type inherits from baseType. | |
static bool | inheritsFrom (const char *typeName, const char *baseTypeName) |
Returns true if typeName inherits from baseTypeName. | |
static TypeId | baseTypeId (TypeId typeId) |
Returns the base type of the given type, or InvalidTypeId if no such base exists. | |
static const std::vector< TypeId > & | baseTypeIds (TypeId typeId) |
static const std::set< TypeId > & | derivedTypeIds (TypeId typeId) |
static TypeId | typeIdFromTypeName (const char *typeName) |
static const char * | typeNameFromTypeId (TypeId typeId) |
static void | registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId) |
Allows external modules to register their own type ids. | |
![]() | |
typedef std::map< TypeId, TypeId > | BaseTypeRegistryMap |
typedef std::map< TypeId, std::vector< TypeId > > | BaseTypesRegistryMap |
typedef std::map< TypeId, std::set< TypeId > > | DerivedTypesRegistryMap |
typedef tbb::spin_rw_mutex | Mutex |
typedef std::map< TypeId, std::string > | TypeIdsToTypeNamesMap |
typedef std::map< std::string, TypeId > | TypeNamesToTypeIdsMap |
![]() | |
static BaseTypeRegistryMap & | baseTypeRegistry () |
static DerivedTypesRegistryMap & | derivedTypesRegistry () |
static BaseTypesRegistryMap & | completeBaseTypesRegistry () |
static DerivedTypesRegistryMap & | completeDerivedTypesRegistry () |
static void | derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &) |
static TypeIdsToTypeNamesMap & | typeIdsToTypeNames () |
static TypeNamesToTypeIdsMap & | typeNamesToTypeIds () |
![]() | |
static Mutex | g_baseTypeIdsMutex |
static Mutex | g_derivedTypeIdsMutex |
The CompoundParameter class implements a Parameter holding many other parameter values, a little like a struct.
IECore::CompoundParameter::CompoundParameter | ( | const std::string & | name = "" , |
const std::string & | description = "" , |
||
ConstCompoundObjectPtr | userData = nullptr , |
||
bool | adoptChildPresets = true |
||
) |
Creates an empty CompoundParameter. If adoptChildPresets is true, then the presets for this parameter will be the intersection of the presets of the child parameters. If adoptChildPresets is false, then the CompoundParameter itself will have no presets.
IECore::CompoundParameter::CompoundParameter | ( | const std::string & | name, |
const std::string & | description, | ||
I | membersBegin, | ||
I | membersEnd, | ||
ConstCompoundObjectPtr | userData = nullptr , |
||
bool | adoptChildPresets = true |
||
) |
Create a CompoundParameter containing all the parameters in the range specified by the forward iterators membersBegin and membersEnd, which are expected to point to ParameterPtr objects.
void IECore::CompoundParameter::addParameter | ( | ParameterPtr | parameter | ) |
Adds a Parameter to the end of the child parameters. Throws an Exception if a child of that name already exists.
Referenced by IECore.ClassVectorParameter::setClass(), and IECore.ClassVectorParameter::setClasses().
void IECore::CompoundParameter::addParameters | ( | I | begin, |
I | end | ||
) |
Calls addParameter for all parmaters between the iterators begin and end. These iterators should point to ParameterPtrs.
Referenced by IECore.OptionalCompoundParameter::__setattr__(), and IECore.ClassParameter::setClass().
|
overridevirtual |
Implemented to return a CompoundObject representing the default values of all the child objects.
Reimplemented from IECore::Parameter.
Object* IECore::CompoundParameter::getParameterValue | ( | const std::string & | name | ) |
Convenience function to find a parameter in parameters() and return the result of calling getValue() on it. Throws an Exception if the named parameter doesn't exist.
|
overridevirtual |
If true was passed to adoptChildPresets at construction, then update the presets with the intersection of the presets of all the child parameters, otherwise returns an empty container or the presets defined by setPresets(). Please note that the map returned may differ between one call to presets() and the next.
Reimplemented from IECore::Parameter.
Object* IECore::CompoundParameter::getValidatedParameterValue | ( | const std::string & | name | ) |
Convenience function to find a parameter in parameters() and return the result of calling getValidatedValue() on it. Throws an Exception if the named parameter doesn't exist.
|
overridevirtual |
If the last set value was a CompoundObject (as it should have been) then updates it with the current child parameter values and returns it.
Reimplemented from IECore::Parameter.
Referenced by IECore.OptionalCompoundParameter::getParameterUndefined().
void IECore::CompoundParameter::insertParameter | ( | ParameterPtr | parameter, |
ConstParameterPtr | other | ||
) |
Inserts parameter before other in the list of child parameters. Throws an Exception if an identically named parameter already exists, or if other is not a child parameter.
Referenced by IECore.ClassVectorParameter::setClasses().
const ParameterVector& IECore::CompoundParameter::orderedParameters | ( | ) | const |
Gives access to the parameters which are members of this compound in a form which maintains the order in which they were passed to the constructor.
T* IECore::CompoundParameter::parameter | ( | const std::string & | name | ) |
Convenience function to find a parameter in parameters(). Returns 0 if the parameter doesn't exist, or does not match the type specified as the template argument.
Referenced by IECoreMaya.FnDagNode::defaultShapeName(), and IECore.ClassVectorParameter::setClass().
bool IECore::CompoundParameter::parameterPath | ( | const Parameter * | child, |
std::vector< std::string > & | path | ||
) | const |
Searches for child recursively underneath this parameter, filling path with the names of all its ancestors, plus the name of child itself. Returns true if child is found and false otherwise.
const ParameterMap& IECore::CompoundParameter::parameters | ( | ) | const |
Gives access to the parameters which are members of this compound in a form which maps from parameter names to parameters. The map itself cannot be modified (the parameters are fixed) but the values of the parameters contained may be set.
Referenced by IECore.BasicPreset::__init__(), IECore.OptionalCompoundParameter::__setattr__(), IECore.ClassLoader::defaultProceduralLoader(), IECore.ParameterParser::registerTypeWithRepr(), IECore.BasicPreset::save(), IECore.ClassVectorParameter::setClass(), and IECore.CompoundVectorParameter::valueValid().
|
overridevirtual |
Implemented to return true only if all children have presetsOnly() true and true was passed to adoptChildPresets at construction.
Reimplemented from IECore::Parameter.
void IECore::CompoundParameter::removeParameter | ( | ParameterPtr | parameter | ) |
Removes the given parameter. Throws an Exception if parameter is not a child of this object.
Referenced by IECore.ClassVectorParameter::removeClass(), and IECore.ClassVectorParameter::setClasses().
void IECore::CompoundParameter::removeParameter | ( | const std::string & | name | ) |
Removes the parameter with the given name. Throws an Exception if no such named parameter exists.
void IECore::CompoundParameter::setParameterValue | ( | const std::string & | name, |
ObjectPtr | value | ||
) |
Convenience function to find a parameter in parameters() and call setValue() on it. Throws an Exception if the named parameter doesn't exist.
|
overridevirtual |
Defines presets for this Parameter. Throws an exception if true was passed to adoptChildPresets at construction.
Reimplemented from IECore::Parameter.
void IECore::CompoundParameter::setValidatedParameterValue | ( | const std::string & | name, |
ObjectPtr | value | ||
) |
Convenience function to find a parameter in parameters() and call setValidatedValue() on it. Throws an Exception if the named parameter doesn't exist.
|
overridevirtual |
Sets the values of child parameters using the matching child objects of the passed CompoundObject. In the case of missing values (or if the value isn't even a CompoundParameter) sets the child parameter value to a NullObject instance to signify it's invalidity.
Reimplemented from IECore::Parameter.
|
overridevirtual |
Values are only valid if they are a CompoundObject with a valid member for each child parameter, and no additional values.
Reimplemented from IECore::Parameter.
Referenced by IECore.OptionalCompoundParameter::valueValid().