SenseApiLib, SenseApiDesc improvements, new Sense API Mgmt Lib Ops role
SenseApiDesc: * Use a number count for num exported implexor APIs instead of NULL-terminated list. * Add sanity checker functions for structs. SenseApiLib: * Invoke the new sanity checkers on new Lib objects. * SenseApiDesc is now a member object instead of being pointed to. SenseApiManager: * loadSenseApiLib now calls the SenseApiDesc getter function. * loadSenseApiLib now fills out the SenseApiLib class object. New Sense API Mgmt Sub-API: This sub-api (metalanguage, some might call it) is used to initialize the lib's connection to the provider. After this call, the lib should be ready to attach new devices to its provider on behalf of Hk.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define __USER_SENSE_API_LIB_H__
|
||||
|
||||
#include <preprocessor.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -15,16 +16,77 @@ struct CExportedImplexorApiDesc
|
||||
const char *name;
|
||||
};
|
||||
|
||||
typedef int (sal_lmo_initializeIndFn)(void);
|
||||
typedef int (sal_lmo_finalizeIndFn)(void);
|
||||
typedef int (sal_lmo_attachDeviceReqFn)(void);
|
||||
typedef int (sal_lmo_detachDeviceReqFn)(void);
|
||||
|
||||
struct Csal_libMgmtOps
|
||||
{
|
||||
/* When Harikoff loads a sense API lib, it calls this function to initialize
|
||||
* the lib. When this returns, the lib should be ready to attach devices.
|
||||
*/
|
||||
sal_lmo_initializeIndFn *initializeInd;
|
||||
/* Harikoff calls this to finalize the lib and free its internal
|
||||
* resources. When this returns, the lib should be ready to be unloaded.
|
||||
*/
|
||||
sal_lmo_finalizeIndFn *finalizeInd;
|
||||
/* Harikoff calls this to attach a device to the lib. When it returns, the
|
||||
* device should be attached and ready to be implexed.
|
||||
*/
|
||||
sal_lmo_attachDeviceReqFn *attachDeviceReq;
|
||||
// When this returns, the device should be detached.
|
||||
sal_lmo_detachDeviceReqFn *detachDeviceReq;
|
||||
};
|
||||
|
||||
struct CSenseApiDesc
|
||||
{
|
||||
/* Shortname that identifies the API used by this lib to talk to the sense
|
||||
* provider.
|
||||
*/
|
||||
const char *name;
|
||||
// These are the implexors whose APIs this lib exports.
|
||||
/* These are the implexors whose APIs this lib exports.
|
||||
*/
|
||||
uint32_t numExportedImplexorApis;
|
||||
CExportedImplexorApiDesc *exportedImplexorApis;
|
||||
/* Sub-API for managing the lib. Library role within the API.
|
||||
*/
|
||||
Csal_libMgmtOps *sal_libMgmtOps;
|
||||
};
|
||||
|
||||
static bool CSenseApiDesc_sanityCheck(const CSenseApiDesc *desc)
|
||||
{
|
||||
if (!desc || !desc->name || desc->numExportedImplexorApis < 1
|
||||
||!desc->exportedImplexorApis || !desc->sal_libMgmtOps)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CExportedImplexorApiDesc_sanityCheck(
|
||||
const CExportedImplexorApiDesc *desc)
|
||||
{
|
||||
if (!desc || !desc->name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Csal_libMgmtOps_sanityCheck(const Csal_libMgmtOps *ops)
|
||||
{
|
||||
if (!ops || !ops->initializeInd || !ops->finalizeInd
|
||||
|| !ops->attachDeviceReq || !ops->detachDeviceReq)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define HK_GET_SENSE_API_DESC_FN_NAME getSenseApiDesc
|
||||
#define HK_GET_SENSE_API_DESC_FN_NAME_STR \
|
||||
HK_QUOTE(HK_GET_SENSE_API_DESC_FN_NAME)
|
||||
|
||||
Reference in New Issue
Block a user