gdsrip logo

gdsriplib.h

The contents of the gdsriplib.h file are shown below:


 
#if(! defined(_GDSRIPLIB_H_))
#define _GDSRIPLIB_H_

#if(defined(_WinNT_))
#include "stdafx.h"
#endif

#include "dbghandler.h"

//Status Flags
#define _RIP_COMPLETE 0		//All bands processed
#define _RIP_BUSY 1		//Rip Engine is busy (internal use)
#define _RIP_BAND_COMPLETE 2	//One band complete but not all
#define _RIP_UNDEFINED 4	//Undefined state
#define _RIP_MEM_READY 6	//Memory ready for ripping (internal use)
#define _RIP_EXIT 7		//Exit Ripping (internal use)
#define _RIP_READY 8            //Provide the first memory buffer (internal use)

//Error Flags
#define _GR_IMAGE_GRID -11	//Bad image grid specification
#define _GR_ERR_MUTEXH -10	//Mutex or condition variable handling error
#define _GR_ERR_TIMEOUT -9	//Wait for band timed out
#define _GR_ERR_INVINPUT -8     //Invalid input provided
#define _GR_ERR_INVOPR -7       //Invalid operation
#define _GR_ERR_INTERNAL -6     //Internal failure
#define _GR_ERR_MEM -5          //Memory related error
#define _GR_ERR_CLOSE -4        //Close library (internal use)
#define _GR_ERR_LICENSE -3	//Error while obtaining license

//Resolution type flags for Query Extents
#define IMAGE_GRID_DPI       1
#define IMAGE_GRID_DPM       2
#define IMAGE_GRID_PIXELS    3

//Rip Orientation/Direction Flags
#define RIP_DIR_STD 1           //Output Band is horizontal 
#define RIP_DIR_VERT 0          //Output Band is vertical

#define _INDEFINITE -1		//Wait for band indefinately

//===================================
//Class defining progress information
//===================================
class _EXPORT_SPEC CGRProgress
{
  public: 
  float m_CurrPct;	//Current Percentage
 
  /*Constructor*/
  CGRProgress();

  /*Destructor*/
  ~CGRProgress();

  /*Copy one object to another*/
  int Copy(const CGRProgress& SourceObj);
};

//================================
//Class defining image information
//================================
class _EXPORT_SPEC CGRImageDesc
{
  public:
   int m_ImageHeight;	//Band height in pixels
   int m_ImageWidth;	//Band width in pixels
   int m_BandNumber;    //Band sequence number
   int m_RowAdjust;
   int m_Scanlines;
   double m_ImageUserExtents[4];
   int m_RipDirection;  //RIP_DIR_STD or RIP_DIR_VERT
   int m_RipIncrement;  //Value that determines where to split the band.

   /*Constructor*/
   CGRImageDesc();

   /*Destructor*/
   ~CGRImageDesc();
  
   /*Copy one object to another*/
   int Copy(const CGRImageDesc& SourceObj);
};

//=================================
//Class defining list of structures
//=================================
class _EXPORT_SPEC CGRTopStructList
{
  private:
   int m_NumElements;	//Number of elemets present
   int m_NumAlloc;      //Amount of memory currently allocated in terms of elements
  public:
   char** m_TopStructList;	//List

   /*Constructor*/
   CGRTopStructList();

   /*Destructor*/
   ~CGRTopStructList();

   /*Add element to list*/
   int AddData(const char* TopStructName);

   /*Get the size of the list (number of elements present)*/
   int Size(void);

};

//===========================================================
//Function: Retrives the current Rip progress information
//Input: Reference to CGRProgress object to store information
//Error codes: _GR_ERR_MUTEXH, 0(success)
//===========================================================
_EXPORT_SPEC int GdsRip_GetProgress(CGRProgress& CurrProgress);

//================================================================================
//Function: Retrives the current Rip status information
//Input: - 
//Error codes: _GR_ERR_MUTEXH
//Return Values: _RIP_COMPLETE _RIP_BAND_COMPLETE (rest are for internal use only)
//================================================================================
_EXPORT_SPEC int GdsRip_GetRipStatus();

