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

common.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 __common__
00026 #define __common__
00027 
00028 #include "exports.h"
00029 #include "TScoreVisitor.h"
00030 #include "bimap.h"
00031 #include "conversions.h"
00032 #include "smartpointer.h"
00033 #include <string>
00034 
00035 using namespace std;
00036 
00037 namespace MusicXML 
00038 {
00039 
00046 class TPartListElement : public virtual visitable, public virtual smartable {
00047      protected:
00048         TPartListElement () {}
00049         virtual ~TPartListElement() {}
00050 };
00051 typedef SMARTP<TPartListElement>    SPartListElement;
00052 
00059 class TNotationElement : public virtual visitable, public virtual smartable {
00060      protected:
00061         TNotationElement () {}
00062         virtual ~TNotationElement() {}
00063 };
00064 typedef SMARTP<TNotationElement>    SNotationElement;
00065 
00072 class TDirectionTypeElement : public virtual visitable, public virtual smartable {
00073      protected:
00074         TDirectionTypeElement () {}
00075         virtual ~TDirectionTypeElement() {}
00076 };
00077 typedef SMARTP<TDirectionTypeElement>   SDirectionTypeElement;
00078 
00085 class TMusicData : public virtual visitable, public virtual smartable {
00086      protected:
00087         TMusicData () {}
00088         virtual ~TMusicData() {}
00089 };
00090 typedef SMARTP<TMusicData>  SMusicData;
00091 
00092 typedef long    position[4];
00093 
00119 class EXP TPosition {
00120     public:
00121         enum { undefined=0, defaultx=1, defaulty, relativex, relativey, last=relativey };
00122         
00123         TPosition() { fPosition[0]=fPosition[1]=fPosition[2]=fPosition[3]= undefined; }
00124         virtual ~TPosition() {}
00125                 
00126         virtual void accept(TScoreVisitor& visitor);
00127         void set (int pos, long val)    { if ((pos>0) && (pos<=last)) fPosition[pos-1] = val; }
00128         long get (int pos) const    { return ((pos>0) && (pos<=last)) ? fPosition[pos-1] : undefined; }
00129 
00131     static const string xmlpos (int d);
00133     static int          xmlpos (const string str);
00134 
00135     private:
00137         position fPosition;
00138 
00139     static bimap<string, int> fPos2String;
00140     static int      fPosTbl[];
00141     static string   fPosStrings[];
00142 };
00143 
00148 class EXP Positionable {
00149     public:
00150         Positionable() {}
00151         virtual ~Positionable() {}
00152 
00153         TPosition& position()                   { return fPosition; }
00154     
00155     private:
00156         TPosition fPosition;
00157 };
00158 
00164 class EXP TPlacement {
00165     public:
00166         enum type { undefined, above, below, last=below };
00167 
00168         TPlacement(int place=undefined) : fPlacement(place) {}
00169         virtual ~TPlacement() {}
00170 
00171         void accept(TScoreVisitor& visitor);
00172         void set (int place)        { fPlacement = place; }
00173         int  get () const           { return fPlacement; }
00174 
00176     static const string xmlplace (int d);
00178     static int          xmlplace (const string str);
00179 
00180     private:
00181         int fPlacement;
00182 
00183     static bimap<string, int> fPlace2String;
00184     static int      fPlaceTbl[];
00185     static string   fPlaceStrings[];
00186 };
00187 
00192 class EXP Placementable {
00193     public:
00194         Placementable() {}
00195         virtual ~Placementable() {}
00196         TPlacement& placement()                 { return fPlacement; }
00197     
00198     private:
00199         TPlacement fPlacement;
00200 };
00201 
00209 class EXP TOrientation {
00210     public:
00211         enum type { undefined, over, under, last = under };
00212 
00213         TOrientation(int orient=undefined) : fOrientation(orient) {}
00214         virtual ~TOrientation() {}
00215 
00216         virtual void accept(TScoreVisitor& visitor);
00217         void set (int orient)   { fOrientation = orient; }
00218         int  get () const       { return fOrientation; }
00219 
00221     static const string xmlorientation (int d);
00223     static int          xmlorientation (const string str);
00224 
00225     private:
00226         int fOrientation;
00227 
00228     static bimap<string, int> fOr2String;
00229     static int      fOrTbl[];
00230     static string   fOrStrings[];        
00231 };
00232 
00236 class EXP Orientable {
00237     public:
00238         Orientable() {}
00239         virtual ~Orientable() {}
00240         TOrientation& orientation()  { return fOrientation; }
00241     private:
00242         TOrientation fOrientation;
00243 };
00244 
00245 
00254 class EXP TFermata : public TNotationElement, public Positionable {
00255 
00256     public:
00257         enum { undefined, upright, inverted, last=inverted };
00258 
00259         EXP friend SMARTP<TFermata> newFermata();
00260 
00261         virtual void accept(TScoreVisitor& visitor);
00262         void setType (int type)     { fType = type; }
00263         int getType () const        { return fType; }
00264 
00266     static const string xmltype (int d);
00268     static int          xmltype (const string str);
00269 
00270     protected:
00271         TFermata() : fType(undefined) {}
00272         virtual ~TFermata() {}
00273 
00274     private:
00275         int         fType;
00276 
00277     static bimap<string, int> fType2String;
00278     static int      fTypeTbl[];
00279     static string   fTypeStrings[];        
00280 };
00281 typedef SMARTP<TFermata> SFermata;
00282 
00292 class EXP TWavyLine : public visitable, public Positionable, public Placementable, public smartable {
00293     public:
00294         enum { undefined = -1 };
00295         EXP friend SMARTP<TWavyLine> newWavyLine(StartStop::type t);
00296         
00297         virtual void accept(TScoreVisitor& visitor);
00298         void setType (StartStop::type t)        { fType = t; }
00299         StartStop::type getType () const        { return fType; }
00300         void setNumber (int num)    { fNumber = num; }
00301         int getNumber () const      { return fNumber; }
00302 
00303     protected:
00304         TWavyLine(StartStop::type type) : fType(type), fNumber(undefined) {}
00305         virtual ~TWavyLine() {}
00306         
00307     private:
00309         StartStop::type fType;
00311         int         fNumber;
00312 //      TTrill      fTrill;
00313 };
00314 typedef SMARTP<TWavyLine> SWavyLine;
00315 
00322 class EXP TSegno : public TDirectionTypeElement, public Positionable {
00323     public:        
00324         EXP friend SMARTP<TSegno> newSegno();
00325         virtual void accept(TScoreVisitor& visitor);
00326 
00327     protected:
00328         TSegno() {}
00329         virtual ~TSegno() {}
00330 };
00331 typedef SMARTP<TSegno> SSegno;
00332 
00339 class EXP TCoda : public TDirectionTypeElement, public Positionable {
00340     public:
00341         EXP friend SMARTP<TCoda> newCoda();
00342         virtual void accept(TScoreVisitor& visitor);
00343 
00344     protected:
00345         TCoda() {}
00346         virtual ~TCoda() {}
00347 };
00348 typedef SMARTP<TCoda> SCoda;
00349 
00356 class EXP TDynamic : public TDirectionTypeElement, public TNotationElement, 
00357                  public Positionable, public Placementable { 
00358     public:
00359         enum dynamic {  pppppp=1, ppppp, pppp, ppp, pp, p,
00360                 mp, mf,
00361                 f, ff, fff, ffff, fffff, ffffff, 
00362                 sf, sfp, sfpp, fp, rf, rfz, sfz, sffz, fz, 
00363                 last=fz };
00364 
00365         EXP friend SMARTP<TDynamic> newDynamic();
00366 
00367         virtual void accept(TScoreVisitor& visitor);
00368         vector<dynamic>& dynamics() { return fDynamic; }
00369         long    add (dynamic d);
00370 
00372     static const string xmldynamic (dynamic d);
00374     static dynamic      xmldynamic (const string str);
00375     
00376     static const string* getDynamicStrings()   { return fDynamicStrings; }
00377         
00378     protected:
00379         TDynamic() {}
00380         virtual ~TDynamic() {}
00381         
00382     private:
00383         vector<dynamic> fDynamic;
00384 
00385     static bimap<string, dynamic> fDynamic2String;
00386     static dynamic      fDynamicTbl[];
00387     static string   fDynamicStrings[];
00388 };
00389 typedef SMARTP<TDynamic> SDynamic;
00390 
00391 } // namespace MusicXML
00392 
00393 #endif

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