
/*
**  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,
     TimerSPTree = 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,TimerPlanarity = 27,NoTimer = 28};

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,ModSPTree = 13,
     ModTreePack = 14,ModMatching = 15,ModTJoin = 16,
     ModPostman = 17,ModLpPricing = 18,ModLpQTest = 19,
     ModLpPivoting = 20,ModCycleCancel = 21,ModMaxBalFlow = 22,
     ModMinCBalFlow = 23,ModPlanarity = 24,ModGLPK = 25,
     ModGraphLoad = 26, ModEdmondsKarp = 27, ModDinic = 28,
     ModPushRelabel = 29,ModPrim = 30,ModPrim2 = 31,ModKruskal = 32,
     ModEdmondsArb = 33,ModPlanarityDMP = 34,ModDikjstra = 35,
     ModBellmanFord = 36,ModFloydWarshall = 37,ModFIFOLabelCorrect = 38,
     ModKarpMeanCycle = 39,ModKleinCanceling = 40,ModShortPath2 = 41,
     ModMeanCycleCanceling = 42,ModNetworkSimplex = 43,
     ModCostScaling = 44,ModBusackerGowen = 45,ModSubgradOptTSP = 46,
     ModTreeApproxTSP = 47,ModChristofides = 48,Mod2OptTSP = 49,
     ModNodeInsert = 50,ModRandomTour = 51,ModFarthestInsert = 52,
     ModMehlhorn = 53,ModStrongConnectivity = 54,Mod2Connectivity = 55,
     ModSchnorr = 56,ModHaoOrlin = 57,ModNodeIdentification = 58,
     ModHierholzer = 59,ModDAGSearch = 60,ModPrimalDual = 61,
     ModAnstee = 62,ModMicaliVazirani = 63,ModBalAugment = 64,
     ModBalScaling = 65,ModBNSExact = 66,ModBNSDepth = 67,
     ModBNSBreadth = 68,ModEnhancedPD = 69,ModBNS = 70,
     ModMaxCutTJoin = 71,ModMaxCutGRASP = 72,ModLMCOrder = 73,
     NoModule = 74};
    
enum TAuthor
    {AuthCFP = 0,AuthBSchmidt = 1,AuthMSchwank = 2,AuthBEisermann = 3,
     AuthAMakhorin = 4,NoAuthor = 5};
    
enum TReference
    {RefJun97 = 0,RefCPCS98 = 1,RefGoMi84 = 2,RefAMO93 = 3,RefGPR96 = 4,
     RefEdKa72 = 5,RefDin70 = 6,RefGoTa88 = 7,RefPrim57 = 8,RefKru56 = 9,
     RefEdm67 = 10,RefDMP64 = 11,RefGou88 = 12,RefDij59 = 13, RefBel58 = 14,
     RefFlo62 = 15,RefKar78 = 16,RefEdJo73 = 17,RefBuGo61 = 18,RefKle67 = 19,
     RefGoTa89 = 20,RefGoTa90 = 21,RefHeKa70 = 22,RefChr76 = 23,RefCro58 = 24,
     RefRei94 = 25,RefPrSt02 = 26,RefTar72 = 27,RefAHU83 = 28,RefSch79 = 29,
     RefHie1873 = 30,RefPaRi90 = 31,RefHaOr94 = 32,RefEd65a = 33,
     RefFrJu99a = 34,RefFrJu99b = 35,RefFrJu01a = 36,RefFrJu01b = 37,
     RefFrJu02 = 38,RefMiVa80 = 39,RefKoSt95 = 40,RefGoKa96 = 41,
     RefAns87 = 42,RefKaMu74 = 43,RefPaCo80 = 44,RefAns85 = 45,RefOrDo72 = 46,
     RefFPRR02 = 47,RefKan96 = 48,NoReference = 49};
    

// Module Data Base
 
struct TModuleStruct {
    char*           moduleName;
    TTimer          moduleTimer;
    TAuthor         implementor1;
    TAuthor         implementor2;
    char*           encodingDate;
    char*           revisionDate;
    TReference      originalReference;
    TReference      authorsReference;
    TReference      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 TReferenceStruct {
    char*           refKey;
    char*           authors;
    char*           title;
    char*           type;
    char*           collection;
    char*           editors;
    int             volume;
    char*           pages;
    char*           publisher;
    int             year;
};

extern const TReferenceStruct 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_INTERNAL=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,MSG_END = 25,
     NO_MSG=26,MSG_COMPOUND=128};


// Exception Handling

class ERGoblin                              {};

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

class ERInternal    : 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
