Changing DLLEXPORT to EXPORT_OUT_API and creating epanet_output_enums.h

This commit is contained in:
Michael Tryby
2019-03-11 17:11:47 -04:00
parent 724bac732b
commit 516ae498c3
6 changed files with 157 additions and 201 deletions

View File

@@ -18,7 +18,6 @@
#include <string>
#include <math.h>
#include <boost/filesystem.hpp>
#define BOOST_TEST_MODULE "output"
#include <boost/test/included/unit_test.hpp>

View File

@@ -32,7 +32,7 @@ target_include_directories(epanet-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl
include(GenerateExportHeader)
generate_export_header(epanet-output
BASE_NAME epanet_output
EXPORT_MACRO_NAME DLLEXPORT
EXPORT_MACRO_NAME EXPORT_OUT_API
EXPORT_FILE_NAME epanet_output_export.h
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)

View File

@@ -11,87 +11,16 @@
#define EPANET_OUTPUT_H_
/* Epanet Results binary file API */
#define MAXFNAME 259 // Max characters in file name
#define MAXID 31 // Max characters in ID name
// This is an opaque pointer to struct. Do not access variables.
typedef void* ENR_Handle;
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2,
ENR_qualUnits = 3
} ENR_Units;
typedef enum {
ENR_CFS = 0,
ENR_GPM = 1,
ENR_MGD = 2,
ENR_IMGD = 3,
ENR_AFD = 4,
ENR_LPS = 5,
ENR_LPM = 6,
ENR_MLD = 7,
ENR_CMH = 8,
ENR_CMD = 9
} ENR_FlowUnits;
typedef enum {
ENR_PSI = 0,
ENR_MTR = 1,
ENR_KPA = 2
} ENR_PressUnits;
typedef enum {
ENR_NONE = 0,
ENR_MGL = 1,
ENR_UGL = 2,
ENR_HOURS = 3,
ENR_PRCNT = 4
} ENR_QualUnits;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
// #ifdef WINDOWS
// #ifdef __cplusplus
// #define DLLEXPORT __declspec(dllexport) __cdecl
// #else
// #define DLLEXPORT __declspec(dllexport) __stdcall
// #endif
// #else
// #define DLLEXPORT
// #endif
#include "epanet_output_enums.h"
#include "epanet_output_export.h"
@@ -99,52 +28,52 @@ typedef enum {
extern "C" {
#endif
int DLLEXPORT ENR_init(ENR_Handle* p_handle_out);
int EXPORT_OUT_API ENR_init(ENR_Handle* p_handle_out);
int DLLEXPORT ENR_open(ENR_Handle p_handle_in, const char* path);
int EXPORT_OUT_API ENR_open(ENR_Handle p_handle_in, const char* path);
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle_in, int* int_out);
int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle_in, int* int_out);
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle_in, int** int_out, int* int_dim);
int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle_in, int** int_out, int* int_dim);
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle_in, ENR_Units t_enum, int* int_out);
int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle_in, ENR_Units t_enum, int* int_out);
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle_in, ENR_Time t_enum, int* int_out);
int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle_in, ENR_Time t_enum, int* int_out);
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle_in, ENR_ElementType t_enum,
int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle_in, ENR_ElementType t_enum,
int elementIndex, char** string_out, int* slen);
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle_in, int pumpIndex,
int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle_in, int pumpIndex,
int* int_out, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle_in, float** float_out, int* int_dim);
int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle_in, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle_in, int nodeIndex, ENR_NodeAttribute t_enum,
int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle_in, int nodeIndex, ENR_NodeAttribute t_enum,
int startPeriod, int endPeriod, float** outValueSeries, int* dim);
int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle_in, int linkIndex, ENR_LinkAttribute t_enum,
int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle_in, int linkIndex, ENR_LinkAttribute t_enum,
int startPeriod, int endPeriod, float** outValueSeries, int* dim);
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle_in, int periodIndex,
int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle_in, int periodIndex,
ENR_NodeAttribute t_enum, float** outValueArray, int* dim);
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle_in, int periodIndex,
int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle_in, int periodIndex,
ENR_LinkAttribute t_enum, float** outValueArray, int* dim);
int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle_in, int periodIndex, int nodeIndex,
int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle_in, int periodIndex, int nodeIndex,
float** float_out, int* int_dim);
int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle_in, int periodIndex, int linkIndex,
int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle_in, int periodIndex, int linkIndex,
float** float_out, int* int_dim);
int DLLEXPORT ENR_close(ENR_Handle* p_handle_out);
int EXPORT_OUT_API ENR_close(ENR_Handle* p_handle_out);
void DLLEXPORT ENR_free(void** array);
void EXPORT_OUT_API ENR_free(void** array);
void DLLEXPORT ENR_clearError(ENR_Handle p_handle_in);
void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle_in);
int DLLEXPORT ENR_checkError(ENR_Handle p_handle_in, char** msg_buffer);
int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle_in, char** msg_buffer);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,79 @@
/*
* epanet_output_enums.h - EPANET Output API enums
*
* Created on: March 11, 2019
*
* Author: Michael E. Tryby
* US EPA - ORD/NRMRL
*/
#ifndef EPANET_OUTPUT_ENUMS_H_
#define EPANET_OUTPUT_ENUMS_H_
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2,
ENR_qualUnits = 3
} ENR_Units;
typedef enum {
ENR_CFS = 0,
ENR_GPM = 1,
ENR_MGD = 2,
ENR_IMGD = 3,
ENR_AFD = 4,
ENR_LPS = 5,
ENR_LPM = 6,
ENR_MLD = 7,
ENR_CMH = 8,
ENR_CMD = 9
} ENR_FlowUnits;
typedef enum {
ENR_PSI = 0,
ENR_MTR = 1,
ENR_KPA = 2
} ENR_PressUnits;
typedef enum {
ENR_NONE = 0,
ENR_MGL = 1,
ENR_UGL = 2,
ENR_HOURS = 3,
ENR_PRCNT = 4
} ENR_QualUnits;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
#endif /* EPANET_OUTPUT_ENUMS_H_ */

