
/*
**  This file forms part of the GOBLIN C++ Class Library.
**
**  Written by Christian Fremuth-Paeger, April 1999.
**  
**  Copying, compiling, distribution and modification
**  of this source code is permitted only in accordance
**  with the GOBLIN general licence information.
*/             


#if !defined(_GLOBALS_H_)

#define _GLOBALS_H_



// Standard C/C++ declarations

#include <climits>
#include <cfloat>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>

#include <iostream>
#include <fstream>
#include <iomanip>
#include <exception>
#include <new>

using namespace std;


// GOBLIN Configuration

#include <config.h>


// Configuration dependent system headers

#if defined(_TIMERS_)

#include <sys/times.h>
#include <unistd.h>

#endif



// Basic Types

#if defined(_BIG_NODES_)

typedef unsigned long   TNode;

#else

typedef unsigned short  TNode;

#endif


#if defined(_SMALL_ARCS_)

typedef unsigned short  TArc;

#else

typedef unsigned long   TArc;

#endif


typedef float           TCap;
typedef double          TFloat;
typedef unsigned long   THandle;
typedef unsigned long   TIndex;
typedef unsigned long   TSize;
typedef unsigned short  TOption;
typedef unsigned long   TVar;
typedef unsigned long   TRestr;
typedef char            TDim;


// Limits and Undefined Symbols 

extern TNode     NoNode;
extern TArc      NoArc;
extern TCap      InfCap;
extern TFloat    InfFloat;
extern THandle   NoHandle;
extern TIndex    NoIndex;
extern TVar      NoVar;
extern TRestr    NoRestr;


// Timer, module, author and bibliographic indices

enum TTimer
    {TimerSolve = 0,TimerIO = 1,
     TimerUnionFind = 2,TimerHash = 3,TimerPrioQ = 4,
     TimerPricing = 5,TimerQTest = 6,TimerPivoting = 7,
     TimerShortPath = 8,TimerMinTree = 9,TimerConnectivity = 10,
     TimerMaxFlow = 11,TimerMinCut = 12,TimerMinCFlow = 13,
     TimerMatching = 14,TimerBranch = 15,TimerLpSolve = 16,
     TimerTsp = 17,TimerColour = 18,TimerSteiner = 19,
     TimerStable = 20,TimerMaxCut = 21,TimerTreePack = 22,
     TimerTJoin = 23,TimerCycleCancel = 24,TimerMaxBalFlow = 25,
     TimerPrimalDual =26,NoTimer = 27};

enum TModule
    {ModRoot = 0,ModLpSolve = 1,ModColour = 2,ModStable = 3,
     ModBranch = 4,ModTSP = 5,ModSteiner = 6,ModMaxCut = 7,
     ModMinTree = 8,ModMaxFlow = 9,ModMinCFlow = 10,
     ModConnectivity = 11,ModMinCut = 12,ModShortPath = 13,
     ModTreePack = 14,ModMatching = 15,ModTJoin = 16,
     ModPostman = 17,ModLpPricing = 18,ModLpQTest = 19,
     ModLpPivoting = 20,ModCycleCancel = 21,ModMaxBalFlow = 22,
     ModMinCBalFlow = 23,NoModule = 24};
    
enum TAuthor
    {AuthCFP = 0,AuthBSchmidt = 1,AuthMSchwank = 2,
     NoAuthor = 3};
    
enum TBibliography
    {RefJun97 = 0,RefCPCS98 = 1,RefGoMi84 = 2,RefAMO93 = 3,
     NoBibliography = 4};
    

// Module Data Base
 
struct TModuleStruct {
    char*           moduleName;
    TTimer          moduleTimer;
    TAuthor         implementor1;
    TAuthor         implementor2;
    char*           encodingDate;
    char*           revisionDate;
    TBibliography   initialReference;
    TBibliography   authorsReference;
    TBibliography   textBook;
};

extern const TModuleStruct listOfModules[];
 
struct TTimerStruct {
    char*           timerName;
    bool            fullFeatured;
};

extern const TTimerStruct listOfTimers[];

struct TAuthorStruct {
    char*           name;
    char*           affiliation;
    char*           e_mail;
};

extern const TAuthorStruct listOfAuthors[];

struct TBibliographyStruct {
    char*           refKey;
    char*           authors;
    char*           title;
    char*           type;
    char*           in;
    char*           editors;
    int             volume;
    char*           publisher;
    int             year;
};

extern const TBibliographyStruct listOfReferences[];


// Class Identifier Constants

enum objectType
    {IDSparseGraph,IDSparseDiGraph,IDSparseBiGraph,IDBalancedFNW,
     IDMixedGraph,IDDenseGraph,IDDenseDiGraph,IDDenseBiGraph,IDUnknown};


// Message Classes

enum msgType
    {ERR_CHECK=0,ERR_PARSE=1,ERR_FILE=2,ERR_RANGE=3,ERR_REJECTED=4,ERR_FATAL=5,
     MSG_APPEND=6,MSG_WARN=7,MSG_TRACE=8,MSG_TRACE2=9,MSG_TIMES=10,MSG_ECHO=11,
     LOG_IO=12,LOG_MAN=13,LOG_MEM=14,LOG_MEM2=15,LOG_RES=16,LOG_RES2=17,
     LOG_METH=18,LOG_METH2=19,LOG_FORMULA=20,LOG_TITLE=21,LOG_SHELL=22,
     LOG_TIMERS=23,LOG_GAPS = 24,NO_MSG=25};


// Exception Handling

class ERGoblin                              {};

class ERIO          : protected ERGoblin    {};
class ERFile        : protected ERIO        {};
class ERParse       : protected ERIO        {};

class ERFatal       : protected ERGoblin    {};

class ERRejected    : protected ERGoblin    {};
class ERRange       : protected ERRejected  {};
class ERCheck       : protected ERRejected  {};


// Memory management

extern long unsigned goblinHeapSize;
extern long unsigned goblinMaxSize;
extern long unsigned goblinNFragments;
extern long unsigned goblinNAllocs;
extern long unsigned goblinNObjects;

void* GoblinRealloc(void* p,size_t size) throw (std::bad_alloc);




#endif