//=========================================================================
//Function: Pass memory buffer for next band and start ripping 
//Input: Address of the memory buffer
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR 
//=========================================================================
_EXPORT_SPEC int GdsRip_StartRip(unsigned char* MemChunkPtr);

//============================================================================
//Function: Retrives the newly ripped band and corresponding image information 
//Input: Location to store buffer address, Object to store image information
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR
//============================================================================
_EXPORT_SPEC int GdsRip_GetRipImage(unsigned char** BufferPtr,CGRImageDesc& ImageInfo);

//===========================================================
//Function: Retrives the number of bands to be processed
//Input: - 
//Error codes: _GR_ERR_MUTEXH, 0(success)
//===========================================================
_EXPORT_SPEC int GdsRip_GetNumberOfBands();

//=================================================================
//Function: Waits for the current band ripping to complete 
//Input: Maximun wait time (milli seconds) default: indefinite wait
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_TIMEOUT
//=================================================================
_EXPORT_SPEC int GdsRip_WaitForBand(int MaxWaitTime = _INDEFINITE);

//=================================================================================
//Function: Initialises and starts the rip engine in a separate thread. Rip Engine 
// does not start ripping until external memory is provided using GdsRip_StartRip() 
//Input: Null terminated argument list of strings (just like argv)
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_INVINPUT, _GR_ERR_LICENSE
//=================================================================================
#if(defined(_UNIX_C_))
_EXPORT_SPEC int GdsRip_SetupRip(char** ArgList);
#elif(defined(_WinNT_))
_EXPORT_SPEC int GdsRip_SetupRip(char** pArgList,HINSTANCE pAppInstance);
#endif

//===========================================================================
//Function: Retrives the extents in gds file units of the provided structure
//          "=" for strcture name gets the extents of the first Top structure
//Input: GDS File name, Structure name, Storage for extent co-ordinates
//Error codes: 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR, _GR_ERR_INTERNAL
//===========================================================================
_EXPORT_SPEC int GdsRip_QueryGdsDataExtents (const char* GdsFileName, 
                                             const char* StructureName,
                                             double& x1,
                                             double& y1,
                                             double& x2,
                                             double& y2
                                            );

//===========================================================================
//Function: Retrives the extents in gds file units of the provided structure
//          "=" for strcture name gets the extents of the first Top structure
//Input: GDS File name, Structure name, Storage for extent co-ordinates
//Error codes: 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR, _GR_ERR_INTERNAL
//===========================================================================
_EXPORT_SPEC int GdsRip_QueryGdsDataExtents(const char* GdsFileName, 
                                            const char* StructureName,
                                            int layer_cnt,
                                            int* layer_list,
                                            double& x1,
                                            double& y1,
                                            double& x2,
                                            double& y2
                                            );

//===========================================================================
//Function: Retrives the extents in gds file units of the provided structure
//          "=" for strcture name gets the extents of the first Top structure
//Input: GDS File name, Structure name, Storage for extent co-ordinates
//Error codes: 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR, _GR_ERR_INTERNAL
//===========================================================================
_EXPORT_SPEC int GdsRip_QueryGdsDataExtents(const char* GdsFileName, 
                                            const char* StructureName,
                                            double& x1,
                                            double& y1,
                                            double& x2,
                                            double& y2,
                                            const int imageGridType, 
                                            const double imageGridValue
                                            );

//===========================================================================
//Function: Retrives the extents in gds file units of the provided structure
//          "=" for strcture name gets the extents of the first Top structure
//Input: GDS File name, Structure name, Storage for extent co-ordinates
//Error codes: 0(success), _GR_ERR_INVINPUT, _GR_ERR_INVOPR, _GR_ERR_INTERNAL
//===========================================================================
_EXPORT_SPEC int GdsRip_QueryGdsDataExtents(const char* GdsFileName, 
                                            const char* StructureName,
                                            int layer_cnt,int* layer_list,
                                            double& x1,
                                            double& y1,
                                            double& x2,
                                            double& y2,
                                            const int imageGridType, 
                                            const double imageGridValue
                                            );

