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