InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ClassFactory.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Robin_Briggs
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Virtual constructors."
24 //
25 // Allows you to register a constructor function, keyed by class ID.
26 // Which in turns allows you to create a new object given a class ID.
27 //
28 //========================================================================================
29 
30 #ifndef __CLASSFACTORY__
31 #define __CLASSFACTORY__
32 
33 #ifndef __ODFRC__
34 #include "OMFactoryCtor.h"
35 
36 class IDataBase;
37 
73 class ClassFactory {
74 public:
75  ClassFactory(ClassID id, BossConstructor classFact = nil);
76 
77  static void InstallClasses(PluginID ownerComponent);
78 
79  ClassID GetClassID() { return fID; }
80  BossConstructor GetFactory() { return fFactory; }
81 
82 private:
83  ClassID fID;
84  BossConstructor fFactory;
85  ClassFactory *fNext;
86  static ClassFactory *gFirstClass;
87 };
88 
89 
90 #define CREATE_CLASSFACTORY(className, clsID) \
91  ClassFactory g##className##Factory(clsID, Create##className); \
92  ClassFactory *Get##className##Factory(); \
93  ClassFactory *Get##className##Factory() { return &g##className##Factory; }
94 
95 
96 #define REGISTER_CLASSFACTORY(className, clsID) \
97  ClassFactory *Get##className##Factory(); \
98  Get##className##Factory();
99 
100 #else // is ODFRC
101 #define REGISTER_CLASSFACTORY(ClassName, clsID) \
102  clsID
103 #endif
104 
105 #endif // __CLASSFACTORY__