2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../core/juce_StandardHeader.h"
30 #include "juce_DynamicObject.h"
33 //==============================================================================
34 DynamicObject::DynamicObject()
38 DynamicObject::~DynamicObject()
42 bool DynamicObject::hasProperty (const Identifier
& propertyName
) const
44 const var
* const v
= properties
.getVarPointer (propertyName
);
45 return v
!= nullptr && ! v
->isMethod();
48 var
DynamicObject::getProperty (const Identifier
& propertyName
) const
50 return properties
[propertyName
];
53 void DynamicObject::setProperty (const Identifier
& propertyName
, const var
& newValue
)
55 properties
.set (propertyName
, newValue
);
58 void DynamicObject::removeProperty (const Identifier
& propertyName
)
60 properties
.remove (propertyName
);
63 bool DynamicObject::hasMethod (const Identifier
& methodName
) const
65 return getProperty (methodName
).isMethod();
68 var
DynamicObject::invokeMethod (const Identifier
& methodName
,
69 const var
* parameters
,
72 return properties
[methodName
].invokeMethod (this, parameters
, numParameters
);
75 void DynamicObject::setMethod (const Identifier
& name
,
76 var::MethodFunction methodFunction
)
78 properties
.set (name
, var (methodFunction
));
81 void DynamicObject::clear()