HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_Engine.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  */
7 
8 #ifndef __SIM_Engine_h__
9 #define __SIM_Engine_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_Cache.h"
13 #include "SIM_Data.h"
14 #include "SIM_Error.h"
15 #include <OP/OP_Value.h>
16 #include <DEP/DEP_MicroNode.h>
17 #include <UT/UT_Map.h>
18 #include <UT/UT_Set.h>
19 #include <UT/UT_SymbolTable.h>
20 
21 #define SIM_PATH_SEPCHAR '/'
22 #define SIM_OBJECT_SEPCHAR ':'
23 #define SIM_OBJECTNUM_SEPCHAR '.'
24 #define SIM_OBJECTDATA_SEPCHAR '/'
25 
26 class UT_InfoTree;
27 class UT_StringArray;
28 class UT_StringRef;
29 class OP_Node;
30 class SIM_BaseCache;
31 class SIM_DopDescription;
33 class SIM_DataFactory;
34 class SIM_Data;
35 class SIM_SimulationState;
36 class SIM_MetaObject;
37 class SIM_MetaObjectArray;
39 class SIM_ObjectArray;
40 class SIM_SaveCommand;
41 
43 {
44 public:
46  virtual const char * className() const
47  { return "SIM_SimulationMicroNode"; }
48  virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &data);
49 protected:
51 };
52 
53 /// This is the main engine behind all simulations. Any number of these
54 /// can be created to create independent simulations. Generally a simulation
55 /// will be owned by a particular OP_Node. For example, the DopNet object
56 /// contains a SIM_Engine.
58 {
59 public:
60  /// Constructor to create a new simulation.
61  SIM_Engine(OP_Node *owner);
62  /// Destructor to destroy all data associated with a simulation.
63  virtual ~SIM_Engine();
64 
65  /// Returns the OP_Node that owns this engine. This may be null if
66  /// the engine isn't associated with a particular node.
67  OP_Node *getOwner() const;
68  /// Gets the full path to the DOP Network node that owns this simulation.
69  const UT_String &getOwnerFullPath() const;
70  void getOwnerFullPathString(UT_String &str) const;
71 
72  /// Allocates a new SIM_Object and adds it to the simulation.
73  /// The name parameter is assigned to the object. This name does not
74  /// have to be unique.
75  SIM_Object *addSimulationObject(bool solvefirstframe);
76  /// Removes a SIM_Object from the simulation.
77  /// The index value is the current location of the object in the
78  /// simulations's list of objects. This value will not be the same
79  /// as the SIM_Object::getObjectId() value, and may change when objects
80  /// are added to or removed from the simulation.
81  void removeSimulationObject(int index);
82  /// Removes a SIM_Object from the simulation.
83  /// This version of this function takes a SIM_Object pointer instead
84  /// of an index. The pointer is converted to an index and the indexed
85  /// version of removeSimulationObject() is called.
86  void removeSimulationObject(SIM_Object *object);
87  /// Returns the number of objects currently in the simulation.
88  int getNumSimulationObjects() const;
89  /// Returns the number of objects currently in the simulation.
90  int64 getNumSimulationData() const;
91  /// Returns a pointer to the SIM_Object at the specified index.
92  /// The index value is the current location of the object in the
93  /// simulations's list of objects. This value will not be the same
94  /// as the SIM_Object::getObjectId() value.
95  const SIM_Object *getSimulationObject(int index) const;
96  /// Returns a pointer to the SIM_Object with the specified unique id.
97  /// This function searches the current list of objects for the
98  /// specified objectid. If the objectid is not found, this function
99  /// returns null.
100  const SIM_Object *getSimulationObjectFromId(int objectid) const;
101  /// Returns the "nth" simulation object that matches a supplied filter.
102  /// If less than the supplied n objects match the filter, 0 is returned.
103  const SIM_Object *getNthSimulationObject(
104  const SIM_DataFilter &filter,
105  int n) const;
106 
107  /// Creates a new relationship. The creationflags parameter accepts the
108  /// same SIM_DATA_* flags accepted by the creationflags parameter of
109  /// SIM_Data::createNamedSubData().
110  SIM_Relationship *addRelationship(const char *name,
111  int creationflags);
112  /// Returns the number of relationships in the current simulation state.
113  int getNumRelationships() const;
114  /// This function allows looping through the simulations relationships.
115  const SIM_Relationship *getRelationship(int index) const;
116  /// Returns the relationship with the specified name.
117  const SIM_Relationship *getRelationship(const char *name) const;
118  /// Gets all the relationships of a particular type. The type of a
119  /// relationship is defined by the one subdata on the SIM_Relationship.
120  void filterConstRelationships(
121  const SIM_DataFilter &filter,
122  SIM_ConstDataArray &rels) const;
123  /// Removes the relationship at the specified position.
124  void removeRelationship(int index);
125  /// Removes the relationship with the specified name.
126  void removeRelationship(const char *name);
127  /// Removes the specified relationship.
128  void removeRelationship(SIM_Relationship *rel);
129  /// Removes all relationships created by a particular DOP node. If -1
130  /// is specified, then all relationships are removed. Relationships in
131  /// the "except" array are not removed.
132  void removeAllRelationships(int createdby,
133  const SIM_RelationshipArray *except);
134 
135  /// Returns either a SIM_Relationship or SIM_Object depending on the
136  /// information stored in the id parameter.
137  const SIM_RootData *getRootDataFromId(
138  const SIM_RootDataId &id) const;
139 
140  // Only HOM should call this method:
141  SIM_RootData *getNonConstRootDataFromId(
142  const SIM_RootDataId &id);
143 
144  /// Returns a pointer to the state of an object at some time in the past.
145  /// This function searches for these past object states in three ways.
146  /// First, if the specified time is equal to a past time step, the state
147  /// for that time step is returned. Second, if the specified time is not
148  /// equal to a past time step, then past time steps are searched for
149  /// object states stored explicitly with createSubStepObject(). Finally,
150  /// if both these methods fail to find a matching object state, then the
151  /// closest object states before and after the specified time are found
152  /// using the first two approaches. Then a new object state is created by
153  /// interpolating between these two states using SIM_Data::interpolate().
154  /// This third approach is skipped if allowinterpolation is set to false.
155  /// If no previous or no future object state can be found, then this
156  /// function returns null.
157  const SIM_Object *getObjectAtTime(const SIM_Object &object,
158  const SIM_Time &time,
159  bool allowinterpolation) const;
160 
161  /// Returns a non-const pointer to an object for a particular time.
162  /// This function is very similar to getObjectAtTime() except for two
163  /// things. First, it requires a non-const starting object, and it is
164  /// a non-const function. Second, if the specified time exactly matches
165  /// a time in the past, the returned object will be a copy of that past
166  /// object, not the object itself. Otherwise modifying that object could
167  /// modify the past. However, if the current time is sepcified, the actual
168  /// object (i.e. a pointer to the passed in SIM_Object) is returned.
169  /// This function is for use by solvers that want to modify their
170  /// affector objects and which do substepping.
171  SIM_Object *getAffectorAtTime(SIM_Object &object,
172  const SIM_Time &time,
173  bool allowinterpolation);
174 
175  /// This is a more direct, more efficient method for reading
176  /// cached versions of objects from previous frames, without interpolation.
177  ///
178  /// Before the call, 'past_objects' must be a valid array of
179  /// SIM_Object* arrays and 'past_times' must be a valid array of SIM_Time.
180  /// 'past_objects' must have size 'max_past'
181  /// each element of 'past_objects' must be an array of SIM_Object* of
182  //// size 'num_objects'
183  /// 'past_times' must be an array of size 'max_past'
184  ///
185  /// Output:
186  /// The number of cached frames is returned.
187  /// The cached version of object[oi] at time past_times[i]
188  /// is stored in the array past_objects[i] at location oi,
189  /// for all 0 <= i < "the returned number of cached frames"
190 
191  int getObjectsAtPastTimes(
192  const SIM_Object**const past_objects[],
193  SIM_Time past_times[],
194  const int num_objects,
195  const SIM_Object*const objects[],
196  const int max_past
197  );
198 
199  /// Creates an object in the current state with a particular time stamp.
200  /// This function is useful for solvers that need to do their own time
201  /// stepping with step sizes smaller than the globally specified time
202  /// step size. These explicitly stored subsamples are accessible later
203  /// with the getObjectAtTime() function.
204  SIM_Object *createSubStepObject(const SIM_Object &object,
205  const SIM_Time &time);
206  /// Removes an object previously created by createSubStepObject().
207  /// If the allwithmatchingid parameter is set to true, not only will
208  /// the specified object be destroyed, but all other objects with the
209  /// same object id created using createSubStepObject() will be destroyed.
210  /// This provides a quick way to destroy all temporary working copies
211  /// of a particular object.
212  void removeSubStepObject(SIM_Object *objectattime,
213  bool allwithmatchingid);
214 
215  /// Loads a simulation state from a file and merges it into the current
216  /// simulation state. The data that gets loaded is not allowed to do any
217  /// sharing of data with the current state, since the data id's can't
218  /// be expected to match. Objects from the file will replace objects from
219  /// the current state if their object ids match. Objects loaded from the
220  /// file will be flagged so that they will not be solved in the current
221  /// timestep. In subsequent timesteps these objects will be solved.
222  /// The filter parameter specifies which objects stored in the file
223  /// are merged in.
224  bool mergeSimulationFile(const char *filename,
225  const SIM_DataFilter &filter,
226  const SIM_ObjectArray &replaceobjects,
227  const OP_Node *defaultcreator,
228  bool forcecreatortodefault,
229  bool acceptnewobjects,
230  bool matchbyname,
231  const char *nameprefix);
232  /// Schedules some objects to be saved to a files at the end of the
233  /// current timestep. The filter parameter makes it possible to save
234  /// only some of the objects to the file. The actual save happens
235  /// in the postSimulationStep().
236  void saveSimulationFile(OP_Node *node,
237  const char *filename,
238  const SIM_DataFilter &filter,
239  const SIM_ObjectArray &objects,
241  /// Saves the entire current state of the simulation immediately.
242  bool saveSimulationState(std::ostream &os,
244  bool saveSimulationStateToFile(const char *fname,
246  bool threadedio) const;
247 
248  /// Sets the current time for the simulation. If the new simulation
249  /// time is less than the current time, the SIM_Cache is simply set to
250  /// use its best match for the chosen time. If the new simulation time
251  /// is greater than the current time, the simulation is stepped forward
252  /// in time to the new time. The resimlasttimestep parameter causes the
253  /// most recent cache entry to be deleted before trying to set the
254  /// current time. This is useful if some parameter of the simulation
255  /// changes on the current timestep. It causes the timestep to be
256  /// recooked with the new parameter. This resimulation may also happen
257  /// if the simulation was interrupted the last time this function was
258  /// called. The forceresetsim parameter tells the SIM_Engine to reset
259  /// the simulation before trying to move to the specified time, whether
260  /// the reset is required or not.
261  void setSimulationTime(const SIM_Time &t,
262  bool resimlasttimestep,
263  bool forceresetsim,
264  bool allowsimulation);
265 
266  /// Marks this engine as invalid without actually clearing or
267  /// resetting anything. A proper reset implies also a frame
268  /// advance to the first frame that can be expensive.
269  /// Note the cache will not be cleared until it is cooked, however!
271  { myFirstSimulationStep = true; }
272 
273  /// Returns the current simulation time.
274  const SIM_Time &getSimulationTime() const;
275  /// Returns the simulation time that corresponds to the given global time.
276  const SIM_Time getEngineTime(const SIM_Time &t) const;
277  /// Returns the global time that corresponds to the given simulation time.
278  const SIM_Time getGlobalTime(const SIM_Time &t) const;
279  /// Returns the time of the earliest simulation state in the cache.
280  const SIM_Time &getEarliestCacheTime() const;
281  const SIM_Time &getLatestCacheTime() const;
282  /// Returns the cached frames.
283  /// Inclusive.
284  void getCachedFrames(UT_IntArray &frames, bool inmemory) const;
285  /// Returns a reference to the cache options for this simulation.
286  const SIM_CacheOptions &getCacheOptions() const;
287  /// Sets the cache options for this simulation.
288  void setCacheOptions(const SIM_CacheOptions &o);
289  /// Returns the time step size.
290  const SIM_Time &getTimeStep() const;
291  /// Sets the global time step size.
292  void setTimeStep(const SIM_Time &time);
293  /// Gets the maximum number of allowed feedback iterations.
294  int getMaxFeedbackIterations() const;
295  /// Sets the maximum number of allowed feedback iterations.
296  void setMaxFeedbackIterations(int max);
297  /// Gets the current feedback iteration we are on. If we are not
298  /// currently solving, this function will return -1;
299  int getFeedbackIteration() const;
300  /// Returns true if the engine is providing data hierarchy hints.
301  bool getProvideDataHints() const;
302  /// Specifies whether the engine should provide data hierarchy hints.
303  void setProvideDataHints(bool providehints);
304  /// Gets the id for the node that is currently being processed.
306  { return myCurrentCreatorId; }
307  /// Gets the index of the node output that is currently being processed.
309  { return myCurrentCreatorIndex; }
310  /// Set the creator information. These values are automatically reset
311  /// to (-1, -1) before performing a simulation step.
312  void setCreatorInfo(int id, int index);
313  /// Returns the SIM_Data pointer with the specified unique id.
314  const SIM_Data *getConstDataWithId(const UT_Guid &id) const;
315  /// Returns the simulation frame number that corresponds to the given
316  /// time. The simulation frame number is the number of timesteps that
317  /// need to be run to get to the specified time, plus one (so that
318  /// time zero is frame 1).
319  int getSimulationFrame(const SIM_Time &time) const;
320  /// Returns the simulation time that corresponds to the given simulation
321  /// frame.
322  const SIM_Time getSimulationTime(int frame) const;
323 
324  /// Adds an error to the engine. The object and data parameters allow
325  /// the DOP_Engine to put the error message on an appropriate DOP Node.
326  /// Errors are found in the SIM error file. This function simply calls
327  /// addErrorSubclass().
328  void addError(const SIM_RootData *rootdata,
329  const SIM_Data *data,
330  int errorcode,
331  const char *errorparm,
332  UT_ErrorSeverity severity) const;
333 
334  /// Returns the total amount of memory used by all data currently in
335  /// this simulation, at the current time or in the cache.
336  int64 getTotalMemorySize() const;
337 
338  /// Removes all node interests from the engine.
339  void removeAllOPInterests() const;
340  /// Adds an interest in the supplied node. When the node changes, the
341  /// engine's handleExternalNodeChange function will be called.
342  void addOPInterest(OP_Node *node) const;
343  void addGuideOPInterest(OP_Node *node) const;
344 
345  /// Passes up to our owner to alert anything that needs an OP_Event
346  /// in response to use becoming dirty.
348 
349  /// Returns all available data type names.
350  /// If a null type pointer is passed in, this function returns a list
351  /// of every data type that the SIM_Engine can create. If a data type
352  /// name is passed in, the list returned will only contain those data
353  /// types that can be cast to the specified data type using the
354  /// SIM_Data::getPointerToType() function.
355  void getDataTypes(UT_StringArray &datatypes,
356  const UT_StringRef &datatype) const;
357  /// Returns all available data types and the source of their definition.
358  /// The definition source will be an empty string if the data type is
359  /// defined internally to Houdini. Otherwise it will be the name of the
360  /// DSO or DLL file that contains the data type.
361  void getDataTypeSources(UT_StringArray &datatypes,
362  UT_StringArray &srcs) const;
363  /// Returns the descriptive name for a data type.
364  /// Given the unique identifying name for a data type this function
365  /// finds the appropriate data factory and returns the descriptive
366  /// string assigned to the type.
367  const char *getDescription(
368  const UT_StringRef &datatype) const;
369  /// Returns the SIM_DopDescription from the SIM_DataFactory of a
370  /// particular data type.
371  const SIM_DopDescription *getDopDescription(
372  const UT_StringRef &datatype) const;
373 
374  /// Returns whether we can cast to a superclass data type without creating
375  /// the SIM_Data.
376  static bool canCastToDataType(
377  const UT_StringRef &from_type,
378  const UT_StringRef &to_type);
379 
380  /// Filters all our simulation objects based on a string pattern.
381  /// Note that the time value is a simulation time, not global time.
382  void findAllObjectsFromString(const char *objspec,
383  SIM_ConstObjectArray &objects,
384  const SIM_Time &t,
385  bool interpolateobj) const;
386  /// Returns a single object matching a specified string pattern.
387  /// Note that the time value is a simulation time, not global time.
388  const SIM_Object *findObjectFromString(const char *objspec,
389  int whichmatch, int *nummatch,
390  const SIM_Time &t,
391  bool interpolateobj) const;
392  /// Returns a list of objects created by the specified node, or any
393  /// nodes inside the specified node (if it is a subnet).
394  void findAllObjectsCreatedBy(OP_Node *creator,
395  SIM_ConstObjectArray &objects) const;
396  /// Filters all our relationships based on a string pattern.
397  /// Note that the time value is a simulation time, not global time.
398  void findAllRelationshipsFromString(
399  const char *relspec,
400  SIM_ConstDataArray &relationships,
401  const SIM_Time &t,
402  bool interpolaterel) const;
403  /// Returns a single relationship matching a specified string pattern.
404  /// Note that the time value is a simulation time, not global time.
405  const SIM_Relationship *findRelationshipFromString(
406  const char *relspec,
407  int whichmatch, int *nummatch,
408  const SIM_Time &t,
409  bool interpolaterel) const;
410 
411  /// Gets a list of all selected data in the simulation.
412  void getSelection(SIM_ConstDataArray &data) const;
413  /// Clears the selection flag on all data in this simulation.
414  void clearSelection() const;
415 
416  /// Returns the scale factor to convert a value in the provided units
417  /// into the equivalent MKS value.
418  fpreal scaleToMKS(const char *fromunits) const;
419  /// Returns the scale factor to convert a value in MKS units into the
420  /// equivalent value in the provided units.
421  fpreal scaleFromMKS(const char *tounits) const;
422 
423  /// The micronode representing the simulation result. It is marked as
424  /// dirtied and propagated whenever the simulation is cleared. Callers can
425  /// use this to express dependencies on/from the simulation.
427  { return mySimMicroNode; }
428  const DEP_MicroNode & simMicroNode() const
429  { return mySimMicroNode; }
430  /// This micronode holds the simulation input. It is wired directly
431  /// to the simMicroNode, however, does not care about refilter
432  /// events.
434  { return mySimInputMicroNode; }
436  { return mySimInputMicroNode; }
438  { return myResimParmsMicroNode; }
440  { return myResimParmsMicroNode; }
442  { return myRefilterParmsMicroNode; }
444  { return myRefilterParmsMicroNode; }
445 
446  /// Sets this simulation as a player. It will replace it's cache
447  /// with simulation data from the files given and not simulate,
448  /// just read the files.
449  void setIsPlayer(bool isPlayer);
450  bool isPlayer() const { return myIsPlayer; }
451 
452  /// Rebuilds the player cache.
453  void resetPlayer();
454  /// Tries to expand the cached frame range
455  void updatePlayerFrames();
456 
457 protected:
458  /// Resets the simulation to a clean state. This function calls
459  /// clearSimulation(), then builds a single empty simulation state.
460  virtual void resetSimulation();
461  /// This function is run before passing each object to its solver.
462  /// The implementation at this level clears out all temporary data
463  /// from the simulation objects.
464  virtual void preSimulationStep();
465  /// This function is run after all objects are processed by their solvers.
466  virtual void postSimulationStep();
467  /// This function is called by our cache whenever the most recent
468  /// simulated timestep is being removed from memory (either deleted
469  /// or moved onto disk).
470  virtual void clearReferencesToMostRecentState();
471  /// Initializes a newly created object. This function is called by
472  /// addSimulationObject(). The default implementation does nothing.
473  virtual void objectCreated(SIM_Object *object);
474  /// Allows special handling of objects that are being removed. This
475  /// function is called by removeSimulationObject(). The default
476  /// implementation does nothing.
477  virtual void objectRemoved(SIM_Object *object);
478  /// Override this method to handle changes to external nodes in which
479  /// we have an interest. The default implementation does nothing.
480  virtual void handleExternalNodeChangeSubclass(
481  OP_Node *changednode,
482  OP_EventType eventtype,
483  void *data,
484  bool isguide);
485  /// The default implementation of this function does nothing.
486  virtual void addErrorSubclass(const SIM_RootData *rootdata,
487  const SIM_Data *data,
488  int errorcode,
489  const char *errorparm,
490  UT_ErrorSeverity severity) const;
491  /// Returns the simulation time that corresponds to the given global time.
492  virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const;
493  /// Returns the global time that corresponds to the given simulation time.
494  virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const;
495  /// This function is the only way for a SIM_Engine subclass to get a
496  /// non-const SIM_Object pointer.
497  SIM_Object *getNonConstSimulationObject(int index);
498 
499  /// Alerts our owner that we are simulating due to an internally
500  /// generated need. Returns the previous state
501  virtual bool setIsSimulating(bool issimulating) const;
502 
503 private:
504  /// Gets the unique id of the OP_Node that owns this engine.
505  int getOwnerUniqueId() const;
506  /// Completely clears all existing data related to a simulation.
507  void clearSimulation();
508  /// Takes one time step forward in the simulation.
509  void doSimulationStep(bool forreset);
510  /// Solves a meta object for one time step. All affectors will already
511  /// be solved.
512  void doSimulationStepForMetaObject(
513  SIM_MetaObject &metaobject,
514  const SIM_Time &timestep,
515  bool isLastMetaObject);
516  /// Merges another simulation state in with our current state. This
517  /// state can come from a file or another live simulation.
518  void mergeSimulation(
519  SIM_SimulationState &fromstate,
520  const SIM_DataFilter *filter,
521  const SIM_ObjectArray *replaceobjects,
522  bool acceptnewobjects,
523  bool matchbyname,
524  const char *nameprefix);
525 
526  /// Solves a relationship for one timestep. All objects will
527  /// already be solved.
528  void solveRelationship(SIM_Relationship *relation,
529  const SIM_Time &timestep);
530 
531  /// Gets the current simulation state. Notably, it returns non-const.
532  /// It is quite questionable to use this non-const function in
533  /// solvers! One should acquire non-const SIM_Objects through
534  /// your affector lists or other ways.
535  SIM_SimulationState &getSimulationObjects();
536  /// Gets a const reference to the current simulation state.
537  const SIM_SimulationState &getSimulationObjects() const;
538 
539  SIM_Object *getNonConstSimulationObjectFromId(
540  int objectid);
541  SIM_Relationship *getNonConstRelationship(const char *name);
542  SIM_Relationship *getNonConstRelationshipFromIndex(int index);
543 
544  /// Returns the SIM_Data pointer with the specified unique id.
545  SIM_Data *getDataWithId(const UT_Guid &id) const;
546  /// Destroy any data that has a zero reference count.
547  void purgeUnusedData() const;
548 
549  /// Register a new piece of data with the engine. This is
550  /// called from the SIM_DataFactory newData function to add
551  /// the data to myAllData and myAllChangedSizeData.
552  void registerNewData(SIM_Data *newdata) const;
553  /// Create data using our factories.
554  /// Only SIM_Data should use this functions.
555  SIM_Data *newData(const UT_StringRef &datatype,
556  bool doinit=true) const;
557  /// Create data using our factories, and set the uniqueid of the new data.
558  /// Only SIM_SimulationState should use this functions.
559  SIM_Data *newData(const UT_StringRef &datatype,
560  const UT_Guid &uniqueid) const;
561  /// Unregister a piece of data that is being deleted. This is
562  /// called from the SIM_DataFactory deleteData function to remove
563  /// the data from myAllData and myAllChangedSizeData.
564  void unregisterDeletedData(SIM_Data *deleteddata) const;
565  /// Delete data using our factories.
566  /// Only SIM_Data should use this functions.
567  void deleteData(SIM_Data *data) const;
568  /// This function is called when the unique id of a SIM_Data changes.
569  /// It lets us keep the myAllData hash table up to date.
570  void changeDataUniqueId(SIM_Data *data,
571  const UT_Guid &newid) const;
572  /// This function is called when a piece of data has decided it needs
573  /// to recalculate its memory size.
574  void setNeedsToRecalculateMemorySize(
575  const SIM_Data *data) const;
576 
577  /// Access our data factories.
578  SIM_DataFactory *getDataFactory(const UT_StringRef &name) const;
579  void addDataFactory(SIM_DataFactory *factory);
580 
581  /// This function is called when an external node in which we have an
582  /// interest changes. It calls handleExternalNodeChangeSubclass.
583  void handleExternalNodeChange(OP_Node *changednode,
584  OP_EventType eventtype,
585  void *data,
586  bool isguide);
587  /// This static version of handleExternalNodeChange converts the callee
588  /// pointer to a SIM_Engine pointer and calls handleExternalNodeChange
589  /// on that engine.
590  static void handleExternalNodeChange(OP_Node *changednode,
591  void *callee,
592  OP_EventType eventtype,
593  void *data);
594  static void handleExternalGuideNodeChange(OP_Node *changednode,
595  void *callee,
596  OP_EventType eventtype,
597  void *data);
598 
599  /// Adds a SIM_DataFactoryCreator to the global list.
600  static void addDataFactoryCreator(SIM_DataFactoryCreator *creator);
601  /// Removes a SIM_DataFactoryCreator from the global list.
602  static void removeDataFactoryCreator(SIM_DataFactoryCreator *creator);
603  /// Returns the global list of data factory creators.
604  static UT_ValArray<SIM_DataFactoryCreator *> &getCreators();
605 
607  SIM_Cache myCache;
608  SIM_BaseCache *myBaseCache;
609  SIM_Time myTimeStep;
610  OP_Node *myOwner;
611  int myMaxFeedbackIterations;
612  int myFeedbackIteration;
613  int myCurrentCreatorId;
614  int myCurrentCreatorIndex;
615  mutable UT_String myOwnerFullPath;
616  mutable UT_ValArray<SIM_SaveCommand *> mySaveCommands;
617  mutable UT_Map<UT_Guid, SIM_Data *> myAllData;
618  mutable UT_Set<const SIM_Data *> myAllChangedSizeData;
619  mutable UT_Set<OP_Node *> myOPInterestNodes;
620  mutable UT_Set<OP_Node *> myGuideOPInterestNodes;
621  mutable int64 myTotalMemorySize;
622  bool myProvideDataHints;
623  bool myFirstSimulationStep;
624  bool myLastCookInterrupted;
625 
626  friend class SIM_Data;
627  friend class SIM_DataFactory;
629  friend class SIM_SimulationState;
630  friend class SIM_SaveCommand;
631  friend class SIM_BaseCache;
632  friend class SIM_Cache;
633 
634 protected:
640 
641 };
642 
643 #endif
DEP_MicroNode & refilterParmsMicroNode()
Definition: SIM_Engine.h:441
DEP_MicroNode myResimParmsMicroNode
Definition: SIM_Engine.h:637
GT_API const UT_StringHolder filename
virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &propdata)
GT_API const UT_StringHolder time
DEP_MicroNode & resimParmsMicroNode()
Definition: SIM_Engine.h:437
bool myIsPlayer
Definition: SIM_Engine.h:639
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual void notifySimulationChangeSinksOfChange()
Definition: SIM_Engine.h:347
int getCurrentCreatorId() const
Gets the id for the node that is currently being processed.
Definition: SIM_Engine.h:305
DEP_MicroNode mySimMicroNode
Definition: SIM_Engine.h:636
Holds pointers to a number of SIM_Relationships.
long long int64
Definition: SYS_Types.h:107
void resetToFirstSimulationStep()
Definition: SIM_Engine.h:270
GLdouble n
Definition: glcorearb.h:2007
virtual const char * className() const
Definition: SIM_Engine.h:46
SIM_SimulationMicroNode mySimInputMicroNode
Definition: SIM_Engine.h:635
DEP_MicroNode & simInputMicroNode()
Definition: SIM_Engine.h:433
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:133
Holds pointers to a number of SIM_Object objects.
GLenum GLenum severity
Definition: glcorearb.h:2538
GLboolean * data
Definition: glcorearb.h:130
DEP_MicroNode myRefilterParmsMicroNode
Definition: SIM_Engine.h:638
GLuint const GLchar * name
Definition: glcorearb.h:785
Holds pointers to a number of const SIM_Object objects.
SIM_Engine & myEngine
Definition: SIM_Engine.h:50
const DEP_MicroNode & refilterParmsMicroNode() const
Definition: SIM_Engine.h:443
double fpreal
Definition: SYS_Types.h:270
const DEP_MicroNode & resimParmsMicroNode() const
Definition: SIM_Engine.h:439
UT_CompressionType
bool isPlayer() const
Definition: SIM_Engine.h:450
GLuint index
Definition: glcorearb.h:785
#define SIM_API
Definition: SIM_API.h:10
OP_EventType
Definition: OP_Value.h:22
Propagation info for a dep micro node.
Definition: DEP_MicroNode.h:35
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
This class stores all the caching options used by the SIM_Cache.
int getCurrentCreatorIndex() const
Gets the index of the node output that is currently being processed.
Definition: SIM_Engine.h:308
const DEP_MicroNode & simInputMicroNode() const
Definition: SIM_Engine.h:435
DEP_MicroNode & simMicroNode()
Definition: SIM_Engine.h:426
const DEP_MicroNode & simMicroNode() const
Definition: SIM_Engine.h:428
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296
GLenum src
Definition: glcorearb.h:1792