root/branches/transport_redesign/libs/hydrogen/include/hydrogen/Pattern.h @ 872

Revision 872, 2.7 KB (checked in by gabriel@…, 4 years ago)

Add H2CORE_ to include guards in libhydrogen headers.

This isn't solving any problem... but adding the namespace to the include guards
promotes the use of simple names. Adding the namespace to the include guard
avoids potential future conflicts with other libraries that have used the same
simple names.

Line 
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 *
21 */
22
23#ifndef H2CORE_PATTERN_H
24#define H2CORE_PATTERN_H
25
26#include <hydrogen/globals.h>
27#include <hydrogen/Object.h>
28
29namespace H2Core
30{
31
32class Note;
33class Instrument;
34
35///
36/// The Pattern is a Note container.
37///
38class Pattern : public Object
39{
40public:
41        typedef std::multimap <int, Note*> note_map_t;
42        note_map_t note_map;
43
44        Pattern( const QString& name, const QString& category, unsigned length = MAX_NOTES );
45        ~Pattern();
46
47        /**
48          Delete notes that pertain to instrument I.
49          The function is thread safe (it locks the audio data while deleting notes)
50        */
51        void purge_instrument( Instrument * I );
52       
53        /**
54          Check if there are any notes pertaining to I
55        */
56        bool references_instrument( Instrument * I );
57       
58        static Pattern* get_empty_pattern();
59        Pattern* copy();
60
61        void debug_dump();
62
63        unsigned get_length() {
64                return __length;
65        }
66        void set_length( unsigned length ) {
67                __length = length;
68        }
69
70        void set_name( const QString& name ) {
71                __name = name;
72        }
73        const QString& get_name() const {
74                return __name;
75        }
76
77        void set_category( const QString& category ) {
78                __category = category;
79        }
80        const QString& get_category() const {
81                return __category;
82        }
83
84private:
85        unsigned __length;
86        QString __name;
87        QString __category;
88};
89
90
91/// Pattern List
92class PatternList : public Object
93{
94public:
95        PatternList();
96        ~PatternList();
97
98        void add( Pattern* new_pattern );
99        Pattern* get( int pos );
100        unsigned int get_size();
101        void clear();
102
103        void replace( Pattern* new_pattern, unsigned pos );
104        int index_of( Pattern* pattern );
105
106        /// Remove a pattern from the list (every instance in the list), the pattern is not deleted!!!
107        /// Returns NULL if the pattern is not in the list
108        Pattern * del( Pattern *pattern );
109
110        /// Remove one pattern from the list, the pattern is not deleted!!!
111        void del( unsigned index );
112
113private:
114        std::vector<Pattern*> list;
115};
116
117};
118
119#endif // H2CORE_PATTERN_H
Note: See TracBrowser for help on using the browser.