View File

@@ -31,7 +31,7 @@
// data from the output file. As such they return arrays of data. The API
// functions automatically allocate memory for the array to be returned. The
// caller is responsible for deallocating memory. The function ENR_free() is
// provided to deallocate memory.
// provided for that purpose.
//
//-----------------------------------------------------------------------------
@@ -96,7 +96,7 @@ int* newIntArray(int n);
char* newCharArray(int n);
int DLLEXPORT ENR_init(ENR_Handle* dp_handle)
int EXPORT_OUT_API ENR_init(ENR_Handle* dp_handle)
// Purpose: Initialized pointer for the opaque ENR_Handle.
//
// Returns: Error code 0 on success, -1 on failure
@@ -122,7 +122,7 @@ int DLLEXPORT ENR_init(ENR_Handle* dp_handle)
return errorcode;
}
int DLLEXPORT ENR_close(ENR_Handle* p_handle)
int EXPORT_OUT_API ENR_close(ENR_Handle* p_handle)
/*------------------------------------------------------------------------
** Input: *p_handle = pointer to ENR_Handle struct
**
@@ -157,7 +157,7 @@ int DLLEXPORT ENR_close(ENR_Handle* p_handle)
return errorcode;
}
int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path)
int EXPORT_OUT_API ENR_open(ENR_Handle p_handle, const char* path)
/*------------------------------------------------------------------------
** Input: path
** Output: p_handle = pointer to ENR_Handle struct
@@ -221,7 +221,7 @@ int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path)
return errorcode;
}
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* version)
int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle, int* version)
/*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct
** Output: version Epanet version
@@ -247,7 +247,7 @@ int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* version)
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* length)
int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* length)
/*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct
** Output: array of element counts (nodes, tanks, links, pumps, valves)
@@ -278,7 +278,7 @@ int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* lengt
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
/*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct
** code
@@ -355,7 +355,7 @@ int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
/*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct
** code = element code
@@ -403,13 +403,13 @@ int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getChemData(ENR_Handle p_handle, char** name, int* length)
int EXPORT_OUT_API ENR_getChemData(ENR_Handle p_handle, char** name, int* length)
{
return 0;
}
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
int elementIndex, char** name, int* length)
/*------------------------------------------------------------------------
** Input: p_handle = pointer to ENR_Handle struct
@@ -469,7 +469,7 @@ int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int* linkIndex, float** outValues, int* length)
/*
* Purpose: Returns pump energy usage statistics.
@@ -514,7 +514,7 @@ int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* length)
int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* length)
/*
* Purpose: Returns network wide average reaction rates and average
* source mass inflow:
@@ -549,7 +549,7 @@ int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* leng
return set_error(p_data->error_handle, errorcode);
}
void DLLEXPORT ENR_free(void** array)
void EXPORT_OUT_API ENR_free(void** array)
//
// Purpose: Frees memory allocated by API calls
//
@@ -560,7 +560,7 @@ void DLLEXPORT ENR_free(void** array)
}
}
int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttribute attr,
int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttribute attr,
int startPeriod, int endPeriod, float** outValueSeries, int* dim)
//
// Purpose: Get time series results for particular attribute. Specify series
@@ -595,7 +595,7 @@ int DLLEXPORT ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttr
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttribute attr,
int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttribute attr,
int startPeriod, int endPeriod, float** outValueSeries, int* dim)
//
// Purpose: Get time series results for particular attribute. Specify series
@@ -630,7 +630,7 @@ int DLLEXPORT ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttr
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
ENR_NodeAttribute attr, float** outValueArray, int* length)
//
// Purpose:
@@ -679,7 +679,7 @@ int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
ENR_LinkAttribute attr, float** outValueArray, int* length)
//
// Purpose:
@@ -729,7 +729,7 @@ int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
int nodeIndex, float** outValueArray, int* length)
//
// Purpose: For a node at given time, get all attributes.
@@ -759,7 +759,7 @@ int DLLEXPORT ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode);
}
int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
int linkIndex, float** outValueArray, int* length)
//
// Purpose: For a link at given time, get all attributes
@@ -786,7 +786,7 @@ int DLLEXPORT ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
return set_error(p_data->error_handle, errorcode);
}
void DLLEXPORT ENR_clearError(ENR_Handle p_handle)
void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle)
{
data_t* p_data;
@@ -794,7 +794,7 @@ void DLLEXPORT ENR_clearError(ENR_Handle p_handle)
clear_error(p_data->error_handle);
}
int DLLEXPORT ENR_checkError(ENR_Handle p_handle, char** msg_buffer)
int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle, char** msg_buffer)
{
int errorcode = 0;
char *temp = NULL;

View File

@@ -23,60 +23,9 @@
typedef void* ENR_Handle;
typedef enum {
ENR_node = 1,
ENR_link = 2
} ENR_ElementType;
/*
typedef enum {
ENR_nodeCount = 1,
ENR_tankCount = 2,
ENR_linkCount = 3,
ENR_pumpCount = 4,
ENR_valveCount = 5
} ENR_ElementCount;
*/
%include "epanet_output_enums.h"
typedef enum {
ENR_flowUnits = 1,
ENR_pressUnits = 2
} ENR_Units;
typedef enum {
ENR_reportStart = 1,
ENR_reportStep = 2,
ENR_simDuration = 3,
ENR_numPeriods = 4
}ENR_Time;
typedef enum {
ENR_demand = 1,
ENR_head = 2,
ENR_pressure = 3,
ENR_quality = 4
} ENR_NodeAttribute;
typedef enum {
ENR_flow = 1,
ENR_velocity = 2,
ENR_headloss = 3,
ENR_avgQuality = 4,
ENR_status = 5,
ENR_setting = 6,
ENR_rxRate = 7,
ENR_frctnFctr = 8
} ENR_LinkAttribute;
#ifdef WINDOWS
#ifdef __cplusplus
#define DLLEXPORT __declspec(dllexport) __cdecl
#else
#define DLLEXPORT __declspec(dllexport) __stdcall
#endif
#else
#define DLLEXPORT
#endif
/* TYPEMAPS FOR OPAQUE POINTER */
/* Used for functions that output a new opaque pointer */
@@ -190,32 +139,32 @@ and return a (possibly) different pointer */
}
}
/* INSERT EXCEPTION HANDLING FOR THESE FUNCTIONS */
int DLLEXPORT ENR_open(ENR_Handle p_handle, const char* path);
int ENR_open(ENR_Handle p_handle, const char* path);
int DLLEXPORT ENR_getVersion(ENR_Handle p_handle, int* int_out);
int DLLEXPORT ENR_getNetSize(ENR_Handle p_handle, int** int_out, int* int_dim);
int DLLEXPORT ENR_getUnits(ENR_Handle p_handle, ENR_Units t_enum, int* int_out);
int DLLEXPORT ENR_getTimes(ENR_Handle p_handle, ENR_Time t_enum, int* int_out);
int DLLEXPORT ENR_getElementName(ENR_Handle p_handle, ENR_ElementType t_enum,
int ENR_getVersion(ENR_Handle p_handle, int* int_out);
int ENR_getNetSize(ENR_Handle p_handle, int** int_out, int* int_dim);
int ENR_getUnits(ENR_Handle p_handle, ENR_Units t_enum, int* int_out);
int ENR_getTimes(ENR_Handle p_handle, ENR_Time t_enum, int* int_out);
int ENR_getElementName(ENR_Handle p_handle, ENR_ElementType t_enum,
int elementIndex, char** string_out, int* slen);
int DLLEXPORT ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
int* int_out, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNetReacts(ENR_Handle p_handle, float** float_out, int* int_dim);
int ENR_getNetReacts(ENR_Handle p_handle, float** float_out, int* int_dim);
int DLLEXPORT ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
int ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
ENR_NodeAttribute t_enum, float** float_out, int* int_dim);
int DLLEXPORT ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
int ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
ENR_LinkAttribute t_enum, float** float_out, int* int_dim);
%exception;
/* NO EXCEPTION HANDLING FOR THESE FUNCTIONS */
int DLLEXPORT ENR_init(ENR_Handle* p_handle_out);
int DLLEXPORT ENR_close(ENR_Handle* p_handle_out);
void DLLEXPORT ENR_free(void** array);
int ENR_init(ENR_Handle* p_handle_out);
int ENR_close(ENR_Handle* p_handle_out);
void ENR_free(void** array);
void DLLEXPORT ENR_clearError(ENR_Handle p_handle);
int DLLEXPORT ENR_checkError(ENR_Handle p_handle, char** msg_buffer);
void ENR_clearError(ENR_Handle p_handle);
int ENR_checkError(ENR_Handle p_handle, char** msg_buffer);
/* CODE ADDED DIRECTLY TO SWIGGED INTERFACE MODULE */