HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_Context.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UN_Context.h ( UN Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UN_Context_h__
13 #define __UN_Context_h__
14 
15 #include "UN_API.h"
16 #include "UN_Graph.h"
17 #include <UT/UT_UniquePtr.h>
18 
19 class UN_GraphData;
20 
21 
22 // ============================================================================
23 /// The owner of the graph and its data.
24 ///
25 /// Note, unlike UN_Graph and UN_Node, etc, this class is not a handle.
26 /// It is an owner of the graph data (rather than a reference to it).
27 /// It is also a provider of other aspcets of the graph (eg, node types,
28 /// port types, etc).
29 ///
30 /// One consequence of this is that this class has a mix of const and non-const
31 /// methods (handle classes have all const methods). Non-const methods
32 /// return types that can be modified, while const methods return the ones
33 /// that are not changeable.
34 
35 // TODO: FIXME: How does UN_Context fit into UN_NodeCategory,
36 // UN_PortType, UN_ParmType, all available from the UN_Framework
37 // registry?
38 // - Its constructor will take a list of category names,
39 // and it will hold to a UN_NodeCategory references in a member array.
40 // - UN_NodeCategory list is obtained from UN_Framework which
41 // discovers node categories, port types, and parm types.
42 // - UN_NodeCategory will provide list of UN_NodeTypes for UN_Nodes
43 // that can live inside the UN_Graph.
44 // - UN_NodeCategory will also provide a list of UN_PortTypes
45 // that UN_Nodes can use. Port type gives connectivity and color hints
46 // to the UI; it will also allow support for compound types (structs).
48 {
49 public:
50  /// @{ Constructor and destructor
51  UN_Context();
52  ~UN_Context();
53  /// @}
54 
55  /// Returns a handle of (reference to) the graph owned by this class.
56  // Note: this class is not a handle, so unlike handle classes
57  // (eg, UN_Node) it needs to have non-const methods if they
58  // return a modifiable object. Since UN_Graph is a handle to a
59  // non-const graph (ie, users can modify this graph using this handle)
60  // this method is non-const.
61  UN_Graph graph() // non-const
62  { return UN_Graph( myGraphData.get() ); }
63 
64 
65  // TODO: FIXME: remove it
66  /// Returns the graph data structures object.
67  /// For use in UN library classes, mainly for unit testing.
68  /// Should not be needed outside of the UN library.
69  UN_GraphData * graphData()
70  { return myGraphData.get(); }
71 
72 private:
73  /// Holds data about the graph.
74  UT_UniquePtr< UN_GraphData > myGraphData;
75 };
76 
77 
78 #endif
79 
#define UN_API
Definition: UN_API.h:11
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
UN_GraphData * graphData()
Definition: UN_Context.h:69
UN_Graph graph()
Returns a handle of (reference to) the graph owned by this class.
Definition: UN_Context.h:61