Pointwise Plugin SDK
apiGRDPUtils.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Pointwise Plugin utility functions
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #ifndef _APIGRDPUTILS_H_
10 #define _APIGRDPUTILS_H_
11 
12 #include <stdio.h>
13 #include <time.h>
14 
15 #include "apiGRDP.h"
16 #include "apiPWP.h"
17 #include "apiPWPUtils.h"
18 #include "apiGridModel.h"
19 
20 extern "C" {
21 
22 /************************************************************************/
44 // include impl-defined instance runtime data types.
45 // Must also define the macro GRDP_RUNTIME_INSTDATADECL
46 #include "rtGrdpInstanceData.h"
47 
55 #if !defined(GRDP_RUNTIME_INSTDATADECL)
56 # define GRDP_RUNTIME_INSTDATADECL
57 #endif
58 
59 
60 /***********************************************************/
61 /***********************************************************/
73 //***************************************************************************
74 //***************************************************************************
102  /* add new group enum values before this line */
103 
106  GRDP_CLKS_SIZE,
108  GRDP_CLKS_LAST = GRDP_CLKS_SIZE-1
110  // sdkINTERNALS
111 };
112 
113 
114 /************************************************************************/
117 struct GRDP_RTITEM {
123 
127 
140  FILE * fp;
141 
152 
158 
164 
165 
173  PWP_UINT32 progTotal;
174 
180  PWP_UINT32 progComplete;
181 
187  clock_t clocks[GRDP_CLKS_SIZE];
188 
194  PWP_BOOL opAborted;
195  // sdkINTERNALS
197 
201 };
202 
203 
204 /************************************************************************/
218 extern GRDP_RTITEM grdpRtItem[];
219 
220 
221 /************************************************************************/
228  /* DOXGRP_APIGRDP_UTILS_DATA */
230 
231 
232 
233 //***************************************************************************
234 //***************************************************************************
242 /************************************************************************/
253 
254 
255 /************************************************************************/
264 GRDP_RTITEM* grdpFindFormatByName (const char name[]);
265  /* DOXGRP_APIGRDP_UTILS_SDKGRDP */
267 
268 
269 
270 //***************************************************************************
271 //***************************************************************************
283 /************************************************************************/
329 
330 
331 /************************************************************************/
345 
346 
347 /************************************************************************/
358 
359 
360 /************************************************************************/
371 
372 
373 /************************************************************************/
388  /* DOXGRP_APIGRDP_UTILS_PROGRESS */
390 
391 
392 //***************************************************************************
393 //***************************************************************************
406 //-------------------------------------------------------------------------
413 void grdpSendDebugMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
414 
415 //-------------------------------------------------------------------------
422 void grdpSendInfoMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
423 
424 //-------------------------------------------------------------------------
431 void grdpSendWarningMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
432 
433 //-------------------------------------------------------------------------
440 void grdpSendErrorMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
441  /* DOXGRP_APIGRDP_UTILS_MSGS */
443 
444 
445 //***************************************************************************
446 //***************************************************************************
456 //-------------------------------------------------------------------------
483  const char value[], const char access[], const char desc[],
484  const char range[]);
485 
486 
487 //-------------------------------------------------------------------------
502 PWP_BOOL grdpAssignInfoValue(const char name[], const char value[],
503  const bool create = true);
504 
505 
506 //-------------------------------------------------------------------------
521 PWP_BOOL grdpAssignInfoValueInt(const char name[], const PWP_INT value,
522  const bool create = true);
523 
524 
525 //-------------------------------------------------------------------------
540 PWP_BOOL grdpAssignInfoValueUInt(const char name[], const PWP_UINT value,
541  const bool create = true);
542 
543 
544 //-------------------------------------------------------------------------
559 PWP_BOOL grdpAssignInfoValueReal(const char name[], const PWP_REAL value,
560  const bool create = true);
561 
562 
563 //-------------------------------------------------------------------------
578 PWP_BOOL grdpAssignInfoValueBool(const char name[], const bool value,
579  const bool create = true);
580 
581 
582 //-------------------------------------------------------------------------
597 PWP_BOOL grdpAssignInfoValueEnum(const char name[], const char value[],
598  bool create = true);
599  /* DOXGRP_APIGRDP_UTILS_VARS */
601 
602 
603 //***************************************************************************
604 //***************************************************************************
613 /************************************************************************/
616 #define GRDP_RT_IMPORT_CONDITIONS(rti) (rti)->pReadInfo->importConditions
617 
618 
619 /************************************************************************/
623 #define GRDP_RT_IS_ABORTED(rti) PWP_CAST_BOOL((rti)->opAborted)
624 
625 /************************************************************************/
628 #define GRDP_RT_ABORT(rti) ((rti)->opAborted = PWP_TRUE)
629 
630 /************************************************************************/
633 #define GRDP_IS_CLKS_ID(id) \
634  PWP_CAST_BOOL(((id) >= 0) && ((id) <= GRDP_CLKS_LAST))
635 
636 /************************************************************************/
639 #define GRDP_RT_CLKS_ID(rti, id) (GRDP_IS_CLKS_ID(id)? (rti)->clocks[id]: 0)
640 
641 /************************************************************************/
645 #define GRDP_RT_CLKS_DIFF(rti, startId, endId) \
646  ((GRDP_IS_CLKS_ID(startId) && GRDP_IS_CLKS_ID(endId)) ? \
647  ((rti)->clocks[endId] - (rti)->clocks[startId]) : 0)
648 
649 /************************************************************************/
653 #define GRDP_RT_CLKS_POLL(rti, id) \
654  GRDP_RT_CLKS_DIFF(rti, id, GRDP_CLKS_PROGINCR)
655 
656 /************************************************************************/
660 #define GRDP_RT_CLKS_POLL_STEP(rti) \
661  GRDP_RT_CLKS_POLL(rti, GRDP_CLKS_BEGSTEP)
662 
663 /************************************************************************/
667 #define GRDP_RT_CLKS_DIFF_STEP(rti) \
668  GRDP_RT_CLKS_DIFF(rti, GRDP_CLKS_BEGSTEP, GRDP_CLKS_ENDSTEP)
669 
670 /************************************************************************/
674 #define GRDP_RT_CLKS_POLL_TOTAL(rti) \
675  GRDP_RT_CLKS_POLL(rti, GRDP_CLKS_PROGINIT)
676 
677 /************************************************************************/
681 #define GRDP_RT_CLKS_DIFF_TOTAL(rti) \
682  GRDP_RT_CLKS_DIFF(rti, GRDP_CLKS_PROGINIT, GRDP_CLKS_PROGEND)
683 
684 /************************************************************************/
688 #define GRDP_CLKS_TO_MSECS(c) ((PWP_INT32)((c) * 1000) / CLOCKS_PER_SEC)
689 
690 /************************************************************************/
694 #define GRDP_CLKS_TO_SECS(c) ((PWP_INT32)(c) / CLOCKS_PER_SEC)
695 
696 /************************************************************************/
700 #define GRDP_CLKS_TO_MINS(c) (GRDP_CLKS_TO_SECS(c) / 60)
701 
702 /************************************************************************/
706 #define GRDP_CLKS_TO_HOURS(c) (GRDP_CLKS_TO_MINS(c) / 60)
707 
708 /************************************************************************/
713 #define GRDP_CLKS_TO_HMS(c, h, m, s) \
714  (s = GRDP_CLKS_TO_SECS(c)), \
715  (h = s / 3600), (s -= h * 3600), \
716  (m = s / 60), \
717  (s -= m * 60)
718 
719 /************************************************************************/
722 #define GRDP_CLKS_TO_FSECS(c) ((PWP_FLOAT)(c) / (PWP_FLOAT)CLOCKS_PER_SEC)
723 
730 } /* extern "C" */
731 
732 #endif /* _APIGRDPUTILS_H_ */
GRDP_CLKS_PROGUPDATE
@ GRDP_CLKS_PROGUPDATE
Definition: apiGRDPUtils.h:96
grdpSendDebugMsg
void grdpSendDebugMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a debug text message (PWP_MSGID_DEBUG) to the framework.
Definition: apiGRDPUtils.cxx:170
grdpRtItem
GRDP_RTITEM grdpRtItem[]
The runtime array of GRDP_RTITEM items.
Definition: apiGRDP.cxx:27
GRDP_CLKS_ENDSTEP
@ GRDP_CLKS_ENDSTEP
Definition: apiGRDPUtils.h:100
PWP_ENUM_VALTYPE
PWP_ENUM_VALTYPE
Supported PWP-API getValue() transfer types.
Definition: apiPWP.h:696
GRDP_RTITEM::pReadInfo
const GRDP_READINFO * pReadInfo
Runtime grid import settings.
Definition: apiGRDPUtils.h:163
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
GRDP_CLKS_PROGEND
@ GRDP_CLKS_PROGEND
Definition: apiGRDPUtils.h:101
grdpAssignInfoValueReal
PWP_BOOL grdpAssignInfoValueReal(const char name[], const PWP_REAL value, const bool create=true)
Creates a key/PWP_REAL-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:239
GRDP_CLKS_BEGSTEP
@ GRDP_CLKS_BEGSTEP
Definition: apiGRDPUtils.h:98
grdpFindFormatByName
GRDP_RTITEM * grdpFindFormatByName(const char name[])
Find an item in grdpRtItem[] by it's name.
Definition: apiGRDPUtils.cxx:33
PWGM_HGRIDMODEL
An opaque handle to a grid model.
Definition: apiGridModel.h:326
grdpSendInfoMsg
void grdpSendInfoMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an info text message (PWP_MSGID_INFO) to the framework.
Definition: apiGRDPUtils.cxx:179
PWP_UINT
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
grdpPublishValueDefinition
PWP_BOOL grdpPublishValueDefinition(const char name[], PWP_ENUM_VALTYPE type, const char value[], const char access[], const char desc[], const char range[])
Creates a collection of key/value pairs that represent a published grid import attribute definition.
Definition: apiGRDPUtils.cxx:207
grdpProgressEnd
PWP_BOOL grdpProgressEnd(GRDP_RTITEM *pRti, const PWP_BOOL ok)
Ends all progress tracking.
Definition: apiGRDPUtils.cxx:154
apiGridModel.h
Pointwise Grid Model API Specification (PWGM-API)
GRDP_RTITEM::FormatInfo
GRDP_FORMATINFO FormatInfo
The Grid Import Plugin format data.
Definition: apiGRDPUtils.h:122
GRDP_ENUM_CLOCKS
GRDP_ENUM_CLOCKS
Supported GRDP clock id values.
Definition: apiGRDPUtils.h:95
grdpAssignInfoValue
PWP_BOOL grdpAssignInfoValue(const char name[], const char value[], const bool create=true)
Creates a key/string-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:218
GRDP_RTITEM
The data representing a grid importer instance.
Definition: apiGRDPUtils.h:117
grdpSendWarningMsg
void grdpSendWarningMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a warning text message (PWP_MSGID_WARNING) to the framework.
Definition: apiGRDPUtils.cxx:188
PWP_REAL
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
GRDP_READINFO
Grid import read control information.
Definition: apiGRDP.h:108
apiGRDP.h
Pointwise Grid Import Plugin API (GRDP-API)
grdpFindFormatById
GRDP_RTITEM * grdpFindFormatById(PWP_UINT32 id)
Find an item in grdpRtItem[] by it's id.
Definition: apiGRDPUtils.cxx:18
GRDP_RTITEM::unfData
PWU_UNFDATA unfData
Unformatted file I/O data.
Definition: apiGRDPUtils.h:151
GRDP_CLKS_PROGINCR
@ GRDP_CLKS_PROGINCR
Definition: apiGRDPUtils.h:99
grdpAssignInfoValueEnum
PWP_BOOL grdpAssignInfoValueEnum(const char name[], const char value[], bool create=true)
Creates a key/enum-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:253
grdpAssignInfoValueInt
PWP_BOOL grdpAssignInfoValueInt(const char name[], const PWP_INT value, const bool create=true)
Creates a key/PWP_INT-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:225
GRDP_RTITEM::pApiData
PWU_RTITEM * pApiData
Pointer to the associated PWU_RTITEM structure.
Definition: apiGRDPUtils.h:126
GRDP_RTITEM::model
PWGM_HGRIDMODEL model
Runtime grid model handle to import.
Definition: apiGRDPUtils.h:157
grdpAssignInfoValueUInt
PWP_BOOL grdpAssignInfoValueUInt(const char name[], const PWP_UINT value, const bool create=true)
Creates a key/PWP_UINT-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:232
PWP_INT
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
grdpProgressBeginStep
PWP_BOOL grdpProgressBeginStep(GRDP_RTITEM *pRti, PWP_UINT32 total)
Begins a progress tracking step.
Definition: apiGRDPUtils.cxx:65
PWP_BOOL
int PWP_BOOL
logical value
Definition: apiPWP.h:303
grdpProgressInit
PWP_BOOL grdpProgressInit(GRDP_RTITEM *pRti, PWP_UINT32 cnt)
Initializes a progress tracking session.
Definition: apiGRDPUtils.cxx:48
GRDP_FORMATINFO
The information returned for each supported GRDP importer.
Definition: apiGRDP.h:70
rtGrdpInstanceData.h
Customizes the typedef GRDP_RTITEM declaration.
grdpAssignInfoValueBool
PWP_BOOL grdpAssignInfoValueBool(const char name[], const bool value, const bool create=true)
Creates a key/bool-value pair that defines a GRDP info attribute.
Definition: apiGRDPUtils.cxx:246
GRDP_RUNTIME_INSTDATADECL
#define GRDP_RUNTIME_INSTDATADECL
Implementation defined runtime instance data macro.
Definition: rtGrdpInstanceData.h:22
grdpSendErrorMsg
void grdpSendErrorMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an error text message (PWP_MSGID_ERROR) to the framework.
Definition: apiGRDPUtils.cxx:197
grdpProgressIncr
PWP_BOOL grdpProgressIncr(GRDP_RTITEM *pRti)
Completes a progress tracking sub-step.
Definition: apiGRDPUtils.cxx:79
apiPWPUtils.h
Data and functions useful to PWP-API compliant plugins.
apiPWP.h
Pointwise Plugin API (PWP-API)
grdpProgressEndStep
PWP_BOOL grdpProgressEndStep(GRDP_RTITEM *pRti)
Completes a progress tracking major step.
Definition: apiGRDPUtils.cxx:137
grdpFormatCnt
PWP_UINT32 grdpFormatCnt
The number of entries in grdpRtItem[] array.
Definition: apiGRDP.cxx:33
GRDP_CLKS_PROGINIT
@ GRDP_CLKS_PROGINIT
Definition: apiGRDPUtils.h:97
PWU_UNFDATA
Unformatted file data block.
Definition: apiPWPUtils.h:344
GRDP_RTITEM::fp
FILE * fp
Runtime FILE pointer.
Definition: apiGRDPUtils.h:140