PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PObject.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/objects/PObject.h
4// Purpose: Contains the Definition of the PObject 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#ifndef __POBJECT_H__
28#define __POBJECT_H__
29
30
31#include <list>
32#include <iostream>
33#include <map>
34
35#include "../base/Variant.h"
36
47
48
50{
51public:
52
54 virtual ~PObject();
55
56 //Overload of the << operator
57 friend std::ostream & operator <<(std::ostream & out, const PObject & object );
58
59 //Initializes the valid property names:
60 virtual bool InitializeProperty(std::string name, Variant v);
61
62
63 //Sets the value of a valid property name. Will not set invalid properties.
64 virtual bool SetProperty(std::string name, Variant v);
65
66 virtual Variant GetProperty(std::string)const;
67
68 // This method needs to be overridden by child classes so that
69 // want to verify whether a property/string combination is legal.
70 // For example, most objects have only a few set legal property names;
71 // and trying to set a different property will lead to an error. Other
72 // properties should only have certain types, or the types should only have
73 // certain values, and validating will guard against the use of improper types and values.
74
75 virtual ObjectValidationError ValidateProperty(std::string, Variant v)const;
76 virtual ObjectValidationError ValidateProperty(std::string)const;
77
78
79protected:
80 virtual std::string ObjectName() const;
81 virtual std::ostream & PrintProperties(std::ostream& out) const;
82 virtual std::ostream & SendToStream(std::ostream& out) const;
83 unsigned int mCopies;
84
85 //Any object can contain a set of text-string addressable properties.
86 std::map<std::string,Variant> mProperties;
87};
88
89
90#endif
ObjectValidationError
Definition PEBLObject.h:37
ObjectValidationError
Definition PObject.h:37
@ OVE_SUCCESS
Definition PObject.h:38
@ OVE_INVALID_PROPERTY_VALUE
Definition PObject.h:42
@ OVE_INVALID_PROPERTY_NAME
Definition PObject.h:40
@ OVE_VALID
Definition PObject.h:39
@ OVE_INVALID_PROPERTY_TYPE
Definition PObject.h:41
std::map< std::string, Variant > mProperties
Definition PObject.h:86
virtual std::ostream & PrintProperties(std::ostream &out) const
friend std::ostream & operator<<(std::ostream &out, const PObject &object)
virtual ObjectValidationError ValidateProperty(std::string) const
unsigned int mCopies
Definition PObject.h:83
virtual Variant GetProperty(std::string) const
virtual bool SetProperty(std::string name, Variant v)
virtual ~PObject()
virtual std::string ObjectName() const
virtual std::ostream & SendToStream(std::ostream &out) const
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
virtual bool InitializeProperty(std::string name, Variant v)