HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_DataFactory.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_DataFactory_h__
9 #define __SIM_DataFactory_h__
10 
11 #include "SIM_API.h"
12 #include <UT/UT_String.h>
13 #include <UT/UT_StringArray.h>
14 #include <UT/UT_StringHolder.h>
15 
16 class UT_Guid;
17 class SIM_Data;
18 class SIM_DataFactory;
19 class SIM_DopDescription;
20 class SIM_Engine;
22 
24 typedef SIM_Data *(*SIM_DataConstructor)(const SIM_DataFactory *);
26 
27 /// This class provides a means of creating and destroying SIM_Data objects.
28 /// Nothing needs to be known about the SIM_Data object except its data
29 /// type name. It is possible to derive a subclass to use instead of
30 /// relying on the default implementations used by the DECLARE_DATAFACTORY
31 /// and IMPLEMENT_DATAFACTORY macros. But generally these macros will be
32 /// sufficient.
34 {
35 public:
36  /// Constructor which receives all the data for this factory.
37  /// The constructor arguments contain all the information that may be
38  /// required for the new data type without actually requiring an
39  /// instance of that data type to be constructed.
41  const UT_StringHolder &datatype,
42  const UT_StringHolder &description,
43  SIM_GetSuperclasses get_superclasses,
44  SIM_DataConstructor constructor,
45  SIM_DataDestructor destructor,
46  const SIM_DopDescription *dopdesc,
47  const SIM_Engine *engine);
48  /// Destructor.
49  virtual ~SIM_DataFactory();
50 
51  /// Return the SIM_Engine that owns this factory.
52  const SIM_Engine &getEngine() const;
53  /// Get the name of the data type that is created by this factory.
54  /// This is the unique identifier that is passed to a SIM_Object to
55  /// create a new instance of this data type.
57  { return myDataType; }
58  /// Get array of all superclass names of our data type
60  UT_StringArray &classes) const
61  { myGetSuperclasses(classes); }
62  /// Gets a string that describes what this data type does.
63  /// This descriptive string is what is presented to the user when
64  /// given a menu of data type choices.
65  const UT_StringHolder &getDescription() const;
66  /// Returns the name of the DSO or DLL file that defines the data type.
67  /// For data types defined internally to Houdini the returned string
68  /// will be empty.
69  const UT_String &getSource() const;
70 
71  /// Create a new instance of our particular subclass of SIM_Data.
72  virtual SIM_Data *newData(bool doinit) const;
73  /// Calls newData() to create some new data, then changes the unique id.
74  SIM_Data *newData(const UT_Guid &uniqueid) const;
75  /// Delete an instance of our particular subclass of SIM_Data.
76  virtual void deleteData(SIM_Data *data) const;
77  /// Return our SIM_DopDescription.
78  virtual const SIM_DopDescription *getDopDescription() const;
79 
80 private:
81  /// All our data is set up in the constructor and cannot be modified.
82  const UT_StringHolder myDataType;
83  const UT_StringHolder myDescription;
84  const SIM_GetSuperclasses myGetSuperclasses;
85  const SIM_DataConstructor myConstructor;
86  const SIM_DataDestructor myDestructor;
87  const SIM_DopDescription *myDopDescription;
88  const SIM_Engine *myEngine;
89  const SIM_DataFactoryCreator *myCreator;
90 
91  friend class SIM_DataFactoryCreator;
92 };
93 
94 /// This helper class lets each SIM_Engine create an instance of
95 /// each SIM_DataFactory available on the system.
97 {
98 public:
99  /// Defines a function for creating a SIM_DataFactory.
100  typedef void (*SIM_DataFactoryCreateFunc)(SIM_Engine *engine);
101 
102  /// Constructor sets the SIM_DataFactory creation function.
103  /// It also registers this SIM_DataFactoryCreator instance with the
104  /// global list in the SIM_Engine class.
105  SIM_DataFactoryCreator(SIM_DataFactoryCreateFunc createfunc);
106  /// Destructor which removes this SIM_DataFactoryCreator from the
107  /// global list owned by the SIM_Engine class.
109 
110  /// Returns the name of the DSO or DLL file that defines the data type.
111  /// For data types defined internally to Houdini the returned string
112  /// will be empty.
113  const UT_String &getSource() const;
114  /// Call the creation function to make a new SIM_DataFactory instance.
115  void createDataFactory(SIM_Engine *engine);
116  /// Call addDataFactory on the specified SIM_Engine.
117  static void addDataFactory(SIM_Engine *engine,
118  SIM_DataFactory *factory);
119 
120 private:
121  SIM_DataFactoryCreateFunc myCreateFunc;
122  const UT_String mySource;
123 
124  static const SIM_DataFactoryCreator *theCreatingFactory;
125 };
126 
127 #endif
128 
virtual int getSource()
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
void(* SIM_GetSuperclasses)(UT_StringArray &)
const UT_StringHolder & getDataType() const
GLboolean * data
Definition: glcorearb.h:130
void getDataTypeSuperclasses(UT_StringArray &classes) const
Get array of all superclass names of our data type.
#define SIM_API
Definition: SIM_API.h:10
SIM_Data *(* SIM_DataConstructor)(const SIM_DataFactory *)
void(* SIM_DataDestructor)(SIM_Data *)