blob: 82ecab207747e84d411b16275c29048ab6a77c35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/**
* Copyright (c) 2019 DENSO CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Scene implementation class
*/
#include "RBASceneImpl.hpp"
#include "RBAModelElementType.hpp"
#include "RBAAbstractProperty.hpp"
#include "RBAIntegerProperty.hpp"
namespace rba
{
RBASceneImpl::RBASceneImpl(const std::string& name)
: RBAScene(),
RBARuleObject{name}
{
}
std::string
RBASceneImpl::getName() const
{
return RBARuleObject::getElementName();
}
RBAModelElementType
RBASceneImpl::getModelElementType() const
{
return RBAModelElementType::Scene;
}
bool
RBASceneImpl::isGlobal() const
{
return global_;
}
const std::list<std::string>&
RBASceneImpl::getPropertyNames() const
{
return propertyNames_;
}
std::int32_t
RBASceneImpl::getPropertyValue(const std::string& propertyName) const
{
const RBAAbstractProperty* const prop {getProperty(propertyName)};
if(prop == nullptr) {
// Returns "-1" if the property is not registered
return -1;
}
// Returns default value
return prop->getValue();
}
const RBARuleObject* RBASceneImpl::getMember(const std::string& memberName) const
{
return getProperty(memberName);
}
const RBAAbstractProperty*
RBASceneImpl::getProperty(const std::string& propertyName) const
{
auto p = nameToProperty_.find(propertyName);
if(p == nameToProperty_.end()) {
// Returns nullptr if the property is not registered
return nullptr;
}
return p->second;
}
void
RBASceneImpl::setGlobal(const bool newGlobal)
{
global_ = newGlobal;
}
const RBAAbstractProperty*
RBASceneImpl::addProperty(const std::string& newName, std::int32_t newValue)
{
auto p = nameToProperty_.find(newName);
if(p != nameToProperty_.end()) {
// No operation if the property is registered
return p->second;
}
// Registration
properties_.push_back(std::make_unique<RBAIntegerProperty>(this,
newName,
newValue));
propertyNames_.push_back(newName);
nameToProperty_[newName] = properties_.back().get();
return properties_.back().get();
}
}
|