Cortex  10.0.0-a4
ObjectKnob.h
1 //
3 // Copyright (c) 2010, 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 IECORENUKE_OBJECTKNOB_H
36 #define IECORENUKE_OBJECTKNOB_H
37 
38 #include "DDImage/Knobs.h"
39 
40 #include "IECore/Object.h"
41 
42 namespace IECoreNuke
43 {
44 
46 class ObjectKnob : public DD::Image::Knob
47 {
48 
49  public :
50 
53  bool setValue( IECore::ConstObjectPtr value );
54  IECore::ConstObjectPtr getValue() const;
55 
58  static ObjectKnob *objectKnob( DD::Image::Knob_Callback f, IECore::ObjectPtr *storage, const char *name, const char *label );
59 
60  protected :
61 
62  ObjectKnob( DD::Image::Knob_Closure *f, IECore::ObjectPtr *storage, const char *name, const char *label = 0 );
63  virtual ~ObjectKnob();
64 
65  virtual const char *Class() const;
66 
67  virtual void to_script( std::ostream &os, const DD::Image::OutputContext *context, bool quote ) const;
68  virtual bool from_script( const char *value );
69  virtual bool not_default() const;
70  virtual void store( DD::Image::StoreType storeType, void *storage, DD::Image::Hash &hash, const DD::Image::OutputContext &context );
71 
72  private :
73 
74  bool valuesEqual( const IECore::Object *value1, const IECore::Object *value2 ) const;
75 
76  IECore::ObjectPtr m_defaultValue;
77  IECore::ObjectPtr m_value;
78 
79 };
80 
81 namespace Detail
82 {
83 
84 // Used to implement the python binding
85 struct PythonObjectKnob : public IECore::RefCounted
86 {
87 
88  IE_CORE_DECLAREMEMBERPTR( PythonObjectKnob );
89 
90  ObjectKnob *objectKnob;
91 
92 };
93 
94 IE_CORE_DECLAREPTR( PythonObjectKnob );
95 
96 } // namespace Detail
97 
98 } // namespace IECoreNuke
99 
100 #endif // IECORENUKE_OBJECTKNOB_H
Definition: Object.h:104
The IECoreNuke namespace holds all the functionality of libIECoreNuke.
Definition: BoolParameterHandler.h:40
A nuke knob capable of holding arbitrary IECore::Objects.
Definition: ObjectKnob.h:46
bool setValue(IECore::ConstObjectPtr value)
Definition: RefCounted.h:124
static ObjectKnob * objectKnob(DD::Image::Knob_Callback f, IECore::ObjectPtr *storage, const char *name, const char *label)