Source: element.h


Annotated List
Files
Globals
Hierarchy
Index
#ifndef _ELEMENT_H_
#define _ELEMENT_H_

// #define DEBUGIT

//
// Do not change the order of the first five types in order to be compatible with Brahms-0.97!
// ___________________________________________________________________________________________

enum Type { SCORETRACK, DRUMTRACK, MASTERTRACK, AUDIOTRACK, COMMENTTRACK, TRACK,
	    ABSTRACT, ATOM, STRING, POSITION, REFERENCE,
	    EVENT, MASTEREVENT, NOTE, MIDIEVENT, SYMBOL, AUDIOEVENT,
	    ORNAMENT, LYRICS, STEM, EXPRESSION, BOW,
	    COMPOUND, SONG, PART, SELECTION, VECTOR, TABLE,
	    OPERATION, ADDON, ADDELEMENT, REMOVEELEMENT, CONVERTTRACK, MOVEPART, COPYPART, COPYGHOSTPART, MOVEEVENT, COPYEVENT, CHANGENOTE,
	    GLUENOTE, SPLITNOTE, ADDORNAMENT, REMOVEORNAMENT, ADDSYMBOL,
	    ADDTOSELECTION, REMOVEFROMSELECTION, NEWSELECTION, SELECTLEFT, SELECTRIGHT, UNSELECT, SPLITPART, GLUEPARTS,
	    COPYSELECTION, CUTSELECTION, PASTESELECTION, DELETESELECTION };

enum { DOWN, UP };

#define STEM_UP   1
#define STEM_AUTO 0
#define STEM_DOWN -1

enum GuiEvents { UNDO, REDO, CHANGES, SELECTIONS, MEMORY };

class ostream;
class ifstream;
class Compound;
class Presentation;

class Vector; // for debugging only
class Table;
class PrProgress;

/** The class Element is the most essentail class (similar to javas object-class). Further
 * more, elements may have a successor and a predecessor. These are needed when elements
 * are arranged with compound objects.
 */
class Element
{
 private:
  Element * _next;
  Element * _prev;
  Presentation * _pr;

#ifdef DEBUGIT
  static int _total;      // for debugging only
  static Element * _list; // for debugging only
  Element * _nnnn;        // for debugging only
#endif

 public:

  /** only used internally */
  Element();
  Element(const Element & el);

  /** the destructor contains code only in debugging mode */
  virtual ~Element();

#ifdef DEBUGIT
  /** for debugging purposes only */
  int total() const { return _total; }

  /** for debugging purposes only */
  void dump(int i=-1);
#endif

 protected:
  Type _type;
  char * spc(int) const;

  static Element * next(Element *);
  static Element * prev(Element *);
  static void splitBefore(Element *);
  static Element * first(Element *);
  static Element * last(Element *);
  static Element * get(int,Element*);
  static void append(Element *, Element *);
  static Element * preput(Element *, Element *);
  static Element * insertBefore(Element *, Element *);
  static void insertAfter(Element *, Element *);
  static Element * remove(Element *);

  /** This method exchanges the contexts of e1 and e2:
   * before: a1 <=> e1 <=> b1     a2 <=> e2 <=> b2
   * after:  a1 <=> e2 <=> b1     a2 <=> e1 <=> b2
   */
  static void exchange(Element * e1, Element * e2);

 public:

  /** checks whether an element is member of a compound */
  bool member(Compound*);

  /** if member of a compound, this method returns the element position within the compound, and -1 otherwise */
  int ord(Compound*);

  /** returns the type of an element as char* */
  const char * ctype() const;

  /** returns the type of an element as a constant integer */
  Type isA() const;

  /** returns true if the element is an event (Note, etc.) */
  virtual bool isEvent() const = 0;

  /** returns true if the element is a track */
  virtual bool isTrack() const = 0;

  /** checks whether two elements are equal */
  //virtual bool operator==(Element*);

  /** checks whether two elements are equal */
  //virtual bool operator==(const char*);

  /** overload this, if this element has a presentation, and delegate to it */
  virtual void show();

  /** overload this, if this element has a presentation, and delegate to it */
  virtual void hide();

  /** implement this to define output for each element */
  virtual ostream & print(int,ostream&) const = 0;

  /** implement this to define short output for each element */
  virtual void flush(const char*) const = 0;

  /** implement this to define the copy process for each element */
  virtual Element * copy() const = 0;

  static void loadContent(Compound * list, const char * term, const char * name, Element*(*loadme)(char*,ifstream*&,Element*), ifstream * inPtr, PrProgress * progress=0, int num=0);
  static void loadContent(Compound * list, const char * term, int num, const char * name[], Element*(*loadme[])(char*,ifstream*&,Element*), ifstream * inPtr, PrProgress * progress=0, int num=0);

};

ostream & operator<<(ostream&,Element&);

#endif

Generated by: wuerthne on clouseau on Fri Sep 21 19:20:46 2001, using kdoc 2.0a53.