Open Reality Reference Guide
iobject.h
1 #ifndef _IObject_H
2 #define _IObject_H
3 /**************************************************************************
4 Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5 All Rights Reserved.
6 
7 The coded instructions, statements, computer programs, and/or related
8 material (collectively the "Data") in these files contain unpublished
9 information proprietary to Autodesk, Inc. and/or its licensors, which is
10 protected by Canada and United States of America federal copyright law
11 and by international treaties.
12 
13 The Data may not be disclosed or distributed to third parties, in whole
14 or in part, without the prior written consent of Autodesk, Inc.
15 ("Autodesk").
16 
17 THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18 ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19 WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20 ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21 OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22 PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23 WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24 FREE.
25 
26 IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27 OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28 EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29 DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30 OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31 DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32 LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33 LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34 DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35 BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
40 #include <kaydara.h>
41 
42 #define IObjectID 0
43 #define IObjectDerived public IObject
44 
46 K_FORWARD( IObject );
47 
49 typedef unsigned long kInterfaceID;
50 
52 #define FncDefine(PFNC,ISPURE) virtual PFNC##ISPURE
53 #define IObjectImplement(ClassName,IObjectOwner) \
54  HIObject ClassName##::IQuery(kInterfaceID pInterfaceID,int IsLocal) {\
55  if ((IObjectOwner!=NULL) && (!IsLocal)) {\
56  return IObjectOwner->IQuery(pInterfaceID);\
57  }\
58  switch (pInterfaceID)
59 #define IObjectEnd return NULL; }
60 #define ILOCAL 1
61 
62 #define IQUERY(Object,Interface) ((H##Interface)((Object)->IQuery(Interface##ID,0)))
63 #define IQUERYLOCAL(Object,Interface) ( (H##Interface)((Object)->IQuery(Interface##ID,ILOCAL)))
64 
65 #define IQ(Object,Interface) IQUERY(Object,Interface)
66 #define IQT(Object,Interface) ((Object) ? IQUERY(Object,Interface):NULL)
67 #define IQL(Object,Interface) IQUERYLOCAL(Object,Interface)
68 
69 /*********************************************************************
70  * Class IObject
71  * This is the base class of all Important interfaces of the system
72  *********************************************************************/
73 
74 #define IObject_Declare(IsPure)\
75 public:\
76  virtual HIObject IQuery(kInterfaceID pInterfaceID, int IsLocal=0)IsPure;\
77  virtual void Destroy(int IsLocal=0)IsPure
78 
79 #define IQuery_Declare(IsPure)\
80 public:\
81  virtual HIObject IQuery (kInterfaceID pInterfaceID, int IsLocal=0)IsPure;
82 
83 class IObject {
84  IObject_Declare(abstract);
85 };
86 
87 typedef HIObject (* kObjectCreatorFnc)(HIObject pOwner,const char *pName,void *pData);
88 
89 #ifdef KARCH_DEV_MSC
90  #define K_INTERFACE_SPECIAL __declspec(novtable)
91  #define NO_DLL __declspec() // Use for the Module parameter if the interface is not exported
92 #else
93  #define K_INTERFACE_SPECIAL
94  #define NO_DLL // Use for the Module parameter if the interface is not exported
95 #endif
96 
97 #define K_INTERFACE( Name,Id ) \
98 K_FORWARD( Name ); \
99 const int Name##ID = Id; \
100 class K_INTERFACE_SPECIAL Name : IObjectDerived { \
101  Name##_Declare(abstract); \
102 }
103 
104 #endif // Must be the last line of the include file
105 
106