//===========================================================================
//Function: Retrieves FPath from gdsmachine library
//===========================================================================
_EXPORT_SPEC char* GdsRip_GetParentDir();

//=========================================================================
//Function: Retrives a list of Top structures in the GDS file 
//Input: GDS file name, TopStructList object to store the list
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_INVOPR, _GR_ERR_INTERNAL
//=========================================================================
_EXPORT_SPEC int GdsRip_GetTopStructList(const char* GdsFileName, 
                                         CGRTopStructList& ListObject
                                        );

//===========================================================
//Function: Informs the Rip Engine to stop ripping and exit 
//Message: Debugging message to determine when exit rip was called
//Error codes: _GR_ERR_MUTEXH, 0(success)
//===========================================================
_EXPORT_SPEC int GdsRip_ExitRip(const char* Message = NULL); /* [6.12.01.1] */

//===========================================
//Function: Initialises the gdsripcom library
//Inputs: -
//Error codes: _GR_ERR_MUTEXH, 0(success)
//===========================================
_EXPORT_SPEC int GdsRip_Initialise();

//===========================================
//Function: Initialises the gdsripcom library
//Inputs: -
//Error codes: _GR_ERR_MUTEXH, 0(success)
//===========================================
_EXPORT_SPEC int GdsRip_Initialise(char* parent_dir);

//===========================================================================
//Function: Runs the engine in a "dry-run" mode just to get the information  
//about Band height, width and numbers
//Inputs: Argument list (same as SetupRip), CGRImageDesc object to store info 
//Error codes: _GR_ERR_MUTEXH, 0(success), _GR_ERR_INVINPUT, _GR_ERR_LICENSE
//===========================================================================
#if(defined(_UNIX_C_))
_EXPORT_SPEC int GdsRip_DoDryRun(char** ArgList, 
                                 CGRImageDesc& RipInfo
                                 );
#elif(defined(_WinNT_))
_EXPORT_SPEC int GdsRip_DoDryRun(char** ArgList, 
                                 CGRImageDesc& RipInfo,
                                 HINSTANCE AppInstance
                                 );
#endif

//===========================================================
//Function: Retrive the version string for the Gdsrip Library
//Return: NULL (failure) or version string (success)
//===========================================================
_EXPORT_SPEC char* GdsRip_GetVersion();

//=================================================
//Function: Re-initiate library for next GdsRip job
//Return: _GR_ERR_MUTEXH (failure) 0 (success)
//=================================================
_EXPORT_SPEC int GdsRip_ReInitLib();

//=========================
//Function: Close GdsRipLib
//Return: 0
//=========================
_EXPORT_SPEC int GdsRip_Close();

//===========================================================================
//Function: Get error message when some function does not return successfully 
//Buffer: Memory to store error message string
//Buffer Size: Size of the Buffer
//Return: 0 (success) -1 (Invalid Buffer) -2 (Internal read error)
//===========================================================================
_EXPORT_SPEC int GdsRip_GetErrorMessage(char* Buffer, const int BufferSize);


//===========================================================================
//Function: Print thread coherant debug messages
//Msg: Message to print
//Return: -2: Internal write error 0:success
//Note: Must define _GRDBG_ or nothing will be printed
//===========================================================================
_EXPORT_SPEC int GdsRip_PrintDebugMsg(const char* Msg);

#if(defined(_UNIX_C_))

//===========================================================================
//Function: Print memory bitmap of data
//Data: Address of the starting location for which bitmap is desired
//NumBytes: Number of bytes to be printed in the bitmap
//memprintb prints the bitmap in binary format 
//memprinth prints the bitmap in hexadecimal format
//===========================================================================
const char* memprintb(const unsigned char* Data, int NumBytes);
const char* memprinth(const unsigned char* Data, int NumBytes);

#endif

#endif