/**************************************************
*
* History: 
*  Creation Dan, <Jul 8 2002>
* Modified Jeff <jul 28 2002> Tag created as class 
*  also uses templated double link list as internal rep.
**************************************************/ 
 
#ifndef _PROPACCUM
#define _PROPACCUM
#include <stdlib.h> // int64_t
#include "dll.h" //double link list
#include "cestypes.h"

#define CES_FIELD_TAG  Tag

//also named in some places: CES_FIELD_TAG
// this is a data sector for the linked list nodes.

class Tag {
   public:
      Tag( long own =0, long ind =0, int64_t pos =0 , int t =2)
        :owner(own), index(ind), position(pos), type(t){}
      
      const int64_t getPosition() const{return position;}
      void          setPosition(int64_t pos=0){ position = pos; }
      
      const long    getOwner   ()const{return owner;}
      void          setOwner   (long own=0){owner = own;}
      
      const long    getIndex   ()const{return index;}
      void          setIndex   (long ind=0){index = ind;}
      
      const int     getType    ()const{return type;}
      void          setType    (int ty=0){type = ty;}
      
   private:    
      long     owner   ;      // unique within scope of editor 
      long     index   ;      // uniquie within scope of owner
      int64_t  position;      // first character effected 
      int      type    ;      // reference for translation of tag type
};


#define BIGNUM long  // for some reason things screw up if this is int64_t ???

// this is the actual linked list of tag nodes.

class PropAccum {

 public:
                   PropAccum();
                  ~PropAccum();
                  
 CESError_t        set (BIGNUM Owner, BIGNUM Index, BIGNUM Position, int Type);
 CESError_t        set (Tag * Data);
 Tag           *   get (BIGNUM Owner, BIGNUM Index, Tag * Dest);
 
 Tag           *   find(BIGNUM Owner, BIGNUM Index);
 Tag           *   locate(BIGNUM owner, BIGNUM index = 0, TagType type = 0, ChrOffset position = 0);
 
 bool              removeNode(BIGNUM Owner, BIGNUM Index);
 
 private:
 
  List<Tag>  propList;//double link list (currently)
 
  int              insert   (BIGNUM Owner, BIGNUM Index, BIGNUM Position, int Type);
  void             modify   (Tag * node, BIGNUM Position, BIGNUM Type);
  void             deleteAll();

};

#endif


