All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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: DOP_Engine.h ( SOP Library, C++)
7  *
9  */
11 #ifndef __DOP_Engine_h__
12 #define __DOP_Engine_h__
14 #include "DOP_API.h"
15 #include "DOP_Output.h"
16 #include <SIM/SIM_Engine.h>
17 #include <DEP/DEP_MicroNode.h>
18 #include <UT/UT_SymbolTable.h>
19 #include <UT/UT_ErrorManager.h>
22 class OP_Network;
23 class SIM_ObjectArray;
24 class DOP_Node;
25 class DOP_Output;
26 class DOP_OutputDependency;
32 /// This subclass of SIM_Engine is the one used to contain simulations
33 /// controlled by DOP_Node networks. It serves as the glue between the
34 /// pure simulation library and the DOP_Node interface given to simulations
35 /// in Houdini.
37 {
38 public:
39  /// Constructor is given a pointer to the network that owns the simulation.
40  DOP_Engine(OP_Node *owner);
41  /// Destructor destroys all data for the simulation.
42  virtual ~DOP_Engine();
44  /// Groups objects passed to a DOP_Node by the input they arrived in.
45  /// Each entry in the returned UT_ValArray represents an input to
46  /// the DOP_Node. If a particular input is not connected, the
47  /// corresponding entry in the array will by null. Generally this
48  /// function will be called from DOP_Node::processObjects() by nodes
49  /// which need to have objects coming through one input interact in
50  /// some way with objects coming through another input.
51  void getObjectsAtInputs(DOP_Node *node,
53  objectsatinputs) const;
55  /// Gets the objects in the stream associated with the supplied node.
56  /// For nodes with multiple outputs, the result is the combination of all
57  /// objects on any output. This function does not do any cooking of the
58  /// networks, or call partitionObjects on any nodes. It only pulls
59  /// existing data from our set of outputs to process. This function
60  /// is for use by expression functions that want to know what objects
61  /// most recently passed through a particular node.
62  void getObjectsForNode(DOP_Node *node,
63  SIM_ConstObjectArray &objects) const;
65  /// Adds the specified root data (cast to an object) as a sort of
66  /// "extra object" processed by a DOP node. These extra objects don't
67  /// affect cooking at all, but show up in the list of objects processed
68  /// by that node (in the MMB info and dopnodeobjs expression).
69  void addObjectForNode(DOP_Node *node,
70  SIM_RootData &rootdata);
72  /// Gets a pointer to the node that is currently being processed by
73  /// the DOP_Engine. The return value will be null if the engine is not
74  /// currently in the preSimulationStep and inside a call to
75  /// DOP_Node::processObjects(). This function is used by subnet DOPs
76  /// to evaluate standard DOP local variables in the context of the node
77  /// that is being processed (since subnets have no context of their own).
78  DOP_Node *getDopNodeBeingProcessed() const;
80  /// Explicitly dirty dependents of this simulation
81  void propagateSimDirty(bool send_event);
83  /// Pass through to our parent's notification
86  /// Returns whether resimulations is globally disabled.
87  static bool getWantResimulation()
88  { return theWantResimulation; }
90  /// Globally disables resimulations caused by external node changes. This
91  /// is meant for internal use.
92  static void setWantResimulation(bool want_resimulation)
93  { theWantResimulation = want_resimulation; }
95 protected:
96  /// Overrides the base class method to make sure that all our internal
97  /// data related to the last timestep cook has been cleared away.
98  virtual void resetSimulation();
99  /// Overrides the actions that occur before doing a simulation step.
100  /// This is where the network of DOP_Nodes is parsed. Each DOP_Node
101  /// has a chance to alter the simulation objects in the
102  /// DOP_Node::processObjects() function. Nodes can also specify
103  /// which objects are sent to each output of the node.
104  virtual void preSimulationStep();
105  /// Overrides the actions that occur after a simulation step.
106  virtual void postSimulationStep();
107  /// When the most recent simulation state is being deleted or
108  /// removed from memory, we have to clear all our references to
109  /// it. This basically means our lists of output objects to process.
110  virtual void clearReferencesToMostRecentState();
111  /// Sets up custom data on a new object.
112  /// This implementation calls the base class implementation, then it
113  /// stores information about the DOP_Node that created the object.
114  virtual void objectCreated(SIM_Object *object);
115  /// Overrides the default behavior when removing a simulation object.
116  /// This implementation eliminates all references to this object stored
117  /// in our internal data then calls the base class implementation.
118  virtual void objectRemoved(SIM_Object *object);
119  /// Override this method to flag ourselves as requiring a resimulation
120  /// when any of our external referenced nodes changes in a significant
121  /// way.
123  OP_Node *changednode,
124  OP_EventType eventtype,
125  void *data);
126  /// Uses the object and data arguments to put the error message on an
127  /// appropriate DOP_Node. First priority is given to the node that
128  /// created the data, then the node that created the object, then the
129  /// node with the display flag.
130  virtual void addErrorSubclass(const SIM_RootData *rootdata,
131  const SIM_Data *data,
132  int errorcode,
133  const char *errorparm,
134  UT_ErrorSeverity severity) const;
135  /// Returns the simulation time that corresponds to the given global time.
136  virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const;
137  /// Returns the global time that corresponds to the given simulation time.
138  virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const;
140  /// Alerts our owner that we are simulating due to an internally
141  /// generated need. Returns the previous state
142  virtual bool setIsSimulating(bool issimulating) const;
144 private:
145  void buildObjectListForOutput(DOP_OutputDependency &output) const;
146  void partitionObjectsForOutput(DOP_OutputDependency &output) const;
147  void createOutputsToProcess(DOP_Node *node, int outputidx,
148  const SIM_Time &optime);
149  void clearOutputsToProcess();
150  void assignObjectsToCreatorOutputs();
151  void removeAllUnusedObjects(const SIM_ObjectArray &usedobjs);
153  UT_ErrorSeverity myOwnerSeverity;
154  DOP_OutputArray myOutputsToProcess;
155  DOP_OutputMap myOutputsSymbolTable;
156  int myProcessingOutput;
158  static bool theWantResimulation;
159 };
161 #endif
virtual void preSimulationStep()
virtual void resetSimulation()
Definition: UT_Error.h:25
virtual void notifySimulationChangeSinksOfChange()
Definition: SIM_Engine.h:346
virtual void handleExternalNodeChangeSubclass(OP_Node *changednode, OP_EventType eventtype, void *data)
static void setWantResimulation(bool want_resimulation)
Definition: DOP_Engine.h:92
#define DOP_API
Definition: DOP_API.h:10
virtual void clearReferencesToMostRecentState()
Holds pointers to a number of SIM_Object objects.
UT_ValArray< DOP_OutputDependency * > DOP_OutputArray
Definition: DOP_Engine.h:26
virtual void postSimulationStep()
This function is run after all objects are processed by their solvers.
UT_Map< DOP_Output, DOP_OutputDependency * > DOP_OutputMap
Definition: DOP_Engine.h:29
GLenum GLenum severity
Definition: glcorearb.h:2538
GLboolean * data
Definition: glcorearb.h:130
Holds pointers to a number of const SIM_Object objects.
virtual void addErrorSubclass(const SIM_RootData *rootdata, const SIM_Data *data, int errorcode, const char *errorparm, UT_ErrorSeverity severity) const
The default implementation of this function does nothing.
virtual void objectCreated(SIM_Object *object)
virtual void objectRemoved(SIM_Object *object)
Definition: OP_Value.h:22
DOP_OutputMap::const_iterator DOP_OutputMapConstIter
Definition: DOP_Engine.h:30
virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const
Returns the simulation time that corresponds to the given global time.
This is the base class for all DOP nodes.
Definition: DOP_Node.h:75
static bool getWantResimulation()
Returns whether resimulations is globally disabled.
Definition: DOP_Engine.h:87
virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const
Returns the global time that corresponds to the given simulation time.
virtual bool setIsSimulating(bool issimulating) const