PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PEBLObject.h
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/PEBLObject.h
4// Purpose: Simple base class for objects
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2005-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
28#ifndef __PEBLOBJECTBASE_H__
29#define __PEBLOBJECTBASE_H__
30
31//#include "PComplexData.h"
32#include "Variant.h"
33#include <iostream>
34#include <map>
35#include <string>
36
44
69
70class PComplexData;
71
73{
74 public:
77 PEBLObjectBase(const PEBLObjectBase & pob);
78 virtual ~PEBLObjectBase();
79
80 //Overload of the << operator
81 friend std::ostream & operator <<(std::ostream & out, const PEBLObjectBase & object );
82
83 //Initializes the valid property names:
84 virtual bool InitializeProperty(std::string name, Variant v);
85
86
87 //Sets the value of a valid property name. Will not set invalid properties.
88 virtual bool SetProperty(std::string name, Variant v);
89
90 Variant GetProperty(std::string)const;
91
92 // This method needs to be overridden by child classes so that
93 // want to verify whether a property/string combination is legal.
94 // For example, most objects have only a few set legal property names;
95 // and trying to set a different property will lead to an error. Other
96 // properties should only have certain types, or the types should only have
97 // certain values, and validating will guard against the use of improper types and values.
98
99 virtual ObjectValidationError ValidateProperty(std::string, Variant v)const;
100 virtual ObjectValidationError ValidateProperty(std::string)const;
101
103
104 virtual std::string ObjectName() const;
105 virtual std::ostream & PrintProperties(std::ostream& out);
106 virtual Variant GetPropertyList();
107 protected:
108 virtual std::ostream & SendToStream(std::ostream& out) const;
110
111 //Any object can contain a set of text-string addressable properties.
112 std::map<std::string, Variant> mProperties;
113
114};
115
116#endif
117
ObjectValidationError
Definition PEBLObject.h:37
@ OVE_SUCCESS
Definition PEBLObject.h:38
@ OVE_INVALID_PROPERTY_VALUE
Definition PEBLObject.h:42
@ OVE_INVALID_PROPERTY_NAME
Definition PEBLObject.h:40
@ OVE_VALID
Definition PEBLObject.h:39
@ OVE_INVALID_PROPERTY_TYPE
Definition PEBLObject.h:41
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_AUDIOBUFFER
Definition PEBLObject.h:48
@ 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
virtual std::string ObjectName() const
virtual std::ostream & SendToStream(std::ostream &out) const
virtual bool InitializeProperty(std::string name, Variant v)
virtual ~PEBLObjectBase()
Standard Destructor.
virtual bool SetProperty(std::string name, Variant v)
std::map< std::string, Variant > mProperties
Definition PEBLObject.h:112
friend std::ostream & operator<<(std::ostream &out, const PEBLObjectBase &object)
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
ComplexDataType GetType()
Definition PEBLObject.h:102
virtual std::ostream & PrintProperties(std::ostream &out)
ComplexDataType mCDT
Definition PEBLObject.h:109
Variant GetProperty(std::string) const
virtual Variant GetPropertyList()
PEBLObjectBase()
Standard Constructor.