-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISXRIServices.h
More file actions
91 lines (79 loc) · 4.02 KB
/
ISXRIServices.h
File metadata and controls
91 lines (79 loc) · 4.02 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once
/**********************************************************************
ISXRIServices.h is a redistributable file that can be used
by other extensions to access the services provided by ISXRI.
It should contain all information for any message that can be sent to
clients from the master (individually or broadcast), or to the master
from clients.
All "in/out" information is relative to the client. If it says "in"
it means the client feeds information in. If it says "out" it means
the client pulls information out.
**********************************************************************/
// ----- "RI Service" messages ------------------------------
// Note: ISXSERVICE_MSG defines the starting point for service-specific
// message numbers. Numbers below ISXSERVICE_MSG are reserved for
// future system use.
// These message numbers are PER SERVICE, so you can and should
// reuse numbers for different services
/* in (requests) */
#define RI_FOO (ISXSERVICE_MSG+1)
// add all requests
/* out (notifications) */
#define RI_BAR (ISXSERVICE_MSG+2)
// add all notifications
// ----- "RI Service" request structures ---------------------
// These structures are sent as the "lpData" in requests or notifications.
/*
* All structures are essentially used to build a function call. Our first
* example handles a call to this function:
bool RIFooFunction(const char *Name, unsigned int Age,float Height);
* This function has 3 parameters, and 1 return value. The structure used will
* reflect exactly this.
*
* Note that because services are all executed in-process, data does not need to
* be serialized, as it would with using network sockets and such -- in other words,
* it is safe to pass original pointers.
*/
// RI_FOO
struct RIRequest_Foo
{
/* in */ const char *Name; // Parameter 1
/* in */ unsigned int Age; // Parameter 2
/* int */ float Height; // Parameter 3
/* out */ bool Success; // Return value
};
// ----- "RI Service" Helper Functions -----------------------
// Put any helper functions for REQUESTS here. Notifications (in contrast) are done by
// the service master, and do not need redistributable helper functions.
/*
* This function sets up the actual service request. It follows the same form as the function we
* are calling, but takes additional parameters to set up the remote service request. This will
* be used by our EzFoo macro, which will hide the service portion from developers wishing to use
* the remote function.
*/
static inline bool RIFoo(ISXInterface *pClient, ISInterface *pISInterface, HISXSERVICE hRIService, const char *Name, unsigned int Age, float Height)
{
// set up lpData
RIRequest_Foo RemoteFunctionCall;
RemoteFunctionCall.Name=Name;
RemoteFunctionCall.Age=Age;
RemoteFunctionCall.Height=Height;
RemoteFunctionCall.Success=false;
// return true if a) the service request was sent correctly and b) the service set Success to true, indicating
// that the Foo operation was successfully completed
return pISInterface->ServiceRequest(pClient,hRIService,RI_FOO,&RemoteFunctionCall) && RemoteFunctionCall.Success;
}
// Most extensions will opt to use the default naming conventions, with a global pISInterface and pExtension,
// and your service handle name. This means you can make an "easy" macro to call RIFoo for them,
// and they can just use EzFoo as if they were calling the actual remote function:
#define EzFoo(_name_,_age_,_height_) RIFoo(pExtension,pISInterface,hRIService,_name_,_age_,_height_)
// Note that EzFoo is now used exactly the same as bool RIFooFunction(const char *Name, unsigned int Age,float Height)
// ----- "RI Service" notification structures ---------------------
// The following structures are for use in RI Service notification handlers
// RI_BAR
// NOTE: For structures that have only one data item, we dont really need a structure. But to make things
// easy to use and understand, it's perfectly fine and compiles to the same machine code anyway.
struct RINotification_Bar
{
/* out */ const char *Text;
};