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


#if !defined(_ABSOBJ_H_)

#define _ABSOBJ_H_

#include <context.h>


class goblinDataObject : public virtual goblinAbstractObject
{
protected:

    goblinController&   CT;
    char*               label;

private:

    unsigned int        refCounter;
    THandle             OH;

public:

    goblinDataObject(goblinController &thisContext = goblinDefaultContext,
        TOption options = 0) throw();
    virtual ~goblinDataObject() throw();

    unsigned long   Allocated() throw();

    
    // *************************************************************** //
    //                     Local Type Declarations                     //
    // *************************************************************** //

    enum TWriteInc {WRITE_INCIDENCES = 1,NO_INCIDENCES = 0};

    enum TConstructorOpt {
        OPT_CLONE = 128,
        OPT_SUB = 32,
        OPT_PARALLELS = 64,
        OPT_COMPLETE = 16,
        OPT_REVERSE = 8
    };

    enum TFoldOptions {
        NO_INDENT = 1,
        SHOW_TITLE = 2
    };
    
    
    // *************************************************************** //
    //                        Memory Management                        //
    // *************************************************************** //

    goblinController &      Context() throw() {return CT;};
    THandle                 Handle() throw() {return OH;};

    
    // *************************************************************** //
    //                Management of Object References                  //
    // *************************************************************** //
    
    void            MakeRef() throw() {refCounter++;};
    void            ReleaseRef() throw() {refCounter--;};
    bool            IsReferenced() throw() {return (refCounter>0);};

    
    // *************************************************************** //
    //                     Dummy display option                        //
    // *************************************************************** //
    
    virtual char*   Display() throw(ERFile,ERRejected);
    virtual void    ConfigDisplay(goblinController &) throw() {};
    char*           Label() throw() {return label;};
    void            SetLabel(char* l) throw();
    
    
    // *************************************************************** //
    //                    Canvas export prototypes                     //
    // *************************************************************** //

    virtual void    Export2XFig(char*) throw(ERFile,ERRejected)
                        {throw ERRejected();};
    virtual void    Export2Tk(char*) throw(ERFile,ERRejected)
                        {throw ERRejected();};
    virtual void    Export2Ascii(char*,TOption=0) throw(ERFile,ERRejected)
                        {throw ERRejected();};

    // *************************************************************** //
    //                  Error Handling and Logging                     //
    // *************************************************************** //
    
    void LogEntry(msgType msg,char* logEntry) throw()
        {CT.LogEntry(msg,OH,logEntry);};
    void LogAppend(char* logEntry) throw()
        {CT.LogAppend(logEntry);};

    void Error(msgType msg,char* methodName,char* description)
        throw(ERRange,ERRejected,ERCheck,ERFile,ERParse)
        {CT.Error(msg,OH,methodName,description);};
    void Warning(char* methodName,char* description) throw()
        {CT.Error(MSG_WARN,OH,methodName,description);};
    
    void NoSuchNode(char*,TNode) throw(ERRange);
    void NoMoreArcs(char*,TNode) throw(ERRejected);
    void NoSuchArc(char*,TArc) throw(ERRange);
    void CancelledArc(char*,TArc) throw(ERRejected);
    void NoSuchHandle(char*,THandle) throw(ERRejected);
    void NoSuchItem(char*,unsigned long) throw(ERRange);
    void NoSuchItem(char*,unsigned short) throw(ERRange);
    void NoSuchIndex(char*,unsigned long) throw(ERRange);
    void NoSuchIndex(char*,unsigned short) throw(ERRange);
    void NoSuchCoordinate(char*,char) throw(ERRange);
    void UnknownOption(char*,int) throw(ERRejected);
    void AmountOutOfRange(char*,TFloat) throw(ERRejected);

    
    // *************************************************************** //
    //                        Module Management                        //
    // *************************************************************** //
    
    void OpenFold()  throw() {CT.IncreaseLogLevel();};
    void CloseFold() throw() {CT.DecreaseLogLevel();};
    
    void OpenFold(TModule,TOption = 0) throw();
    void CloseFold(TModule,TOption = 0) throw();

    void SetLowerBound(TTimer,TFloat) throw(ERRejected);
    void SetUpperBound(TTimer,TFloat) throw(ERRejected);
    void SetBounds(TTimer,TFloat,TFloat) throw(ERRejected);

    TFloat LowerBound(TTimer) throw();
    TFloat UpperBound(TTimer) throw();

};


#endif
