Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | Related Pages

TDirection.h

00001 /*
00002 
00003   MusicXML Library
00004   Copyright (C) 2003  Grame
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either
00009   version 2.1 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library; if not, write to the Free Software
00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020   Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
00021   grame@grame.fr
00022 
00023 */
00024 
00025 #ifndef __TDirection__
00026 #define __TDirection__
00027 
00028 #include "exports.h"
00029 #include "common.h"
00030 #include "smartpointer.h"
00031 #include "TSound.h"
00032 
00033 using namespace std;
00034 
00035 namespace MusicXML 
00036 {
00037 
00048 class EXP TOctaveShift : public TDirectionTypeElement, public Positionable {
00049 
00050     public:
00051         enum { undefined=-1, up=1, down, stop, last=stop };
00052         EXP friend SMARTP<TOctaveShift> newOctaveShift(int type);
00053         
00054         virtual void accept(TScoreVisitor& visitor);
00055 
00056         void    setType(int type);
00057         void    setNumber(int num);
00058         void    setSize(int size);
00059 
00060         int     getType() const     { return fType; }
00061         int     getNumber() const   { return fNumber; }
00062         int     getSize() const     { return fSize; }
00063 
00065     static const string xmltype (int d);
00067     static        int   xmltype (const string str);
00068  
00069     protected:
00070         TOctaveShift(int type) : fType(type), fNumber(undefined), fSize(8) {}
00071         virtual ~TOctaveShift() {}
00072     private:
00073         int         fType;
00074         int         fNumber;
00075         int         fSize;
00076 
00077     static bimap<string, int> fType2String;
00078     static int      fTypeTbl[];
00079     static string   fTypeStrings[];        
00080 };
00081 typedef SMARTP<TOctaveShift> SOctaveShift;
00082 
00094 class EXP TBracket : public TDirectionTypeElement, public Positionable {
00095 
00096     public:
00097         enum { undefined=-1, up=1, down, both, arrow, none, last=none };
00098         EXP friend SMARTP<TBracket> newBracket(StartStop::type t);
00099         
00100         virtual void accept(TScoreVisitor& visitor);
00101 
00102         void    setType(StartStop::type type);
00103         void    setNumber(int num);
00104         void    setLineEnd(int lend);
00105         void    setLineType(LineType::type t);
00106 
00107         StartStop::type getType() const     { return fType; }
00108         int     getNumber() const           { return fNumber; }
00109         int     getLineEnd() const          { return fLineEnd; }
00110         LineType::type  getLineType() const { return fLineType; }
00111 
00113     static const string xmllineend (int d);
00115     static        int   xmllineend (const string str);
00116  
00117     protected:
00118         TBracket(StartStop::type t) 
00119             : fType(t), fNumber(undefined), fLineEnd(undefined), fLineType(LineType::undefined) {}
00120         virtual ~TBracket() {}
00121 
00122     private:
00123         StartStop::type fType;
00124         int             fNumber;
00125         int             fLineEnd;
00126         LineType::type  fLineType;
00127 
00128     static bimap<string, int> fLEnd2String;
00129     static int      fLEndTbl[];
00130     static string   fLEndStrings[];        
00131 };
00132 typedef SMARTP<TBracket> SBracket;
00133 
00139 class EXP TDashes : public TDirectionTypeElement, public Positionable {
00140 
00141     public:
00142         enum { undefined=-1 };
00143         EXP friend SMARTP<TDashes> newDashes(StartStop::type t);
00144 
00145         virtual void accept(TScoreVisitor& visitor);
00146 
00147         void            setType(StartStop::type t);
00148         void            setNumber(int num);
00149         StartStop::type getType() const             { return fType; }
00150         int             getNumber() const           { return fNumber; }
00151  
00152     protected:
00153         TDashes(StartStop::type t) : fType(t), fNumber(undefined) {}
00154         virtual ~TDashes() {}
00155     private:
00156         StartStop::type fType;
00157         int             fNumber;
00158 };
00159 typedef SMARTP<TDashes> SDashes;
00160 
00170 class EXP TWords : public TDirectionTypeElement, public Positionable {
00171 
00172     public:
00173         enum { undefined=-1, left=1, center, right, last=right };
00174         EXP friend SMARTP<TWords> newWords();
00175         
00176         virtual void accept(TScoreVisitor& visitor);
00177 
00178         void        setJustify (int just);
00179         void        setLang (const string& lang);
00180         void        setValue(const string& value);
00181 
00182         int         getJustify() const      { return fJustify; }
00183         const string&   getLang() const     { return fLang; }
00184         const string&   getValue() const    { return fValue; }
00185 
00187     static const string xmljustify (int d);
00189     static        int   xmljustify (const string str);
00190 
00191     protected:
00192         TWords() : fJustify(undefined) {}
00193         virtual ~TWords() {}
00194 
00195     private:
00196         int         fJustify;
00197         string      fLang;
00198         string      fValue;
00199 
00200     static bimap<string, int> fJust2String;
00201     static int      fJustTbl[];
00202     static string   fJustStrings[];        
00203 };
00204 typedef SMARTP<TWords> SWords;
00205 
00217 class EXP TWedge : public TDirectionTypeElement, public Positionable {
00218 
00219     public:
00220         enum { undefined=-1, crescendo=1, diminuendo, stop, last=stop };
00221 
00222         EXP friend SMARTP<TWedge> newWedge(int type);
00223         
00224         virtual void accept(TScoreVisitor& visitor);
00225 
00226         void    setType (int type);
00227         void    setNumber(int num);
00228         void    setSpread(int sp);
00229 
00230         int     getType () const    { return fType; }
00231         int     getNumber () const  { return fNumber; }
00232         int     getSpread () const  { return fSpread; }
00233 
00235     static const string xmltype (int d);
00237     static        int   xmltype (const string str);
00238 
00239     protected:
00240         TWedge(int type) 
00241             : fType(type), fNumber(undefined), fSpread(undefined) {}
00242         virtual ~TWedge() {}
00243     private:
00244         int     fType;
00245         int     fNumber;
00246         int     fSpread;
00247 
00248     static bimap<string, int> fType2String;
00249     static int      fTypeTbl[];
00250     static string   fTypeStrings[];        
00251 };
00252 typedef SMARTP<TWedge> SWedge;
00253 
00257 class EXP TSymbolicNoteDuration : public virtual smartable {
00258 
00259     public:
00260         EXP friend SMARTP<TSymbolicNoteDuration> newSymbolicNoteDuration ();
00261 
00262         void    setBeat (NoteType::type beatUnit);
00263         void    setDots (unsigned dots);
00264         NoteType::type  getBeat () const    { return fBeatUnit; }
00265         unsigned        getDots () const    { return fDots; }
00266 
00267     protected:
00268         TSymbolicNoteDuration () : fBeatUnit(NoteType::undefined), fDots(0) {}
00269         virtual ~TSymbolicNoteDuration() {}
00270 
00271     private:
00272         NoteType::type  fBeatUnit;
00273         unsigned        fDots;
00274 };
00275 typedef SMARTP<TSymbolicNoteDuration> SSymbolicNoteDuration;
00276 
00289 class EXP TMetronome : public TDirectionTypeElement, public TSymbolicNoteDuration, public Positionable {
00290 
00291     public:
00292         EXP friend SMARTP<TMetronome> newMetronome();
00293 
00294         virtual void accept(TScoreVisitor& visitor);
00295         
00296         void            setParentheses (YesNo::type val);
00297         void            setPerMinute (string pm);
00298         void            setPerMinute (long pm);
00299         YesNo::type     getParentheses () const             { return fParentheses; }
00300         string          getPerMinute () const               { return fPerMinute; }
00301 
00307         SSymbolicNoteDuration& equal()                      { return fEqual; }
00308 
00309     protected:
00310         TMetronome() : fParentheses(YesNo::undefined) {}
00311         virtual ~TMetronome() {}
00312 
00313     private:
00314         YesNo::type     fParentheses;
00315         string          fPerMinute;
00316         SSymbolicNoteDuration   fEqual;
00317 };
00318 typedef SMARTP<TMetronome> SMetronome;
00319 
00331 class EXP TDirectionType : public visitable, public smartable {
00332 
00333     public:
00334         EXP friend SMARTP<TDirectionType> newDirectionType();
00335 
00336         virtual void accept(TScoreVisitor& visitor);
00337         long  add (const SDirectionTypeElement& elt);
00338         vvector<SDirectionTypeElement>& elements()      { return fElements; }
00339 
00340     protected:
00341         TDirectionType() {}
00342         virtual ~TDirectionType() {}
00343     private:
00344         vvector<SDirectionTypeElement>  fElements;
00345 };
00346 typedef SMARTP<TDirectionType> SDirectionType;
00347 
00358 class EXP TDirection : public TMusicData, public Placementable {
00359 
00360     public:
00362         enum { undefined = -1 };
00363         
00364         EXP friend SMARTP<TDirection> newDirection();
00365         
00366         virtual void accept(TScoreVisitor& visitor);
00367 
00368         long add(const SDirectionType& dir);
00369         void setOffset(long offset);
00370         void setVoice(long voice);
00371         void setStaff(long staff);
00372 
00373         SSound& sound()                             { return fSound; }
00374 
00375         long getOffset() const              { return fOffset; }
00376         long getVoice() const               { return fVoice; }
00377         long getStaff() const               { return fStaff; }
00378         vvector<SDirectionType>& types()    { return fTypeList; }
00379 
00380     protected:
00381         TDirection()
00382             : fOffset(0), fVoice(undefined), fStaff(undefined) {}
00383         virtual ~TDirection() {}
00384 
00385     private:
00387         vvector <SDirectionType> fTypeList;
00389         long        fOffset;
00391         long        fVoice;
00393         long        fStaff;
00395         SSound      fSound;
00396 };
00397 typedef SMARTP<TDirection> SDirection;
00398 
00399 } // namespace MusicXML
00400 
00401 
00402 #endif

Generated on Tue Mar 23 09:49:43 2004 for LibMusicXML by doxygen 1.3.3