aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/dependency/api_dependent.h
blob: 23b7a54a61c1b14b5260752d399a9269cc6aa95b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef __WASABI_API_DEPENDENT_H
#define __WASABI_API_DEPENDENT_H

#include <bfc/dispatch.h>
#include "api_dependentviewer.h"

// we define some common event codes here. if your object needs more send
// them as parameters to OBJECTSPECIFIC

// some system-level codes for cb param. You can implement your own events
// with DEPCB_EVENT and the parameters
namespace DependentCB
{
	enum {
	    DEPCB_NOP = 0,
	    DEPCB_DELETED = 100, 		// object being deleted
	    DEPCB_EVENT = 1000, 			// object-specific event. use param1 etc to send your messages
	};
};

class NOVTABLE ifc_dependent : public Dispatchable
{
protected:
	ifc_dependent() {}
	~ifc_dependent() {}
public:
	void dependent_regViewer(ifc_dependentviewer *viewer, int add) ;
	void *dependent_getInterface(const GUID *classguid);

	DISPATCH_CODES
	{
		API_DEPENDENT_REGVIEWER = 10,
		API_DEPENDENT_GETINTERFACE = 20,
	};
};

inline void ifc_dependent::dependent_regViewer(api_dependentviewer *viewer, int add)
	{
		_voidcall(API_DEPENDENT_REGVIEWER, viewer, add);
	}
	inline void *ifc_dependent::dependent_getInterface(const GUID *classguid)
	{
		return _call(API_DEPENDENT_GETINTERFACE, (void *)0, classguid);
	}


// this is a helper for dependent_getInterface
#define HANDLEGETINTERFACE(x) { \
		if (*classguid == *x::depend_getClassGuid()) return static_cast<x *>(this); \
	}

typedef ifc_dependent api_dependent;

#endif