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

This class simply represent an abstract text-based object. More...

#include <PCustomObject.h>

Inheritance diagram for PCustomObject:
PEBLObjectBase

Public Member Functions

 PCustomObject ()
 
 PCustomObject (const std::string &text)
 
 PCustomObject (PCustomObject &object)
 
virtual ~PCustomObject ()
 
virtual bool SetProperty (std::string, Variant v)
 
virtual Variant GetProperty (std::string) const
 
virtual ObjectValidationError ValidateProperty (std::string, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string) const
 
std::list< std::string > GetObjectOrder ()
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
ComplexDataType GetType ()
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 This sends the color descriptions to the specified stream.
 
virtual std::string ObjectName () const
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 

Protected Attributes

std::string mName
 
std::list< std::string > mObjectOrder
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 

Detailed Description

This class simply represent an abstract text-based object.

Definition at line 36 of file PCustomObject.h.

Constructor & Destructor Documentation

◆ PCustomObject() [1/3]

PCustomObject::PCustomObject ( )

Definition at line 37 of file PCustomObject.cpp.

37 :
39 mName("Unknown Custom Object")
40{
41
42
43}
@ CDT_CUSTOMOBJECT
Definition PEBLObject.h:62
std::string mName
PEBLObjectBase()
Standard Constructor.

◆ PCustomObject() [2/3]

PCustomObject::PCustomObject ( const std::string &  text)

Definition at line 47 of file PCustomObject.cpp.

47 :
49 mName(name)
50{
51
52}

◆ PCustomObject() [3/3]

PCustomObject::PCustomObject ( PCustomObject object)

Definition at line 55 of file PCustomObject.cpp.

55 :
56 PEBLObjectBase(object)
57
58{
59
60}

◆ ~PCustomObject()

PCustomObject::~PCustomObject ( )
virtual

Definition at line 63 of file PCustomObject.cpp.

64{
65 mProperties.clear();
66}
std::map< std::string, Variant > mProperties
Definition PEBLObject.h:112

References PEBLObjectBase::mProperties.

Member Function Documentation

◆ GetObjectOrder()

std::list< std::string > PCustomObject::GetObjectOrder ( )
inline

Definition at line 50 of file PCustomObject.h.

50{return mObjectOrder;};
std::list< std::string > mObjectOrder

References mObjectOrder.

◆ GetProperty()

Variant PCustomObject::GetProperty ( std::string  name) const
virtual

Definition at line 87 of file PCustomObject.cpp.

88{
89 std::string uname = PEBLUtility::ToUpper(name);
90 return PEBLObjectBase::GetProperty(uname);
91}
Variant GetProperty(std::string) const
std::string ToUpper(const std::string &text)

References PEBLObjectBase::GetProperty(), and PEBLUtility::ToUpper().

Referenced by Evaluator::CallFunction(), Evaluator::Evaluate1(), and PrintProperties().

◆ GetPropertyList()

Variant PCustomObject::GetPropertyList ( )
protectedvirtual

Reimplemented from PEBLObjectBase.

Definition at line 145 of file PCustomObject.cpp.

146{
147
148 PList * returnList = new PList();
149
150 for(std::list<std::string>::iterator i = mObjectOrder.begin(); i != mObjectOrder.end(); ++i)
151 {
152 returnList->PushBack(Variant(*i));
153 }
154
156 PComplexData * tmpPCD= (new PComplexData(tmpObj));
157 Variant tmp = Variant(tmpPCD);
158 delete tmpPCD;
159 tmpPCD=NULL;
160 return tmp;
161}
#define NULL
Definition BinReloc.cpp:317
Definition PList.h:45
void PushBack(const Variant &v)
Definition PList.cpp:149

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

◆ ObjectName()

std::string PCustomObject::ObjectName ( ) const
protectedvirtual

Reimplemented from PEBLObjectBase.

Definition at line 118 of file PCustomObject.cpp.

119{
120 return mName;
121}

References mName.

Referenced by SendToStream().

◆ PrintProperties()

std::ostream & PCustomObject::PrintProperties ( std::ostream &  out)
protectedvirtual

Reimplemented from PEBLObjectBase.

Definition at line 124 of file PCustomObject.cpp.

125{
126 out << "----------\n";
127 for(std::list<std::string>::iterator i = mObjectOrder.begin(); i != mObjectOrder.end(); ++i)
128 {
129 std::string name = (*i);
130 std::string uname = PEBLUtility::ToUpper(name);
131
132 out << "[" << name << "]: " << GetProperty(uname) << endl;
133
134 }
135 out << "----------\n";
136
137
138 return out;
139
140}
virtual Variant GetProperty(std::string) const

References GetProperty(), mObjectOrder, and PEBLUtility::ToUpper().

◆ SendToStream()

std::ostream & PCustomObject::SendToStream ( std::ostream &  out) const
protectedvirtual

This sends the color descriptions to the specified stream.

Reimplemented from PEBLObjectBase.

Definition at line 111 of file PCustomObject.cpp.

112{
113 out << ObjectName()<< std::flush;
114 return out;
115}
virtual std::string ObjectName() const

References ObjectName().

◆ SetProperty()

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

Reimplemented from PEBLObjectBase.

Definition at line 69 of file PCustomObject.cpp.

70{
71 //We won't do any validation here. Maybe in the future
72 //some validation could be done here; allowing the usere
73 //to specify things like value type, or a subset of values.
74 std::string uname = PEBLUtility::ToUpper(name);
75 bool newname = (mProperties.find(uname) == mProperties.end());
76
77 mProperties[uname]=v;
78
79 if(newname){
80 mObjectOrder.push_back(std::string(name));
81 }
82
83 return true;
84}

References mObjectOrder, PEBLObjectBase::mProperties, and PEBLUtility::ToUpper().

Referenced by PEBLUtility::ExtractJSONObject().

◆ ValidateProperty() [1/2]

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

Reimplemented from PEBLObjectBase.

Definition at line 99 of file PCustomObject.cpp.

100{
102 if(ove == OVE_VALID)
103 return ove;
104 else
106
107}
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40
@ OVE_VALID
Definition PEBLObject.h:39
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const

References OVE_INVALID_PROPERTY_NAME, OVE_VALID, and PEBLObjectBase::ValidateProperty().

◆ ValidateProperty() [2/2]

ObjectValidationError PCustomObject::ValidateProperty ( std::string  name,
Variant  v 
) const
virtual

Reimplemented from PEBLObjectBase.

Definition at line 94 of file PCustomObject.cpp.

95{
96 return ValidateProperty(name);
97}
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const

References ValidateProperty().

Referenced by Evaluator::CallFunction(), Evaluator::Evaluate1(), and ValidateProperty().

Member Data Documentation

◆ mName

std::string PCustomObject::mName
protected

Definition at line 57 of file PCustomObject.h.

Referenced by ObjectName().

◆ mObjectOrder

std::list<std::string> PCustomObject::mObjectOrder
protected

Definition at line 58 of file PCustomObject.h.

Referenced by GetObjectOrder(), GetPropertyList(), PrintProperties(), and SetProperty().


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