1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
/**
* \file dfcProject.h
* \brief DFCGen filter project management.
* \copyright Copyright (C) 2006-2022 Ralf Hoppe <ralf.hoppe@dfcgen.de>
*/
#ifndef DCFPROJECT_H
#define DCFPROJECT_H
/* INCLUDE FILES **************************************************************/
#include "dfcgen.h"
#include "designDlg.h"
#ifdef __cplusplus
extern "C" {
#endif
/* GLOBAL TYPE DECLARATIONS ***************************************************/
/** DFCGen project info data.
*/
typedef struct
{
char *author; /**< Pointer to author name (may be NULL) */
char *title; /**< Pointer to project name (may be NULL) */
char *desc; /**< Pointer to project description (may be NULL) */
} DFCPRJ_INFO;
/** DFCGen project.
*/
typedef struct
{
DFCPRJ_INFO info; /**< Project info (header) */
FLTCLASS fltcls; /**< Filter class */
DESIGNDLG design; /**< Filter design data (union) */
FLTCOEFF filter; /**< Coefficients in Z domain */
unsigned flags; /**< Flags, e.g. DFCPRJ_FLAG_SUPERSEDED */
} DFCPRJ_FILTER;
/* GLOBAL CONSTANT DECLARATIONS ***********************************************/
/** This flag indicates that the design was supersed. Maybe anyone has modified
coefficients or roots directly, then the design is superseded.
*/
#define DFCPRJ_FLAG_SUPERSEDED 1
/** This flag indicates that the project was saved after changes made to
coefficients.
*/
#define DFCPRJ_FLAG_SAVED 2
/** Internally and only temporary used flag (reserved).
*/
#define DFCPRJ_FLAG_INTERNAL 0x8000
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
/* GLOBAL MACRO DEFINITIONS ***************************************************/
/* MACRO **********************************************************************/
/** Gets the current project flags.
*
* \return Returns project flags.
******************************************************************************/
#define dfcPrjGetFlags() dfcPrjSetFlags (~0, 0)
/* EXPORTED FUNCTIONS *********************************************************/
/* FUNCTION *******************************************************************/
/** Sets the (new) passed design and filter into the current project. All old
* project data, except the header information, are free'ed. The project flag
* DFCPRJ_FLAG_SUPERSEDED is set if \p type is equal to FLTCLASS_NOTDEF, else
* it is cleared.
*
* \param type Class of filter. If FLTCLASS_NOTDEF is passed in here,
* then the current filter class is unchanged.
* \param pFilter Pointer to new filter (coefficients) data.
* \param pDesign Pointer to new design data. Set this to NULL if design
* data shall not be changed (or are not available).
*
******************************************************************************/
void dfcPrjSetFilter (FLTCLASS type, FLTCOEFF* pFilter, DESIGNDLG *pDesign);
/* FUNCTION *******************************************************************/
/** Sets new project information data.
*
* \param pInfo Pointer to new project info.
*
******************************************************************************/
void dfcPrjSetInfo (DFCPRJ_INFO *pInfo);
/* FUNCTION *******************************************************************/
/** Gets the filter design dialog parameters (if return value is unequal to
* FLTCLASS_NOTDEF).
*
* \param pBuf Buffer which gets the filter design (may be NULL).
*
* \return Class of filter.
******************************************************************************/
FLTCLASS dfcPrjGetDesign (DESIGNDLG *pBuf);
/* FUNCTION *******************************************************************/
/** Returns a pointer to the current filter definition.
*
* \return Pointer to filter coefficients/roots (or NULL if not
* defined).
******************************************************************************/
FLTCOEFF* dfcPrjGetFilter (void);
/* FUNCTION *******************************************************************/
/** Returns a pointer to the current project information.
*
* \return Pointer to project info.
******************************************************************************/
DFCPRJ_INFO* dfcPrjGetInfo (void);
/* FUNCTION *******************************************************************/
/** Exports the current filter project to a file.
*
* \param filename Filename of file (inclusive path).
*
* \return Zero on succes, else an error number from errno.h.
******************************************************************************/
int dfcPrjExport (char *filename);
/* FUNCTION *******************************************************************/
/** Saves the current filter project to a file.
*
* \param filename Filename of file (inclusive path).
*
* \return Zero on succes, else an error number.
******************************************************************************/
int dfcPrjSave (char *filename);
/* FUNCTION *******************************************************************/
/** Loads a new filter project from a file. In case of an error it sets the
* pointer to the error structure, which itself can be used to display the
* original error message. Modification of the error structure pointer
* indicates an critical error. In that case it has to be free'ed with
* g_error_free().
*
* \param filename Filename of file (inclusive path).
* \param err Pointer to an error (structure) pointer. The pointer
* to the error structure must be set NULL before calling
* function dfcPrjLoad().
*
******************************************************************************/
void dfcPrjLoad (char *filename, GError **err);
/* FUNCTION *******************************************************************/
/** Frees all malloc'ed memory space from a project. Free'ing the project
* memory includes the header info (do not call prjFileFree() in addition).
*
* \param pProject Pointer to project data. Set to NULL to free the
* current project.
*
******************************************************************************/
void dfcPrjFree (DFCPRJ_FILTER *pProject);
/* FUNCTION *******************************************************************/
/** Sets, clears and gets project flags.
*
* \param andMask Mask to be applied to project flags by an \e AND operation.
* \param orMask Mask to be applied to project flags by an \e OR operation.
*
* \return Returns old project flags.
******************************************************************************/
unsigned dfcPrjSetFlags (unsigned andMask, unsigned orMask);
#ifdef __cplusplus
}
#endif
#endif /* DCFPROJECT_H */
/******************************************************************************/
/* END OF FILE */
/******************************************************************************/
|