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-2018 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 
20 //************************************************
21 // impl-defined plugin version values
22 //************************************************
23 #include "rtPwpVersions.h"
24 
25 /*------------------------------------*/
27 
28 // include the impl-defined PWP runtime item array data
29 #include "rtPwpInitItems.h"
30 
31  // special items NOT returned bt PwpEnumAPIs() - always LAST!
32  /*............................*/
33  {
34  {PWP_MESSAGECB_DEFAULT, {0,0}},
35  0,
36  },
37  /*............................*/
38  {
39  {PWP_MESSAGECB_SPY, {0,0}},
40  0,
41  },
42 };
43 
46 
47 
48 /**************************************/
50 {
51  PWP_BOOL ret = PWP_TRUE;
52  return ret;
53 }
54 
55 /**************************************/
56 PWP_BOOL PwpActivateAPI(const char api[])
57 {
58  return PwuFindPublishedAPI(api) ? PWP_TRUE : PWP_FALSE;
59 }
60 
61 /**************************************/
63 {
64 }
65 
66 /**************************************/
67 const char* PwpEnumAPIs(PWP_UINT32 ndx, PWP_APIINFO *pInfo)
68 {
69  const char* ret = (ndx < publishedApiCnt) ? pwpRtItem[ndx].apiInfo.name : 0;
70  if (ret && pInfo) {
71  *pInfo = pwpRtItem[ndx].apiInfo;
72  }
73  return ret;
74 }
75 
76 /**************************************/
78 {
79  return publishedApiCnt;
80 }
81 
82 /**************************************/
84 {
85  return PwuFindApiMsgCB(api);
86 }
87 
88 /**************************************/
90 {
92  PWP_PLUGININFO info = {
93 # include "rtPwpPluginInfo.h"
94  };
95 
99 
100  if (pInfo) {
101  *pInfo = info;
102  }
103  return ret;
104 }
105 
106 /**************************************/
107 PWP_BOOL PwpIsLicensed(const char api[], const PWP_LICENSEDATA *pLicenseData)
108 {
109  return (pLicenseData && PwuFindPublishedAPI(api)) ? PWP_TRUE : PWP_FALSE;
110 }
111 
112 /**************************************/
113 PWP_MESSAGECB PwpSetMessageCallback(const char api[], PWP_MESSAGECB msgCallback)
114 {
115  PWP_MESSAGECB ret = 0;
116  PWU_RTITEM *pApiItem = PwuFindTotalAPI(api);
117  if (pApiItem) {
118  ret = pApiItem->msgCB;
119  //PwuSendDebugMsg(api, "removing callback", 0);
120  pApiItem->msgCB = msgCallback;
121  //PwuSendDebugMsg(api, "adding callback", 1);
122  }
123  return ret;
124 }
125 
126 /**************************************/
127 PWP_VOID PwpSetLanguage(const char language[])
128 {
129  if (language && language[0]) {
130  }
131 }
132 
133 
134 /**************************************/
135 PWP_BOOL PwpGetValue(const char group[], const char key[], PWP_HVALUE hVal)
136 {
137  PWP_BOOL ret = PWP_FALSE;
138  if (group && key && PWP_HVALUE_ISVALID(hVal)) {
139  ret = PwuGetValue(group, key, hVal);
140  }
141  return ret;
142 }
#define PWP_MESSAGECB_DEFAULT
Special API name used to register the default message handler.
Definition: apiPWP.h:484
PWP_UINT32 PwpGetAPICount()
Get the number of APIs supported by this plugin.
Definition: apiPWP.cxx:77
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:67
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:194
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:471
void PWP_VOID
no value
Definition: apiPWP.h:233
#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:83
PWP_VOID PwpDestroy()
Called by framework just before plugin library is closed.
Definition: apiPWP.cxx:62
Static Initialization Data for the PWP_PLUGININFO structure.
Defines Implementation Version Information.
#define PWP_TRUE
PWP_BOOL logical "true" value.
Definition: apiPWP.h:227
PWP_UINT32 totalApiCnt
The total # of published and unpublished entries in pwpRtItem[].
Definition: apiPWP.cxx:44
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:598
PWP_VOID PwpSetLanguage(const char language[])
Sets the active language.
Definition: apiPWP.cxx:127
PWU_RTITEM pwpRtItem[]
The runtime array of PWU_RTITEM items.
Definition: apiPWP.cxx:26
Installation&#39;s license data. NOT IMPLEMENTED YET.
Definition: apiPWP.h:407
Base plugin utilities.
PWP_BOOL PwpInitialize()
Initializes the plugin.
Definition: apiPWP.cxx:49
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:107
The API information returned by plugins for each supported API.
Definition: apiPWP.h:568
int PWP_BOOL
logical value
Definition: apiPWP.h:221
PWP_UINT32 publishedApiCnt
The total # of published entries in pwpRtItem[].
Definition: apiPWP.cxx:45
PWP_MESSAGECB PwpSetMessageCallback(const char api[], PWP_MESSAGECB msgCallback)
Sets the message callback function for the given api.
Definition: apiPWP.cxx:113
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:363
Static Initialization Data for the PWU_RTITEM Array.
PWP_UINT32 PWP_VERSIONVAL
Version data component value.
Definition: apiPWP.h:385
#define PWP_MESSAGECB_SPY
Special API name used to register the spy message handler.
Definition: apiPWP.h:497
PWU_RTITEM * PwuFindPublishedAPI(const char api[])
Find a published api in pwpRtItem[].
Definition: apiPWPUtils.cxx:49
PWP_MESSAGECB defCB
assigned default message callback
Definition: apiPWP.h:601
PWP_BOOL PwpGetValue(const char group[], const char key[], PWP_HVALUE hVal)
Get the value for a grouped key.
Definition: apiPWP.cxx:135
PWP_BOOL PwpActivateAPI(const char api[])
Activates the plugin for a given API spec.
Definition: apiPWP.cxx:56
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:224
Provides general information about a plugin.
Definition: apiPWP.h:580
PWP_MESSAGECB spyCB
assigned spy message callback
Definition: apiPWP.h:604
PWU_RTITEM * PwuFindTotalAPI(const char api[])
Find any api in pwpRtItem[].
Definition: apiPWPUtils.cxx:42
Data and functions useful to PWP-API compliant plugins.