1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
32 //-----------------------------------------------------------------------------
33 #ifndef __CHUCK_OO_H__
34 #define __CHUCK_OO_H__
36 #include "chuck_def.h"
43 //-----------------------------------------------------------------------------
44 // name: struct Chuck_VM_Object
45 // dsec: base vm object
46 //-----------------------------------------------------------------------------
47 struct Chuck_VM_Object
50 Chuck_VM_Object( t_CKBOOL pooled
= FALSE
)
51 { this->init_ref(); m_pooled
= pooled
; }
52 virtual ~Chuck_VM_Object() { }
53 virtual void init() { this->init_ref(); }
54 virtual void done() { }
57 void init_ref() { m_ref_count
= 0; }
58 void add_ref() { m_ref_count
++; }
59 void release() { assert( m_ref_count
> 0 ); m_ref_count
--;
61 if( !m_pooled
) delete this;
62 else assert( FALSE
); }
71 //-----------------------------------------------------------------------------
72 // name: struct Chuck_Object
74 //-----------------------------------------------------------------------------
75 struct Chuck_Object
: Chuck_VM_Object
81 //-----------------------------------------------------------------------------
82 // name: struct Chuck_Array
83 // desc: native ChucK arrays
84 //-----------------------------------------------------------------------------
86 struct Chuck_Array
: Chuck_Object
89 Chuck_Array( t_CKINT size
= 1 );
93 T
operator[]( t_CKINT i
);
96 t_CKINT
push_back( T val
);
101 std::vector
<T
> m_vector
;
107 //-----------------------------------------------------------------------------
109 // desc: base Chuck Event class
110 //-----------------------------------------------------------------------------
111 struct Chuck_Event
: Chuck_Object
119 t_CKUINT
broadcast();