PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PEBLObjectBase Class Reference

#include <PEBLObject.h>

Inheritance diagram for PEBLObjectBase:
AudioInfo PColor PCustomObject PFont PJoystick PList PNetwork PParallelPort PStream PWidget PlatformAudioOut PlatformAudioOut PlatformEnvironment PlatformEnvironment PlatformKeyboard

Public Member Functions

 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
virtual bool SetProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
virtual ObjectValidationError ValidateProperty (std::string, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::string ObjectName () const
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 

Protected Attributes

ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 

Friends

std::ostream & operator<< (std::ostream &out, const PEBLObjectBase &object)
 

Detailed Description

Definition at line 72 of file PEBLObject.h.

Constructor & Destructor Documentation

◆ PEBLObjectBase() [1/3]

PEBLObjectBase::PEBLObjectBase ( )

Standard Constructor.

Definition at line 43 of file PEBLObject.cpp.

44{
46}
@ CDT_UNDEFINED
Definition PEBLObject.h:46
ComplexDataType mCDT
Definition PEBLObject.h:109

References CDT_UNDEFINED, and mCDT.

◆ PEBLObjectBase() [2/3]

PEBLObjectBase::PEBLObjectBase ( ComplexDataType  cdt)

Standard Constructor.

Definition at line 48 of file PEBLObject.cpp.

49{
50 mCDT=cdt;
51
52}

References mCDT.

◆ PEBLObjectBase() [3/3]

PEBLObjectBase::PEBLObjectBase ( const PEBLObjectBase pob)

Definition at line 54 of file PEBLObject.cpp.

55{
56
57}

◆ ~PEBLObjectBase()

PEBLObjectBase::~PEBLObjectBase ( )
virtual

Standard Destructor.

Definition at line 60 of file PEBLObject.cpp.

61{
62 mProperties.clear();
63 // cout << "Deleting pob\n";
64}
std::map< std::string, Variant > mProperties
Definition PEBLObject.h:112

References mProperties.

Member Function Documentation

◆ GetProperty()

Variant PEBLObjectBase::GetProperty ( std::string  name) const

Definition at line 94 of file PEBLObject.cpp.

95{
96
97 std::string uname = PEBLUtility::ToUpper(name);
98
99
101
102
103
104 if((err == OVE_SUCCESS ) | ( err == OVE_VALID ))
105 {
106 return mProperties.find(uname)->second;
107 }
108 else
109 {
110 PError::SignalFatalError("Attempted to get invalid property [" + name + "] of object.");
111 }
112 return Variant(0);
113}
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_SUCCESS
Definition PEBLObject.h:38
@ OVE_VALID
Definition PEBLObject.h:39
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
std::string ToUpper(const std::string &text)
void SignalFatalError(const std::string &message)

References mProperties, OVE_SUCCESS, OVE_VALID, PError::SignalFatalError(), PEBLUtility::ToUpper(), and ValidateProperty().

Referenced by PlatformTextBox::Draw(), PlatformWindow::Draw(), PFont::GetBackgroundColorPtr(), PDrawObject::GetColor(), PFont::GetFontColorPtr(), PDrawObject::GetOutlineColor(), PComplexData::GetProperty(), PStream::GetProperty(), PCustomObject::GetProperty(), PDrawObject::GetProperty(), PLine::GetProperty(), PThickLine::GetProperty(), PRectangle::GetProperty(), PSquare::GetProperty(), PEllipse::GetProperty(), PCircle::GetProperty(), PPolygon::GetProperty(), PBezier::GetProperty(), PFont::GetProperty(), PImageBox::GetProperty(), PMovie::GetProperty(), PTextObject::GetProperty(), PWidget::GetProperty(), PWindow::GetProperty(), PlatformEnvironment::GetProperty(), PlatformLabel::RenderText(), PlatformTextBox::RenderText(), PlatformTextBox::SetEditable(), and PlatformTextBox::SetFont().

◆ GetPropertyList()

Variant PEBLObjectBase::GetPropertyList ( )
virtual

Reimplemented in PCustomObject.

Definition at line 190 of file PEBLObject.cpp.

191{
192
193 //Create a plist to put the properties in
194
195 PList * newlist = new PList();
196
197
198
199 std::map<std::string, Variant>::const_iterator i;
200 i = mProperties.begin();
201 while(i != mProperties.end())
202 {
203 newlist->PushBack(i->first);
204 i++;
205 }
206
208 tmpObj = counted_ptr<PEBLObjectBase>(newlist);
209 PComplexData * tmpPCD = (new PComplexData(tmpObj));
210 Variant tmp = Variant(tmpPCD);
211 delete tmpPCD;
212 tmpPCD=NULL;
213 return tmp;
214
215}
#define NULL
Definition BinReloc.cpp:317
Definition PList.h:45
void PushBack(const Variant &v)
Definition PList.cpp:149

References mProperties, NULL, and PList::PushBack().

Referenced by PEBLObjects::GetPropertyList().

◆ GetType()

ComplexDataType PEBLObjectBase::GetType ( )
inline

Definition at line 102 of file PEBLObject.h.

102{return mCDT;};

References mCDT.

Referenced by PComplexData::GetType().

◆ InitializeProperty()

◆ ObjectName()

◆ PrintProperties()

ostream & PEBLObjectBase::PrintProperties ( std::ostream &  out)
virtual

Reimplemented in PCustomObject.

Definition at line 172 of file PEBLObject.cpp.

173{
174 out << "----------\n";
175 std::map<std::string, Variant>::const_iterator i;
176 i = mProperties.begin();
177 while(i != mProperties.end())
178 {
179 out << "[" << i->first << "]: " << i->second << endl;
180 i++;
181 }
182 out << "----------\n";
183
184
185 return out;
186
187}

References mProperties.

Referenced by PEBLObjects::PrintProperties().

◆ SendToStream()

◆ SetProperty()

bool PEBLObjectBase::SetProperty ( std::string  name,
Variant  v 
)
virtual

Reimplemented in PlatformCanvas, PlatformLine, PlatformThickLine, PlatformRectangle, PlatformSquare, PlatformEllipse, PlatformCircle, PlatformPolygon, PlatformBezier, PlatformImageBox, PlatformLabel, PlatformTextBox, PlatformWindow, PStream, PCanvas, PColor, PCustomObject, PDrawObject, PLine, PThickLine, PRectangle, PSquare, PEllipse, PCircle, PPolygon, PBezier, PFont, PImageBox, PLabel, PMovie, PTextBox, PTextObject, PWidget, PWindow, PlatformCanvas, PlatformEnvironment, PlatformLabel, PlatformTextBox, and PlatformEnvironment.

Definition at line 67 of file PEBLObject.cpp.

68{
69
71
72 if(err == OVE_SUCCESS)
73 {
74 mProperties[name]=v;
75 return true;
76 }
77 else
78 {
79 Variant msg = Variant("Failing to set property:[") +
80 Variant(name)+ Variant("]:[")+v+Variant("]\n");
81
83 return false;
84 }
85}

References mProperties, OVE_SUCCESS, PError::SignalFatalError(), and ValidateProperty().

Referenced by PlatformTextBox::Draw(), PWidget::Hide(), PDrawObject::SetAA(), PColor::SetAlpha(), PFont::SetAntiAliased(), PWidget::SetBackgroundColor(), PColor::SetBlue(), PCanvas::SetColor(), PDrawObject::SetColor(), PTextObject::SetDirection(), PlatformTextBox::SetEditable(), PThickLine::SetEnds(), PDrawObject::SetFilled(), PlatformLabel::SetFont(), PlatformTextBox::SetFont(), PFont::SetFontFileName(), PFont::SetFontSize(), PFont::SetFontStyle(), PColor::SetGreen(), PWidget::SetHeight(), PlatformCanvas::SetHeight(), PNetwork::SetHostIP(), PNetwork::SetHostName(), PNetwork::SetOpen(), PDrawObject::SetOutlineColor(), PWidget::SetParent(), PMovie::SetPlaybackPosition(), PNetwork::SetPort(), PCanvas::SetPosition(), PImageBox::SetPosition(), PLabel::SetPosition(), PWidget::SetPosition(), PComplexData::SetProperty(), PStream::SetProperty(), PLabel::SetProperty(), PMovie::SetProperty(), PTextBox::SetProperty(), PWidget::SetProperty(), PColor::SetRed(), PWidget::SetRotation(), PImageBox::SetSize(), PMovie::SetSize(), PLine::SetSize(), PRectangle::SetSize(), PEllipse::SetSize(), PCircle::SetSize(), PSquare::SetSize(), PTextObject::SetText(), PThickLine::SetThickness(), PMovie::SetVolume(), PlatformCanvas::SetWidth(), PWidget::SetWidth(), PlatformCanvas::SetZoomX(), PWidget::SetZoomX(), PlatformImageBox::SetZoomX(), PlatformCanvas::SetZoomY(), PWidget::SetZoomY(), PlatformImageBox::SetZoomY(), and PWidget::Show().

◆ ValidateProperty() [1/2]

ObjectValidationError PEBLObjectBase::ValidateProperty ( std::string  name) const
virtual

Reimplemented in PColor, PlatformCanvas, PlatformLine, PlatformThickLine, PlatformRectangle, PlatformSquare, PlatformEllipse, PlatformCircle, PlatformPolygon, PlatformBezier, PlatformImageBox, PlatformLabel, PlatformTextBox, PlatformWindow, PStream, PCanvas, PCustomObject, PDrawObject, PLine, PThickLine, PRectangle, PSquare, PEllipse, PCircle, PPolygon, PBezier, PFont, PImageBox, PLabel, PMovie, PTextBox, PTextObject, PWidget, and PWindow.

Definition at line 123 of file PEBLObject.cpp.

124{
125
126 std::string uname = PEBLUtility::ToUpper(name);
127
128
129#if 0
130 cout << "Testing: [" << uname << "]" <<endl;
131 cout << "Object is: " << *this << endl;
132 cout << "-----------------\n";
133
134 std::map<std::string, Variant>::const_iterator i;
135 i = mProperties.begin();
136 while(i != mProperties.end())
137 {
138 cout << "[" << i->first << "]: " << i->second << endl;
139 i++;
140 }
141 cout << "----------\n";
142#endif
143
144
145 if(mProperties.find(uname) == mProperties.end())
146 {
147
149 }
150 else
151 {
152
153 return OVE_SUCCESS;
154 }
155}
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40

References mProperties, OVE_INVALID_PROPERTY_NAME, OVE_SUCCESS, and PEBLUtility::ToUpper().

◆ ValidateProperty() [2/2]

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const PEBLObjectBase object 
)
friend

Definition at line 159 of file PEBLObject.cpp.

160{
161 object.SendToStream(out);
162 return out;
163}

Member Data Documentation

◆ mCDT

◆ mProperties


The documentation for this class was generated from the following files: