My Project
baseinterface.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2006.8
4 // Description: API for interfaces.
5 //-----------------------------------------------------------------------------
6 #pragma once
7 
8 #include "PEtypes.h"
9 
10 namespace ParaEngine
11 {
12  class BaseInterface;
13 
15  #define BASEINTERFACE_ID Interface_ID(0, 1)
16 
19  {
20  public:
21  virtual BaseInterface* GetInterface(Interface_ID id) { return NULL; }
22  };
23 
30  {
31  public:
32  // from InterfaceServer
33  BaseInterface* GetInterface(Interface_ID id) { if (id == BASEINTERFACE_ID) return this; else return NULL; }
34 
35  // identification
36  virtual Interface_ID GetID() { return BASEINTERFACE_ID; }
37 
38  // interface lifetime management
39  // there is an implied Acquire() whenever an interface is served via a GetInterface()
40  enum LifetimeType { noRelease, immediateRelease, wantsRelease, serverControlled };
41 
42  // LifetimeControl returns noRelease since
43  // AcquireInterface and ReleaseInterface do not perform
44  // any real acquiring and releasing (reference counting, etc.)
45  // If the implementation of AcquireInterface and ReleaseInterface changes
46  // in this class or derived classes, the return value of LifetimeControl
47  // needs to be updated accordingly.
48  // RegisterNotifyCallback returns true if the callback will be called at or before deletion
49  virtual LifetimeType LifetimeControl() { return noRelease; }
50  virtual BaseInterface* AcquireInterface() { return (BaseInterface*)this; };
51  virtual void ReleaseInterface() { };
52 
53  // direct interface delete request
54  virtual void DeleteInterface() { };
55 
56  // interface cloning
57  virtual BaseInterface* CloneInterface(void* remapDir = NULL) { return NULL; }
58  };
59 }
60 
The base class for interfaces in ParaEngine.
Definition: baseinterface.h:29
different physics engine has different winding order.
Definition: EventBinding.h:32
an interface ID
Definition: PEtypes.h:267
Base class for those classes and interfaces in ParaEngine that can serve interfaces.
Definition: baseinterface.h:18