Pointwise Plugin SDK
apiPWP.cxx
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * PWP Plugin example
4  *
5  * Proprietary software product of Pointwise, Inc.
6  * Copyright (c) 1995-2020 Pointwise, Inc.
7  * All rights reserved.
8  *
9  ***************************************************************************/
10 
11 #include <string.h>
12 
13 // Define this on the build command line for verbose build messages
14 // #define SHOW_PWP_MESSAGES
15 #include "apiPWP.h"
16 #include "apiPWPUtils.h"
17 #include "apiUtils.h"
18 
19 //************************* COMPILE TIME SANITY CHECKS *************************
20 // PWP_INT and PWP_UINT are must be sizeof(void*) for the target machine
23 
24 
25 //************************************************
26 // impl-defined plugin version values
27 //************************************************
28 #include "rtPwpVersions.h"
29 
30 /*------------------------------------*/
32 
33 // include the impl-defined PWP runtime item array data
34 #include "rtPwpInitItems.h"
35 
36  // special items NOT returned bt PwpEnumAPIs() - always LAST!
37  /*............................*/
38  {
39  {PWP_MESSAGECB_DEFAULT, {0,0}},
40  0,
41  },
42  /*............................*/
43  {
44  {PWP_MESSAGECB_SPY, {0,0}},
45  0,
46  },
47 };
48 
51 
52 
53 /**************************************/
55 {
56  PWP_BOOL ret = PWP_TRUE;
57  return ret;
58 }
59 
60 /**************************************/
61 PWP_BOOL PwpActivateAPI(const char api[])
62 {
63  return PwuFindPublishedAPI(api) ? PWP_TRUE : PWP_FALSE;
64 }
65 
66 /**************************************/
68 {
69 }
70 
71 /**************************************/
72 const char* PwpEnumAPIs(PWP_UINT32 ndx, PWP_APIINFO *pInfo)
73 {
74  const char* ret = (ndx < publishedApiCnt) ? pwpRtItem[ndx].apiInfo.name : 0;
75  if (ret && pInfo) {
76  *pInfo = pwpRtItem[ndx].apiInfo;
77  }
78  return ret;
79 }
80 
81 /**************************************/
83 {
84  return publishedApiCnt;
85 }
86 
87 /**************************************/
89 {
90  return PwuFindApiMsgCB(api);
91 }
92 
93 /**************************************/
95 {
97  PWP_PLUGININFO info = {
98 # include "rtPwpPluginInfo.h"
99  };
100 
101  info.apiCount = publishedApiCnt;
104 
105  if (pInfo) {
106  *pInfo = info;
107  }
108  return ret;
109 }
110 
111 /**************************************/
112 PWP_BOOL PwpIsLicensed(const char api[], const PWP_LICENSEDATA *pLicenseData)
113 {
114  return (pLicenseData && PwuFindPublishedAPI(api)) ? PWP_TRUE : PWP_FALSE;
115 }
116 
117 /**************************************/
118 PWP_MESSAGECB PwpSetMessageCallback(const char api[], PWP_MESSAGECB msgCallback)
119 {
120  PWP_MESSAGECB ret = 0;
121  PWU_RTITEM *pApiItem = PwuFindTotalAPI(api);
122  if (pApiItem) {
123  ret = pApiItem->msgCB;
124  //PwuSendDebugMsg(api, "removing callback", 0);
125  pApiItem->msgCB = msgCallback;
126  //PwuSendDebugMsg(api, "adding callback", 1);
127  }
128  return ret;
129 }
130 
131 /**************************************/
132 PWP_VOID PwpSetLanguage(const char language[])
133 {
134  if (language && language[0]) {
135  }
136 }
137 
138 
139 /**************************************/
140 PWP_BOOL PwpGetValue(const char group[], const char key[], PWP_HVALUE hVal)
141 {
142  PWP_BOOL ret = PWP_FALSE;
143  if (group && key && PWP_HVALUE_ISVALID(hVal)) {
144  ret = PwuGetValue(group, key, hVal);
145  }
146  return ret;
147 }
#define PWP_MESSAGECB_DEFAULT
Special API name used to register the default message handler.
Definition: apiPWP.h:570
PWP_UINT32 PwpGetAPICount()
Get the number of APIs supported by this plugin.
Definition: apiPWP.cxx:82
PWP_MESSAGECB msgCB
The API&#39;s assigned message callback.
Definition: apiPWPUtils.h:57
const char * PwpEnumAPIs(PWP_UINT32 ndx, PWP_APIINFO *pInfo)
Enumerates the APIs supported by this plugin.
Definition: apiPWP.cxx:72
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:212
Pointwise Plugin API (PWP-API)
PWP_UINT32(* PWP_MESSAGECB)(const char api[], PWP_ENUM_MSGID id, void *pMsg)
Message handler callback function signature.
Definition: apiPWP.h:557
void PWP_VOID
no value
Definition: apiPWP.h:319
#define ARRAYSIZE(arrname)
Calculates the size of a statically declared array.
Definition: apiUtils.h:166
PWP_MESSAGECB PwpGetMessageCallback(const char api[])
Gets the current message callback.
Definition: apiPWP.cxx:88
PWP_VOID PwpDestroy()
Called by framework just before plugin library is closed.
Definition: apiPWP.cxx:67
Static Initialization Data for the PWP_PLUGININFO structure.
Defines Implementation Version Information.
#define VERIFY_EXPLICIT_CAST(from, to)
Helper macro that verifies the sizes of two objects are the same.
Definition: apiUtils.h:253
#define PWP_TRUE
PWP_BOOL logical "true" value.
Definition: apiPWP.h:311
PWP_UINT32 totalApiCnt
The total # of published and unpublished entries in pwpRtItem[].
Definition: apiPWP.cxx:49
PWP_BOOL PwuGetValue(const char group[], const char name[], PWP_HVALUE hVal)
Implementation of the PwpGetValue() API function.
PWP_UINT32 apiCount
number of APIs implemented by this plugin
Definition: apiPWP.h:684
PWP_VOID PwpSetLanguage(const char language[])
Sets the active language.
Definition: apiPWP.cxx:132
PWU_RTITEM pwpRtItem[]
The runtime array of PWU_RTITEM items.
Definition: apiPWP.cxx:31
Installation&#39;s license data. NOT IMPLEMENTED YET.
Definition: apiPWP.h:493
Base plugin utilities.
PWP_BOOL PwpInitialize()
Initializes the plugin.
Definition: apiPWP.cxx:54
PWP_MESSAGECB PwuFindApiMsgCB(const char api[])
Search pwpRtItem[] for an API&#39;s messageCB.
Definition: apiPWPUtils.cxx:56
PWP_BOOL PwpIsLicensed(const char api[], const PWP_LICENSEDATA *pLicenseData)
Determines if plugin api is licensed for use on this machine.
Definition: apiPWP.cxx:112
The API information returned by plugins for each supported API.
Definition: apiPWP.h:654
int PWP_BOOL
logical value
Definition: apiPWP.h:305
PWP_UINT32 publishedApiCnt
The total # of published entries in pwpRtItem[].
Definition: apiPWP.cxx:50
PWP_MESSAGECB PwpSetMessageCallback(const char api[], PWP_MESSAGECB msgCallback)
Sets the message callback function for the given api.
Definition: apiPWP.cxx:118
The runtime data representing a PWP-API suported by a plugin.
Definition: apiPWPUtils.h:44
#define VERSION_PWP_MAJOR
The PWP-API major version value.
Definition: rtPwpVersions.h:21
#define PWP_HVALUE_ISVALID(h)
returns non-zero value if handle is valid
Definition: apiPWP.h:449
Static Initialization Data for the PWU_RTITEM Array.
PWP_UINT32 PWP_VERSIONVAL
Version data component value.
Definition: apiPWP.h:471
#define PWP_MESSAGECB_SPY
Special API name used to register the spy message handler.
Definition: apiPWP.h:583
PWU_RTITEM * PwuFindPublishedAPI(const char api[])
Find a published api in pwpRtItem[].
Definition: apiPWPUtils.cxx:49
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:287
PWP_MESSAGECB defCB
assigned default message callback
Definition: apiPWP.h:687
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:284
PWP_BOOL PwpGetValue(const char group[], const char key[], PWP_HVALUE hVal)
Get the value for a grouped key.
Definition: apiPWP.cxx:140
PWP_BOOL PwpActivateAPI(const char api[])
Activates the plugin for a given API spec.
Definition: apiPWP.cxx:61
PWP_PROTOTYPE_DECL PWP_VERSIONVAL PwpGetPluginInfo(PWP_PLUGININFO *pInfo)
Get information about this plugin.
PWP_APIINFO apiInfo
The PWP-API instance information.
Definition: apiPWPUtils.h:50
#define PWP_FALSE
PWP_BOOL logical "false" value.
Definition: apiPWP.h:308
Provides general information about a plugin.
Definition: apiPWP.h:666
PWP_MESSAGECB spyCB
assigned spy message callback
Definition: apiPWP.h:690
PWU_RTITEM * PwuFindTotalAPI(const char api[])
Find any api in pwpRtItem[].
Definition: apiPWPUtils.cxx:42
Data and functions useful to PWP-API compliant plugins.