flatom.cpp 1.39 KB
Newer Older
thomas's avatar
thomas committed
1
/* 
thomas's avatar
thomas committed
2

thomas's avatar
thomas committed
3
flext - C++ layer for Max/MSP and pd (pure data) externals
thomas's avatar
thomas committed
4

thomas's avatar
thomas committed
5
6
7
8
9
10
11
12
13
14
15
16
Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.  

*/

/*! \file flatom.cpp
    \brief Definitions for handling the t_atom type and lists thereof.
*/

#include <flext.h>

thomas's avatar
thomas committed
17
18
flext_base::AtomList::AtomList(int argc,const t_atom *argv):
	lst(NULL),cnt(0)
thomas's avatar
thomas committed
19
{
thomas's avatar
thomas committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
	operator()(argc,argv);
}

flext_base::AtomList::AtomList(const AtomList &a):
	lst(NULL),cnt(0)
{
	operator =(a);
}

flext_base::AtomList::~AtomList() {	Clear(); }

flext_base::AtomList &flext_base::AtomList::operator()(int argc,const t_atom *argv)
{
	if(lst && cnt != argc) { delete[] lst; lst = NULL; }

	if(argc) {
		cnt = argc;
		lst = new t_atom[cnt];

		if(argv) {
			for(int i = 0; i < argc; ++i) {
				switch(lst[i].a_type = argv[i].a_type) {
				case A_FLOAT:
					lst[i].a_w.w_float = argv[i].a_w.w_float;
					break;
thomas's avatar
thomas committed
45
#ifdef MAXMSP
thomas's avatar
thomas committed
46
47
48
				case A_LONG:
					lst[i].a_w.w_int = argv[i].a_w.w_int;
					break;
thomas's avatar
thomas committed
49
#endif
thomas's avatar
thomas committed
50
51
52
				case A_SYMBOL:
					lst[i].a_w.w_symbol = argv[i].a_w.w_symbol;
					break;
thomas's avatar
thomas committed
53
#ifdef PD
thomas's avatar
thomas committed
54
55
56
				case A_POINTER:
					lst[i].a_w.w_gpointer = argv[i].a_w.w_gpointer;
					break;
thomas's avatar
thomas committed
57
#endif
thomas's avatar
thomas committed
58
59
60
61
62
				default:
					post("AtomList - atom type (%i) not supported",lst[i].a_type);
					lst[i].a_type = A_NULL;
					break;
				}
thomas's avatar
thomas committed
63
64
65
			}
		}
	}
thomas's avatar
thomas committed
66
	return *this;
thomas's avatar
thomas committed
67
68
}

thomas's avatar
thomas committed
69

thomas's avatar
thomas committed
70