root/trunk/src/core/include/hydrogen/basics/pattern.h @ 2261

Revision 2261, 3.4 KB (checked in by jeremyz, 23 months ago)

start cleaning Pattern class

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 H2C_PATTERN_H
24#define H2C_PATTERN_H
25
26#include <set>
27
28#include <hydrogen/object.h>
29
30namespace H2Core
31{
32
33class Note;
34class Instrument;
35
36/**
37Pattern class is a Note container
38*/
39class Pattern : public H2Core::Object
40{
41        H2_OBJECT
42    public:
43        std::multimap <int, Note*> note_map;
44        std::set<Pattern*> virtual_pattern_set;
45        std::set<Pattern*> virtual_pattern_transitive_closure_set;
46        /**
47         * constructor
48         * \param name the name of the pattern
49         * \param category the name of the pattern
50         * \param length the length of the pattern
51         */
52        Pattern( const QString& name="Pattern", const QString& category="not_categorized", int length=MAX_NOTES );
53        /** copy constructor */
54        Pattern( Pattern* other );
55        /** destructor */
56        ~Pattern();
57
58        ///< set the name of the pattern
59        void set_name( const QString& name );
60        ///< get the name of the pattern
61        const QString& get_name() const;
62        ///< set the category of the pattern
63        void set_category( const QString& category );
64        ///< get the category of the pattern
65        const QString& get_category() const;
66        ///< set the length of the pattern
67        void set_length( int length );
68        ///< get the length of the pattern
69        int get_length() const;
70
71        /**
72         * check if this pattern contains a note referencing the given instrument
73         * \param instr the instrument
74        */
75        bool references( Instrument* instr );
76        /**
77         * delete the notes referencing the given instrument
78         * The function is thread safe (it locks the audio data while deleting notes)
79         * \param instr the instrument
80        */
81        void purge_instrument( Instrument* instr );
82        /**
83         * mark all notes as old
84         */
85        void set_to_old();
86
87    private:
88        int __length;                   ///< the length of the pattern
89        QString __name;                 ///< the name of thepattern
90        QString __category;             ///< the category of the pattern
91};
92
93// DEFINITIONS
94
95inline void Pattern::set_name( const QString& name )
96{
97    __name = name;
98}
99
100inline const QString& Pattern::get_name() const
101{
102    return __name;
103}
104
105inline void Pattern::set_category( const QString& category )
106{
107    __category = category;
108}
109
110inline const QString& Pattern::get_category() const
111{
112    return __category;
113}
114
115inline void Pattern::set_length( int length )
116{
117    __length = length;
118}
119
120inline int Pattern::get_length() const
121{
122    return __length;
123}
124
125};
126
127#endif // H2C_PATTERN_H
128
129/* vim: set softtabstop=4 expandtab:  */
Note: See TracBrowser for help on using the browser.