PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PComplexData.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/base/PComplexData.h
4// Purpose: Contains base class for complex data, held by the Variant Class
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003-2026 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#include "PComplexData.h"
28
29#include <iostream>
30
31#include "../utility/PError.h"
32#include "../utility/rc_ptrs.h"
33
34
35using std::ostream;
36using std::cerr;
37using std::endl;
38
43
49
50
51PComplexData::PComplexData( const counted_ptr <PEBLObjectBase > & object )
52 : mPEBLObject(object)
53{
54}
55
57{
58 //cout << "Deleting complex data\n";
59}
60
61
64 : mPEBLObject(pcd.mPEBLObject)
65{
66}
67
70 : mPEBLObject(pcd->mPEBLObject)
71{
72}
73
74
75
76//Overload of the << operator
77ostream & operator << ( ostream & out, const PComplexData & pcd )
78{
79 pcd.SendToStream( out );
80 return out;
81}
82
83
84//This prints out stuff to a stream.
85ostream & PComplexData::SendToStream( ostream & out ) const
86{
87 out << *mPEBLObject;
88 return out;
89}
90
91
93{
94 if(mPEBLObject.get() != NULL) return mPEBLObject->GetType();
95 else return CDT_UNDEFINED;
96}
97
98
100{
101 return mPEBLObject;
102
103}
104
105
106
108{
109 return mPEBLObject;
110
111}
112std::string PComplexData::GetTypeName() const
113{
114
115 switch (GetType() )
116 {
117 case CDT_LIST:
118 return "Complex Data: List";
119
120 case CDT_ENVIRONMENT:
121 return "Complex Data: Environment";
122
123 case CDT_WINDOW:
124 return "Complex Data: Window";
125
126 case CDT_COLOR:
127 return "Complex Data: Color";
128
129 case CDT_FONT:
130 return "Complex Data: Font";
131
132 case CDT_LABEL:
133 return "Complex Data: Label";
134
135 case CDT_TEXTBOX:
136 return "Complex Data: TextBox";
137
138 case CDT_IMAGEBOX:
139 return "Complex Data: ImageBox";
140
141 case CDT_KEYBOARD:
142 return "Complex Data: Keyboard";
143
144 case CDT_FILESTREAM:
145 return "Complex Data: FileStream";
146
147 case CDT_AUDIOOUT:
148 return "Complex Data: Audio Out";
149
150 case CDT_DRAWOBJECT:
151 return "Complex Data: Drawing Object";
152
153 case CDT_THICKLINE:
154 return "Complex Data: Thick Line";
155
157 return "Complex Data: Network Connection";
158
159 case CDT_PARALLELPORT:
160 return "Complex Data: Parallel Port";
161
162 case CDT_COMPORT:
163 return "Complex Data: Com Port";
164
165 case CDT_JOYSTICK:
166 return "Complex Data: Joystick";
167 case CDT_MOVIE:
168 return "Complex Data: Movie";
169
170 case CDT_CUSTOMOBJECT:
171 return "Complex Data: Custom Object";
172
173 case CDT_UNDEFINED:
174 default:
175 return "Complex Data: Undefined";
176 }
177
178}
179
180
181
182void PComplexData::SetProperty( std::string prop, Variant v )
183{
184
185 mPEBLObject->SetProperty(prop,v);
186}
187
188
189Variant PComplexData::GetProperty( std::string prop )const
190{
191 return mPEBLObject->GetProperty(prop);
192}
193
194
195bool PComplexData::PropertyExists( std::string prop )const
196{
197
198 enum ObjectValidationError tmp = mPEBLObject->ValidateProperty(prop);
199 bool success = tmp == OVE_SUCCESS;
200
201 return success;
202}
203
204
205
207{
208 return GetType() == CDT_LIST;
209}
210
211
213{
214 return GetType() == CDT_ENVIRONMENT;
215}
216
217
219{
220 if ( ( GetType() == CDT_WINDOW ) || ( GetType() == CDT_LABEL ) || ( GetType() == CDT_IMAGEBOX )
221 || (GetType()==CDT_THICKLINE)
222 || ( GetType() == CDT_TEXTBOX ) || ( GetType() == CDT_DRAWOBJECT ) || ( GetType() == CDT_CANVAS ) || GetType() == CDT_MOVIE || GetType() == CDT_CUSTOMOBJECT)
223 return true;
224 else
225 return false;
226}
227
228
230{
231 return GetType() == CDT_WINDOW;
232}
233
234
236{
237 return GetType() == CDT_COLOR;
238}
239
240
242{
243 return GetType() == CDT_FONT;
244}
245
247{
248 return ( GetType() == CDT_TEXTBOX ) || ( GetType() == CDT_LABEL );
249}
250
252{
253 return GetType() == CDT_LABEL;
254}
255
257{
258 return GetType() == CDT_TEXTBOX;
259}
260
261
262
264{
265 return GetType() == CDT_IMAGEBOX;
266}
267
268
270{
271 return GetType() == CDT_JOYSTICK;
272}
273
274
276{
277 return GetType() == CDT_KEYBOARD;
278}
279
281{
282 return GetType() == CDT_FILESTREAM;
283}
284
286{
287 return GetType() == CDT_AUDIOOUT;
288}
289
290
292{
293 return GetType() == CDT_DRAWOBJECT;
294}
295
296
298{
299 //cout << "Checking thickline:" << GetType() << ":" << GetTypeName() << endl;
300 return GetType() == CDT_THICKLINE;
301}
302
304{
305 return GetType() == CDT_CANVAS;
306}
307
308
313
314
316{
317 return GetType() == CDT_PARALLELPORT;
318}
319
321{
322 return GetType() == CDT_COMPORT;
323}
324
325
327{
328 return GetType() == CDT_MOVIE;
329}
330
331
333{
334 //cout << "checking custom object" << GetType() << "|" << GetTypeName() << endl;
335
336 return GetType() == CDT_CUSTOMOBJECT;
337}
338
340{
341
342 if(IsList()) return dynamic_cast<PList*>(mPEBLObject.get());
343 else return NULL;
344
345}
#define NULL
Definition BinReloc.cpp:317
ostream & operator<<(ostream &out, const PComplexData &pcd)
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_SUCCESS
Definition PEBLObject.h:38
ComplexDataType
Definition PEBLObject.h:45
@ CDT_JOYSTICK
Definition PEBLObject.h:54
@ CDT_PARALLELPORT
Definition PEBLObject.h:65
@ CDT_WINDOW
Definition PEBLObject.h:58
@ CDT_TEXTBOX
Definition PEBLObject.h:57
@ CDT_FONT
Definition PEBLObject.h:52
@ CDT_LIST
Definition PEBLObject.h:56
@ CDT_COMPORT
Definition PEBLObject.h:66
@ CDT_MOVIE
Definition PEBLObject.h:67
@ CDT_THICKLINE
Definition PEBLObject.h:61
@ CDT_AUDIOOUT
Definition PEBLObject.h:47
@ CDT_FILESTREAM
Definition PEBLObject.h:51
@ CDT_NETWORKCONNECTION
Definition PEBLObject.h:64
@ CDT_ENVIRONMENT
Definition PEBLObject.h:50
@ CDT_IMAGEBOX
Definition PEBLObject.h:53
@ CDT_KEYBOARD
Definition PEBLObject.h:55
@ CDT_LABEL
Definition PEBLObject.h:59
@ CDT_CANVAS
Definition PEBLObject.h:63
@ CDT_DRAWOBJECT
Definition PEBLObject.h:60
@ CDT_UNDEFINED
Definition PEBLObject.h:46
@ CDT_CUSTOMOBJECT
Definition PEBLObject.h:62
@ CDT_COLOR
Definition PEBLObject.h:49
Variant GetProperty(std::string prop) const
bool IsImageBox() const
counted_ptr< PEBLObjectBase > GetObject() const
bool IsWidget() const
bool IsColor() const
bool IsTextObject() const
bool IsWindow() const
bool IsAudioOut() const
std::string GetTypeName() const
bool IsDrawObject() const
bool IsEnvironment() const
bool IsParallelPort() const
bool IsMovie() const
PList * GetList() const
bool IsList() const
ComplexDataType GetType() const
bool IsLabel() const
bool IsTextBox() const
void SetProperty(std::string, Variant v)
bool IsKeyboard() const
bool IsFileStream() const
bool IsComPort() const
bool PropertyExists(std::string prop) const
bool IsFont() const
counted_ptr< PEBLObjectBase > GetPEBLObject() const
bool IsNetworkConnection() const
bool IsThickLine() const
std::ostream & SendToStream(std::ostream &out) const
bool IsCustomObject() const
~PComplexData()
Destructor. Does not destroy the pointed-to contents.
bool IsJoystick() const
bool IsCanvas() const
virtual bool SetProperty(std::string name, Variant v)
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
ComplexDataType GetType()
Definition PEBLObject.h:102
Variant GetProperty(std::string) const
Definition PList.h:45
X * get() const
Definition rc_ptrs.h:110