summaryrefslogtreecommitdiffstats
path: root/src/core/logic
diff options
context:
space:
mode:
authorKenji Hosokawa <khosokawa@jp.adit-jv.com>2020-08-24 21:58:42 +0900
committerKenji Hosokawa <khosokawa@jp.adit-jv.com>2020-08-24 21:58:42 +0900
commit2b4ae7fde370bc3316ab30cc38b74d23e785b360 (patch)
tree41b6eb70b3419c2fbd192ed133c5890a985eddec /src/core/logic
parent6694a4d2952ebd171564932200cac00d6e5792f4 (diff)
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com> Change-Id: I381abb0a6521f5349768a76ef7ceecbce4b2d701
Diffstat (limited to 'src/core/logic')
-rw-r--r--src/core/logic/RBAAffectInfo.cpp67
-rw-r--r--src/core/logic/RBAAffectInfo.hpp58
-rw-r--r--src/core/logic/RBAArbitrator.cpp1987
-rw-r--r--src/core/logic/RBABackUpAllocatable.cpp33
-rw-r--r--src/core/logic/RBABackUpAllocatable.hpp42
-rw-r--r--src/core/logic/RBACommonMakerTable.cpp126
-rw-r--r--src/core/logic/RBACommonMakerTable.hpp52
-rw-r--r--src/core/logic/RBAConstraintInfo.cpp695
-rw-r--r--src/core/logic/RBAConstraintInfo.hpp119
-rw-r--r--src/core/logic/RBAConstraintMap.hpp38
-rw-r--r--src/core/logic/RBAContentStatus.cpp72
-rw-r--r--src/core/logic/RBAContentStatus.hpp58
-rw-r--r--src/core/logic/RBARequest.cpp44
-rw-r--r--src/core/logic/RBARequest.hpp59
-rw-r--r--src/core/logic/RBARequestQueMember.cpp48
-rw-r--r--src/core/logic/RBARequestQueMember.hpp64
-rw-r--r--src/core/logic/RBAResultImpl.cpp1088
-rw-r--r--src/core/logic/RBAResultImpl.hpp343
-rw-r--r--src/core/logic/RBAResultSet.cpp996
-rw-r--r--src/core/logic/RBAResultSet.hpp246
-rw-r--r--src/core/logic/RBARollbacker.cpp95
-rw-r--r--src/core/logic/RBARollbacker.hpp84
-rw-r--r--src/core/logic/RBAViewAction.cpp88
-rw-r--r--src/core/logic/RBAViewMove.cpp89
-rw-r--r--src/core/logic/RBAViewMove.hpp62
-rw-r--r--src/core/logic/RBAViewTransition.cpp137
-rw-r--r--src/core/logic/RBAViewTransition.hpp64
27 files changed, 6854 insertions, 0 deletions
diff --git a/src/core/logic/RBAAffectInfo.cpp b/src/core/logic/RBAAffectInfo.cpp
new file mode 100644
index 0000000..6cf4e98
--- /dev/null
+++ b/src/core/logic/RBAAffectInfo.cpp
@@ -0,0 +1,67 @@
+/**
+ * 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.
+ */
+
+/**
+ * AffectInfo class definition
+ */
+
+#include "RBAAffectInfo.hpp"
+
+namespace rba
+{
+
+/**
+ * @brief Returns whether the allocable already affects the target allocable
+ * @param allocatable Influential Allocatable
+ * @param affectAllocatable Affected Allocatable
+ * @return bool
+ */
+bool
+RBAAffectInfo::alreadyKnowsThatFormerHasAffectedToLatter(const RBAAllocatable* const allocatable,
+ const RBAAllocatable* const affectAllocatable) const
+{
+ for(const auto& alloc : reaffected_[allocatable]) {
+ if(alloc == affectAllocatable) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * @brief Register Affect information
+ * @param allocatable Influential Allocatable
+ * @param affectAllocatable Affected Allocatable
+ */
+void
+RBAAffectInfo::addInfoThatFormerAffectedToLatter(const RBAAllocatable* const allocatable,
+ const RBAAllocatable* const affectAllocatable)
+{
+ static_cast<void>(reaffected_[allocatable].insert(affectAllocatable));
+}
+
+/**
+ * @brief Deletes the Affect information of "allocatable" registered by
+ *        other allocatables registered by arbitration of the specified
+ *        recursion hierarchy of the specified "allocatable".
+ * @param affectAllocatable
+ */
+void RBAAffectInfo::removeAffectInfo(const RBAAllocatable* const affectAllocatable)
+{
+ static_cast<void>(reaffected_.erase(affectAllocatable));
+}
+
+}
diff --git a/src/core/logic/RBAAffectInfo.hpp b/src/core/logic/RBAAffectInfo.hpp
new file mode 100644
index 0000000..c9c73be
--- /dev/null
+++ b/src/core/logic/RBAAffectInfo.hpp
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+
+/**
+ * AffectInfo class header
+ */
+
+#ifndef RBAAFFECTINFO_HPP
+#define RBAAFFECTINFO_HPP
+
+#include <unordered_map>
+#include <set>
+
+namespace rba
+{
+
+class RBAAllocatable;
+
+class RBAAffectInfo
+{
+public:
+ RBAAffectInfo()=default;
+ RBAAffectInfo(const RBAAffectInfo&)=delete;
+ RBAAffectInfo(const RBAAffectInfo&&)=delete;
+ RBAAffectInfo& operator=(const RBAAffectInfo&)=delete;
+ RBAAffectInfo& operator=(const RBAAffectInfo&&)=delete;
+ virtual ~RBAAffectInfo()=default;
+
+public:
+ bool alreadyKnowsThatFormerHasAffectedToLatter(const RBAAllocatable* const allocatable,
+ const RBAAllocatable* const affectAllocatable) const;
+ void addInfoThatFormerAffectedToLatter(const RBAAllocatable* const allocatable,
+ const RBAAllocatable* const affectAllocatable);
+ void removeAffectInfo(const RBAAllocatable* const affectAllocatable);
+
+private:
+ // Information of other "allocatable" affected by "allocatable"
+ mutable std::unordered_map<const RBAAllocatable*,
+ std::set<const RBAAllocatable*>>reaffected_;
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAArbitrator.cpp b/src/core/logic/RBAArbitrator.cpp
new file mode 100644
index 0000000..9fdd7d3
--- /dev/null
+++ b/src/core/logic/RBAArbitrator.cpp
@@ -0,0 +1,1987 @@
+/**
+ * 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.
+ */
+
+ /**
+ * Arbitrator class definition
+ */
+
+#include <algorithm>
+#include <sstream>
+#include "RBAArbitrator.hpp"
+#include "RBAModelImpl.hpp"
+#include "RBAResult.hpp"
+#include "RBAResultSet.hpp"
+#include "RBAAffectInfo.hpp"
+#include "RBAConstraintImpl.hpp"
+#include "RBAViewAction.hpp"
+#include "RBAViewTransition.hpp"
+#include "RBAViewMove.hpp"
+#include "RBARollbacker.hpp"
+#include "RBALogManager.hpp"
+#include "RBAModelElementType.hpp"
+
+namespace rba {
+
+RBAArbitrator::RBAArbitrator(RBAModel* newModel)
+{
+ setModel(newModel);
+}
+
+#ifdef RBA_USE_LOG
+RBAArbitrator::RBAArbitrator(RBAModel* newModel, RBALogManager* logManager)
+{
+ setModel(newModel);
+ RBALogManager::setLogManager(logManager);
+ // Even if the argument logManager is null, it may be setLogManager()
+ // from outside the rba, so it is determined by getLogManager() instead of
+ // the argument determination.
+ if (RBALogManager::getLogManager() != nullptr) {
+ setSimulationMode(true);
+ }
+}
+#endif
+
+RBAArbitrator::~RBAArbitrator() noexcept
+{
+}
+
+void
+RBAArbitrator::setModel(RBAModel* newModel)
+{
+ setModel(dynamic_cast<RBAModelImpl*>(newModel));
+}
+
+const RBAModel*
+RBAArbitrator::getModel() const
+{
+ return dynamic_cast<RBAModel*>(model_);
+}
+
+void
+RBAArbitrator::initialize(std::list<std::string>& contexts)
+{
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ setRequestData(contexts, true);
+}
+
+std::unique_ptr<RBAResult>
+RBAArbitrator::execute(const std::string& contextName, bool require)
+{
+ const std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ if (isValidContext(contextName) == false) {
+ // In case of error, creates a copy of "Result",
+ // sets the error flag in it and returns
+ std::unique_ptr<RBAResultImpl> result {std::make_unique<RBAResultImpl>(
+ this, std::make_unique<RBAResultSet>(*getBackupResultSet()))};
+ result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE);
+ return std::move(result);
+ } else {
+ static_cast<void>(setRequestData(contextName, require, nullptr,
+ static_cast<std::uint32_t>(getRequestQue().size())));
+ return arbitrateMain();
+ }
+}
+
+std::unique_ptr<RBAResult>
+RBAArbitrator::execute(std::list<std::string>& contexts,
+ bool require)
+{
+ const std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ if (isValidContext(contexts) == false) {
+ // In case of error, creates a copy of "Result",
+ // sets the error flag in it and returns
+ std::unique_ptr<RBAResultImpl> result {std::make_unique<RBAResultImpl>(
+ this, std::make_unique<RBAResultSet>(*getBackupResultSet()))};
+ result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE);
+ return std::move(result);
+ } else {
+ setRequestData(contexts, require);
+ return arbitrateMain();
+ }
+}
+
+std::unique_ptr<RBAResult>
+RBAArbitrator::execute(const std::string& sceneName,
+ std::list<std::pair<std::string,std::int32_t>>& properties)
+{
+ const std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ // Check argument
+ if (isValidContext(sceneName) == false) {
+ // In case of error, creates a copy of "Result",
+ // sets the error flag in it and returns
+ std::unique_ptr<RBAResultImpl> result {std::make_unique<RBAResultImpl>(
+ this, std::make_unique<RBAResultSet>(*getBackupResultSet()))};
+ result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE);
+ return std::move(result);
+ } else {
+ static_cast<void>(setRequestData(sceneName, true, &properties,
+ static_cast<std::uint32_t>(getRequestQue().size())));
+ return arbitrateMain();
+ }
+}
+
+std::unique_ptr<RBAResult>
+RBAArbitrator::setResultContentState(const std::string& allocatableName,
+ const std::string& contextName)
+{
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ RBAResultSet* const backupResultSetTmp {getBackupResultSet().get()};
+ if (getReservedResultSet() == nullptr) {
+ setResult(std::make_unique<RBAResultImpl>(this,
+ std::make_unique<RBAResultSet>(),
+ std::move(getBackupResultSet())));
+ } else {
+ RBAResultSet* const reservedResultSetTmp {getReservedResultSet().get()};
+ setResult(std::make_unique<RBAResultImpl>(this,
+ std::move(getReservedResultSet()),
+ std::move(getBackupResultSet())));
+ setReservedResultSet(std::make_unique<RBAResultSet>(*reservedResultSetTmp));
+ }
+ setBackupResultSet(std::make_unique<RBAResultSet>(*backupResultSetTmp));
+
+ // find allocatable
+ const RBAAllocatable* alloc {nullptr};
+ const RBAAreaImpl* const area {model_->findAreaImpl(allocatableName)};
+ if(area != nullptr) {
+ alloc = area;
+ }
+ else {
+ const RBAZoneImpl* const zone {model_->findZoneImpl(allocatableName)};
+ if(zone != nullptr) {
+ alloc = zone;
+ }
+ }
+ // find content state
+ const RBAContentState* state {nullptr};
+ const RBAViewContentStateImpl* const viewState
+ {model_->findViewContentStateImpl(contextName)};
+ if(viewState != nullptr) {
+ state = viewState;
+ }
+ else {
+ const RBASoundContentStateImpl* const soundState
+ {model_->findSoundContentStateImpl(contextName)};
+ if(soundState != nullptr) {
+ state = soundState;
+ }
+ }
+ if( (alloc == nullptr) || (state == nullptr) ) {
+ // Unknown context or allocatable
+ getResult()->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE);
+ return std::move(getResultRef());
+ }
+ // Set alloc and state to result
+ const RBAContentState* const beforeContentState {alloc->getState()};
+ const_cast<RBAAllocatable*>(alloc)->setState(state);
+ const_cast<RBAAllocatable*>(alloc)->setChecked(true);
+ getResult()->setActive(state, true);
+ getResult()->setContentState(alloc, state);
+
+ // ----------------------------------------------------------
+ // Post processing of Arbitration
+ // ----------------------------------------------------------
+ postArbitrate();
+
+ // Excecute offline constraint
+#ifdef RBA_USE_LOG
+ checkAllConstraints();
+#endif
+
+ // ----------------------------------------------------------
+ // Update the state of Content
+ // ----------------------------------------------------------
+ if (beforeContentState != nullptr) {
+ // Update the state of the Content originally assigned to
+ // the requested Allocatable
+ dynamic_cast<RBAContent*>(beforeContentState->getOwner())->updateStatus(getResultRef().get());
+ }
+ // Update the state of requested Content
+ dynamic_cast<RBAContent*>(state->getOwner())->updateStatus(getResultRef().get());
+
+ // Cancel processing of Content
+ checkCancelContent();
+
+ // Update display and non-display Area
+ updateResult();
+
+ // Generate Result
+ createResultData();
+
+ // Store backup of current arbitration result set
+ setBackupResultSet(getResult()->createBackupCurrentResultSet());
+ // Create next arbitration result set
+ setNextResultSet(getResult()->createNextCurrentResultSet());
+
+ return std::move(getResultRef());
+}
+
+std::unique_ptr<RBAResult>
+RBAArbitrator::cancelArbitration()
+{
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ if(getReservedResultSet() == nullptr) {
+ std::unique_ptr<RBAResultImpl> res
+ {std::make_unique<RBAResultImpl>(this,
+ std::make_unique<RBAResultSet>())};
+ res->setStatusType(RBAResultStatusType::CANCEL_ERROR);
+ return std::move(res);
+ }
+
+ setResult(
+ std::make_unique<RBAResultImpl>(this,
+ std::make_unique<RBAResultSet>(),
+ std::move(getReservedResultSet())));
+ setBackupResultSet(getResult()->createBackupCurrentResultSet());
+ setNextResultSet(getResult()->createNextCurrentResultSet());
+
+ return std::move(getResultRef());
+}
+
+void
+RBAArbitrator::clearArbitration()
+{
+ std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ getCancelChecked().clear();
+ setReservedResultSet(nullptr);
+ setBackupResultSet(std::make_unique<RBAResultSet>());
+ for(const auto& scene : model_->getSceneImpls()) {
+ for(const std::string propertyName : scene->getPropertyNames()) {
+ const std::int32_t value {scene->getPropertyValue(propertyName)};
+ getBackupResultSet()->setSceneProperty(scene, propertyName, value);
+ }
+ }
+ setNextResultSet(
+ std::make_unique<RBAResultSet>(*getBackupResultSet().get()));
+ setResult(std::make_unique<RBAResultImpl>(
+ this,
+ std::make_unique<RBAResultSet>(*getBackupResultSet().get())));
+
+ model_->clearElementsStatus();
+}
+
+bool
+RBAArbitrator::setScene(const std::string& sceneName, bool require,
+ std::list<std::pair<std::string, std::int32_t>>& properties)
+{
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ return setRequestData(sceneName, require, &properties);
+}
+
+bool
+RBAArbitrator::setContentState(const std::string& contextName, bool require)
+{
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ const std::deque<std::unique_ptr<RBARequestQueMember>>& requestQue{getRequestQue()};
+ std::uint32_t syncIndex{static_cast<std::uint32_t>(requestQue.size())};
+ if (syncIndex > 0U ) {
+ const std::unique_ptr<RBARequestQueMember>& prevReq{requestQue.back()};
+ if (prevReq->isOn() == require) {
+ syncIndex = prevReq->getSyncIndex();
+ }
+ }
+ return setRequestData(contextName, require, nullptr, syncIndex);
+}
+
+bool
+RBAArbitrator::setAllocatableResult(const std::string& allocatableName,
+ const std::string& contextName)
+{
+ std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ // Get allocatable
+ const auto alloc = model_->findAllocatable(allocatableName);
+ if(alloc == nullptr) {
+ return false;
+ }
+
+ // Get context
+ const auto state = model_->findContentState(contextName);
+ if(state == nullptr) {
+ return false;
+ }
+
+ // Set state to allocatable
+ const auto beforeContentState = alloc->getState();
+ const_cast<RBAAllocatable*>(alloc)->setState(state);
+ RBAResultSet* const nextResultSet {getNextResultSet().get()};
+ RBAResultSet* const prevResultSet {getBackupResultSet().get()};
+ nextResultSet->setContentState(alloc, state);
+ prevResultSet->setContentState(alloc, state);
+ nextResultSet->setActive(state, true);
+ prevResultSet->setActive(state, true);
+
+ // ----------------------------------------------------------
+ // Update the state of Content
+ // ----------------------------------------------------------
+ // Create "result" and update state, because updating the content state
+ // determines the transition destination this time
+ // based on previous state.
+ setResult(std::make_unique<RBAResultImpl>(
+ this,
+ std::make_unique<RBAResultSet>(*getBackupResultSet()),
+ std::make_unique<RBAResultSet>(*getNextResultSet())));
+ RBAContent* const content {dynamic_cast<RBAContent*>(state->getOwner())};
+ content->updateRequestStatus(getResult()->getCurResultSet().get(), true);
+ if (beforeContentState != nullptr) {
+ // Update the state of the content originally assigned to
+ // the requested Allocatable
+ dynamic_cast<RBAContent*>(beforeContentState->getOwner())->updateStatus(getResultRef().get());
+ }
+ // Update the state of requested Content
+ content->updateStatus(getResultRef().get());
+
+ setBackupResultSet(std::make_unique<RBAResultSet>(*getResult()->getPreResultSet()));
+ setNextResultSet(getResult()->createNextCurrentResultSet());
+
+ return true;
+}
+
+bool
+RBAArbitrator::RBAArbitrator::evaluate(RBAExpression* expression)
+{
+ if(expression == nullptr) {
+ return false;
+ }
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ RBAConstraintInfo info;
+ // Constraint expression evaluation
+ return expression->execute(&info, this);
+}
+
+const RBARuleObject*
+RBAArbitrator::evaluateObject(RBAExpression* expression)
+{
+ if(expression == nullptr) {
+ return nullptr;
+ }
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ RBAConstraintInfo info;
+ // Constraint expression evaluation
+ const RBARuleObject* const ruleObj
+ {expression->getReferenceObject(&info, this)};
+ if (ruleObj != nullptr) {
+ return ruleObj->getRawObject();
+ } else {
+ return nullptr;
+ }
+}
+
+int32_t
+RBAArbitrator::evaluateValue(RBAExpression* expression)
+{
+ if(expression == nullptr) {
+ return -99;
+ }
+ const std::lock_guard<std::recursive_mutex> lock{getMutex()};
+ RBAConstraintInfo info;
+ // Constraint expression evaluation
+ return expression->getValue(&info, this);
+}
+
+
+void
+RBAArbitrator::setModel(RBAModelImpl* const newModel)
+{
+ std::lock_guard<std::recursive_mutex> lock {getMutex()};
+ model_ = newModel;
+ model_->createSortedAllocatables();
+ clearArbitration();
+}
+
+bool
+RBAArbitrator::
+satisfiesConstraints() const
+{
+ const std::lock_guard<std::recursive_mutex> lock{mutex_};
+ // Temporarily store the actual result_
+ // because result_ is used for evaluation
+ std::unique_ptr<RBAResultImpl> tmpResult {std::move(result_)};
+ result_ = std::make_unique<RBAResultImpl>(
+ this,
+ std::make_unique<RBAResultSet>(*(reservedResultSet_.get())),
+ std::make_unique<RBAResultSet>(*(resultSetForSatisfiesConstraints_.get())));
+ bool result {true};
+ for(const RBAConstraintImpl*& constraint : model_->getConstraintImpls()) {
+ if (constraint->isRuntime() == true) {
+ result = const_cast<RBAConstraintImpl*>(constraint)->execute(const_cast<RBAArbitrator*>(this));
+ if (result == false) {
+ break;
+ }
+ }
+ }
+ result_ = std::move(tmpResult);
+ return result;
+}
+
+/**
+ * Execute arbitration
+ */
+std::unique_ptr<RBAResult>
+RBAArbitrator::arbitrateMain()
+{
+ // Store request state before arbitration,
+ // in case cancelArbitration() is executed
+ reservedResultSet_ = std::make_unique<RBAResultSet>(*backupResultSet_);
+
+ // Differential arbitration for each request
+ if (requestQue_.empty()) {
+ // Prepare Result here because it will be used in differenceArbitrate.
+ result_ = std::make_unique<RBAResultImpl>(this,
+ std::move(backupResultSet_),
+ std::move(nextResultSet_));
+ // Arbitration request without arguments.
+ // there is a possibility of being queued in "requestQue_"
+ // due to "onDisplayed" in this,
+ differenceArbitrate();
+ }
+ if (!requestQue_.empty()) {
+ result_ = std::make_unique<RBAResultImpl>(this,
+ std::move(backupResultSet_),
+ std::move(nextResultSet_));
+ do {
+ const std::unique_ptr<RBARequestQueMember> request {std::move(requestQue_.front())};
+ requestQue_.pop_front();
+ result_->setActive(request->getContentState(), request->isOn());
+ // Update the state of Content
+ RBAContent* const content {dynamic_cast<RBAContent*>(request->getContentState()->getOwner())};
+ content->updateRequestStatus(result_->getCurResultSet().get(), request->isOn());
+ if (requestQue_.empty()) {
+ differenceArbitrate();
+ if (!requestQue_.empty()) {
+ // Update "result_" for the next differenceArbitrate().
+ result_ = std::make_unique<RBAResultImpl>(this,
+ std::move(backupResultSet_),
+ std::move(nextResultSet_));
+ }
+ } else if (requestQue_.front()->getSyncIndex() != request->getSyncIndex()) {
+ differenceArbitrate();
+ // Update "result_" for the next differenceArbitrate().
+ result_ = std::make_unique<RBAResultImpl>(this,
+ std::move(backupResultSet_),
+ std::move(nextResultSet_));
+ } else {
+ // No Operation
+ }
+ } while (!requestQue_.empty());
+ }
+
+ result_ = std::make_unique<RBAResultImpl>(
+ this, std::make_unique<RBAResultSet>(*reservedResultSet_),
+ result_->createBackupCurrentResultSet());
+
+ // Cancel processing of Content
+ checkCancelContent();
+
+ // Update displayed and non-displayed Area
+ updateResult();
+
+#ifdef RBA_USE_LOG
+ RBALogManager::setType(RBALogManager::TYPE_RESULT);
+ logResultArbitration();
+
+ setLogToResult();
+ RBALogManager::setType(RBALogManager::TYPE_NOTHING);
+#endif
+
+ createResultData();
+ // Store backup of current arbitration result set
+ backupResultSet_ = result_->createBackupCurrentResultSet();
+ // Create next arbitration result set
+ nextResultSet_ = result_->createNextCurrentResultSet();
+
+ // The "result_" of the return value is changed to another name,
+ // because "result_" will be used for storing.
+ auto retResult = std::move(result_);
+
+ // Hold the arbitration result because the arbitration result may be used
+ // in cases other than arbitration.
+ result_ = std::make_unique<RBAResultImpl>(retResult.get());
+
+ // A compile error occurs if std::move() is missing because
+ // std::unique_ptr<RBAResultImpl> is cast to std::unique_ptr<RBAResult>
+ return std::move(retResult);
+}
+
+bool
+RBAArbitrator::
+isValidContext(const std::string& context)
+{
+ if (context != "") {
+ const RBAContentState* const state {model_->findContentState(context)};
+ if (state == nullptr) {
+ const RBASceneImpl* const scene {model_->findSceneImpl(context)};
+ if (scene == nullptr) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool
+RBAArbitrator::
+isValidContext(std::list<std::string>& contexts)
+{
+ for(const std::string contextName : contexts) {
+ if(isValidContext(contextName) == false) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Reflect input information
+ */
+
+bool
+RBAArbitrator::setRequestData(
+ const std::string& context, bool require,
+ std::list<std::pair<std::string, std::int32_t>>* const properties,
+ std::uint32_t syncIndex)
+{
+ bool isSet {false};
+ if (context != "") {
+ // When content state is specified
+ // If contextName is the only content name, pop the first content state
+ const RBAContentState* state {model_->findContentState(context)};
+ if (state != nullptr) {
+ requestQue_.push_back( std::make_unique<RBARequestQueMember>(state, require, syncIndex));
+ isSet = true;
+ } else {
+ // When Scene is specified
+ const RBASceneImpl* const scene {model_->findSceneImpl(context)};
+ if (scene != nullptr) {
+ // for next arbitration
+ nextResultSet_->setActive(scene, require);
+ // For when "Result" is referenced before the next arbitration
+ result_->setActive(scene, require);
+ isSet = true;
+ if (properties != nullptr) {
+ for (auto& p : *properties) {
+ const RBAAbstractProperty* const ap {scene->getProperty(p.first)};
+ if (ap != nullptr) {
+ // for next arbitration
+ nextResultSet_->setSceneProperty(ap, p.second);
+ // For when "Result" is referenced before the next arbitration
+ result_->setSceneProperty(ap, p.second);
+ }
+ }
+ }
+ }
+ }
+ }
+ return isSet;
+}
+
+void
+RBAArbitrator::setRequestData(const RBAContentState* state,
+ bool require)
+{
+ if (requestQue_.empty()){
+ requestQue_.push_back( std::make_unique<RBARequestQueMember>(state, require, 0U));
+ } else {
+ requestQue_.push_back( std::make_unique<RBARequestQueMember>(state, require, requestQue_.back()->getSyncIndex()));
+ }
+}
+
+void
+RBAArbitrator::setRequestData(const RBAContent* const content,
+ bool require)
+{
+ if (requestQue_.empty()){
+ requestQue_.push_back( std::make_unique<RBARequestQueMember>(content->getStates().front(), require, 0U));
+ } else {
+ requestQue_.push_back( std::make_unique<RBARequestQueMember>(content->getStates().front(), require, requestQue_.back()->getSyncIndex()));
+ }
+}
+
+void
+RBAArbitrator::setActive(const RBASceneImpl* const scene, const bool require)
+{
+ if (nextResultSet_ != nullptr) {
+ // Update nextResultSet_" when onScene is done in onRequest or onWithdrawn
+ nextResultSet_->setActive(scene, require);
+ } else {
+ result_->setActive(scene, require);
+ }
+}
+
+void
+RBAArbitrator::setSceneProperty(const RBAAbstractProperty* const prop, const std::int32_t value)
+{
+ if (nextResultSet_ != nullptr) {
+ // Update nextResultSet_" when onScene is done in onRequest or onWithdrawn
+ nextResultSet_->setSceneProperty(prop, value);
+ } else {
+ result_->getCurResultSet()->setSceneProperty(prop, value);
+ }
+}
+
+void
+RBAArbitrator::setRequestData(std::list<std::string>& contexts,
+ const bool require)
+{
+ const std::uint32_t syncIndex {static_cast<std::uint32_t>(requestQue_.size())};
+ for (auto& c : contexts) {
+ static_cast<void>(setRequestData(c, require, nullptr, syncIndex));
+ }
+}
+
+/**
+ * @brief Execute an extended version of arbitration that allows arbitration
+ when the "implication" is false
+ * @param areas
+ */
+void
+RBAArbitrator::
+arbitrate(std::list<RBAAllocatable*>& allocatables)
+{
+ LOG_arbitrateAreaLogLine("----Arbitrate----");
+ std::set<const RBAAllocatable*> revisitedInitSet;
+
+ std::set<const RBAAllocatable*> revisited;
+ for (auto& alloc : allocatables) {
+ revisited = revisitedInitSet;
+ // -------------------------------------------------------------------------
+ // To prevent an infinite loop, generate information to limit registration
+   // of other "allocable" that affected the target "allocatable"
+ // during arbitration
+ // -------------------------------------------------------------------------
+ RBAAffectInfo affectInfo;
+ LOG_arbitrateAreaLogLine(
+ alloc->getSymbol() + "[" + alloc->getElementName() + "] check start");
+ arbitrateAllocatable(alloc, revisited, 0, &affectInfo, nullptr);
+ }
+ for (auto& a : model_->getSortedAllocatables()) {
+ result_->setContentState(a, a->getState());
+ }
+}
+
+/**
+ * @brief Recursively arbitrate "allocatable"
+ * @param allocatable Allocatable that you want to arbitrate
+ * @param revisited Allocatable that re-arbitration is complete
+ * @param nest Re-arbitration nesting hierarchy (first arbitration is zero)
+ * @param affectInfo Allocatable information affected by "allocatable"
+ */
+void RBAArbitrator::arbitrateAllocatable(
+ RBAAllocatable* allocatable,
+ std::set<const RBAAllocatable*>& revisited,
+ const std::int32_t nest,
+ RBAAffectInfo* const affectInfo,
+ RBARollbacker* const parentRollbacker)
+{
+#ifdef RBA_USE_LOG
+ RBALogManager::setIndent(nest);
+#endif
+ // "Allocable" affected by "Allocable" which is the target of this arbitration
+ // during the recursive process until this variable is defined,
+ std::set<const RBAAllocatable*> affectAllocatables;
+ affectAllocatables.insert(allocatable->getAllocatablesAffectedByYou().begin(),
+ allocatable->getAllocatablesAffectedByYou().end());
+
+ const RBAContentState* const beforeState {allocatable->getState()};
+
+ // Mark Content allocation for target Allocable" as "checked"
+ allocatable->setChecked(true);
+ // Get content status sorted by arbitration policy
+ // (only active requests)
+ std::list<const RBAContentState*> contentStates;
+ getSortedContentStates(allocatable, contentStates);
+ for(const RBAContentState* const contentState : contentStates) {
+ // Allocate Content to Area
+ allocatable->setState(contentState);
+#ifdef RBA_USE_LOG
+ {
+ std::string str = " Content[";
+ if (contentState == nullptr) {
+ str += "null";
+ } else {
+ str += contentState->getOwner()->getElementName() + "::"
+ + contentState->getElementName();
+ }
+ str += "] check online constraints start";
+ RBALogManager::arbitrateContentLogLine(str);
+ }
+#endif
+ bool isSkipped {false};
+ const bool isPassed {checkConstraintAndReArbitrate(
+ allocatable, revisited, nest, affectInfo, parentRollbacker,
+ allocatable->getConstraints(), &isSkipped, false)};
+ if (isPassed == true) {
+
+ // ----------------------------------------------------------
+ // Check if self-allocatable should be hidden
+ // by constraint expression after content allocation process.
+ // Check even if content is not assigned because there is contentValue()
+ // ----------------------------------------------------------
+#ifdef RBA_USE_LOG
+ std::string alloSymbol = allocatable->getSymbol();
+ std::string alloName = allocatable->getElementName();
+ if (allocatable->isArea() == true) {
+ LOG_arbitrateAreaLogLine(
+ " check online constraints to confirm area hidden state");
+ } else {
+ LOG_arbitrateAreaLogLine(
+ " check online constraints to confirm zone muted state");
+ }
+#endif
+ // Mark "hidden" of target "Allocable" as "checked"
+ allocatable->setHiddenChecked(true);
+ // Set "hidden" of target "Allocable" to false
+ allocatable->setHidden(false);
+ bool hiddenIsPassed {checkConstraintAndReArbitrate(
+ allocatable, revisited, nest, affectInfo, parentRollbacker,
+ allocatable->getHiddenFalseCheckConstraints(), &isSkipped,
+ !allocatable->isZone())};
+ if (hiddenIsPassed == false) {
+ allocatable->setHidden(true);
+ hiddenIsPassed = checkConstraintAndReArbitrate(
+ allocatable, revisited, nest, affectInfo, parentRollbacker,
+ allocatable->getHiddenTrueCheckConstraints(), &isSkipped,
+ !allocatable->isZone());
+ if (hiddenIsPassed == false) {
+ // Clear hiding state of Allocatable
+ allocatable->setHiddenChecked(false);
+ } else {
+ LOG_arbitrateAreaLogLine(
+ alloSymbol + "[" + alloName + "] change "
+ + allocatable->getHiddenSymbol());
+ }
+ }
+
+ // -------------------------------------
+ // For Zone, judge attenuation after hiding (mute)
+ // -------------------------------------
+ bool attenuateIsPassed {true};
+ if (allocatable->isZone()) {
+ RBAZoneImpl* const zone {dynamic_cast<RBAZoneImpl*>(allocatable)};
+ // Mark "attenuattion" of target "Zone" as checked"
+ zone->setAttenuateChecked(true);
+ // Set "attenuattion" of target "Zone" to false
+ zone->setAttenuated(false);
+ LOG_arbitrateAreaLogLine(
+ " check online constraints to confirm zone attenuated state");
+ attenuateIsPassed = checkConstraintAndReArbitrate(
+ allocatable, revisited, nest, affectInfo, parentRollbacker,
+ allocatable->getAttenuateFalseCheckConstraints(), &isSkipped, true);
+ if (attenuateIsPassed == false) {
+ zone->setAttenuated(true);
+ attenuateIsPassed = checkConstraintAndReArbitrate(
+ allocatable, revisited, nest, affectInfo, parentRollbacker,
+ allocatable->getAttenuateTrueCheckConstraints(), &isSkipped, true);
+ if (attenuateIsPassed == false) {
+ allocatable->setAttenuateChecked(false);
+ } else {
+ LOG_arbitrateAreaLogLine(
+ alloSymbol + "[" + alloName + "] change attenuated");
+ }
+ }
+ }
+#ifdef RBA_USE_LOG
+ {
+ std::string str = alloSymbol + "[" + alloName + "] ";
+ if (allocatable->isArea() == true) {
+ str += "displays";
+ } else {
+ str += "outputs";
+ }
+ str += " Content[";
+ const RBAContentState* state = allocatable->getState();
+ if (state == nullptr) {
+ str += "null";
+ } else {
+ str += state->getOwner()->getElementName() + "::"
+ + state->getElementName();
+ }
+ str += "] " + allocatable->getHiddenSymbol() + "["
+ + RBALogManager::boolToString(allocatable->isHidden()) + "]";
+ if (allocatable->isZone() == true) {
+ str += " attenuated["
+ + RBALogManager::boolToString(allocatable->isAttenuated()) + "]";
+ }
+ str += "\n";
+ LOG_arbitrateAreaLogLine(str);
+ }
+#endif
+ if ((hiddenIsPassed == true) && (attenuateIsPassed == true)) {
+ break;
+ }
+ }
+ }
+ // ---------------------------------------------------------------------
+ // Re-arbitration of the Allocatable that influenced
+ // ---------------------------------------------------------------------
+ if ((beforeState != allocatable->getState())
+ || allocatable->isHidden()
+ || allocatable->isAttenuated()) {
+
+ // Re-arbitration is performed in a state other than "hidden"
+ // When allocating content. Therefore, if state become "hidden" or
+ // "attenuation", re-arbitration is required for the "allocatable"
+ // that was affected by re-arbitration during content allocation.
+ // Update the increased Area that influenced
+ if (allocatable->isHidden() || allocatable->isAttenuated()) {
+ for (const auto& a : allocatable->getAllocatablesAffectedByYou()) {
+ static_cast<void>(affectAllocatables.insert(a));
+ }
+ }
+
+ // If the re-arbitration source of Area/Zone (including any re-arbitration
+ // sources, if any reconciliation nests) becomes an Area/Zone affected by
+ // the re-arbitration area/zone, such Area/Zone is excluded from
+ // the re-arbitration target and the affected Area/Zone is re-arbitrated.
+ // Further, even if the affected Area/Zone is unarbitrated Allocatable
+ // at that time, it is excluded from the re-arbitration target of
+ // the affected Area. This is because it is sufficient to arbitrate
+ // during normal arbitration.
+ for (const auto& a : revisited) {
+ if (affectAllocatables.find(a) != affectAllocatables.end()
+ || (!a->isChecked())) {
+ static_cast<void>(affectAllocatables.erase(a));
+ }
+ }
+ std::list<const RBAAllocatable*> sortedAllocatables(affectAllocatables.begin(),affectAllocatables.end());
+ sortedAllocatables.sort(&RBAAllocatable::compareIndex);
+ if (parentRollbacker != nullptr) {
+ std::shared_ptr<RBARollbacker> rollbacker {std::make_shared<RBARollbacker>()};
+ parentRollbacker->addChild(rollbacker);
+ rollbacker->backup(sortedAllocatables);
+ }
+
+ for (auto& affect : sortedAllocatables) {
+ // Remove Allocatable which will be re-arbitration from Allocatable
+ // that influenced Allocable during arbitration.
+ allocatable->removeAffectAllocatable(affect);
+ }
+ static_cast<void>(revisited.insert(allocatable)); // Add to arbitrated Area
+ for (auto& affectAllocatable : sortedAllocatables) {
+ // @Deviation (EXP55-CPP,Rule-5_2_5,A5-2-3)
+ // [Contents that deviate from the rules]
+ // This is a 'const_cast' expression that strips away a 'const' or
+ // 'volatile' qualifier.
+ // [Why there is no problem if it deviate from the rules]
+   // Confirmed that there is no problem from the design point of view.
+ // We won't fix it now because we need to redesign the class, but
+ // no much effort as of now.
+ RBAAllocatable* allo {const_cast<RBAAllocatable*>(affectAllocatable)};
+
+ // Initialize the check flag of the Allocatable that performs the
+ // re-arbitration of the affetcted Allocatable
+ // If the affected Allocables are cleared in advance, a skip occurred in
+ // the constraint expression evaluation during the re-arbitration of
+ // the affected Allocatable that was carried out earlier, after that
+ // re-arbitration will work during re-arbitration of affected Allocatable.
+ // Therefore, clear check flag individually
+ // before re-arbitration of affected Allocable
+ allo->clearChecked();
+
+ LOG_arbitrateAreaLogLine( " " +
+ affectAllocatable->getSymbol() + "["
+ + affectAllocatable->getElementName()
+ + "] affect allocatable check start");
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Recursively calling arbitrateAllocatable()
+ // [Why there is no problem if it deviate from the rules]
+ // - This process is necessary for re-arbitration of the affected Area,
+ // - stack overflow will not occur becasue the infinite loop
+ // prevention process is imeplemented.
+ arbitrateAllocatable(allo, revisited, nest + 1, affectInfo,
+ parentRollbacker);
+ }
+ for(const RBAAllocatable* const revisitAllocatable : sortedAllocatables) {
+ static_cast<void>(revisited.erase(revisitAllocatable));
+ }
+ }
+
+ // --------------------------------------------------
+ // Delete temporary affect information
+ // to prevent infinite loop during re-arbitration
+ // --------------------------------------------------
+ affectInfo->removeAffectInfo(allocatable);
+#ifdef RBA_USE_LOG
+ RBALogManager::setIndent(nest-1);
+#endif
+}
+
+/**
+ * @brief Sort content state based on arbitration policy
+ * @param allocatable
+ * @param contentStates
+ * @return success/failure of sort
+ */
+bool
+RBAArbitrator::
+sortContentStates(const RBAAllocatable* const allocatable,
+ std::list<const RBAContentState*>& states) const
+{
+ bool isResult {true};
+ switch(allocatable->getAllocatableArbitrationPolicy()) {
+ case RBAArbitrationPolicy::FIRST_COME_FIRST:
+ states.sort(&RBAContentState::compareFirstComeFirst);
+ break;
+ case RBAArbitrationPolicy::LAST_COME_FIRST:
+ states.sort(&RBAContentState::compareLastComeFirst);
+ break;
+ case RBAArbitrationPolicy::PRIORITY_FIRST_COME_FIRST:
+ states.sort(&RBAContentState::comparePriorityFirstComeFirst);
+ break;
+ case RBAArbitrationPolicy::DEFAULT:
+ case RBAArbitrationPolicy::PRIORITY_LAST_COME_FIRST:
+ states.sort(&RBAContentState::comparePriorityLastComeFirst);
+ break;
+ default:
+ isResult = false;
+ break;
+ }
+
+ return isResult;
+}
+
+/**
+ * @brief Get re-arbitration list from judgment NG constraint
+ * @param totalRevisitAllocatables
+ * @param allocatable
+ * @param falseConstraints
+ * @param revisited
+ */
+void
+RBAArbitrator::
+collectRevisitAllocatable(std::list<const RBAAllocatable*>* const totalRevisitAllocatables,
+ RBAAllocatable*& allocatable,
+ std::list<RBAConstraintImpl*>& falseConstraints,
+ std::set<const RBAAllocatable*>& revisited)
+{
+ std::set<const RBAAllocatable*> revisitAllocatablesSet;
+
+  // Determine if re-arbitration should be done based on the constraint
+ // that the determination was NG
+ for(RBAConstraintImpl*& constraint : falseConstraints) {
+ // Get Contraint information
+ const RBAConstraintInfo* const info {constraint->getInfo()};
+ // Allocatable, a candidate for re-arbitration
+ std::set<const RBAAllocatable*> rightFalseAllocatables;
+
+ if (info->needsRearbitrationFor(allocatable)) {
+ info->collectRearbitrationTargetFor(allocatable, rightFalseAllocatables, false);
+ }
+ if (rightFalseAllocatables.empty()) {
+ // Non-implication constraint expression
+ // To ensure that "currently arbitrated allocable" does not lose to lower
+ // priority allocable, arbitration of low priority Allocable is performed
+ // if low priority Allocable is included in
+ // "re-arbitration candidate Allocable".
+ info->collectFalseAllocatables(rightFalseAllocatables);
+ bool isContainsLowPriorityAllocatable {false};
+ for(const RBAAllocatable* const rightFalseAllocatable
+ : rightFalseAllocatables) {
+ if(RBAAllocatable::compareIndex(allocatable,rightFalseAllocatable)) {
+ // index is smaller for higher priority allocable
+ isContainsLowPriorityAllocatable = true;
+ break;
+ }
+ }
+ if(!isContainsLowPriorityAllocatable) {
+ continue;
+ }
+ }
+
+ // Remove Allocable during arbitration from re-arbitration target
+ static_cast<void>(rightFalseAllocatables.erase(allocatable));
+
+ // If even one Allocable candidate for re-arbitration has been
+ // re-arbitrated, re-arbitration will not be performed again.
+ // Go to next content assignment
+ for(const RBAAllocatable* const rightFalseAllocatable : rightFalseAllocatables) {
+ if(revisited.find(rightFalseAllocatable) != revisited.end()) {
+ return;
+ }
+ }
+
+ // Set re-arbitration Allocable
+ for(const RBAAllocatable* const alloc : rightFalseAllocatables) {
+ static_cast<void>(revisitAllocatablesSet.insert(alloc));
+ }
+ }
+
+ // Re-arbitration Allocatable exists
+ if(!(revisitAllocatablesSet.empty())) {
+ // copy std::set to std::list
+ static_cast<void>(totalRevisitAllocatables->insert(totalRevisitAllocatables->end(),
+ revisitAllocatablesSet.begin(),
+ revisitAllocatablesSet.end()));
+ // Sort re-arbitration Areas in ascending order based on priority
+ // It is necessary to sort by index comparison considering the order of models.
+ totalRevisitAllocatables->sort(&RBAAllocatable::compareIndex);
+ }
+}
+
+/**
+ * Confirm cancellation of all content status
+ * to cancel Request which lost in arbitration
+ */
+void
+RBAArbitrator::
+postArbitrate()
+{
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine("----Cancel Request----");
+#endif
+ for(const RBAContentState* const state : model_->getContentStates()) {
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine("Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] check start");
+#endif
+ static_cast<void>(cancelChecked_.insert(state));
+ if(!result_->isActive(state)) {
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is not Active skip");
+#endif
+ continue;
+ }
+ if(result_->isAlreadyOutputting(state)) {
+#ifdef RBA_USE_LOG
+ std::string contTypeName;
+ if(state->isViewContentState()) {
+ contTypeName = "Visible";
+ }
+ else {
+ contTypeName = "Sounding";
+ }
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is "+contTypeName+" skip");
+#endif
+ continue;
+ }
+
+ changeContentStateCancelWithPolicy(state);
+ }
+
+#ifdef RBA_USE_LOG
+ // Log output for coverage of request cancellation
+ for(const RBAContentState* state : model_->getContentStates()) {
+ std::string contentName = state->getOwner()->getElementName();
+ std::string stateName = state->getElementName();
+ std::string canceled = isCancel(state) ? "t" : "f";
+ RBALogManager::coverageCanceledRequestLogLine(
+ contentName + "," + stateName + ',' +canceled);
+ }
+#endif
+}
+
+/**
+ * @brief Change the cancellation information of hidden Content status
+ based on arbitration results and cancellation policy
+ * @param state
+ */
+void
+RBAArbitrator::
+changeContentStateCancelWithPolicy(const RBAContentState* const state)
+{
+ switch(dynamic_cast<RBAContent*>(state->getOwner())->getContentLoserType()) {
+ case RBAContentLoserType::GOOD_LOSER:
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is Canceled because GOOD_LOSER");
+#endif
+ setCancel(state, true);
+ break;
+ case RBAContentLoserType::NEVER_GIVEUP:
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is not Canceled because NEVER_GIVEUP");
+#endif
+ setCancel(state, false);
+ break;
+ case RBAContentLoserType::DO_NOT_GIVEUP_UNTIL_WIN:
+ if(state->isModelElementType(RBAModelElementType::ViewContentState)) {
+ if(result_->isPreVisible(dynamic_cast<const RBAViewContentStateImpl*>(state))) {
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is Canceled because DO_NOT_GIVEUP_UNTIL_WIN");
+#endif
+ setCancel(state, true);
+ } else {
+#ifdef RBA_USE_LOG
+ RBALogManager::cancelRequestLogLine(" Content["+
+ state->getOwner()->getElementName()+"::"+
+ state->getElementName()+
+ "] is not Canceled because DO_NOT_GIVEUP_UNTIL_WIN");
+#endif
+ setCancel(state, false);
+ }
+ }
+ else {
+ if(result_->isPreSounding(dynamic_cast<const RBASoundContentStateImpl*>(state))) {
+ setCancel(state, true);
+ } else {
+ setCancel(state, false);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+#ifdef RBA_USE_LOG
+void
+RBAArbitrator::
+checkAllConstraints()
+{
+ std::string log;
+ LOG_arbitrateConstraintLogLine("----Check All Constraint----");
+
+ if(simulationMode_) {
+ for(const RBAConstraintImpl* constraint : model_->getConstraintImpls()) {
+ bool result = const_cast<RBAConstraintImpl*>(constraint)->execute(this);
+ if(result == false) {
+ result_->addFailedConstraint(constraint);
+ }
+ if (constraint->isRuntime() == true) {
+ log += "online ";
+ } else {
+ log += "offline ";
+ }
+ log += "constraint[" + constraint->getElementName() + "] ";
+ log += "result[" + RBALogManager::boolToString(result) + "]\n";
+ }
+ if (log.empty() != true ) {
+ log.erase(log.end() - 1, log.end()); // Remove last line break
+ }
+ }
+
+}
+#endif
+
+void
+RBAArbitrator::
+checkCancelContent() const
+{
+ for(const RBAViewContentState* const viewState
+ : result_->getActiveViewContentStates()) {
+ if(result_->isCancel(viewState)) {
+ result_->cancelContentState(dynamic_cast<const RBAContentState*>(viewState));
+ }
+ }
+ for(const RBASoundContentState* const soundState
+ : result_->getActiveSoundContentStates()) {
+ if(result_->isCancel(soundState)) {
+ result_->cancelContentState(dynamic_cast<const RBAContentState*>(soundState));
+ }
+ }
+}
+
+/**
+ * @brief Update display and non-dislay Allocatable List
+ */
+void
+RBAArbitrator::
+updateResult()
+{
+ // Deactivate canceled Content
+ result_->updateActiveContentStates();
+
+ // Update coordinates of Area
+ for(auto& area : result_->getVisibleAreas()) {
+ const RBAAreaImpl* const areaImpl {dynamic_cast<const RBAAreaImpl*>(area)};
+ const auto posCont = model_->findPositionContainerImpl(area->getName());
+ const auto sizeObj = result_->getSize(area);
+ if((posCont != nullptr) && (sizeObj != nullptr)) {
+ const auto offset = posCont->getOffset(sizeObj->getName());
+ const_cast<RBAAreaImpl*>(areaImpl)->setOffsetX(offset.first);
+ const_cast<RBAAreaImpl*>(areaImpl)->setOffsetY(offset.second);
+ }
+ }
+
+ // Set output Content state list
+ std::set<const RBAContentState*> outputtingContentStateSet;
+ for(auto& alloc : result_->getOutputtingAllocatables()) {
+ const auto state = result_->getAllocatedContentState(alloc);
+ static_cast<void>(outputtingContentStateSet.insert(state));
+ }
+ for(auto& state : outputtingContentStateSet) {
+ static_cast<void>(result_->addOutputtingContentState(state));
+ }
+
+ for(auto& state : result_->getActiveContentStates()) {
+ // If the Area allocated in the display request is not displayed,
+ // set it to "Stanby Content".
+ const auto allocs = result_->getAllocatable(state);
+ if(allocs.empty()) {
+ result_->addStandbyContent(dynamic_cast<RBAContent*>(state->getOwner()));
+ }
+ }
+}
+
+/**
+ * ### Generate result information
+ *
+ * Generate animation information (RBAViewAction) and register it in the
+ * viewActions list of RBAResult.
+ * The animation information generation pattern is as follows.
+ * | Area A(pre) | Area B(pre) | Area A(cur) | Area B(cur) | type |
+ * |:-: |:-: |:-: |:-: |:---- |
+ * | (none) | - | **content** | - | TRANSITON_ADD |
+ * | **content** | - | (none) | - | TRANSITION_REMOVE |
+ * | **contentA** | - | **contentB** | - | TRANSITION_REPLACE |
+ * | **content** | (none) | (none) | **content** | MOVE |
+ */
+void
+RBAArbitrator::
+createResultData()
+{
+ std::list<std::unique_ptr<RBAViewAction>> actions;
+ // Check the Areas that have not changed
+ std::set<const RBAArea*> stableAreas;
+ for(const RBAArea* const preArea : result_->getPreVisibleAreas()) {
+ if(result_->isVisible(preArea)) {
+ const RBAViewContent* const curContent {result_->getContentState(preArea)->getOwner()};
+ const RBAViewContent* const preContent {result_->getPreContentState(preArea)->getOwner()};
+ if(curContent == preContent) {
+ static_cast<void>(stableAreas.insert(preArea));
+ }
+ }
+ }
+ // Check "MOVE"
+ std::set<const RBAViewContent*> movedContents;
+ for(const RBAArea* curArea : result_->getVisibleAreas()) {
+ // Current display Area
+ const RBAViewContentState* curState {result_->getContentState(curArea)};
+ const RBAViewContent* const curContent {curState->getOwner()};
+ // Skip stable Area
+ if(stableAreas.find(curArea) != stableAreas.end()) {
+ continue;
+ }
+ for(const RBAArea* preArea : result_->getPreVisibleAreas()) {
+ // Do not consider stable areas to have changed
+ if (stableAreas.find(preArea) != stableAreas.end()) {
+ continue;
+ }
+ // Previous display Area
+ const RBAViewContent* const preContent {result_->getPreContentState(preArea)->getOwner()};
+ if(curContent == preContent) {
+ // "MOVE" if there is matching content
+ actions.push_back(std::make_unique<RBAViewMove>(preArea, curArea,
+ curState));
+ // Check moved Content
+ static_cast<void>(movedContents.insert(curState->getOwner()));
+ }
+ }
+ }
+ // Check "REMOVE"
+ for(const RBAArea* preArea : result_->getPreVisibleAreas()) {
+ // Skip stable Area
+ if(stableAreas.find(preArea) != stableAreas.end()) {
+ continue;
+ }
+ const RBAViewContentState* preState {result_->getPreContentState(preArea)};
+ // Skip if Content is "MOVE"
+ if(movedContents.find(preState->getOwner())
+ != movedContents.end()) {
+ continue;
+ }
+ if(!result_->isVisible(preArea)) {
+ // If the previously displayed Area isn't displayed, it is REMOVE.
+ actions.push_back(std::make_unique<RBAViewTransition>(
+ RBAViewActionType::TRANSITION_REMOVE, preArea, preState));
+ }
+ }
+ // Check Examine ADD/REMOVE and REPLACE related to MOVE
+ for(const RBAArea* curArea : result_->getVisibleAreas()) {
+ // Display Area at this time
+ // Skip stable Area
+ if(stableAreas.find(curArea) != stableAreas.end()) {
+ continue;
+ }
+ const RBAViewContentState* curState {result_->getContentState(curArea)};
+ const RBAViewContent* const curContent {curState->getOwner()};
+ const RBAViewContentState* preState {result_->getPreContentState(curArea)};
+
+ if(movedContents.find(curContent) != movedContents.end()) {
+ if((preState != nullptr) && (!result_->isVisible(preState))) {
+ // If the previously displayed content isn't displayed, it is REMOVE.
+ actions.push_back(std::make_unique<RBAViewTransition>(
+ RBAViewActionType::TRANSITION_REMOVE,
+ curArea, preState));
+ }
+ else {
+ continue;
+ }
+ }
+ else if(result_->isPreVisible(curArea)) {
+ // It was the display Area last time
+ // If pre is MOVE content
+ const RBAViewContent* const preContent {preState->getOwner()};
+ if(movedContents.find(preContent) != movedContents.end()) {
+ // Content at this time is ADD
+ actions.push_back(std::make_unique<RBAViewTransition>(
+ RBAViewActionType::TRANSITION_ADD,
+ curArea, curState));
+ }
+ else if(curContent != preContent) {
+ // REPLACE because the content is different
+ actions.push_back(std::make_unique<RBAViewTransition>(
+ RBAViewActionType::TRANSITION_REPLACE,
+ curArea, preState, curState));
+ } else {
+ ;
+ }
+ }
+ else {
+ // ADD because it was not the display Area last time
+ actions.push_back(std::make_unique<RBAViewTransition>(
+ RBAViewActionType::TRANSITION_ADD,
+ curArea, curState));
+ }
+ }
+
+ // Sort and register
+ actions.sort(&compareViewAction);
+ for(auto& action : actions) {
+ result_->addViewAction(action);
+ }
+}
+
+void
+RBAArbitrator::differenceArbitrate()
+{
+#ifdef RBA_USE_LOG
+ // Set request information in log
+ RBALogManager::setType(RBALogManager::TYPE_REQUEST);
+ logRequestArbitration();
+ RBALogManager::setType(RBALogManager::TYPE_PREVIOUS_RESULT);
+ logPreResultArbitration();
+ logRequestForCoverage();
+#endif
+
+ for (auto& a : model_->getSortedAllocatables()) {
+ a->clearStatus();
+ }
+
+ // ----------------------------------------------------------
+ // Arbitration
+ // ----------------------------------------------------------
+ // Priority and post-win arbitoration
+ // (Value arbitration is the same as priority arbitration)
+#ifdef RBA_USE_LOG
+RBALogManager::setType(RBALogManager::TYPE_ARBITRATE);
+#endif
+ arbitrate(model_->getSortedAllocatables());
+
+ // ----------------------------------------------------------
+ // Post processing of arbitration
+ // ----------------------------------------------------------
+#ifdef RBA_USE_LOG
+RBALogManager::setType(RBALogManager::TYPE_CANCEL_REQUEST);
+#endif
+ // when the constraint expression is evaluated by satisfiesConstraints(),
+ // if the cancel state is different from the time when execute() is executed,
+ // the result may be false. Therefore, it is necessary to store
+ // the state before cancellation processing.
+ // When performing the constraint expression evaluation in
+ // satisfiedConstraints(), restore to this value and evaluate.
+ resultSetForSatisfiesConstraints_ = std::make_unique<RBAResultSet>(
+ *result_->getCurResultSet());
+ postArbitrate();
+
+ // Move offline Constraint
+#ifdef RBA_USE_LOG
+RBALogManager::setType(RBALogManager::TYPE_CHECK_ALL_CONSTRAINTS);
+ checkAllConstraints();
+#endif
+
+ // ----------------------------------------------------------
+ // Update Content state
+ // ----------------------------------------------------------
+ for (auto& c : model_->getContents()){
+ const_cast<RBAContent*>(c)->updateStatus(result_.get());
+ }
+
+ backupResultSet_ = result_->createBackupCurrentResultSet();
+ nextResultSet_ = result_->createNextCurrentResultSet();
+
+#ifdef RBA_USE_LOG
+ logResultForCoverage();
+#endif
+}
+
+bool
+RBAArbitrator::
+checkConstraints( std::list<RBAConstraintImpl*>& constraints,
+ std::list<RBAConstraintImpl*>& falseConstraints,
+ const RBAAllocatable* const allocatable)
+{
+ bool containsSkip {false};
+ for (const auto& constraint : constraints) {
+ const bool isPassed {constraint->execute(this)};
+ if (isPassed == false) {
+ falseConstraints.push_back(constraint);
+ }
+ if (constraint->getInfo()->isExceptionBeforeArbitrate()) {
+ if (constraint->getInfo()->needsReRearbitrationFor(allocatable)) {
+ containsSkip = true;
+ }
+ }
+ }
+ return containsSkip;
+}
+
+bool
+RBAArbitrator::
+checkConstraintAndReArbitrate(RBAAllocatable* allocatable,
+ std::set<const RBAAllocatable*>& revisited,
+ const std::int32_t nest,
+ RBAAffectInfo* const affectInfo,
+ RBARollbacker* const parentRollbacker,
+ std::list<RBAConstraintImpl*>& constraints,
+ bool * const isSkipped,
+ const bool isFinal)
+{
+ bool isPassed {false};
+ std::list<RBAConstraintImpl*> falseConstraints;
+ const bool containsSkip {checkConstraints(constraints, falseConstraints, allocatable)};
+ if(falseConstraints.empty()) {
+ *isSkipped = (*isSkipped || containsSkip);
+ if(!containsSkip && !*isSkipped && isFinal) {
+ static_cast<void>(revisited.insert(allocatable));
+ }
+ isPassed = true;
+ } else {
+ std::list<const RBAAllocatable*> revisitAllocatables;
+ collectRevisitAllocatable(&revisitAllocatables, allocatable, falseConstraints, revisited);
+ if(!(revisitAllocatables.empty())) {
+ // There is re-arbitration Allocatable.
+ // Generates backup information for rollback when re-arbitration fails.
+ // For efficiency, instantiate only once when re-arbitration is needed
+ // for the first time.
+ // Since it is backed up after content allocation,
+ // it is necessary to set NULL to the allocated content after rollback.
+
+ // Rollback information when arbitration fails
+ std::shared_ptr<RBARollbacker> rollbacker {std::make_shared<RBARollbacker>()};
+ if (parentRollbacker != nullptr) {
+ parentRollbacker->addChild(rollbacker);
+ }
+ rollbacker->backup(revisitAllocatables);
+ // Initialize all re-arbitration Allocatable
+ for (auto& a : revisitAllocatables) {
+ const_cast<RBAAllocatable*>(a)->clearChecked();
+ }
+ // --------------------------------------------------
+ // Re-arbitrate "Allocatable" that has not been re-arbitrated
+ // in the re-arbitration candidate list
+ // --------------------------------------------------
+ static_cast<void>(revisited.insert(allocatable));
+ for(const RBAAllocatable* const revisitAllocatable : revisitAllocatables) {
+ LOG_arbitrateAreaLogLine( " " +
+ revisitAllocatable->getSymbol() + "["
+ + revisitAllocatable->getElementName()
+ + "] revisit allocatable check start");
+ arbitrateAllocatable(const_cast<RBAAllocatable*>(revisitAllocatable),
+ revisited, nest + 1, affectInfo, rollbacker.get());
+ }
+ for(const RBAAllocatable* const revisitAllocatable : revisitAllocatables) {
+ static_cast<void>(revisited.erase(revisitAllocatable));
+ }
+ // --------------------------------------------------
+ // Check if content allocation succeeded as a result of re-arbitration
+ // --------------------------------------------------
+ falseConstraints.clear();
+ static_cast<void>(checkConstraints(constraints, falseConstraints, allocatable));
+ if (falseConstraints.empty()) {
+ // The content of the allocatable allocation is fixed by re-arbitration,
+ // so exit the loop and proceed to the next allocatable.
+ // In some cases, "Allocatable" is re-arbitrated due to recursion and
+ // allocated Content is lost, but go to the next Allocable because
+ // all contents have been checked
+ isPassed = true;
+ } else {
+ // Roll back arbitration status and affected information
+ rollbacker->rollback();
+ if (parentRollbacker != nullptr) {
+ parentRollbacker->removeChild(rollbacker);
+ }
+ }
+ }
+ }
+ if (isPassed == false) {
+ //Collect Areas that affected the area in arbitration status
+ std::set<const RBAAllocatable*> allocatablesWhichHaveAffectedToThisAllocatable;
+
+ for (const RBAConstraintImpl* const constraint : falseConstraints) {
+ constraint->getInfo()->collectAffectedAllocatables(
+ false, allocatablesWhichHaveAffectedToThisAllocatable, false,
+ false);
+ }
+ static_cast<void>(allocatablesWhichHaveAffectedToThisAllocatable.erase(allocatable));
+
+ // Record fact that affected the area being arbitrated on Area that
+ // affected Area during arbitration.
+ // The re-arbitration of the affected area is recorded in AffectInfo,
+ // so it does not record the re-arbitrated area.
+ for (const RBAAllocatable* const a : allocatablesWhichHaveAffectedToThisAllocatable) {
+ if (!(affectInfo->alreadyKnowsThatFormerHasAffectedToLatter(a,
+ allocatable))) {
+ const_cast<RBAAllocatable*>(a)->addAllocatableWhichHasBeenAffectedByYou(
+ allocatable);
+ affectInfo->addInfoThatFormerAffectedToLatter(a, allocatable);
+ }
+ }
+ }
+ return isPassed;
+}
+
+void
+RBAArbitrator::
+setCancel(const RBAContentState* const state, const bool checked)
+{
+ result_->setCancel(state, checked);
+}
+
+bool
+RBAArbitrator::
+isCancel(const RBAContentState* const state) const
+{
+ if(state->isViewContentState()) {
+ return result_->isCancel(state);
+ }
+ else {
+ return result_->isCancel(state);
+ }
+}
+
+void
+RBAArbitrator::
+getSortedContentStates(const RBAAllocatable* const allocatable,
+ std::list<const RBAContentState*>& contentStates) const
+{
+ for (const RBAContent* const content : allocatable->getInternalContents()) {
+ const RBAContentState* const state {result_->getActiveState(content)};
+ if (state != nullptr) {
+ contentStates.push_back(state);
+#ifdef RBA_USE_LOG
+ } else {
+ RBALogManager::arbitrateContentLogLine(
+ " Content[" + content->getElementName() + "] is not Active skip");
+#endif
+ }
+ }
+ static_cast<void>(sortContentStates(allocatable, contentStates));
+ // Add null at the end, to evaluate constraint expression when unassigned
+ contentStates.push_back(nullptr);
+}
+
+std::int32_t
+RBAArbitrator::
+getViewActionPriority(const RBAViewActionType viewActionType)
+{
+ std::int32_t result{0};
+
+ switch(viewActionType) {
+ case RBAViewActionType::TRANSITION_REMOVE:
+ result = 4;
+ break;
+ case RBAViewActionType::MOVE:
+ result = 3;
+ break;
+ case RBAViewActionType::TRANSITION_ADD:
+ result = 2;
+ break;
+ case RBAViewActionType::TRANSITION_REPLACE:
+ result = 1;
+ break;
+ default:
+ break;
+ }
+
+ return result;
+}
+
+bool
+RBAArbitrator::
+compareViewAction(const std::unique_ptr<RBAViewAction>& lhs,
+ const std::unique_ptr<RBAViewAction>& rhs)
+{
+ const std::int32_t lval {getViewActionPriority(lhs->getViewActionType())};
+ const std::int32_t rval {getViewActionPriority(rhs->getViewActionType())};
+
+ return lval > rval;
+}
+
+RBAResultImpl*
+RBAArbitrator::getResult() const
+{
+ return result_.get();
+}
+
+void RBAArbitrator::setResult(std::unique_ptr<RBAResultImpl> result)
+{
+ result_ = std::move(result);
+}
+
+std::set<const RBAContentState*>& RBAArbitrator::getCancelChecked()
+{
+ return cancelChecked_;
+}
+
+std::unique_ptr<RBAResultImpl>& RBAArbitrator::getResultRef() const
+{
+ return result_;
+}
+
+std::unique_ptr<RBAResultSet>& RBAArbitrator::getNextResultSet()
+{
+ return nextResultSet_;
+}
+
+void RBAArbitrator::setNextResultSet(std::unique_ptr<RBAResultSet> nextResultSet)
+{
+ nextResultSet_ = std::move(nextResultSet);
+}
+
+std::unique_ptr<RBAResultSet>& RBAArbitrator::getBackupResultSet()
+{
+ return backupResultSet_;
+}
+
+void RBAArbitrator::setBackupResultSet(std::unique_ptr<RBAResultSet> backupResultSet)
+{
+ backupResultSet_ = std::move(backupResultSet);
+}
+
+std::unique_ptr<RBAResultSet>& RBAArbitrator::getReservedResultSet()
+{
+ return reservedResultSet_;
+}
+
+void RBAArbitrator::setReservedResultSet(std::unique_ptr<RBAResultSet> reservedResultSet)
+{
+ reservedResultSet_ = std::move(reservedResultSet);
+}
+
+std::recursive_mutex& RBAArbitrator::getMutex() const
+{
+ return mutex_;
+}
+
+#ifdef RBA_USE_LOG
+void RBAArbitrator::setSimulationMode(bool simulationMode)
+{
+ simulationMode_ = simulationMode;
+}
+#endif
+
+std::deque<std::unique_ptr<RBARequestQueMember>>& RBAArbitrator::getRequestQue()
+{
+ return requestQue_;
+}
+
+#ifdef RBA_USE_LOG
+/**
+ * Output request information for log view
+ */
+void
+RBAArbitrator::logRequestArbitration()
+{
+ const std::list<const RBAAllocatable*> allocatables =
+ model_->getAllocatables();
+ RBALogManager::requestLogLine("----Request Information----");
+ RBALogManager::requestLogLine(
+ "Allocatable Count:" + std::to_string(allocatables.size()));
+ for (const RBAAllocatable* allocatable : allocatables) {
+ RBALogManager::requestLogLine(
+ " " + allocatable->getSymbol() + "[" + allocatable->getElementName()
+ + "] policy[" + allocatable->getArbitrationPolicyString()
+ + "] visibility[" + allocatable->getVisibilityString() + "]");
+ }
+
+ const std::list<const RBAContentState*> contentStates = model_
+ ->getContentStates();
+ RBALogManager::requestLogLine(
+ "ContentState Count:" + std::to_string(contentStates.size()));
+ for (const RBAContentState* contentState : contentStates) {
+ std::string active;
+ if (contentState->getModelElementType() == RBAModelElementType::ViewContentState) {
+ active = RBALogManager::boolToString(
+ result_->isActive(
+ dynamic_cast<const RBAViewContentState*>(contentState)));
+ } else {
+ active = RBALogManager::boolToString(
+ result_->isActive(
+ dynamic_cast<const RBASoundContentState*>(contentState)));
+ }
+ RBALogManager::requestLogLine(
+ " " + dynamic_cast<RBAContent*>(contentState->getOwner())->getSymbol() + "["
+ + contentState->getOwner()->getElementName() + "::"
+ + contentState->getElementName() + "] priority["
+ + contentState->getPriorityString() + "] isActive[" + active
+ + "] order[" + contentState->getOrderString() + "]");
+ }
+
+ const std::list<const RBAScene*> scenes = model_->getScenes();
+ RBALogManager::requestLogLine("Scene Count:" + std::to_string(scenes.size()));
+ for (const RBAScene* scene : scenes) {
+ RBALogManager::requestLogLine(
+ " Scene[" + scene->getName() + "] isActive["
+ + RBALogManager::boolToString(result_->isActive(scene))
+ + "]");
+ }
+
+ std::list<RBAConstraint*> constraints = model_->getConstraints();
+ RBALogManager::requestLogLine(
+ "Constraint Count:" + std::to_string(constraints.size()));
+ for (RBAConstraint* constraint : constraints) {
+ RBAConstraintImpl* impl = dynamic_cast<RBAConstraintImpl*>(constraint);
+ RBALogManager::requestLogLine(
+ " Constraint[" + impl->getName() + "] Expression["
+ + impl->getExpression()->getExpressionText() + "] runtime["
+ + RBALogManager::boolToString(impl->isRuntime()) + "]");
+ }
+
+}
+
+/**
+ * Output previous arbitration result for log view
+ */
+void
+RBAArbitrator::logPreResultArbitration()
+{
+ RBALogManager::resultLogLine("----Previous Result Information----");
+
+ auto allocs = model_->getAllocatables();
+ RBALogManager::resultLogLine("Allocatable TotalCount:"
+ + std::to_string(allocs.size()));
+ for (auto& alloc : allocs) {
+ auto contentState = result_->getPreContentState(alloc);
+ auto hidden = result_->isPreHidden(alloc);
+ std::string str = " " + alloc->getSymbol()
+ + "[" + alloc->getElementName() + "] Content[";
+ if (contentState == nullptr) {
+ str += "null";
+ } else {
+ str += contentState->getOwner()->getElementName()
+ + "::" + contentState->getElementName();
+ }
+ str += "] " + alloc->getHiddenSymbol()
+ + "[" + RBALogManager::boolToString(hidden) + "]";
+ if (alloc->isZone() == true) {
+ str += " attenuated[";
+ str += RBALogManager::boolToString(
+ result_->isPreAttenuated(dynamic_cast<const RBAZone*>(alloc)));
+ str += "]";
+ }
+ RBALogManager::resultLogLine(str);
+ if (contentState && !hidden) {
+ RBALogManager::coveragePrevResultLogLine(
+ "A," + alloc->getElementName() + ","
+ + contentState->getOwner()->getElementName() + ","
+ + contentState->getElementName());
+ }
+ }
+
+ auto contents = model_->getContents();
+ RBALogManager::resultLogLine("Content TotalCount:"
+ + std::to_string(contents.size()));
+ for (auto& content : contents) {
+ auto state = result_->getPreActiveState(content);
+ bool isOutputting = false;
+ bool isActive = false;
+ if (state != nullptr) {
+ isActive = true;
+ isOutputting = result_->isPreOutputting(state);
+ }
+ RBALogManager::resultLogLine(
+ " " + content->getSymbol() + "[" + content->getElementName() + "] "
+ + content->getVisibleSymbol() + "["
+ + RBALogManager::boolToString(isOutputting) + "] active["
+ + RBALogManager::boolToString(isActive) + "]");
+ for (auto alloc : content->getAllocatables()) {
+ auto allocatedState = result_->getPreContentState(alloc);
+ if ((allocatedState != nullptr)
+ && (allocatedState->getOwner() == content)) {
+ RBALogManager::resultLogLine(
+ " allocated " + alloc->getSymbol() + "["
+ + alloc->getElementName() + "]");
+ }
+ }
+ }
+}
+
+/**
+ * Output current arbitration result for log view
+ */
+void
+RBAArbitrator::logResultArbitration()
+{
+ RBALogManager::resultLogLine("----Result Information----");
+
+ const std::list<const RBAAllocatable*> allocatables
+ = model_->getAllocatables();
+ RBALogManager::resultLogLine("Allocatable TotalCount:" + std::to_string(allocatables.size()));
+ for(const RBAAllocatable* allocatable : allocatables) {
+ const RBAContentState* contentState = result_->getContentState(allocatable);
+ std::string str = " ";
+ str += allocatable->getSymbol();
+ str += "[";
+ str += allocatable->getElementName();
+ str += "] Content[";
+ if (contentState == nullptr) {
+ str += "null";
+ } else {
+ str += contentState->getOwner()->getElementName() + "::"
+ + contentState->getElementName();
+ }
+ str += "] ";
+ str += allocatable->getHiddenSymbol();
+ str += "[";
+ str += RBALogManager::boolToString(result_->isHidden(allocatable));
+ str += "]";
+ if (allocatable->isZone() == true) {
+ str += " attenuated[";
+ str += RBALogManager::boolToString(result_->isAttenuated(dynamic_cast<const RBAZone*>(allocatable)));
+ str += "]";
+ }
+ RBALogManager::resultLogLine(str);
+ }
+
+ const std::list<const RBAContent*> contents = model_->getContents();
+ RBALogManager::resultLogLine("Content TotalCount:" + std::to_string(contents.size()));
+ for(const RBAContent* content : contents) {
+ bool isOutputting = false;
+ bool isCancel = false;
+ const RBAContentState* state = result_->getActiveState(content);
+ if(state != nullptr) {
+ isOutputting = result_->isOutputting(state);
+ } else {
+ for(const RBAContentState* state : content->getStates()) {
+ isCancel |= result_->isCancel(state);
+ }
+ }
+ RBALogManager::resultLogLine(" "
+ + content->getSymbol()
+ + "["
+ + content->getElementName()
+ + "] "
+ + content->getVisibleSymbol()
+ + "["
+ + RBALogManager::boolToString(isOutputting)
+ + "] cancel["
+ + RBALogManager::boolToString(isCancel)
+ + "]");
+ for(const RBAAllocatable* allocatable : content->getAllocatables()) {
+ const RBAContentState* allocatedState
+ = result_->getContentState(allocatable);
+ if((allocatedState != nullptr) && (allocatedState->getOwner() == content)) {
+ RBALogManager::resultLogLine(" allocated "
+ + allocatable->getSymbol() + "["
+ + allocatable->getElementName() + "]");
+ }
+ }
+ }
+}
+
+/**
+ * For coverage: Output request information
+ */
+void
+RBAArbitrator::logRequestForCoverage()
+{
+ for(const RBAContentState* contentState : model_->getContentStates()) {
+ std::ostringstream oss;
+ oss << "C,";
+ if(result_->isActive(contentState)) {
+ oss << "on,";
+ }
+ else {
+ oss << "off,";
+ }
+ oss << contentState->getOwner()->getElementName() << ",";
+ oss << contentState->getElementName() << ",";
+ oss << contentState->getContentStateOrder();
+ RBALogManager::coverageRequestLogLine(oss.str());
+ }
+ for(const RBAScene* scene : model_->getScenes()) {
+ std::ostringstream oss;
+ oss << "S,";
+ if(result_->isActive(scene)) {
+ oss << "on,";
+ }
+ else {
+ oss << "off,";
+ }
+ oss << scene->getName();
+ for(const auto& name : scene->getPropertyNames()) {
+ std::int32_t value {result_->getSceneProperty(scene, name)};
+ oss << ",";
+ oss << name;
+ oss << ":";
+ oss << value;
+ }
+ RBALogManager::coverageRequestLogLine(oss.str());
+ }
+}
+
+/**
+ * For coverage: Output result information
+ */
+void
+RBAArbitrator::logResultForCoverage()
+{
+ for(const RBAAllocatable* allocatable : model_->getAllocatables()) {
+ std::ostringstream oss;
+ oss << "A,";
+ oss << allocatable->getElementName() + ",";
+ const RBAContentState* contentState = result_->getContentState(allocatable);
+ if((contentState != nullptr) && (!result_->isHidden(allocatable))) {
+ oss << contentState->getOwner()->getElementName();
+ }
+ RBALogManager::coverageResultLogLine(oss.str());
+ }
+}
+
+void
+RBAArbitrator::setLogToResult()
+{
+ std::ostringstream oss;
+ oss << RBALogManager::getAllConstraintLog();
+ oss << RBALogManager::getRequestLog();
+ oss << RBALogManager::getPreviousResultLog();
+ oss << RBALogManager::getArbitrateLog();
+ oss << RBALogManager::getCancelRequestLog();
+ oss << RBALogManager::getCheckAllConstraintLog();
+ oss << RBALogManager::getResultLog();
+ result_->setLog(oss.str());
+}
+#endif
+
+}
diff --git a/src/core/logic/RBABackUpAllocatable.cpp b/src/core/logic/RBABackUpAllocatable.cpp
new file mode 100644
index 0000000..2843db1
--- /dev/null
+++ b/src/core/logic/RBABackUpAllocatable.cpp
@@ -0,0 +1,33 @@
+/**
+ * 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.
+ */
+
+/**
+ * BackUpAllocatable class
+ */
+
+#include "RBABackUpAllocatable.hpp"
+
+namespace rba
+{
+
+RBABackUpAllocatable::RBABackUpAllocatable(const std::string& name)
+ : RBARuleObject{name},
+ RBAAllocatable{name}
+{
+}
+
+}
+
diff --git a/src/core/logic/RBABackUpAllocatable.hpp b/src/core/logic/RBABackUpAllocatable.hpp
new file mode 100644
index 0000000..a57aa01
--- /dev/null
+++ b/src/core/logic/RBABackUpAllocatable.hpp
@@ -0,0 +1,42 @@
+/**
+ * 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.
+ */
+
+/**
+ * BackUpAllocatable class header
+ */
+
+#ifndef RBABACKUPALLOCATABLE_HPP
+#define RBABACKUPALLOCATABLE_HPP
+
+#include "RBAAllocatable.hpp"
+
+namespace rba
+{
+class RBABackUpAllocatable : public RBAAllocatable
+{
+public:
+ explicit RBABackUpAllocatable(const std::string& name);
+ RBABackUpAllocatable(const RBABackUpAllocatable&)=delete;
+ RBABackUpAllocatable(const RBABackUpAllocatable&&)=delete;
+ RBABackUpAllocatable& operator=(const RBABackUpAllocatable&)=delete;
+ RBABackUpAllocatable& operator=(const RBABackUpAllocatable&&)=delete;
+ virtual ~RBABackUpAllocatable()=default;
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBACommonMakerTable.cpp b/src/core/logic/RBACommonMakerTable.cpp
new file mode 100644
index 0000000..dde13b7
--- /dev/null
+++ b/src/core/logic/RBACommonMakerTable.cpp
@@ -0,0 +1,126 @@
+/**
+ * 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.
+ */
+
+/// @file RBACommonMakerTable.cpp
+/// @brief Expression element maker table class definition file
+
+#include "RBACommonMakerTable.hpp"
+#include "RBAActiveStateMaker.hpp"
+#include "RBAAllocatedContentMaker.hpp"
+#include "RBAActiveContentsMaker.hpp"
+#include "RBAAndOperatorMaker.hpp"
+#include "RBAContentValueMaker.hpp"
+#include "RBAExistsOperatorMaker.hpp"
+#include "RBAForAllOperatorMaker.hpp"
+#include "RBAGetAllocatablesMaker.hpp"
+#include "RBAGetContentsListMaker.hpp"
+#include "RBAGetPropertyMaker.hpp"
+#include "RBAHasBeenDisplayedMaker.hpp"
+#include "RBAHasComeEarlierThanMaker.hpp"
+#include "RBAHasComeLaterThanMaker.hpp"
+#include "RBAIfStatementMaker.hpp"
+#include "RBAImpliesOperatorMaker.hpp"
+#include "RBAIntegerValueMaker.hpp"
+#include "RBAIsActiveMaker.hpp"
+#include "RBAIsEqualToOperatorMaker.hpp"
+#include "RBAIsGreaterThanEqualOperatorMaker.hpp"
+#include "RBAIsGreaterThanOperatorMaker.hpp"
+#include "RBAIsLowerThanEqualOperatorMaker.hpp"
+#include "RBAIsLowerThanOperatorMaker.hpp"
+#include "RBAIsOnMaker.hpp"
+#include "RBAIsTypeOfOperatorMaker.hpp"
+#include "RBALambdaExpressionMaker.hpp"
+#include "RBAMaxOperatorMaker.hpp"
+#include "RBAMemberFeatureReferenceMaker.hpp"
+#include "RBAMinOperatorMaker.hpp"
+#include "RBASelectOperatorMaker.hpp"
+#include "RBANotOperatorMaker.hpp"
+#include "RBAObjectCompareMaker.hpp"
+#include "RBAObjectReferenceMaker.hpp"
+#include "RBAOrOperatorMaker.hpp"
+#include "RBAPlusOperatorMaker.hpp"
+#include "RBAPreviousModifierMaker.hpp"
+#include "RBASetOfOperatorMaker.hpp"
+#include "RBASizeOperatorMaker.hpp"
+#include "RBAStateValueMaker.hpp"
+#include "RBAVariableMaker.hpp"
+#include "RBAConstraintMaker.hpp"
+#include "RBASceneMaker.hpp"
+#include "RBAModelElement.hpp"
+
+namespace rba
+{
+
+RBACommonMakerTable::RBACommonMakerTable()
+ : RBAAbstractMakerTable{}
+{
+ addTag("scenes");
+ addTag("constraints");
+ addTag("postconstraints");
+ addTag("rules");
+}
+
+std::list<std::unique_ptr<RBAModelElementMaker>>
+RBACommonMakerTable::getMakers() const
+{
+ std::list<std::unique_ptr<RBAModelElementMaker>> makers;
+ makers.push_back(std::make_unique<RBAActiveStateMaker>());
+ makers.push_back(std::make_unique<RBAAllocatedContentMaker>());
+ makers.push_back(std::make_unique<RBAActiveContentsMaker>());
+ makers.push_back(std::make_unique<RBAAndOperatorMaker>());
+ makers.push_back(std::make_unique<RBAContentValueMaker>());
+ makers.push_back(std::make_unique<RBAExistsOperatorMaker>());
+ makers.push_back(std::make_unique<RBAForAllOperatorMaker>());
+ makers.push_back(std::make_unique<RBAGetAllocatablesMaker>());
+ makers.push_back(std::make_unique<RBAGetContentsListMaker>());
+ makers.push_back(std::make_unique<RBAGetPropertyMaker>());
+ makers.push_back(std::make_unique<RBAHasBeenDisplayedMaker>());
+ makers.push_back(std::make_unique<RBAHasComeEarlierThanMaker>());
+ makers.push_back(std::make_unique<RBAHasComeLaterThanMaker>());
+ makers.push_back(std::make_unique<RBAIfStatementMaker>());
+ makers.push_back(std::make_unique<RBAImpliesOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIntegerValueMaker>());
+ makers.push_back(std::make_unique<RBAIsActiveMaker>());
+ makers.push_back(std::make_unique<RBAIsEqualToOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIsGreaterThanEqualOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIsGreaterThanOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIsLowerThanEqualOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIsLowerThanOperatorMaker>());
+ makers.push_back(std::make_unique<RBAIsOnMaker>());
+ makers.push_back(std::make_unique<RBAIsTypeOfOperatorMaker>());
+ makers.push_back(std::make_unique<RBALambdaExpressionMaker>());
+ makers.push_back(std::make_unique<RBAMaxOperatorMaker>());
+ makers.push_back(std::make_unique<RBAMemberFeatureReferenceMaker>());
+ makers.push_back(std::make_unique<RBAMinOperatorMaker>());
+ makers.push_back(std::make_unique<RBASelectOperatorMaker>());
+ makers.push_back(std::make_unique<RBANotOperatorMaker>());
+ makers.push_back(std::make_unique<RBAObjectCompareMaker>());
+ makers.push_back(std::make_unique<RBAObjectReferenceMaker>());
+ makers.push_back(std::make_unique<RBAOrOperatorMaker>());
+ makers.push_back(std::make_unique<RBAPlusOperatorMaker>());
+ makers.push_back(std::make_unique<RBAPreviousModifierMaker>());
+ makers.push_back(std::make_unique<RBASetOfOperatorMaker>());
+ makers.push_back(std::make_unique<RBASizeOperatorMaker>());
+ makers.push_back(std::make_unique<RBAStateValueMaker>());
+ makers.push_back(std::make_unique<RBAVariableMaker>());
+ makers.push_back(std::make_unique<RBAConstraintMaker>());
+ makers.push_back(std::make_unique<RBASceneMaker>());
+ RBAModelElementMaker::addMaker("SCENE", std::make_unique<RBASceneMaker>());
+
+ return makers;
+}
+
+}
diff --git a/src/core/logic/RBACommonMakerTable.hpp b/src/core/logic/RBACommonMakerTable.hpp
new file mode 100644
index 0000000..ae18dad
--- /dev/null
+++ b/src/core/logic/RBACommonMakerTable.hpp
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+
+/// @file RBACommonMakerTable.hpp
+/// @brief Expression element maker table class header
+
+#ifndef RBACOMMONMAKERTABLE_HPP
+#define RBACOMMONMAKERTABLE_HPP
+
+#include "RBAAbstractMakerTable.hpp"
+
+namespace rba
+{
+
+class DLL_EXPORT RBACommonMakerTable : public RBAAbstractMakerTable
+{
+public:
+ RBACommonMakerTable();
+ RBACommonMakerTable(const RBACommonMakerTable&)=delete;
+ RBACommonMakerTable(const RBACommonMakerTable&&)=delete;
+ RBACommonMakerTable& operator=(const RBACommonMakerTable&)=delete;
+ RBACommonMakerTable& operator=(const RBACommonMakerTable&&)=delete;
+ virtual ~RBACommonMakerTable()=default;
+
+public:
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+ std::list<std::unique_ptr<RBAModelElementMaker>> getMakers() const override;
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAConstraintInfo.cpp b/src/core/logic/RBAConstraintInfo.cpp
new file mode 100644
index 0000000..b208c5f
--- /dev/null
+++ b/src/core/logic/RBAConstraintInfo.cpp
@@ -0,0 +1,695 @@
+/**
+ * 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.
+ */
+
+/// ConstraintInfo class
+
+#include <algorithm>
+#include "RBAAllocatable.hpp"
+#include "RBAConstraintInfo.hpp"
+#include "RBAExpression.hpp"
+#include "RBAModelElementType.hpp"
+
+namespace rba
+{
+
+void RBAConstraintInfo::setExpression(const RBAExpression* const expression)
+{
+ expression_ = expression;
+}
+
+const RBAExpression*
+RBAConstraintInfo::getExpression() const
+{
+ return expression_;
+}
+
+void RBAConstraintInfo::addOperandAllocatable(const RBAAllocatable* const operandAllocatable)
+{
+ static_cast<void>(operandAllocatable_.insert(operandAllocatable));
+}
+
+void RBAConstraintInfo::setResult(const RBAExecuteResult result)
+{
+ result_ = result;
+}
+
+RBAConstraintInfo*
+RBAConstraintInfo::getChild(const std::uint32_t index) const
+{
+ const std::size_t requiredSize {static_cast<std::size_t>(index + 1U)};
+ if (children_.size() < requiredSize) {
+ children_.resize(requiredSize, std::make_unique<RBAConstraintInfo>());
+ }
+ // Use "[]" instead of "at" because it doesn't access out of range
+ return children_[static_cast<std::size_t>(index)].get();
+}
+
+void RBAConstraintInfo::setChild(const std::shared_ptr<RBAConstraintInfo> info)
+{
+ // This function is used in "let" expressions, which generate a new
+ // "ConstraintInfo" on each evaluation.
+ // Therefore, in the case of "add", "children" will be added for each arbitration,
+ // so use "set" to set "children" for each arbitration.
+ children_ = { info };
+}
+
+void RBAConstraintInfo::addTrueAllocatable(const RBAAllocatable* const allocatable)
+{
+ static_cast<void>(trueAllocatables_.insert(allocatable));
+}
+
+void RBAConstraintInfo::addFalseAllocatable(const RBAAllocatable* const allocatable)
+{
+ static_cast<void>(falseAllocatables_.insert(allocatable));
+}
+
+void RBAConstraintInfo::addTrueAllocatableFromOperand()
+{
+ for (const auto& c : children_) {
+ for (const auto& a : c->operandAllocatable_) {
+ static_cast<void>(trueAllocatables_.insert(a));
+ }
+ }
+}
+
+void RBAConstraintInfo::addFalseAllocatableFromOperand()
+{
+ for (const auto& c : children_) {
+ for (const auto& a : c->operandAllocatable_) {
+ static_cast<void>(falseAllocatables_.insert(a));
+ }
+ }
+}
+
+void RBAConstraintInfo::clearFalseAllocatable()
+{
+ falseAllocatables_.clear();
+}
+
+/// TCheck whether to invert True/False
+/// @return
+bool RBAConstraintInfo::isRevert() const
+{
+ if ((expression_ != nullptr)
+ && expression_->isModelElementType(RBAModelElementType::NotOperator)) {
+ return true;
+ }
+ return false;
+}
+
+bool RBAConstraintInfo::isSizeOperator() const
+{
+ if ((expression_ != nullptr)
+ && (expression_->isModelElementType(RBAModelElementType::SizeOperator))) {
+ return true;
+ }
+ return false;
+}
+
+const bool RBAConstraintInfo::isImplies() const
+{
+ if ((expression_ != nullptr)
+ && (expression_->isModelElementType(RBAModelElementType::ImpliesOperator)
+ || expression_->isModelElementType(RBAModelElementType::IfStatement))) {
+ return true;
+ }
+ return false;
+}
+
+void RBAConstraintInfo::clear()
+{
+ for (const std::shared_ptr<RBAConstraintInfo>& child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // recursively calling clear()
+ //  [Reason that there is no problem if the rule is deviated]
+ // ConstraintInfo is created for each node in the Constraint expression
+ // tree. The Constraint expression tree is determined by the constraint
+ // expressions written in the model file, and its depth is finite.
+ // Therefore, stack overflow does not occur and there is no problem
+ child->clear();
+ }
+ result_ = RBAExecuteResult::SKIP;
+ exceptionBeforeArbitrate_ = false;
+ trueAllocatables_.clear();
+ falseAllocatables_.clear();
+ operandAllocatable_.clear();
+}
+
+bool RBAConstraintInfo::isExceptionBeforeArbitrate() const
+{
+ return exceptionBeforeArbitrate_;
+}
+
+void RBAConstraintInfo::setExceptionBeforeArbitrate(
+ const bool exceptionBeforeArbitrate)
+{
+ exceptionBeforeArbitrate_ = exceptionBeforeArbitrate;
+}
+
+bool RBAConstraintInfo::needsReRearbitrationFor(
+ const RBAAllocatable* const allocatable) const
+{
+ bool result {false};
+ if (children_.empty() == false) {
+ switch (expression_->getModelElementType()) {
+ case RBAModelElementType::ImpliesOperator:
+ if (children_.front()->isExceptionBeforeArbitrate()) {
+ result = children_.back()->needsReRearbitrationFor(allocatable);
+ }
+ break;
+ case RBAModelElementType::IfStatement:
+ if (children_.front()->isExceptionBeforeArbitrate()) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::needsReRearbitrationFor=(_,
+ // p={c::rba::RBAAllocatable})' is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ result = children_.back()->needsReRearbitrationFor(allocatable);
+ }
+ break;
+ default:
+ for (const auto& child : children_) {
+ result = (result || child->needsReRearbitrationFor(allocatable));
+ }
+ result =
+ (result || (trueAllocatables_.find(allocatable) != trueAllocatables_.end())
+ || (falseAllocatables_.find(allocatable) != falseAllocatables_.end()));
+ break;
+ }
+ }
+ return result;
+}
+
+bool RBAConstraintInfo::needsRearbitrationFor(const RBAAllocatable* const allocatable,
+ bool isImplies) const
+{
+ bool result {false}; // 再調停要否
+ if (children_.empty() == false) {
+ // When the syntax of the constraint expression is
+ // - ImpliesOperator
+ // - IfStatement
+ // - other than the above
+ switch (expression_->getModelElementType()) {
+ case RBAModelElementType::ImpliesOperator:
+ // If the left side of the implication is true and
+ // the left side contains an Allocatable during arbitration,
+ // re-arbitration is required.
+ //
+ // If the left side of the implication is true and
+ // the left side contains an allocatable state reference expression,
+ // re-arbitration is NOT required.
+ if (children_.front()->isTrue()) {
+ if (children_.front()->contains(allocatable)) {
+ result = true;
+ } else {
+ if (children_.front()->contains(nullptr)) {
+ isImplies = true;
+ }
+ result = (result || children_.back()->needsRearbitrationFor(allocatable,
+ isImplies));
+ }
+ }
+ break;
+ case RBAModelElementType::IfStatement:
+ // If the IF condition includes Allocatble in arbitration,
+ // re-arbitration is required.
+ // If the IF condition includes an Allocatable state reference
+ // expression, re-arbitration is NOT required.
+ // If the IF condition does not include an allocatable state reference
+ // expression, search the child syntax.
+ if (children_.front()->contains(allocatable)) {
+ result = true;
+ } else {
+ if (children_.front()->contains(nullptr)) {
+ isImplies = true;
+ }
+ result = (result || children_.back()->needsRearbitrationFor(allocatable,
+ isImplies));
+ }
+ break;
+ default:
+ for (const auto& child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::needsRearbitrationFor=(_,
+ // p={c::rba::RBAAllocatable},_o)' is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ result = (result || child->needsRearbitrationFor(allocatable, isImplies));
+ }
+ // The Constraint expression does not include IF or implication,
+ // or
+ // the Allocatable state reference expression is not included in the
+ // left side of the IF condition of the parent syntax or
+ // the implication of the parent syntax,
+ // or
+ // "Allocable" during arbitration is included in the left side of
+ // the IF condition of the parent syntax or the implication of the
+ // parent syntax,
+ //
+ // re-arbitration is required.
+ if (!isImplies && contains(allocatable)) {
+ result = true;
+ }
+ break;
+ }
+ }
+ return result;
+}
+
+/// @brief Collect "Allocatable" whose right side is false.
+/// @details
+/// - Do not collect if an exception has occurred
+/// - When expression_ is nullptr or When expression_ is implication
+/// - If the left side is satisfied and there is a condition on the left
+/// side that is affected by the allocatable state, collect the
+/// allocatable that caused the right side to be false.
+/// - If the left side is satisfied and there is NO condition affected by
+/// the allocatable state on the left side, this function is called on
+/// the right side. (To correspond to implication or IF nest)
+/// - When expression_ is IF
+/// - If there is a condition on the left side that is affected by the
+/// "Allocatable" state, collect the "Allocatable that caused the
+/// right side to be false.
+/// - If there is no condition affected by the allocatable state on the left
+/// side, call this function for the right side.
+/// (To correspond to the implication or nest of IF)
+/// - When expression_ is negative
+/// - Call this function with "isNot" inverted for the left side.
+/// (To deal with implications or IFs present in children.)
+/// - When expression_ is above
+/// - Call this function for the child ConstraintInfo.
+/// (To deal with implications or IFs present in children.)
+/// @param[in] allocatable "Allcatable" during arbitration
+/// @param[out] targets "Allocatable" for re-arbitration
+/// @param[in] isNot Inversion state of right and wrong by negation operator.
+void RBAConstraintInfo::collectRearbitrationTargetFor(
+ const RBAAllocatable* const allocatable, std::set<const RBAAllocatable*>& targets,
+ const bool isNot) const
+{
+ if (isExceptionBeforeArbitrate()) {
+ return;
+ }
+ if (children_.empty() == false) {
+ switch (expression_->getModelElementType()) {
+ case RBAModelElementType::ImpliesOperator:
+ if (children_.front()->isTrue()) {
+ if (isNot) {
+ children_.back()->collectTrueAllocatables(targets);
+ } else {
+ children_.back()->collectFalseAllocatables(targets);
+ }
+ } else if (!children_.front()->isFalse()) {
+ children_.back()->collectRearbitrationTargetFor(allocatable, targets,
+ isNot);
+ } else {
+ }
+ break;
+ case RBAModelElementType::IfStatement:
+ if (isNot) {
+ children_.back()->collectTrueAllocatables(targets);
+ } else {
+ children_.back()->collectFalseAllocatables(targets);
+ }
+ break;
+ case RBAModelElementType::NotOperator:
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::collectRearbitrationTargetFor=(_,p={c::rba::RBAAllocatable},
+ // &{c::std::set<p={c::rba::RBAAllocatable},{c::std::less<p={c::rba::RBAAllocatable}>},
+ // {c::std::allocator<p={c::rba::RBAAllocatable}>}>},_o)' is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ children_.front()->collectRearbitrationTargetFor(allocatable, targets,
+ !isNot);
+ break;
+ default:
+ for (const auto& child : children_) {
+ child->collectRearbitrationTargetFor(allocatable, targets, isNot);
+ }
+ break;
+ }
+ }
+}
+
+void RBAConstraintInfo::collectTrueAllocatables(
+ std::set<const RBAAllocatable*>& allocatables) const
+{
+ if (isExceptionBeforeArbitrate() || isFalse()) {
+ return;
+ }
+ if (isRevert()) {
+ for (const auto& child : children_) {
+ child->collectFalseAllocatables(allocatables);
+ }
+ allocatables.insert(falseAllocatables_.begin(), falseAllocatables_.end());
+ } else if (isImplies()) {
+ children_.back()->collectTrueAllocatables(allocatables);
+ } else if (isSizeOperator()) {
+ // Since the size operator evaluates the number of sets,
+ // the Allocatable that combines FalseAllocatable and TrueAllocatable
+ // becomes TrueAllocatables.
+ children_.back()->collectTrueAllocatables(allocatables);
+ children_.back()->collectFalseAllocatables(allocatables);
+ } else {
+ for (const auto& child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::collectTrueAllocatables=(_,
+ // &{c::std::set<p={c::rba::RBAAllocatable},
+ // {c::std::less<p={c::rba::RBAAllocatable}>},
+ // {c::std::allocator<p={c::rba::RBAAllocatable}>}>})' is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ child->collectTrueAllocatables(allocatables);
+ }
+ allocatables.insert(trueAllocatables_.begin(), trueAllocatables_.end());
+ }
+ return;
+}
+
+void RBAConstraintInfo::collectFalseAllocatables(
+ std::set<const RBAAllocatable*>& allocatables) const
+{
+ if (isExceptionBeforeArbitrate() || isTrue()) {
+ return;
+ }
+ if (isRevert()) {
+ for (const auto& child : children_) {
+ child->collectTrueAllocatables(allocatables);
+ }
+ allocatables.insert(trueAllocatables_.begin(), trueAllocatables_.end());
+ } else if (isImplies()) {
+ children_.back()->collectFalseAllocatables(allocatables);
+ } else if (isSizeOperator()) {
+ // The size operator evaluates the number of sets, so "Allocatable",
+ // which is a combination of "FalseAllocatable" and "TrueAllocatable",
+ // becomes "FalseAllocatables".
+ children_.back()->collectTrueAllocatables(allocatables);
+ children_.back()->collectFalseAllocatables(allocatables);
+ } else {
+ for (const auto& child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::collectFalseAllocatables=(_,
+ // &{c::std::set<p={c::rba::RBAAllocatable},
+ // {c::std::less<p={c::rba::RBAAllocatable}>},
+ // {c::std::allocator<p={c::rba::RBAAllocatable}>}>})'
+ // is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ child->collectFalseAllocatables(allocatables);
+ }
+ allocatables.insert(falseAllocatables_.begin(), falseAllocatables_.end());
+ }
+ return;
+}
+
+bool RBAConstraintInfo::contains(const RBAAllocatable* const allocatable) const
+{
+ if (allocatable != nullptr) {
+ if (trueAllocatables_.find(allocatable) != trueAllocatables_.end()) {
+ return true;
+ }
+ if (falseAllocatables_.find(allocatable) != falseAllocatables_.end()) {
+ return true;
+ }
+ } else {
+ if (!trueAllocatables_.empty() || !falseAllocatables_.empty()) {
+ return true;
+ }
+ }
+ for (const auto& child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::contains=(_,
+ // p={c::rba::RBAAllocatable})'
+ // is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ if (child->contains(allocatable)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool RBAConstraintInfo::isTrue() const
+{
+ return (result_ == RBAExecuteResult::TRUE);
+}
+
+bool RBAConstraintInfo::isFalse() const
+{
+ return (result_ == RBAExecuteResult::FALSE);
+}
+
+void RBAConstraintInfo::collectAffectedAllocatables(
+ const bool isRevert, std::set<const RBAAllocatable*>& affectAllocatables,
+ const bool collecting,
+ const bool forObject)
+{
+ // Collect the allocatable that caused the constraint expression to be False.
+ // It is implemented by recursively calling ConstraintInfo of the tree
+ // structure created at the time of "Constraint" expression evaluation.
+ // with this function.
+ // Collect True because the success or failure of ConstraintInfo below
+ // "negative" is reversed.
+ switch (getExpression()->getModelElementType()) {
+ case RBAModelElementType::NotOperator:
+ // ConstraintInfo below negative negates success or failure,
+ // so invert isRevert and call child Info.
+ children_[0U]->collectAffectedAllocatables(!isRevert, affectAllocatables,
+ collecting, forObject);
+ break;
+ case RBAModelElementType::SizeOperator:
+ // Since the size operator evaluates the number of sets,
+ // "Allocatable" which is a combination of "FalseAllocatable" and
+ // "TrueAllocatable" becomes "affectAllocatables".
+ children_[0U]->collectAffectedAllocatables(false, affectAllocatables,
+ true, true);
+ break;
+ case RBAModelElementType::OrOperator:
+ case RBAModelElementType::ExistsOperator:
+ // the same processing is performed, because "Exists {A,B}{x|x.isXXX}"
+ // is equivalent to "A.isXXX OR B.isXXX"
+ if (!isRevert) {
+ // Processing when "Info" of "OR" in which evaluation result that is not
+ // qualified by an odd number of negative is "Skip" or evaluation reslt
+ // that is not qualified by an odd number of negative is "False".
+ if (!isTrue()) {
+ // Collect the Allocatable of child Info whose
+ // whose evaluation result is False.
+ // When "A.isXXX OR B.isXXX", if the evaluation result of A is True,
+ // the evaluation result of OR will be True even if the evaluation
+ // result of B is False. Therefore, A affects B.
+ // Conversely, B also affects A.
+ // Therefore, set "collecting" to True and
+ // search "child Info" for allocatable.
+ for (auto& i : children_) {
+ i->collectAffectedAllocatables(isRevert, affectAllocatables, true,
+ forObject); // Collct when "OR"
+ }
+ }
+ } else {
+ // Processing when "Info" of "OR" in which evaluation result that is not
+ // qualified by an odd number of negative is "Skip" or evaluation reslt
+ // that is not qualified by an odd number of negative is "False".
+ // "!(A.isXXX OR B.isXXX)" can be decomposed into
+ // "!A.isXXX AND !B.isXXX", so if "NOT", perform the same processing
+ // as "AND".
+ if (!isFalse()) {
+ for (auto& i : children_) {
+ i->collectAffectedAllocatables(isRevert, affectAllocatables,
+ collecting, forObject);
+ }
+ }
+ }
+ break;
+ case RBAModelElementType::AndOperator:
+ case RBAModelElementType::ForAllOperator:
+ //"For-All {A,B}{x|x.isXXX}" is equivalent to "A.isXXX AND B.isXXX",
+ // so the same processing is performed
+ if (isRevert) {
+ // Processing when "Info" of "AND" in which evaluation result that
+ // is not qualified by an odd number of "negative" is "Skip" or
+ // evaluation reslt that is not qualified by an odd number of negative
+ // is "True".
+ //
+ // "!(A.isXXX AND B.isXXX)" can be decomposed into
+ // "!A.isXXX OR !B.isXXX", so if "NOT", perform the same processing
+ // as "OR".
+ if (!isFalse()) {
+ for (auto& i : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAConstraintInfo::collectAffectedAllocatables(_,_o,&{c::std::set<p={c::rba::RBAAllocatable},
+ // {c::std::less<p={c::rba::RBAAllocatable}>},{c::std::allocator<p={c::rba::RBAAllocatable}>}>},_o)' is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ i->collectAffectedAllocatables(isRevert, affectAllocatables, true,
+ forObject);
+ }
+ }
+ } else {
+ // Processing when "Info" of "AND" in which evaluation result that
+ // is not qualified by an odd number of "negative" is "Skip" or
+ // evaluation reslt that is not qualified by an odd number of negative
+ // is "True".
+ //
+ // When "A.isXXX AND B.isXXX", the evaluation result of "AND" does not
+ // become True unless the evaluation result of B becomes True,
+ // regardless of the evaluation result of A. Therefore, A does not
+ // affect B, and B does not affect A.
+ // Therefore, "collecting" is as it is, and the "child Info" is
+ // searched for an allocable influence.
+ if (!isTrue()) {
+ for (auto& i : children_) {
+ i->collectAffectedAllocatables(isRevert, affectAllocatables,
+ collecting, forObject);
+ }
+ }
+ }
+ break;
+ case RBAModelElementType::MaxOperator:
+ case RBAModelElementType::MinOperator:
+ {
+ // When the <set> expression is "IF(A.isDisplayed) THEN {B,C} ELSE {D,E}",
+ // scan the left side to extract A as the area of influence
+ children_[0U]->collectAffectedAllocatables(false, affectAllocatables,
+ collecting,forObject);
+ // All the operands that are "x" in the lambda expression affect
+ // each other, so it is necessary to extract them as the affected Area.
+ for (std::uint8_t i { 1U }; i < children_.size(); ++i) {
+ children_[i]->collectAffectedAllocatables(isRevert, affectAllocatables,
+ true, true);
+ }
+ break;
+ }
+ // "A -> B" is the same as "!A OR B".
+ case RBAModelElementType::ImpliesOperator:
+ if (!isRevert) {
+ if (!isTrue()) {
+ // "A.isXXX -> B.isXXX" can be decomposed into "!A.isXXX OR B.isXXX",
+ // so the same process as OR is performed
+ // For the above reason, the acquisition target on the left side
+ // inverts isRevert.
+ children_[0U]->collectAffectedAllocatables(!isRevert,
+ affectAllocatables, true,
+ forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ }
+ } else {
+ if (!isFalse()) {
+ // "!(A.isXXX -> B.isXXX)" can be decomposed into "A.isXXX OR !B.isXXX"
+ // For the above reason, the acquisition target on the left side
+ // inverts isRevert.
+ children_[0U]->collectAffectedAllocatables(!isRevert,
+ affectAllocatables,
+ collecting, forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables,
+ collecting, forObject);
+ }
+ }
+ break;
+ case RBAModelElementType::IfStatement:
+ // "IF(A) THEN B ELSE C" is the same as "!A OR B" if A is True,
+ // and the same as "A OR C" if A is False
+ if (children_[0U]->isTrue()) {
+ if (!isRevert) {
+ if (!isTrue()) {
+ // "IF(A.isXXX) THEN B.isXXX ELSE C.isXXX" can be decomposed into
+ // "(!A.isXXX OR B.isXXX)" when A is True.
+ // For the above reason, the acquisition target on the left side
+ // inverts isRevert.
+ children_[0U]->collectAffectedAllocatables(!isRevert,
+ affectAllocatables, true,
+ forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ }
+ } else {
+ if (!isFalse()) {
+ // "!(IF(A.isXXX) THEN B.isXXX ELSE C.isXXX)" can be decomposed into
+ // "(!A.isXXX OR !B.isXXX)" when A is True.
+ // For the above reason, the acquisition target on the left side
+ // inverts isRevert.
+ children_[0U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ }
+ }
+ } else {
+ if (!isRevert) {
+ if (!isTrue()) {
+ // "IF(A.isXXX) THEN B.isXXX ELSE C.isXXX" can be decomposed into
+ // "(A.isXXX OR C.isXXX)" when A is False.
+ children_[0U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ }
+ } else {
+ if (!isFalse()) {
+ // "!(IF(A.isXXX) THEN B.isXXX ELSE C.isXXX)" can be decomposed into
+ // "(A.isXXX OR !C.isXXX)" when A is False.
+ children_[0U]->collectAffectedAllocatables(!isRevert,
+ affectAllocatables, true,
+ forObject);
+ children_[1U]->collectAffectedAllocatables(isRevert,
+ affectAllocatables, true,
+ forObject);
+ }
+ }
+ }
+ break;
+ default: // Collect Allocatable
+ if (collecting) {
+ if (isRevert) {
+ affectAllocatables.insert(trueAllocatables_.begin(),
+ trueAllocatables_.end());
+ } else {
+ affectAllocatables.insert(falseAllocatables_.begin(),
+ falseAllocatables_.end());
+ }
+ if (forObject) {
+ for (const auto& a : operandAllocatable_) {
+ affectAllocatables.insert(a);
+ }
+ }
+ }
+ for (auto& i : children_) {
+ i->collectAffectedAllocatables(isRevert, affectAllocatables, collecting,
+ forObject);
+ }
+ break;
+ }
+ return;
+}
+
+}
+
diff --git a/src/core/logic/RBAConstraintInfo.hpp b/src/core/logic/RBAConstraintInfo.hpp
new file mode 100644
index 0000000..8ab88dd
--- /dev/null
+++ b/src/core/logic/RBAConstraintInfo.hpp
@@ -0,0 +1,119 @@
+/**
+ * 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.
+ */
+
+/// ConstraintInfo (Constraint expression Information) class header
+
+#ifndef RBACONSTRAINTINFO_HPP
+#define RBACONSTRAINTINFO_HPP
+
+#include <cstdint>
+#include <memory>
+#include <set>
+#include <vector>
+#include "RBAExecuteResult.hpp"
+#include "RBADllExport.hpp"
+
+namespace rba {
+
+class RBAAllocatable;
+class RBAExpression;
+
+class DLL_EXPORT RBAConstraintInfo
+{
+public:
+ RBAConstraintInfo()=default;
+ RBAConstraintInfo(const RBAConstraintInfo&)=delete;
+ RBAConstraintInfo(const RBAConstraintInfo&&)=delete;
+ RBAConstraintInfo& operator=(const RBAConstraintInfo&)=delete;
+ RBAConstraintInfo& operator=(const RBAConstraintInfo&&)=delete;
+ virtual ~RBAConstraintInfo()=default;
+
+public:
+ void setExpression(const RBAExpression* const expression);
+ const RBAExpression* getExpression() const;
+ void addOperandAllocatable(const RBAAllocatable* const operandAllocatable);
+ void setResult(const RBAExecuteResult result);
+ RBAConstraintInfo* getChild(const std::uint32_t index) const;
+ void setChild(const std::shared_ptr<RBAConstraintInfo> info);
+ void addTrueAllocatable(const RBAAllocatable* const allocatable);
+ void addFalseAllocatable(const RBAAllocatable* const allocatable);
+ void addTrueAllocatableFromOperand();
+ void addFalseAllocatableFromOperand();
+ void clearFalseAllocatable();
+ const bool isImplies() const;
+ void clear();
+
+ bool isExceptionBeforeArbitrate() const;
+ void setExceptionBeforeArbitrate(const bool exceptionBeforeArbitrate);
+
+ /// @brief Determine the need for re-arbitration
+ /// @param [in] allocatable Allcatable druing arbitration
+ /// @param [in] isImplies Whether the constraint expression contains
+ /// implication syntax.
+ /// @return Necessity of re-arbitration (true: need / false: No need)
+ bool needsRearbitrationFor(const RBAAllocatable* const allocatable,
+ bool isImplies = false) const;
+
+ bool needsReRearbitrationFor(const RBAAllocatable* const allocatable) const;
+ void collectRearbitrationTargetFor(const RBAAllocatable* const allocatable,
+ std::set<const RBAAllocatable*>& targets,
+ const bool isNot) const;
+ void collectTrueAllocatables(std::set<const RBAAllocatable*>& allocatables) const;
+ void collectFalseAllocatables(std::set<const RBAAllocatable*>& allocatables) const;
+ bool contains(const RBAAllocatable* const allocatable) const;
+ bool isTrue() const;
+ bool isFalse() const;
+
+ /// @brief Extraction of affected Area/Zone
+ /// @param [in] isRevert Negative context (true: inside / false: outside)
+ /// @param [out] affectAllocatables List of affected Allcatable
+ /// @param [out] collecting Collection target context
+ /// (true: inside / false: outside)
+ /// @param [out] forObject ReferenceObject context
+ /// (true: inside / false: outside)
+ /// @return Necessity of re-arbitration (true: need / false: No need)
+ void collectAffectedAllocatables(
+ const bool isRevert, std::set<const RBAAllocatable*>& affectAllocatables,
+ const bool collecting,
+ const bool forObject);
+
+private:
+ bool isRevert() const;
+ bool isSizeOperator() const;
+
+private:
+ bool exceptionBeforeArbitrate_ {false};
+ const RBAExpression* expression_ {nullptr};
+ RBAExecuteResult result_ {RBAExecuteResult::SKIP};
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+ std::set<const RBAAllocatable*> trueAllocatables_;
+ std::set<const RBAAllocatable*> falseAllocatables_;
+ std::set<const RBAAllocatable*> operandAllocatable_;
+ // use to respond with an empty set
+ const std::set<const RBAAllocatable*> emptyAllocatables_;
+ mutable std::vector<std::shared_ptr<RBAConstraintInfo>> children_;
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAConstraintMap.hpp b/src/core/logic/RBAConstraintMap.hpp
new file mode 100644
index 0000000..6f37694
--- /dev/null
+++ b/src/core/logic/RBAConstraintMap.hpp
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+/**
+ * RBAConstraintMap.hpp
+ */
+
+#ifndef RBACONSTRAINTMAP_HPP
+#define RBACONSTRAINTMAP_HPP
+
+namespace rba
+{
+
+enum class RBAConstraintMap : std::uint8_t
+{
+ CONTENT_ALLOCATE_CONSTRAINTS,
+ HIDDEN_TRUE_CHECK_CONSTRAINTS,
+ HIDDEN_FALSE_CHECK_CONSTRAINTS,
+ ATTENUATE_TRUE_CHECK_CONSTRAINTS,
+ ATTENUATE_FALSE_CHECK_CONSTRAINTS,
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAContentStatus.cpp b/src/core/logic/RBAContentStatus.cpp
new file mode 100644
index 0000000..04ed6d9
--- /dev/null
+++ b/src/core/logic/RBAContentStatus.cpp
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+//
+// ContentStatus (Content state transition management) class
+//
+
+#include "RBAContentState.hpp"
+#include "RBAContentStatus.hpp"
+#include "RBAContentStatusType.hpp"
+
+namespace rba
+{
+
+void RBAContentStatus::onRequest()
+{
+ if ((status_ != RBAContentStatusType::Displayed)
+ && (status_ != RBAContentStatusType::StandBy)) {
+ status_ = RBAContentStatusType::Undisplayed;
+ }
+}
+void RBAContentStatus::setStatusType(
+ const RBAContentStatusType type)
+{
+ status_ = type;
+}
+RBAContentStatusType RBAContentStatus::getStatusType() const
+{
+ return status_;
+}
+bool RBAContentStatus::isActive() const
+{
+ return ((status_ != RBAContentStatusType::NoRequest)
+ && (status_ != RBAContentStatusType::Canceled));
+}
+
+bool RBAContentStatus::isUndisplayed() const
+{
+ return (status_ == RBAContentStatusType::Undisplayed);
+}
+
+bool RBAContentStatus::isDisplayed() const
+{
+ return (status_ == RBAContentStatusType::Displayed);
+}
+bool RBAContentStatus::isStandby() const
+{
+ return (status_ == RBAContentStatusType::StandBy);
+}
+bool RBAContentStatus::hasBeenCanceled() const
+{
+ return (status_ == RBAContentStatusType::Canceled);
+}
+bool RBAContentStatus::hasBeenDisplayed() const
+{
+ return ((status_ == RBAContentStatusType::Displayed)
+ || (status_ == RBAContentStatusType::StandBy));
+}
+} /* namespace rba */
diff --git a/src/core/logic/RBAContentStatus.hpp b/src/core/logic/RBAContentStatus.hpp
new file mode 100644
index 0000000..69f7e8d
--- /dev/null
+++ b/src/core/logic/RBAContentStatus.hpp
@@ -0,0 +1,58 @@
+/**
+ * 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.
+ */
+
+//
+// ContentStatus (Content state transition management) class
+//
+
+#ifndef RBACONTENTSTATUS_HPP
+#define RBACONTENTSTATUS_HPP
+#include <cstdint>
+
+#include "RBAContentStatusType.hpp"
+
+namespace rba
+{
+class RBAContentState;
+
+class RBAContentStatus
+{
+ public:
+ RBAContentStatus()=default;
+ // Copy constructor is defined in default because it is used in another class
+ RBAContentStatus(const RBAContentStatus&)=default;
+ RBAContentStatus(const RBAContentStatus&&)=delete;
+ // Copy assignment operator is defined in default
+ // because it is used in other classes
+ RBAContentStatus& operator=(const RBAContentStatus&)=default;
+ RBAContentStatus& operator=(const RBAContentStatus&&)=delete;
+ virtual ~RBAContentStatus()=default;
+ void onRequest();
+ void setStatusType(const RBAContentStatusType type);
+ RBAContentStatusType getStatusType() const;
+ bool isActive() const;
+ bool isUndisplayed() const;
+ bool isDisplayed() const;
+ bool isStandby() const;
+ bool hasBeenCanceled() const;
+ bool hasBeenDisplayed() const;
+ private:
+ RBAContentStatusType status_ {RBAContentStatusType::NoRequest};
+};
+
+} /* namespace rba */
+
+#endif /* RBACONTENTSTATUS_HPP */
diff --git a/src/core/logic/RBARequest.cpp b/src/core/logic/RBARequest.cpp
new file mode 100644
index 0000000..c55cac1
--- /dev/null
+++ b/src/core/logic/RBARequest.cpp
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBARequest (request arbitration) class implementation
+ */
+
+#include "RBARequest.hpp"
+
+namespace rba
+{
+
+RBARequest::RBARequest(const std::string& context, const bool isOn) :
+ context_{context},
+ isOn_{isOn}
+{
+}
+
+std::string
+RBARequest::getContext() const
+{
+ return context_;
+}
+
+bool
+RBARequest::isOn() const
+{
+ return isOn_;
+}
+
+}
diff --git a/src/core/logic/RBARequest.hpp b/src/core/logic/RBARequest.hpp
new file mode 100644
index 0000000..b6da5e4
--- /dev/null
+++ b/src/core/logic/RBARequest.hpp
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBARequest (request arbitration) class header
+ */
+
+#ifndef RBAREQUEST_HPP
+#define RBAREQUEST_HPP
+
+#include <string>
+#include "RBADllExport.hpp"
+
+namespace rba
+{
+
+class DLL_EXPORT RBARequest
+{
+ public:
+ explicit RBARequest(const std::string& context, const bool isOn = true);
+ RBARequest(const RBARequest&)=delete;
+ RBARequest(const RBARequest&&)=delete;
+ RBARequest& operator=(const RBARequest&)=delete;
+ RBARequest& operator=(const RBARequest&&)=delete;
+ virtual ~RBARequest()=default;
+
+ public:
+ std::string getContext() const;
+ bool isOn() const;
+
+ private:
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+ std::string context_;
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+ bool isOn_;
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBARequestQueMember.cpp b/src/core/logic/RBARequestQueMember.cpp
new file mode 100644
index 0000000..a5a0d35
--- /dev/null
+++ b/src/core/logic/RBARequestQueMember.cpp
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBARequestQueueMember class implementation
+ */
+
+#include <cstdint>
+
+#include "RBARequestQueMember.hpp"
+#include "RBAContentState.hpp"
+
+namespace rba {
+
+RBARequestQueMember::RBARequestQueMember(const RBAContentState* const contentState, const bool isOn,
+ const std::uint32_t syncIndex):
+ contentState_{contentState},
+ isOn_{isOn},
+ syncIndex_{syncIndex}
+{
+}
+
+const RBAContentState* RBARequestQueMember::getContentState() const {
+ return contentState_;
+}
+
+bool RBARequestQueMember::isOn() const {
+ return isOn_;
+}
+
+std::uint32_t RBARequestQueMember::getSyncIndex() const {
+ return syncIndex_;
+}
+
+}
diff --git a/src/core/logic/RBARequestQueMember.hpp b/src/core/logic/RBARequestQueMember.hpp
new file mode 100644
index 0000000..cb18987
--- /dev/null
+++ b/src/core/logic/RBARequestQueMember.hpp
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBARequestQueueMember class header
+ */
+
+#ifndef RBAREQUESTQUEMEMBER_HPP
+#define RBAREQUESTQUEMEMBER_HPP
+
+#include <cstdint>
+
+namespace rba {
+
+class RBAContentState;
+
+class RBARequestQueMember {
+ public:
+ RBARequestQueMember(const RBAContentState* const contentState, const bool isOn, const std::uint32_t syncIndex);
+ RBARequestQueMember()=delete;
+ RBARequestQueMember(const RBARequestQueMember&)=delete;
+ RBARequestQueMember(const RBARequestQueMember&&)=delete;
+ RBARequestQueMember& operator=(const RBARequestQueMember&)=delete;
+ RBARequestQueMember& operator=(const RBARequestQueMember&&)=delete;
+ virtual ~RBARequestQueMember() = default;
+
+ const RBAContentState* getContentState() const;
+ bool isOn() const;
+ std::uint32_t getSyncIndex() const;
+
+ private:
+ // Content state for which arbitration was requested
+ const RBAContentState* contentState_;
+ // Whether display/output request or scene ON request
+ bool isOn_;
+
+ /// Index of arbitration syntax
+ /// QueMenber with the same value will be arbitrated at the same timing,
+ /// and if the values are different, differential arbitration is performed.
+ /// When a request for execute(list,bool) is received, the content icluded
+ /// in the list will all have the same value.
+ /// When setContentState(ContentState, bool) request is received twice,
+ /// the first request and the second request have different values.
+ /// When created by onRequest or onWithdrawn,
+ /// it has the same value as the request that triggered it.
+ std::uint32_t syncIndex_;
+};
+
+}
+
+#endif /* RBAREQUESTQUEMEMBER_HPP */
diff --git a/src/core/logic/RBAResultImpl.cpp b/src/core/logic/RBAResultImpl.cpp
new file mode 100644
index 0000000..41c291f
--- /dev/null
+++ b/src/core/logic/RBAResultImpl.cpp
@@ -0,0 +1,1088 @@
+/**
+ * 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.
+ */
+
+/**
+ * RBAResultImpl (result of arbitration implementation) class
+ */
+
+#include "RBAResultImpl.hpp"
+
+#include "RBAContentStatusType.hpp"
+#include "RBAArbitrator.hpp"
+#include "RBAViewContentImpl.hpp"
+#include "RBAViewContentStateImpl.hpp"
+#include "RBASoundContentImpl.hpp"
+#include "RBASoundContentStateImpl.hpp"
+#include "RBAResultSet.hpp"
+#include "RBAAllocatable.hpp"
+#include "RBAContentState.hpp"
+#include "RBAContent.hpp"
+#include "RBAAreaImpl.hpp"
+#include "RBAZoneImpl.hpp"
+#include "RBASceneImpl.hpp"
+#include "RBASizeImpl.hpp"
+#include "RBAConstraint.hpp"
+#include "RBAModelElementType.hpp"
+#include "RBAViewActionType.hpp"
+#include "RBAViewTransition.hpp"
+#include "RBAViewMove.hpp"
+
+namespace rba {
+
+RBAResultImpl::RBAResultImpl(const RBAArbitrator* const arb,
+ std::unique_ptr<RBAResultSet> newPrevResultSet):
+ RBAResult(),
+ preResultSet_{std::move(newPrevResultSet)},
+ arb_{arb},
+ statusType_{RBAResultStatusType::SUCCESS}
+{
+ curResultSet_ = std::make_unique<RBAResultSet>();
+ curResultSet_->copyActives(preResultSet_);
+ curResultSet_->copyProperties(preResultSet_);
+}
+
+RBAResultImpl::RBAResultImpl(const RBAArbitrator* const arb,
+ std::unique_ptr<RBAResultSet> newPrevResultSet,
+ std::unique_ptr<RBAResultSet> newCurResultSet):
+ RBAResult(),
+ curResultSet_{std::move(newCurResultSet)},
+ preResultSet_{std::move(newPrevResultSet)},
+ arb_{arb},
+ statusType_{RBAResultStatusType::SUCCESS}
+{
+}
+
+RBAResultImpl::RBAResultImpl(const RBAResultImpl* const replicationTarget)
+ : RBAResult{},
+ curResultSet_{std::make_unique<RBAResultSet>(*(replicationTarget->curResultSet_.get()))},
+ preResultSet_{std::make_unique<RBAResultSet>(*(replicationTarget->preResultSet_.get()))},
+ arb_{replicationTarget->arb_},
+ statusType_{RBAResultStatusType::SUCCESS},
+ log_{replicationTarget->log_}
+{
+ for (const auto &va : replicationTarget->viewActions_) {
+ if (va->getViewActionType() == RBAViewActionType::MOVE) {
+ viewActions_.push_back(
+ std::make_unique<RBAViewMove>(va->getFromArea(), va->getToArea(),
+ va->getContentState()));
+ } else if (va->getViewActionType()
+ == RBAViewActionType::TRANSITION_REPLACE) {
+ viewActions_.push_back(
+ std::make_unique<RBAViewTransition>(va->getViewActionType(),
+ va->getArea(),
+ va->getFromContentState(),
+ va->getToContentState()));
+ } else {
+ viewActions_.push_back(
+ std::make_unique<RBAViewTransition>(va->getViewActionType(),
+ va->getArea(),
+ va->getContentState()));
+ }
+ }
+}
+
+//
+// External
+//
+
+// [get VisibleArea/SoundingZone]
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getVisibleAreas() const
+{
+ return curResultSet_->getVisibleAreas();
+}
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getPreVisibleAreas() const
+{
+ return preResultSet_->getVisibleAreas();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getSoundingZones() const
+{
+ return curResultSet_->getSoundingZones();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getPreSoundingZones() const
+{
+ return preResultSet_->getSoundingZones();
+}
+
+// [get Visible/Sounding ContentStates]
+
+const std::list<const RBAViewContentState*>&
+RBAResultImpl::getVisibleContentStates() const
+{
+ return curResultSet_->getVisibleContentStates();
+}
+
+const std::list<const RBAViewContentState*>&
+RBAResultImpl::getPreVisibleContentStates() const
+{
+ return preResultSet_->getVisibleContentStates();
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultImpl::getSoundingContentStates() const
+{
+ return curResultSet_->getSoundingContentStates();
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultImpl::getPreSoundingContentStates() const
+{
+ return preResultSet_->getSoundingContentStates();
+}
+
+// [get Active View/Sound ContentStates]
+
+const std::list<const RBAViewContentState*>&
+RBAResultImpl::getActiveViewContentStates() const
+{
+ return curResultSet_->getActiveViewContentStates();
+}
+
+const std::list<const RBAViewContentState*>&
+RBAResultImpl::getPreActiveViewContentStates() const
+{
+ return preResultSet_->getActiveViewContentStates();
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultImpl::getActiveSoundContentStates() const
+{
+ return curResultSet_->getActiveSoundContentStates();
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultImpl::getPreActiveSoundContentStates() const
+{
+ return preResultSet_->getActiveSoundContentStates();
+}
+
+// [get etActive Scenes]
+
+const std::list<const RBAScene*>&
+RBAResultImpl::getActiveScenes() const
+{
+ return curResultSet_->getActiveScenes();
+}
+
+const std::list<const RBAScene*>&
+RBAResultImpl::getPreActiveScenes() const
+{
+ return preResultSet_->getActiveScenes();
+}
+
+// [get InvisibleAreas/UnsoundingZone]
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getInvisibleAreas() const
+{
+ return curResultSet_->getInvisibleAreas();
+}
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getPreInvisibleAreas() const
+{
+ return preResultSet_->getInvisibleAreas();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getUnsoundingZones() const
+{
+ return curResultSet_->getUnsoundingZones();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getPreUnsoundingZones() const
+{
+ return preResultSet_->getUnsoundingZones();
+}
+
+// [get HiddenAreas/MuteZones]
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getHiddenAreas() const
+{
+ return curResultSet_->getHiddenAreas();
+}
+
+const std::list<const RBAArea*>&
+RBAResultImpl::getPreHiddenAreas() const
+{
+ return preResultSet_->getHiddenAreas();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getMuteZones() const
+{
+ return curResultSet_->getMuteZones();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getPreMuteZones() const
+{
+ return preResultSet_->getMuteZones();
+}
+
+// [get Attenuated]
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getAttenuatedZones() const
+{
+ return curResultSet_->getAttenuatedZones();
+}
+
+const std::list<const RBAZone*>&
+RBAResultImpl::getPreAttenuatedZones() const
+{
+ return preResultSet_->getAttenuatedZones();
+}
+
+// [get Canceled Contents]
+
+const std::list<const RBAViewContent*>&
+RBAResultImpl::getCanceledViewContents() const
+{
+ return curResultSet_->getCanceledViewContents();
+}
+
+const std::list<const RBAViewContent*>&
+RBAResultImpl::getPreCanceledViewContents() const
+{
+ return preResultSet_->getCanceledViewContents();
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultImpl::getCanceledSoundContents() const
+{
+ return curResultSet_->getCanceledSoundContents();
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultImpl::getPreCanceledSoundContents() const
+{
+ return preResultSet_->getCanceledSoundContents();
+}
+
+// [get Standby Contents]
+
+const std::list<const RBAViewContent*>&
+RBAResultImpl::getStandbyViewContents() const
+{
+ return curResultSet_->getStandbyViewContents();
+}
+
+const std::list<const RBAViewContent*>&
+RBAResultImpl::getPreStandbyViewContents() const
+{
+ return preResultSet_->getStandbyViewContents();
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultImpl::getStandbySoundContents() const
+{
+ return curResultSet_->getStandbySoundContents();
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultImpl::getPreStandbySoundContents() const
+{
+ return preResultSet_->getStandbySoundContents();
+}
+
+// [get ContentStates]
+
+const RBAViewContentState*
+RBAResultImpl::getContentState(const RBAArea* area) const
+{
+ return dynamic_cast<const RBAViewContentState*>(
+ curResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(area)));
+}
+
+const RBAViewContentState*
+RBAResultImpl::getPreContentState(const RBAArea* area) const
+{
+ return dynamic_cast<const RBAViewContentState*>(
+ preResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(area)));
+}
+
+const RBASoundContentState*
+RBAResultImpl::getContentState(const RBAZone* zone) const
+{
+ return dynamic_cast<const RBASoundContentState*>(
+ curResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(zone)));
+}
+
+const RBASoundContentState*
+RBAResultImpl::getPreContentState(const RBAZone* zone) const
+{
+ return dynamic_cast<const RBASoundContentState*>(
+ preResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(zone)));
+}
+
+// [get Areas/Zones by ConentState]
+
+const std::list<const RBAArea*>
+RBAResultImpl::getArea(const RBAViewContentState* state) const
+{
+ std::list<const RBAArea*> areaList;
+ curResultSet_->getArea(state, areaList);
+ return areaList;
+}
+
+const std::list<const RBAArea*>
+RBAResultImpl::getPreArea(const RBAViewContentState* state) const
+{
+ std::list<const RBAArea*> areaList;
+ preResultSet_->getArea(state, areaList);
+ return areaList;
+}
+
+const std::list<const RBAZone*>
+RBAResultImpl::getZone(const RBASoundContentState* state) const
+{
+ std::list<const RBAZone*> zoneList;
+ curResultSet_->getZone(state, zoneList);
+ return zoneList;
+}
+
+const std::list<const RBAZone*>
+RBAResultImpl::getPreZone(const RBASoundContentState* state) const
+{
+ std::list<const RBAZone*> zoneList;
+ preResultSet_->getZone(state, zoneList);
+ return zoneList;
+}
+
+// [get Areas/Zones by Content]
+
+const std::list<const RBAArea*>
+RBAResultImpl::getArea(const RBAViewContent* content) const
+{
+ std::list<const RBAArea*> areaList;
+ curResultSet_->getArea(content, areaList);
+ return areaList;
+}
+
+const std::list<const RBAArea*>
+RBAResultImpl::getPreArea(const RBAViewContent* content) const
+{
+ std::list<const RBAArea*> areaList;
+ preResultSet_->getArea(content, areaList);
+ return areaList;
+}
+
+const std::list<const RBAZone*>
+RBAResultImpl::getZone(const RBASoundContent* content) const
+{
+ std::list<const RBAZone*> zoneList;
+ curResultSet_->getZone(content, zoneList);
+ return zoneList;
+}
+
+const std::list<const RBAZone*>
+RBAResultImpl::getPreZone(const RBASoundContent* content) const
+{
+ std::list<const RBAZone*> zoneList;
+ preResultSet_->getZone(content, zoneList);
+ return zoneList;
+}
+
+// [get Size]
+
+const RBASize*
+RBAResultImpl::getSize(const RBAArea* area) const
+{
+ return curResultSet_->getSize(area);
+}
+
+const RBASize*
+RBAResultImpl::getPreSize(const RBAArea* area) const
+{
+ return preResultSet_->getSize(area);
+}
+
+// [check Active Scene]
+bool
+RBAResultImpl::isActive(const RBAScene* scene) const
+{
+ return curResultSet_->isActive(scene);
+}
+
+bool
+RBAResultImpl::isPreActive(const RBAScene* scene) const
+{
+ return preResultSet_->isActive(scene);
+}
+
+// [check Active Content]
+bool
+RBAResultImpl::isActive(const RBAContent* const content) const
+{
+ return curResultSet_->isActive(content);
+}
+bool
+RBAResultImpl::isActive(const RBAViewContent* content) const
+{
+ return curResultSet_->isActive(dynamic_cast<const RBAContent*>(content));
+}
+
+bool
+RBAResultImpl::isActive(const RBASoundContent* content) const
+{
+ return curResultSet_->isActive(dynamic_cast<const RBAContent*>(content));
+}
+bool
+RBAResultImpl::isPreActive(const RBAContent* const content) const
+{
+ return preResultSet_->isActive(content);
+}
+bool
+RBAResultImpl::isPreActive(const RBAViewContent* content) const
+{
+ return preResultSet_->isActive(dynamic_cast<const RBAContent*>(content));
+}
+
+bool
+RBAResultImpl::isPreActive(const RBASoundContent* content) const
+{
+ return preResultSet_->isActive(dynamic_cast<const RBAContent*>(content));
+}
+
+// [check Active ContentState]
+bool
+RBAResultImpl::isActive(const RBAContentState* const state) const
+{
+ return curResultSet_->isActive(state);
+}
+
+bool
+RBAResultImpl::isActive(const RBAViewContentState* const state) const
+{
+ return isActive(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isActive(const RBASoundContentState* const state) const
+{
+ return isActive(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreActive(const RBAContentState* const state) const
+{
+ return preResultSet_->isActive(state);
+}
+
+bool
+RBAResultImpl::isPreActive(const RBAViewContentState* const state) const
+{
+ return isPreActive(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreActive(const RBASoundContentState* const state) const
+{
+ return isPreActive(dynamic_cast<const RBAContentState*>(state));
+}
+
+const RBAContentState*
+RBAResultImpl::getActiveState(const RBAContent* const content) const
+{
+ if (curResultSet_->isActive(content)){
+ return curResultSet_->getReqestState(content);
+ }
+ return nullptr;
+}
+
+const RBAContentState*
+RBAResultImpl::getPreActiveState(const RBAContent* const content) const
+{
+ if (preResultSet_->isActive(content)){
+ return preResultSet_->getReqestState(content);
+ }
+ return nullptr;
+}
+
+// [check Visible/Sounding Alloc ContentState]
+
+bool
+RBAResultImpl::isOutputting(const RBAAllocatable* const alloc) const
+{
+ return curResultSet_->isOutputting(alloc);
+}
+
+bool
+RBAResultImpl::isPreOutputting(const RBAAllocatable* const alloc) const
+{
+ return preResultSet_->isOutputting(alloc);
+}
+
+bool
+RBAResultImpl::isOutputting(const RBAContentState* const state) const
+{
+ return curResultSet_->isOutputting(state);
+}
+
+bool
+RBAResultImpl::isPreOutputting(const RBAContentState* const state) const
+{
+ return preResultSet_->isOutputting(state);
+}
+
+bool
+RBAResultImpl::isVisible(const RBAViewContentState* state) const
+{
+ return isOutputting(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreVisible(const RBAViewContentState* state) const
+{
+ return isPreOutputting(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isSounding(const RBASoundContentState* state) const
+{
+ return isOutputting(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreSounding(const RBASoundContentState* state) const
+{
+ return isPreOutputting(dynamic_cast<const RBAContentState*>(state));
+}
+
+// [get View/Sound ContentState]
+
+const RBAContentState*
+RBAResultImpl::getAllocatedContentState(const RBAAllocatable* const allocatable) const
+{
+ return curResultSet_->getContentState(allocatable);
+}
+
+const RBAContentState*
+RBAResultImpl::getPreAllocatedContentState(const RBAAllocatable* const allocatable) const
+{
+ return preResultSet_->getContentState(allocatable);
+}
+
+const RBAViewContentState*
+RBAResultImpl::getViewContentState(const RBAArea* area) const
+{
+ return dynamic_cast<const RBAViewContentState*>(
+ curResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(area)));
+}
+
+const RBAViewContentState*
+RBAResultImpl::getPreViewContentState(const RBAArea* area) const
+{
+ return dynamic_cast<const RBAViewContentState*>(
+ preResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(area)));
+}
+
+const RBASoundContentState*
+RBAResultImpl::getSoundContentState(const RBAZone* zone) const
+{
+ return dynamic_cast<const RBASoundContentState*>(
+ curResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(zone)));
+}
+
+const RBASoundContentState*
+RBAResultImpl::getPreSoundContentState(const RBAZone* zone) const
+{
+ return dynamic_cast<const RBASoundContentState*>(
+ preResultSet_->getContentState(dynamic_cast<const RBAAllocatable*>(zone)));
+}
+
+// [check Hidden/Mute]
+
+bool
+RBAResultImpl::isHidden(const RBAArea* area) const
+{
+ return isHidden(dynamic_cast<const RBAAllocatable*>(area));
+}
+
+bool
+RBAResultImpl::isPreHidden(const RBAArea* area) const
+{
+ return isPreHidden(dynamic_cast<const RBAAllocatable*>(area));
+}
+
+bool
+RBAResultImpl::isMute(const RBAZone* zone) const
+{
+ return isHidden(dynamic_cast<const RBAAllocatable*>(zone));
+}
+
+bool
+RBAResultImpl::isPreMute(const RBAZone* zone) const
+{
+ return isPreHidden(dynamic_cast<const RBAAllocatable*>(zone));
+}
+
+// [check Attenuated]
+bool
+RBAResultImpl::isAttenuated(const RBAZone* zone) const
+{
+ return curResultSet_->isAttenuated(zone);
+}
+
+bool
+RBAResultImpl::isPreAttenuated(const RBAZone* zone) const
+{
+ return preResultSet_->isAttenuated(zone);
+}
+
+// [common]
+
+const std::list<const RBAViewAction*>&
+RBAResultImpl::getViewActions() const
+{
+ viewActionsForPublicUse_.clear();
+ for (auto& va :viewActions_) {
+ viewActionsForPublicUse_.push_back(va.get());
+ }
+ return viewActionsForPublicUse_;
+}
+
+RBAResultStatusType
+RBAResultImpl::getStatusType() const
+{
+ return statusType_;
+}
+
+bool
+RBAResultImpl::isLater(const RBAContent* const target,
+ const RBAContent* const comparisonTarget) const
+{
+ return curResultSet_->isLater(target, comparisonTarget);
+}
+
+std::string
+RBAResultImpl::getLog() const
+{
+ return log_;
+}
+
+void
+RBAResultImpl::setLog(const std::string& log)
+{
+ log_ = log;
+}
+
+bool
+RBAResultImpl::hasDisplayingArea(const RBADisplay* display) const
+{
+ if (display == nullptr) {
+ return false;
+ } else {
+ return curResultSet_->hasDisplayingArea(display);
+ }
+}
+
+bool
+RBAResultImpl::satisfiesConstraints() const
+{
+ if(statusType_ != RBAResultStatusType::SUCCESS) {
+ return false;
+ }
+ return arb_->satisfiesConstraints();
+}
+
+void
+RBAResultImpl::setSceneProperty(const RBASceneImpl* const scene,
+ const std::string& propertyName,
+ const std::int32_t value)
+{
+ curResultSet_->setSceneProperty(scene->getProperty(propertyName), value);
+}
+
+void
+RBAResultImpl::setSceneProperty(const RBAAbstractProperty* const property,
+ const std::int32_t value)
+{
+ curResultSet_->setSceneProperty(property, value);
+}
+
+std::int32_t
+RBAResultImpl::getSceneProperty(const RBAScene* scene,
+ const std::string& propertyName) const
+{
+ if(scene == nullptr) {
+ return -99;
+ }
+
+ const RBAAbstractProperty* const prop
+ {dynamic_cast<const RBASceneImpl*>(scene)->getProperty(propertyName)};
+ if(prop == nullptr) {
+ return -99;
+ }
+
+ return curResultSet_->getSceneProperty(prop);
+}
+
+std::int32_t
+RBAResultImpl::getSceneProperty(const RBAAbstractProperty* const property) const
+{
+ return curResultSet_->getSceneProperty(property);
+}
+
+std::int32_t
+RBAResultImpl::getPreSceneProperty(const RBAAbstractProperty* const property) const
+{
+ return preResultSet_->getSceneProperty(property);
+}
+
+//
+// Internal
+//
+
+// Impl [VisibleArea/SoundingZone]
+
+const std::set<const RBAAllocatable*>&
+RBAResultImpl::getOutputtingAllocatables() const
+{
+ return curResultSet_->getOutputtingAllocatables();
+}
+
+// Impl [get Active View/Sound ContentStates]
+
+const std::set<const RBAContentState*>&
+RBAResultImpl::getActiveContentStates() const
+{
+ return curResultSet_->getActiveContentStates();
+}
+
+// Impl [get ContentStates]
+const RBAContentState*
+RBAResultImpl::getContentState(const RBAAllocatable* const allocatable) const
+{
+ return curResultSet_->getContentState(allocatable);
+}
+
+const RBAContentState*
+RBAResultImpl::getDirectContentState(const RBAAllocatable* const allocatable) const
+{
+ return curResultSet_->getDirectContentState(allocatable);
+}
+
+const RBAContentState*
+RBAResultImpl::getPreContentState(const RBAAllocatable* const allocatable) const
+{
+ return preResultSet_->getContentState(allocatable);
+}
+
+const RBAContentState*
+RBAResultImpl::getDirectPreContentState(const RBAAllocatable* const allocatable) const
+{
+ return preResultSet_->getDirectContentState(allocatable);
+}
+
+// Impl [get Areas/Zones by ConentState]
+
+std::list<const RBAAllocatable*>
+RBAResultImpl::getAllocatable(const RBAContentState* const state) const
+{
+ std::list<const RBAAllocatable*> allocatables;
+ if(state->isViewContentState()) {
+ std::list<const RBAArea*> areaList;
+ curResultSet_->getArea(dynamic_cast<const RBAViewContentState*>(state),
+ areaList);
+ for (const auto& area : areaList) {
+ allocatables.push_back(dynamic_cast<const RBAAllocatable*>(area));
+ }
+ }
+ else {
+ std::list<const RBAZone*> zoneList;
+ curResultSet_->getZone(dynamic_cast<const RBASoundContentState*>(state),
+ zoneList);
+ for (const auto& zone : zoneList) {
+ allocatables.push_back(dynamic_cast<const RBAAllocatable*>(zone));
+ }
+ }
+ return allocatables;
+}
+
+// Impl [check Aleady Visible/Sounding]
+bool
+RBAResultImpl::isAlreadyOutputting(const RBAContentState* const state) const
+{
+ return curResultSet_->isAlreadyOutputting(state);
+}
+
+// Impl [set Active Scene]
+
+void
+RBAResultImpl::setActive(const RBAScene* const scene, const bool newActive)
+{
+ curResultSet_->setActive(scene, newActive);
+}
+
+// Impl [set Active ContentState]
+
+void
+RBAResultImpl::setActive(const RBAContentState* const state, const bool newActive)
+{
+ curResultSet_->setActive(state, newActive);
+}
+
+// Impl [add Standby Content]
+
+void
+RBAResultImpl::addStandbyContent(const RBAContent* const content)
+{
+ curResultSet_->addStandbyContent(content);
+}
+
+// Impl [check Visible/Sounding Area/Zone]
+
+bool
+RBAResultImpl::isVisible(const RBAArea* area) const
+{
+ return curResultSet_->isOutputting(dynamic_cast<const RBAAllocatable*>(area));
+}
+
+bool
+RBAResultImpl::isPreVisible(const RBAArea* area) const
+{
+ return preResultSet_->isOutputting(dynamic_cast<const RBAAllocatable*>(area));
+}
+
+bool
+RBAResultImpl::isSounding(const RBAZone* zone) const
+{
+ return curResultSet_->isOutputting(dynamic_cast<const RBAAllocatable*>(zone));
+}
+
+bool
+RBAResultImpl::isPreSounding(const RBAZone* zone) const
+{
+ return preResultSet_->isOutputting(dynamic_cast<const RBAAllocatable*>(zone));
+}
+
+// Impl [set View/Sound ContentState]
+
+void RBAResultImpl::setContentState(const RBAAllocatable* const allocatable,
+ const RBAContentState* const state)
+{
+ curResultSet_->setContentState(allocatable, state);
+}
+
+// Impl [check Hidden/Mute Area/Zone]
+
+bool
+RBAResultImpl::isHidden(const RBAAllocatable* const allocatable) const
+{
+ return curResultSet_->isHidden(allocatable);
+}
+
+bool
+RBAResultImpl::isPreHidden(const RBAAllocatable* const allocatable) const
+{
+ return preResultSet_->isHidden(allocatable);
+}
+
+// Impl [set Cancel ContentState]
+
+void
+RBAResultImpl::setCancel(const RBAContentState* const state, const bool checked)
+{
+ curResultSet_->setCancel(state, checked);
+}
+
+// Impl [check Cancel ContentState]
+
+bool
+RBAResultImpl::isCancel(const RBAContentState* const state) const
+{
+ return curResultSet_->isCancel(state);
+}
+
+bool
+RBAResultImpl::isPreCancel(const RBAContentState* const state) const
+{
+ return preResultSet_->isCancel(state);
+}
+
+bool
+RBAResultImpl::isCancel(const RBAViewContentState* state) const
+{
+ return isCancel(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreCancel(const RBAViewContentState* state) const
+{
+ return isPreCancel(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isCancel(const RBASoundContentState* state) const
+{
+ return isCancel(dynamic_cast<const RBAContentState*>(state));
+}
+
+bool
+RBAResultImpl::isPreCancel(const RBASoundContentState* state) const
+{
+ return isPreCancel(dynamic_cast<const RBAContentState*>(state));
+}
+
+// Impl [add Visible/Sounding ContentState]
+
+void
+RBAResultImpl::addOutputtingContentState(const RBAContentState* const state)
+{
+ curResultSet_->addOutputtingContentState(state);
+}
+
+// Impl [cancel ContentState]
+
+void
+RBAResultImpl::cancelContentState(const RBAContentState* const state)
+{
+ curResultSet_->cancelContentState(state);
+}
+
+// Impl [common]
+
+std::unique_ptr<RBAResultSet>
+RBAResultImpl::createBackupCurrentResultSet()
+{
+ return std::make_unique<RBAResultSet>(*curResultSet_);
+}
+
+std::unique_ptr<RBAResultSet>
+RBAResultImpl::createNextCurrentResultSet()
+{
+ std::unique_ptr<RBAResultSet> nextResultSet {std::make_unique<RBAResultSet>()};
+ nextResultSet->copyActives(curResultSet_);
+ nextResultSet->copyProperties(curResultSet_);
+ return nextResultSet;
+}
+
+void
+RBAResultImpl::addViewAction(std::unique_ptr<RBAViewAction>& newViewAction)
+{
+ viewActions_.push_back(move(newViewAction));
+}
+
+void
+RBAResultImpl::setStatusType(const RBAResultStatusType newStatusType)
+{
+ statusType_ = newStatusType;
+}
+
+void
+RBAResultImpl::updateActiveContentStates()
+{
+ curResultSet_->updateActiveContentStates();
+}
+
+void
+RBAResultImpl::setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing,
+ const RBAContent* const viewContent)
+{
+ curResultSet_->setContentOfEventProcessing(eventProcessing, viewContent);
+}
+
+std::unique_ptr<RBAResultSet>&
+RBAResultImpl::getCurResultSet()
+{
+ return curResultSet_;
+}
+
+std::unique_ptr<RBAResultSet>&
+RBAResultImpl::getPreResultSet()
+{
+ return preResultSet_;
+}
+
+RBAContentStatusType RBAResultImpl::getStatusType(const RBAContent* const content) const
+{
+ return curResultSet_->getStatusType(content);
+}
+bool RBAResultImpl::isStandby(const RBAContent* const content) const
+{
+ return curResultSet_->isStandby(content);
+}
+
+bool RBAResultImpl::hasBeenCanceled(const RBAContent* const content) const
+{
+ return curResultSet_->hasBeenCanceled(content);
+}
+
+bool RBAResultImpl::hasBeenPreCanceled(const RBAContent* const content) const
+{
+ return preResultSet_->hasBeenCanceled(content);
+}
+
+bool RBAResultImpl::hasBeenDisplayed(const RBAContent* const content) const
+{
+ return curResultSet_->hasBeenDisplayed(content);
+}
+bool RBAResultImpl::hasBeenPreDisplayed(const RBAContent* const content) const
+{
+ return preResultSet_->hasBeenDisplayed(content);
+}
+
+void RBAResultImpl::updateStatus(const RBAContent* const content)
+{
+ const RBAContentState* const s {getActiveState(content)};
+ if (s != nullptr) {
+ if (isOutputting(s)) {
+ curResultSet_->setStatusType(content, RBAContentStatusType::Displayed);
+ } else if (isCancel(s)) {
+ curResultSet_->setStatusType(content, RBAContentStatusType::Canceled);
+ } else if (curResultSet_->getStatusType(content) != RBAContentStatusType::Undisplayed) {
+ curResultSet_->setStatusType(content, RBAContentStatusType::StandBy);
+ } else {
+ ;
+ }
+ }
+}
+
+std::unordered_map<const RBAContent*, RBAContentStatus>* RBAResultImpl::getCurStatus() const
+{
+ return curResultSet_->getStatus();
+}
+
+std::set<const RBASceneImpl*>& RBAResultImpl::getDifferentConditionScenes() const
+{
+ return (curResultSet_->getDifferentConditionScenes(*preResultSet_.get()));
+}
+#ifdef RBA_USE_LOG
+void
+RBAResultImpl::addFailedConstraint(const RBAConstraint* constraint)
+{
+ curResultSet_->addFailedConstraint(constraint);
+}
+
+const std::list<const RBAConstraint*>&
+RBAResultImpl::getFailedConstraints() const
+{
+ return curResultSet_->getFailedConstraints();
+}
+#endif
+
+}
diff --git a/src/core/logic/RBAResultImpl.hpp b/src/core/logic/RBAResultImpl.hpp
new file mode 100644
index 0000000..d7a1aa1
--- /dev/null
+++ b/src/core/logic/RBAResultImpl.hpp
@@ -0,0 +1,343 @@
+/**
+ * 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.
+ */
+
+/**
+ * RBAResultImpl (result of arbitration implementation) class header
+ */
+
+#ifndef RBARESULTIMPL_HPP
+#define RBARESULTIMPL_HPP
+
+#include <memory>
+#include <unordered_map>
+#include <set>
+#include "RBAResult.hpp"
+#include "RBAResultStatusType.hpp"
+#include "RBAContentStatusType.hpp"
+
+namespace rba {
+
+class RBAArbitrator;
+class RBAArea;
+class RBAViewContent;
+class RBAViewContentState;
+class RBASize;
+class RBAScene;
+class RBAAbstractProperty;
+class RBAAreaImpl;
+class RBAContentStateImpl;
+class RBAViewContentImpl;
+class RBAViewContentStateImpl;
+class RBASizeImpl;
+class RBASceneImpl;
+class RBAResultSet;
+class RBAViewAction;
+class RBAZoneImpl;
+class RBASoundContentImpl;
+class RBASoundContentStateImpl;
+class RBASoundContent;
+class RBASoundContentState;
+class RBAContentState;
+class RBAAllocatable;
+class RBAContent;
+class RBAEventProcessing;
+class RBAConstraint;
+class RBAContentStatus;
+
+class DLL_EXPORT RBAResultImpl : public RBAResult
+{
+public:
+ RBAResultImpl(const RBAArbitrator* const arb,
+ std::unique_ptr<RBAResultSet> newPrevResultSet);
+ RBAResultImpl(const RBAArbitrator* const arb,
+ std::unique_ptr<RBAResultSet> newPrevResultSet,
+ std::unique_ptr<RBAResultSet> newCurResultSet);
+ RBAResultImpl(const RBAResultImpl* const replicationTarget);
+ RBAResultImpl(const RBAResultImpl&)=delete;
+ RBAResultImpl(const RBAResultImpl&&)=delete;
+ RBAResultImpl& operator=(const RBAResultImpl&)=delete;
+ RBAResultImpl& operator=(const RBAResultImpl&&)=delete;
+ virtual ~RBAResultImpl()=default;
+
+public:
+
+ //
+ // External
+ //
+
+ // [get VisibleArea/SoundingZone]
+ const std::list<const RBAArea*>& getVisibleAreas() const override;
+ const std::list<const RBAArea*>& getPreVisibleAreas() const override;
+ const std::list<const RBAZone*>& getSoundingZones() const override;
+ const std::list<const RBAZone*>& getPreSoundingZones() const override;
+
+ // [get Visible/Sounding ContentStates]
+ const std::list<const RBAViewContentState*>& getVisibleContentStates() const override;
+ const std::list<const RBAViewContentState*>& getPreVisibleContentStates() const override;
+ const std::list<const RBASoundContentState*>& getSoundingContentStates() const override;
+ const std::list<const RBASoundContentState*>& getPreSoundingContentStates() const override;
+
+ // [get Active View/Sound ContentStates]
+ const std::list<const RBAViewContentState*>& getActiveViewContentStates() const override;
+ const std::list<const RBAViewContentState*>& getPreActiveViewContentStates() const override;
+ const std::list<const RBASoundContentState*>& getActiveSoundContentStates() const override;
+ const std::list<const RBASoundContentState*>& getPreActiveSoundContentStates() const override;
+
+ // [get Active Scenes]
+ const std::list<const RBAScene*>& getActiveScenes() const override;
+ const std::list<const RBAScene*>& getPreActiveScenes() const override;
+
+ // [get InvisibleAreas/UnsoundingZone]
+ const std::list<const RBAArea*>& getInvisibleAreas() const override;
+ const std::list<const RBAArea*>& getPreInvisibleAreas() const override;
+ const std::list<const RBAZone*>& getUnsoundingZones() const override;
+ const std::list<const RBAZone*>& getPreUnsoundingZones() const override;
+
+ // [get HiddenAreas/MuteZones]
+ const std::list<const RBAArea*>& getHiddenAreas() const override;
+ const std::list<const RBAArea*>& getPreHiddenAreas() const override;
+ const std::list<const RBAZone*>& getMuteZones() const override;
+ const std::list<const RBAZone*>& getPreMuteZones() const override;
+
+ // [get Attenuated]
+ const std::list<const RBAZone*>& getAttenuatedZones() const override;
+ const std::list<const RBAZone*>& getPreAttenuatedZones() const override;
+
+ // [get Canceled Contents]
+ const std::list<const RBAViewContent*>& getCanceledViewContents() const override;
+ const std::list<const RBAViewContent*>& getPreCanceledViewContents() const override;
+ const std::list<const RBASoundContent*>& getCanceledSoundContents() const override;
+ const std::list<const RBASoundContent*>& getPreCanceledSoundContents() const override;
+
+ // [get Standby Contents]
+ const std::list<const RBAViewContent*>& getStandbyViewContents() const override;
+ const std::list<const RBAViewContent*>& getPreStandbyViewContents() const override;
+ const std::list<const RBASoundContent*>& getStandbySoundContents() const override;
+ const std::list<const RBASoundContent*>& getPreStandbySoundContents() const override;
+
+ // [get ContentStates]
+ const RBAViewContentState* getContentState(const RBAArea* area) const override;
+ const RBAViewContentState* getPreContentState(const RBAArea* area) const override;
+ const RBASoundContentState* getContentState(const RBAZone* zone) const override;
+ const RBASoundContentState* getPreContentState(const RBAZone* zone) const override;
+
+ // [get Areas/Zones by ConentState]
+ const std::list<const RBAArea*> getArea(const RBAViewContentState* state) const override;
+ const std::list<const RBAArea*> getPreArea(const RBAViewContentState* state) const override;
+ const std::list<const RBAZone*> getZone(const RBASoundContentState* state) const override;
+ const std::list<const RBAZone*> getPreZone(const RBASoundContentState* state) const override;
+
+ // [get Areas/Zones by Content]
+ const std::list<const RBAArea*> getArea(const RBAViewContent* content) const override;
+ const std::list<const RBAArea*> getPreArea(const RBAViewContent* content) const override;
+ const std::list<const RBAZone*> getZone(const RBASoundContent* content) const override;
+ const std::list<const RBAZone*> getPreZone(const RBASoundContent* content) const override;
+
+ // [get Size]
+ const RBASize* getSize(const RBAArea* area) const override;
+ const RBASize* getPreSize(const RBAArea* area) const override;
+
+ // [check Active Scene]
+ bool isActive(const RBAScene* scene) const override;
+ bool isPreActive(const RBAScene* scene) const override;
+
+ // [check Active Content]
+ bool isActive(const RBAContent* const content) const;
+ bool isPreActive(const RBAContent* const content) const;
+ bool isActive(const RBAViewContent* content) const override;
+ bool isActive(const RBASoundContent* content) const override;
+ bool isPreActive(const RBAViewContent* content) const override;
+ bool isPreActive(const RBASoundContent* content) const override;
+
+ // [check Visible/Sounding Area/Zone]
+ bool isVisible(const RBAArea* area) const override;
+ bool isPreVisible(const RBAArea* area) const override;
+ bool isSounding(const RBAZone* zone) const override;
+ bool isPreSounding(const RBAZone* zone) const override;
+
+ // [check Visible/Sounding ContentState]
+ bool isVisible(const RBAViewContentState* state) const override;
+ bool isPreVisible(const RBAViewContentState* state) const override;
+ bool isSounding(const RBASoundContentState* state) const override;
+ bool isPreSounding(const RBASoundContentState* state) const override;
+
+ // [get View/Sound ContentState]
+ const RBAViewContentState* getViewContentState(const RBAArea* area) const override;
+ virtual const RBAViewContentState* getPreViewContentState(const RBAArea* area) const;
+ const RBASoundContentState* getSoundContentState(const RBAZone* zone) const override;
+ const RBASoundContentState* getPreSoundContentState(const RBAZone* zone) const override;
+
+ // [check Hidden/Mute]
+ bool isHidden(const RBAArea* area) const override;
+ bool isPreHidden(const RBAArea* area) const override;
+ bool isMute(const RBAZone* zone) const override;
+ bool isPreMute(const RBAZone* zone) const override;
+
+ // [check Attenuated]
+ bool isAttenuated(const RBAZone* zone) const override;
+ bool isPreAttenuated(const RBAZone* zone) const override;
+
+ // [check Cancel]
+ bool isCancel(const RBAViewContentState* state) const override;
+ bool isPreCancel(const RBAViewContentState* state) const override;
+ bool isCancel(const RBASoundContentState* state) const override;
+ bool isPreCancel(const RBASoundContentState* state) const override;
+
+ // [common]
+ const std::list<const RBAViewAction*>& getViewActions() const override;
+ RBAResultStatusType getStatusType() const override;
+ bool isLater(const RBAContent* const target,
+ const RBAContent* const comparisonTarget) const;
+
+ std::string getLog() const override;
+ void setLog(const std::string& log);
+
+ bool hasDisplayingArea(const RBADisplay* display) const override;
+
+ bool satisfiesConstraints() const override;
+
+ std::int32_t getSceneProperty(const RBAScene* scene,
+ const std::string& propertyName) const override;
+ //
+ // Internal
+ //
+
+ // Impl [get VisibleArea/SoundingZone]
+ const std::set<const RBAAllocatable*>& getOutputtingAllocatables() const;
+
+ // Impl [get Active View/Sound ContentStates]
+ const std::set<const RBAContentState*>& getActiveContentStates() const;
+
+ // Impl [get ContentStates]
+ const RBAContentState* getContentState(const RBAAllocatable* const allocatable) const;
+ const RBAContentState* getDirectContentState(const RBAAllocatable* const allocatable) const;
+ const RBAContentState* getPreContentState(const RBAAllocatable* const allocatable) const;
+ const RBAContentState* getDirectPreContentState(const RBAAllocatable* const allocatable) const;
+
+ // Impl [get Areas/Zones by ConentState]
+ std::list<const RBAAllocatable*> getAllocatable(const RBAContentState* const state) const;
+
+ // Impl [check Aleady Outputting]
+ bool isAlreadyOutputting(const RBAContentState* const state) const;
+
+ // Impl [set Active Scene]
+ void setActive(const RBAScene* const scene, const bool newActive);
+
+ // Impl [check Active ContentState]
+ bool isActive(const RBAContentState* const state) const;
+ bool isActive(const RBAViewContentState* const state) const;
+ bool isActive(const RBASoundContentState* const state) const;
+ bool isPreActive(const RBAContentState* const state) const;
+ bool isPreActive(const RBAViewContentState* const state) const;
+ bool isPreActive(const RBASoundContentState* const state) const;
+ const RBAContentState* getActiveState(const RBAContent* const content) const;
+ const RBAContentState* getPreActiveState(const RBAContent* const content) const;
+
+ // Impl [set Active ContentState]
+ void setActive(const RBAContentState* const state, const bool newActive);
+
+ // Impl [add Standby Content]
+ void addStandbyContent(const RBAContent* const content);
+
+ // Impl [check Visible/Sounding Alloc ContentState]
+ bool isOutputting(const RBAAllocatable* const alloc) const;
+ bool isPreOutputting(const RBAAllocatable* const alloc) const;
+ bool isOutputting(const RBAContentState* const state) const;
+ bool isPreOutputting(const RBAContentState* const state) const;
+
+ // Impl [get View/Sound ContentState by Allocatable]
+ const RBAContentState* getAllocatedContentState(const RBAAllocatable* const allocatable) const;
+ const RBAContentState* getPreAllocatedContentState(const RBAAllocatable* const allocatable) const;
+
+ // Impl [set View/Sound ContentState]
+ void setContentState(const RBAAllocatable* const allocatable, const RBAContentState* const state);
+
+ // Impl [check Hidden/Mute Area/Zone]
+ bool isHidden(const RBAAllocatable* const allocatable) const;
+ bool isPreHidden(const RBAAllocatable* const allocatable) const;
+
+ // Impl [set Cancel ContentState]
+ void setCancel(const RBAContentState* const state, const bool checked);
+
+ // Impl [check Cancel ContentState]
+ bool isCancel(const RBAContentState* const state) const;
+ bool isPreCancel(const RBAContentState* const state) const;
+
+ // Impl [add Visible/Sounding ContentState]
+ void addOutputtingContentState(const RBAContentState* const state);
+
+ // Impl [cancel ContentState]
+ void cancelContentState(const RBAContentState* const state);
+
+ // Impl [common]
+ std::unique_ptr<RBAResultSet> createBackupCurrentResultSet();
+ std::unique_ptr<RBAResultSet> createNextCurrentResultSet();
+ void addViewAction(std::unique_ptr<RBAViewAction>& newViewAction);
+ void setStatusType(const RBAResultStatusType newStatusType);
+ void updateActiveContentStates();
+ void setSceneProperty(const RBASceneImpl* const scene,
+ const std::string& propertyName,
+ const std::int32_t value);
+ void setSceneProperty(const RBAAbstractProperty* const property,
+ const std::int32_t value);
+ std::int32_t getSceneProperty(const RBAAbstractProperty* const property) const;
+ std::int32_t getPreSceneProperty(const RBAAbstractProperty* const property) const;
+ void setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing,
+ const RBAContent* const viewContent);
+ std::unique_ptr<RBAResultSet>& getCurResultSet();
+ std::unique_ptr<RBAResultSet>& getPreResultSet();
+ RBAContentStatusType getStatusType(const RBAContent* const content) const;
+ bool isStandby(const RBAContent* const content) const;
+ bool hasBeenCanceled(const RBAContent* const content) const;
+ bool hasBeenPreCanceled(const RBAContent* const content) const;
+ bool hasBeenDisplayed(const RBAContent* const content) const;
+ bool hasBeenPreDisplayed(const RBAContent* const content) const;
+
+ /// @brief Update status of Content
+ /// @details Update the status based on the request status,
+ /// output status, and status at the time of request of the content
+ /// @param[in] content Content to be updated
+ void updateStatus(const RBAContent* const content);
+
+ std::unordered_map<const RBAContent*, RBAContentStatus>* getCurStatus() const;
+ std::set<const RBASceneImpl*>& getDifferentConditionScenes() const;
+#ifdef RBA_USE_LOG
+ void addFailedConstraint(const RBAConstraint* constraint);
+ const std::list<const RBAConstraint*>& getFailedConstraints() const;
+#endif
+
+private:
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+ std::unique_ptr<RBAResultSet> curResultSet_;
+ std::unique_ptr<RBAResultSet> preResultSet_;
+ mutable std::list<std::unique_ptr<RBAViewAction>> viewActions_;
+ mutable std::list<const RBAViewAction*> viewActionsForPublicUse_;
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+ const RBAArbitrator* arb_;
+ RBAResultStatusType statusType_;
+ std::string log_;
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAResultSet.cpp b/src/core/logic/RBAResultSet.cpp
new file mode 100644
index 0000000..bcc9892
--- /dev/null
+++ b/src/core/logic/RBAResultSet.cpp
@@ -0,0 +1,996 @@
+/**
+ * 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.
+ */
+
+/**
+ * ResultSet (set arbitration result) class
+ */
+
+#include <algorithm>
+#include <unordered_map>
+#include "RBAResultSet.hpp"
+
+#include "RBAContentStatusType.hpp"
+#include "RBAAreaImpl.hpp"
+#include "RBAViewContentImpl.hpp"
+#include "RBAViewContentState.hpp"
+#include "RBASizeImpl.hpp"
+#include "RBAZone.hpp"
+#include "RBAZoneImpl.hpp"
+#include "RBASoundContent.hpp"
+#include "RBASoundContentState.hpp"
+#include "RBASceneImpl.hpp"
+#include "RBAContentState.hpp"
+#include "RBAContent.hpp"
+#include "RBAAbstractAllocatable.hpp"
+#include "RBAAllocatable.hpp"
+#include "RBAConstraint.hpp"
+#include "RBADisplay.hpp"
+#include "RBAAbstractProperty.hpp"
+
+namespace rba {
+
+RBAResultSet::RBAResultSet(const RBAResultSet& resultSet)
+ : outputtingAllocs_{resultSet.outputtingAllocs_}
+ , hiddenAllocs_{resultSet.hiddenAllocs_}
+ , activeContentStates_{resultSet.activeContentStates_}
+ , canceledContentStates_{resultSet.canceledContentStates_}
+ , allocToContentState_{resultSet.allocToContentState_}
+ , visibleAreas_{resultSet.visibleAreas_}
+ , soundingZones_{resultSet.soundingZones_}
+ , invisibleAreas_{resultSet.invisibleAreas_}
+ , unsoundingZones_{resultSet.unsoundingZones_}
+ , hiddenAreas_{resultSet.hiddenAreas_}
+ , muteZones_{resultSet.muteZones_}
+ , attenuatedZones_{resultSet.attenuatedZones_}
+ , canceledViewContents_{resultSet.canceledViewContents_}
+ , canceledSoundContents_{resultSet.canceledSoundContents_}
+ , standbyViewContents_{resultSet.standbyViewContents_}
+ , standbySoundContents_{resultSet.standbySoundContents_}
+ , visibleContentStates_{resultSet.visibleContentStates_}
+ , soundingContentStates_{resultSet.soundingContentStates_}
+ , activeViewContentStates_{resultSet.activeViewContentStates_}
+ , activeSoundContentStates_{resultSet.activeSoundContentStates_}
+ , requestOrderView_{resultSet.requestOrderView_}
+ , requestOrderSound_{resultSet.requestOrderSound_}
+ , activeScenes_{resultSet.activeScenes_}
+ , propertyMap_{resultSet.propertyMap_}
+ , event_content_{resultSet.event_content_}
+ , contentToStatus_{resultSet.contentToStatus_}
+ , requestContentStateMap_{resultSet.requestContentStateMap_}
+#ifdef RBA_USE_LOG
+ , failedConstraints_{resultSet.failedConstraints_}
+#endif
+{
+}
+
+// Impl [get VisibleArea/SoundingZone]
+
+const std::set<const RBAAllocatable*>&
+RBAResultSet::getOutputtingAllocatables() const
+{
+ return outputtingAllocs_;
+}
+
+const std::list<const RBAArea*>&
+RBAResultSet::getVisibleAreas() const
+{
+ return visibleAreas_;
+}
+
+const std::list<const RBAZone*>&
+RBAResultSet::getSoundingZones() const
+{
+ return soundingZones_;
+}
+
+// Impl [get Visible/Sounding ContentStates]
+
+const std::list<const RBAViewContentState*>&
+RBAResultSet::getVisibleContentStates() const
+{
+ return visibleContentStates_;
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultSet::getSoundingContentStates() const
+{
+ return soundingContentStates_;
+}
+
+// Impl [get Active View/Sound ContentStates]
+
+const std::set<const RBAContentState*>&
+RBAResultSet::getActiveContentStates() const
+{
+ return activeContentStates_;
+}
+
+const std::list<const RBAViewContentState*>&
+RBAResultSet::getActiveViewContentStates() const
+{
+ return activeViewContentStates_;
+}
+
+const std::list<const RBASoundContentState*>&
+RBAResultSet::getActiveSoundContentStates() const
+{
+ return activeSoundContentStates_;
+}
+
+// Impl [get Active Scenes]
+
+const std::list<const RBAScene*>&
+RBAResultSet::getActiveScenes() const
+{
+ return activeScenes_;
+}
+
+// Impl [get InvisibleAreas/UnsoundingZone]
+
+const std::list<const RBAArea*>&
+RBAResultSet::getInvisibleAreas() const
+{
+ return invisibleAreas_;
+}
+
+const std::list<const RBAZone*>&
+RBAResultSet::getUnsoundingZones() const
+{
+ return unsoundingZones_;
+}
+
+// Impl [get HiddenAreas/MuteZones]
+
+const std::list<const RBAArea*>&
+RBAResultSet::getHiddenAreas() const
+{
+ return hiddenAreas_;
+}
+
+const std::list<const RBAZone*>&
+RBAResultSet::getMuteZones() const
+{
+ return muteZones_;
+}
+
+// Impl [get Attenuated]
+const std::list<const RBAZone*>&
+RBAResultSet::getAttenuatedZones() const
+{
+ return attenuatedZones_;
+}
+
+// Impl [get Canceled Contents]
+
+const std::list<const RBAViewContent*>&
+RBAResultSet::getCanceledViewContents() const
+{
+ return canceledViewContents_;
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultSet::getCanceledSoundContents() const
+{
+ return canceledSoundContents_;
+}
+
+// Impl [get Standby Contents]
+
+const std::list<const RBAViewContent*>&
+RBAResultSet::getStandbyViewContents() const
+{
+ return standbyViewContents_;
+}
+
+const std::list<const RBASoundContent*>&
+RBAResultSet::getStandbySoundContents() const
+{
+ return standbySoundContents_;
+}
+
+// Impl [get ContentStates]
+
+const RBAContentState*
+RBAResultSet::getContentState(const RBAAllocatable* const alloc) const
+{
+ if(alloc != nullptr) {
+ auto it = allocToContentState_.find(alloc);
+ if(it != allocToContentState_.end()) {
+ auto state = it->second;
+ // If the content(state) assigned to the "alloc" has the
+ // allocatable function (such as cyclic), the contentState assigned to it
+ // is the contentState assigned to the "alloc".
+ // Search this until it is not allocatable content.
+ while ((state != nullptr)
+ && (dynamic_cast<RBAAllocatable*>(state->getOwner()) != nullptr)) {
+ it = allocToContentState_.find(dynamic_cast<RBAAllocatable*>(state->getOwner()));
+ state = it->second;
+ }
+ return state;
+ }
+ }
+ return nullptr;
+}
+
+const RBAContentState*
+RBAResultSet::getDirectContentState(const RBAAllocatable* const alloc) const
+{
+ if(alloc != nullptr) {
+ auto it = allocToContentState_.find(alloc);
+ if(it != allocToContentState_.end()) {
+ return it->second;
+ }
+ }
+ return nullptr;
+}
+
+// Impl [get Areas/Zones by ConentState]
+
+void
+RBAResultSet::getAlloc(const RBAContentState* const state,
+ std::list<const RBAAllocatable*>& allocList) const
+{
+ if(state != nullptr) {
+ for(const auto& it : allocToContentState_) {
+ if(it.second == state) {
+ allocList.push_back(it.first);
+ }
+ }
+ }
+}
+
+void
+RBAResultSet::getArea(const RBAViewContentState* const state,
+ std::list<const RBAArea*>& areaList) const
+{
+ if(state != nullptr) {
+ for(const auto& it : allocToContentState_) {
+ if(dynamic_cast<const RBAViewContentState*>(it.second) == state) {
+ const RBAContent* const content {dynamic_cast<const RBAContent*>(it.first)};
+ if (content != nullptr) { // In case of CyclicContent
+ // Get ViewContentState assigned to CyclicContent
+ const RBAViewContentState* const ownerState
+ {dynamic_cast<const RBAViewContentState*>(getReqestState(content))};
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // calling getArea() recursively
+ //  [Reason that there is no problem if the rule is deviated]
+ // When getArea() is performed on CyclicContent, at that time,
+ // respond Area where ViewContent assigned to CyclicContent
+ // is assigned. When CyclicContent is assigned to CyclicContent,
+ // multiple recursive calls may be made, but the rule model
+ // definition is finite.
+ // Therefore, stack overflow will not be occured, no problem.
+ getArea(ownerState, areaList);
+ } else {
+ areaList.push_back(dynamic_cast<const RBAArea*>(it.first));
+ }
+ }
+ }
+ }
+}
+
+void
+RBAResultSet::getZone(const RBASoundContentState* const state,
+ std::list<const RBAZone*>& zoneList) const
+{
+ if(state != nullptr) {
+ for(const auto& it : allocToContentState_) {
+ if (dynamic_cast<const RBASoundContentState*>(it.second) == state) {
+ const RBAContent* const content {dynamic_cast<const RBAContent*>(it.first)};
+ if (content != nullptr) {
+ const RBASoundContentState* const ownerState
+ {dynamic_cast<const RBASoundContentState*>(getReqestState(content))};
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // Function '::rba::RBAResultSet::getZone=(_,
+ // p={c::rba::RBASoundContentState},
+ // &{c::std::__cxx11::list<p={c::rba::RBAZone},
+ // {c::std::allocator<p={c::rba::RBAZone}>}>})'
+ // is recursive.
+ //  [Reason that there is no problem if the rule is deviated]
+ // Recursive call is required as a feature
+ getZone(ownerState, zoneList);
+ } else {
+ zoneList.push_back(dynamic_cast<const RBAZone*>(it.first));
+ }
+ }
+ }
+ }
+}
+
+// Impl [get Areas/Zones by Content]
+
+void
+RBAResultSet::getArea(const RBAViewContent* const content,
+ std::list<const RBAArea*>& areaList) const
+{
+ if(content != nullptr) {
+ for(auto& state : content->getContentStates()) {
+ getArea(state, areaList);
+ if(!areaList.empty()) {
+ break;
+ }
+ }
+ }
+}
+
+void
+RBAResultSet::getZone(const RBASoundContent* const content,
+ std::list<const RBAZone*>& zoneList) const
+{
+ if(content != nullptr) {
+ for(auto& state : content->getContentStates()) {
+ getZone(state, zoneList);
+ if(!zoneList.empty()) {
+ break;
+ }
+ }
+ }
+}
+
+// Impl [get Size]
+
+const RBASize*
+RBAResultSet::getSize(const RBAArea* const area) const
+{
+ if(area == nullptr) {
+ return nullptr;
+ }
+ const RBAAreaImpl* const areaImpl {dynamic_cast<const RBAAreaImpl*>(area)};
+ auto it = allocToContentState_.find(areaImpl);
+ if(it == allocToContentState_.end() || (it->second == nullptr)) {
+ return nullptr;
+ }
+ const RBAContent* const content {dynamic_cast<RBAContent*>(it->second->getOwner())};
+ const RBASize* backupAreaSize {nullptr};
+ std::int32_t backupDiffVal {-1};
+ for(auto& areaSize : areaImpl->getSizes()) {
+ const RBASizeImpl* const areaSizeImpl {dynamic_cast<const RBASizeImpl*>(areaSize)};
+ for(auto& contentSize : content->getSizes()) {
+ const RBASizeImpl* const contentSizeImpl {dynamic_cast<const RBASizeImpl*>(contentSize)};
+ const auto diffVal = areaSizeImpl->diff(contentSizeImpl);
+ if(diffVal == 0) {
+ return areaSizeImpl;
+ }
+ else if((backupDiffVal < 0) || (backupDiffVal > diffVal)) {
+ backupAreaSize = areaSizeImpl;
+ backupDiffVal = diffVal;
+ } else {
+ ;
+ }
+ }
+ }
+
+ return backupAreaSize;
+}
+
+// Impl [check Active Scene]
+
+bool
+RBAResultSet::isActive(const RBAScene* const scene) const
+{
+ return (std::find(activeScenes_.begin(), activeScenes_.end(), scene)
+ != activeScenes_.end());
+}
+
+// Impl [check Active ContentState]
+bool
+RBAResultSet::isActive(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content) != contentToStatus_.end()) {
+ return contentToStatus_[content].isActive();
+ }
+ return false;
+}
+
+bool
+RBAResultSet::isActive(const RBAContentState* const state) const
+{
+ const RBAContent* const content {dynamic_cast<RBAContent*>(state->getOwner())};
+ return (isActive(content) && (getReqestState(content) == state));
+}
+
+const RBAContentState*
+RBAResultSet::getReqestState(const RBAContent* const content) const
+{
+ if (requestContentStateMap_.find(content) != requestContentStateMap_.end()) {
+ return requestContentStateMap_[content];
+ }
+ return nullptr;
+}
+
+// Impl [check Outputting Allocatable]
+
+bool
+RBAResultSet::isOutputting(const RBAAllocatable* const alloc) const
+{
+ return outputtingAllocs_.find(alloc) != outputtingAllocs_.end();
+}
+
+// Impl [check Outputting ContentState]
+
+bool
+RBAResultSet::isOutputting(const RBAContentState* const state) const
+{
+ std::list<const RBAAllocatable*> allocList;
+ getAlloc(state, allocList);
+ for(auto& alloc : allocList) {
+ if(isOutputting(alloc)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Impl [check Hidden/Mute Area/Zone]
+
+bool
+RBAResultSet::isHidden(const RBAAllocatable* const alloc) const
+{
+ return hiddenAllocs_.find(alloc) != hiddenAllocs_.end();
+}
+
+// Impl [check Attenuated Zone]
+
+bool
+RBAResultSet::isAttenuated(const RBAZone* const zone) const
+{
+ return std::find(attenuatedZones_.begin(), attenuatedZones_.end(), zone) != attenuatedZones_.end();
+}
+
+// Impl [check Cancel ContentState]
+
+bool
+RBAResultSet::isCancel(const RBAContentState* const state) const
+{
+ return canceledContentStates_.find(state) != canceledContentStates_.end();
+}
+
+// Impl [check Aleady OutPutting]
+
+bool
+RBAResultSet::isAlreadyOutputting(const RBAContentState* const state) const
+{
+ const auto content = dynamic_cast<const RBAContent*>(state->getOwner());
+ for(auto& alloc : content->getAllocatables()) {
+ if((getContentState(alloc) == state) && !alloc->isHidden()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Impl [set Active Scene]
+
+/**
+ * @brief Set display request or display withdrawal request, for Scene
+ * @param scene Scene
+ * @param newActive true: display request, false: display withdrawal request
+ */
+void
+RBAResultSet::setActive(const RBAScene* const scene, const bool newActive)
+{
+ const auto it = std::find(activeScenes_.begin(), activeScenes_.end(), scene);
+ if(it == activeScenes_.end()) {
+ if(newActive) {
+ activeScenes_.push_back(scene);
+ }
+ }
+ else {
+ if(!newActive) {
+ static_cast<void>(activeScenes_.erase(it));
+ }
+ }
+}
+
+// Impl [set Active ContentState]
+
+/**
+ * @brief Set display request or display withdrawal request, for Content state
+ * @details If the content has already been registered,
+ delete the registered content.
+ * @param contentState Content state
+ * @param newActive true: display request, false: display withdrawal request
+ */
+void
+RBAResultSet::setActive(const RBAContentState* const state, const bool newActive)
+{
+ updateRequestStatus(dynamic_cast<RBAContent*>(state->getOwner()), newActive);
+
+ // Check if Content is already active
+ const RBAContentState* temp {nullptr};
+ for(auto& cs : activeContentStates_) {
+ if(cs->getOwner() == state->getOwner()) {
+ temp = cs;
+ break;
+ }
+ }
+ // Delete if Content is active
+ if (temp != nullptr) {
+ setOrder(temp, 0);
+ static_cast<void>(activeContentStates_.erase(temp));
+ if (temp->isViewContentState()) {
+ activeViewContentStates_.remove(dynamic_cast<const RBAViewContentState*>(temp));
+ } else {
+ activeSoundContentStates_.remove(dynamic_cast<const RBASoundContentState*>(temp));
+ }
+ }
+
+ // Rgistre active
+ if(newActive) {
+ requestContentStateMap_[dynamic_cast<const RBAContent*>(state->getOwner())] = state;
+ static_cast<void>(activeContentStates_.insert(state));
+ if (state->isViewContentState()) {
+ setOrder(state, requestOrderView_);
+ requestOrderView_++;
+ activeViewContentStates_.push_back(dynamic_cast<const RBAViewContentState*>(state));
+ } else {
+ setOrder(state, requestOrderSound_);
+ requestOrderSound_++;
+ activeSoundContentStates_.push_back(dynamic_cast<const RBASoundContentState*>(state));
+ }
+ }
+ else {
+ setOrder(state, 0);
+ static_cast<void>(requestContentStateMap_.erase(dynamic_cast<const RBAContent*>(state->getOwner())));
+ }
+}
+
+// [cancel ContentState]
+
+void
+RBAResultSet::cancelContentState(const RBAContentState* const state)
+{
+ setOrder(state, 0);
+ if (state->isViewContentState()) {
+ canceledViewContents_.push_back(dynamic_cast<const RBAViewContent*>(state->getOwner()));
+ } else {
+ canceledSoundContents_.push_back(dynamic_cast<const RBASoundContent*>(state->getOwner()));
+ }
+}
+
+// Impl [set Cancel ContentState]
+
+void
+RBAResultSet::setCancel(const RBAContentState* const state, const bool checked)
+{
+ if(checked) {
+ static_cast<void>(canceledContentStates_.insert(state));
+ }
+ else {
+ static_cast<void>(canceledContentStates_.erase(state));
+ }
+}
+
+// Impl [set ContentState]
+
+void
+RBAResultSet::setContentState(const RBAAllocatable* const alloc, const RBAContentState* const state)
+{
+ //alloc
+ allocToContentState_[alloc] = state;
+ const bool isHiddenRes {alloc->isHidden()};
+ const bool existsState {(state != nullptr)};
+ const RBAAreaImpl* area {dynamic_cast<const RBAAreaImpl*>(alloc)};
+ const RBAZoneImpl* zone {dynamic_cast<const RBAZoneImpl*>(alloc)};
+
+ if (isHiddenRes) {
+ static_cast<void>(hiddenAllocs_.insert(alloc));
+ } else {
+ // Currently, there is no case to delete the Allocable stored in
+ // hiddenAllocs_. In the future, since hiding may be forcibly released,
+ // implement it.
+ static_cast<void>(hiddenAllocs_.erase(alloc));
+ }
+
+ if (!isHiddenRes && existsState) {
+ if (alloc->isArea() || alloc->isZone()) {
+ static_cast<void>(outputtingAllocs_.insert(alloc));
+ }
+ if (isOutputting(alloc)) {
+ const RBAContentState* s {state};
+ while ((s != nullptr) && (dynamic_cast<RBAAllocatable*>(s->getOwner()) != nullptr)) {
+ RBAAllocatable* extAlloc {dynamic_cast<RBAAllocatable*>(s->getOwner())};
+ static_cast<void>(outputtingAllocs_.insert(extAlloc));
+ s = extAlloc->getState();
+ }
+ }
+
+ if (alloc->isArea()) {
+ if (std::find(visibleAreas_.begin(), visibleAreas_.end(), area) == visibleAreas_.end()) {
+ visibleAreas_.push_back(area);
+ }
+ invisibleAreas_.remove(area);
+ } else if (alloc->isZone()) {
+ if (std::find(soundingZones_.begin(), soundingZones_.end(), zone) == soundingZones_.end()) {
+ soundingZones_.push_back(zone);
+ }
+ unsoundingZones_.remove(zone);
+ } else {
+ ;
+ }
+ } else {
+ static_cast<void>(outputtingAllocs_.erase(alloc));
+ if (alloc->isArea()) {
+ // Currently, there is no case to delete the Area stored in visibleAreas_.
+ // In the future, it may happen that content allocation is
+ // forcibly released, so implement thes.
+ visibleAreas_.remove(area);
+ if (std::find(invisibleAreas_.begin(), invisibleAreas_.end(), area) == invisibleAreas_.end()) {
+ invisibleAreas_.push_back(area);
+ }
+ } else if (alloc->isZone()) {
+ // Currently, there is no case to delete the Area stored in soundingZones_.
+ // In the future, it may happen that content allocation is
+ // forcibly released, so implement thes.
+ soundingZones_.remove(zone);
+ if (std::find(unsoundingZones_.begin(), unsoundingZones_.end(), zone) == unsoundingZones_.end()) {
+ unsoundingZones_.push_back(zone);
+ }
+ } else {
+ ;
+ }
+ }
+
+ if (isHiddenRes && existsState) {
+ if (alloc->isArea()) {
+ if (std::find(hiddenAreas_.begin(), hiddenAreas_.end(), area) == hiddenAreas_.end()) {
+ hiddenAreas_.push_back(area);
+ }
+ } else if (alloc->isZone()) {
+ if (std::find(muteZones_.begin(), muteZones_.end(), zone) == muteZones_.end()) {
+ muteZones_.push_back(zone);
+ }
+ } else {
+ ;
+ }
+ } else {
+ if (alloc->isArea()) {
+ hiddenAreas_.remove(area);
+ } else if (alloc->isZone()) {
+ muteZones_.remove(zone);
+ } else {
+ ;
+ }
+ }
+
+ if (alloc->isZone()) {
+ if (existsState && !isHiddenRes && zone->isAttenuated()) {
+ if (std::find(attenuatedZones_.begin(), attenuatedZones_.end(), zone) == attenuatedZones_.end()) {
+ attenuatedZones_.push_back(zone);
+ }
+ } else {
+ // Currently, there is no case to delete the Allocatable stored in
+ // attenuatedZones_. In the future, there may be cases in which
+ // "attenuation" is forcibly canceled, so implement this.
+ attenuatedZones_.remove(zone);
+ }
+ }
+}
+
+// Impl [add Visible/Sounding ContentState]
+
+void
+RBAResultSet::addOutputtingContentState(const RBAContentState* const state)
+{
+ if (state->isViewContentState()) {
+ visibleContentStates_.push_back(dynamic_cast<const RBAViewContentState*>(state));
+ }
+ else if (state->isSoundContentState()) {
+ soundingContentStates_.push_back(dynamic_cast<const RBASoundContentState*>(state));
+ }
+ else {
+ ;
+ }
+}
+
+// Impl [add Standby Content]
+
+void
+RBAResultSet::addStandbyContent(const RBAContent* const content)
+{
+ if (content->isViewContent()) {
+ standbyViewContents_.push_back(dynamic_cast<const RBAViewContent*>(content));
+ }
+ else if (content->isSoundContent()) {
+ standbySoundContents_.push_back(dynamic_cast<const RBASoundContent*>(content));
+ }
+ else {
+ ;
+ }
+}
+
+// [activeView]
+
+void
+RBAResultSet::copyActives(const std::unique_ptr<RBAResultSet>& resultSet)
+{
+ activeContentStates_ = resultSet->activeContentStates_;
+ activeViewContentStates_ = resultSet->activeViewContentStates_;
+ activeSoundContentStates_ = resultSet->activeSoundContentStates_;
+ activeScenes_ = resultSet->activeScenes_;
+ contentToStatus_ = resultSet->contentToStatus_;
+ requestContentStateMap_ = resultSet->requestContentStateMap_;
+
+ // Reset order
+ requestOrderView_ = 1;
+ requestOrderSound_ = 1;
+ for(const RBAViewContentState* const viewState : activeViewContentStates_) {
+ setOrder(dynamic_cast<const RBAContentState*>(viewState), requestOrderView_);
+ requestOrderView_++;
+ }
+ for(const RBASoundContentState* const soundState : activeSoundContentStates_) {
+ setOrder(dynamic_cast<const RBAContentState*>(soundState), requestOrderSound_);
+ requestOrderSound_++;
+ }
+}
+
+void
+RBAResultSet::updateActiveContentStates()
+{
+ for (auto& state : canceledContentStates_) {
+ static_cast<void>(activeContentStates_.erase(state));
+ if (state->isViewContentState()) {
+ activeViewContentStates_.remove(dynamic_cast<const RBAViewContentState*>(state));
+ } else {
+ activeSoundContentStates_.remove(dynamic_cast<const RBASoundContentState*>(state));
+ }
+ }
+}
+
+void
+RBAResultSet::copyProperties(const std::unique_ptr<RBAResultSet>& resultSet)
+{
+ propertyMap_ = resultSet->propertyMap_;
+}
+
+void
+RBAResultSet::setSceneProperty(const RBAScene* const scene,
+ const std::string& propertyName,
+ const std::int32_t value)
+{
+ propertyMap_[dynamic_cast<const RBASceneImpl*>(scene)->getProperty(propertyName)] = value;
+}
+
+void
+RBAResultSet::setSceneProperty(const RBAAbstractProperty* const property,
+ const std::int32_t value)
+{
+ propertyMap_[property] = value;
+}
+
+std::int32_t
+RBAResultSet::getSceneProperty(const RBAAbstractProperty* const property) const
+{
+ auto it = propertyMap_.find(property);
+ if(it == propertyMap_.end()) {
+ // Property not registered
+ return -99;
+ }
+
+ return it->second;
+}
+
+void
+RBAResultSet::setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing,
+ const RBAContent* const content)
+{
+ event_content_[eventProcessing] = content;
+}
+
+const RBAContent*
+RBAResultSet::getContentOfEventProcessing(const RBAEventProcessing* const eventProcessing) const
+{
+ if (event_content_.find(eventProcessing) != event_content_.end()) {
+ return event_content_.at(eventProcessing);
+ }
+ return nullptr;
+}
+
+bool
+RBAResultSet::hasDisplayingArea(const RBADisplay* const display) const
+{
+ bool displayed {false};
+ const std::list<const RBAArea*> areas {display->getAreas()};
+ const auto areasBegin = areas.begin();
+ const auto areasEnd = areas.end();
+ for(const RBAArea* const area : visibleAreas_) {
+ if (std::find(areasBegin, areasEnd, area) != areasEnd) {
+ displayed = true;
+ break;
+ }
+ }
+ return displayed;
+}
+
+bool
+RBAResultSet::isLater(const RBAContent* const target,
+ const RBAContent* const comparisonTarget) const
+{
+ bool isLaterRes {false};
+ bool isBreak {false};
+
+ if (target->isViewContent()) {
+ const RBAViewContent* const targetContent {
+ dynamic_cast<const RBAViewContent*>(target)};
+ const RBAViewContent* const comparisonTargetContent {
+ dynamic_cast<const RBAViewContent*>(comparisonTarget)};
+ for (auto it = activeViewContentStates_.rbegin();
+ (it != activeViewContentStates_.rend()) && (!isBreak) ; it++) {
+ if ((*it)->getOwner() == targetContent) {
+ isLaterRes = true;
+ isBreak = true;
+ } else if ((*it)->getOwner() == comparisonTargetContent) {
+ isBreak = true;
+ } else {
+ ;
+ }
+ }
+ } else {
+ const RBASoundContent* const targetContent {
+ dynamic_cast<const RBASoundContent*>(target)};
+ const RBASoundContent* const comparisonTargetContent {
+ dynamic_cast<const RBASoundContent*>(comparisonTarget)};
+ for (auto it = activeSoundContentStates_.rbegin();
+ (it != activeSoundContentStates_.rend()) && (!isBreak); it++) {
+ if ((*it)->getOwner() == targetContent) {
+ isLaterRes = true;
+ isBreak = true;
+ } else if ((*it)->getOwner() == comparisonTargetContent) {
+ isBreak = true;
+ } else {
+ ;
+ }
+ }
+ }
+ return isLaterRes;
+}
+
+std::set<const RBASceneImpl*>&
+RBAResultSet::getDifferentConditionScenes(const RBAResultSet& target)
+{
+ // Detect the difference from the target scene On state
+ const std::list<const RBAScene*> targetScenes {target.getActiveScenes()};
+ for (auto& s : activeScenes_) {
+ if (std::find(targetScenes.begin(), targetScenes.end(), s)
+ == targetScenes.end()) {
+ static_cast<void>(differentConditionScenes_.insert(dynamic_cast<const RBASceneImpl*>(s)));
+ }
+ }
+ for (auto& s : targetScenes) {
+ if (std::find(activeScenes_.begin(), activeScenes_.end(), s)
+ == activeScenes_.end()) {
+ static_cast<void>(differentConditionScenes_.insert(dynamic_cast<const RBASceneImpl*>(s)));
+ }
+ }
+
+ // Detect the difference from the target scene property state
+ for (auto& p : propertyMap_) {
+ if (target.getSceneProperty(p.first) != p.second) {
+ static_cast<void>(differentConditionScenes_.insert(p.first->getScene()));
+ }
+ }
+ for (auto& p : target.getScenePropertyMap()) {
+ if (getSceneProperty(p.first) != p.second) {
+ static_cast<void>(differentConditionScenes_.insert(p.first->getScene()));
+ }
+ }
+ return differentConditionScenes_;
+}
+
+void
+RBAResultSet::updateRequestStatus(const RBAContent* const content, const bool isOnRequest)
+{
+ if (isOnRequest) {
+ contentToStatus_[content].onRequest();
+ } else {
+ // When a content "off request" comes in, turn off the content request
+ // even if the requested state is different from Active state at that time.
+ static_cast<void>(contentToStatus_.erase(content));
+ }
+}
+
+void
+RBAResultSet::setStatusType(const RBAContent* const content, const RBAContentStatusType type)
+{
+ contentToStatus_[content].setStatusType(type);
+}
+
+RBAContentStatusType
+RBAResultSet::getStatusType(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content) != contentToStatus_.end()) {
+ return contentToStatus_[content].getStatusType();
+ }else {
+ return RBAContentStatusType::NoRequest;
+ }
+}
+
+bool
+RBAResultSet::isOutput(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content) != contentToStatus_.end()) {
+ return contentToStatus_[content].isDisplayed();
+ } else {
+ return false;
+ }
+}
+
+bool
+RBAResultSet::isStandby(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content)
+ != contentToStatus_.end()) {
+ return contentToStatus_[content].isStandby();
+ } else {
+ return false;
+ }
+}
+
+bool
+RBAResultSet::hasBeenCanceled(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content) != contentToStatus_.end()) {
+ return contentToStatus_[content].hasBeenCanceled();
+ } else {
+ return false;
+ }
+}
+
+bool
+RBAResultSet::hasBeenDisplayed(const RBAContent* const content) const
+{
+ if (contentToStatus_.find(content) != contentToStatus_.end()) {
+ return contentToStatus_[content].hasBeenDisplayed();
+ } else {
+ return false;
+ }
+}
+
+std::unordered_map<const RBAContent*, RBAContentStatus>*
+RBAResultSet::getStatus() const
+{
+ return &contentToStatus_;
+}
+
+#ifdef RBA_USE_LOG
+void
+RBAResultSet::addFailedConstraint(const RBAConstraint* constraint)
+{
+ failedConstraints_.push_back(constraint);
+}
+
+const std::list<const RBAConstraint*>&
+RBAResultSet::getFailedConstraints()
+{
+ return failedConstraints_;
+}
+#endif
+
+const std::unordered_map<const RBAAbstractProperty*, std::int32_t>&
+RBAResultSet::getScenePropertyMap() const
+{
+ return propertyMap_;
+}
+
+void
+RBAResultSet::setOrder(const RBAContentState* const state, const std::int32_t newOrder) const
+{
+ const_cast<RBAContentState*>(state)->setOrder(newOrder);
+}
+
+}
diff --git a/src/core/logic/RBAResultSet.hpp b/src/core/logic/RBAResultSet.hpp
new file mode 100644
index 0000000..3aca4e9
--- /dev/null
+++ b/src/core/logic/RBAResultSet.hpp
@@ -0,0 +1,246 @@
+/**
+ * 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.
+ */
+
+/**
+ * ResultSet (set arbitration result) class header
+ */
+
+#ifndef RBARESULTSET_HPP
+#define RBARESULTSET_HPP
+
+#include <cstdint>
+#include <list>
+#include <memory>
+#include <set>
+#include <unordered_map>
+#include <mutex>
+
+#include "RBAContentStatusType.hpp"
+#include "RBAContentStatus.hpp"
+
+namespace rba
+{
+
+class RBADisplay;
+class RBASize;
+class RBAAllocatable;
+class RBAArea;
+class RBAZone;
+class RBAContent;
+class RBAViewContent;
+class RBASoundContent;
+class RBAContentState;
+class RBAViewContentState;
+class RBASoundContentState;
+class RBAScene;
+class RBASceneImpl;
+class RBAAbstractProperty;
+class RBAEventProcessing;
+class RBAConstraint;
+
+class RBAResultSet
+{
+public:
+ RBAResultSet()=default;
+ RBAResultSet(const RBAResultSet& resultSet);
+ RBAResultSet(const RBAResultSet&&)=delete;
+ RBAResultSet& operator=(const RBAResultSet&)=delete;
+ RBAResultSet& operator=(const RBAResultSet&&)=delete;
+ virtual ~RBAResultSet()=default;
+
+public:
+ // Impl [get VisibleArea/SoundingZone]
+ const std::set<const RBAAllocatable*>& getOutputtingAllocatables() const;
+ const std::list<const RBAArea*>& getVisibleAreas() const;
+ const std::list<const RBAZone*>& getSoundingZones() const;
+
+ // Impl [get Visible/Sounding ContentStates]
+ const std::list<const RBAViewContentState*>& getVisibleContentStates() const;
+ const std::list<const RBASoundContentState*>& getSoundingContentStates() const;
+
+ // Impl [get Active View/Sound ContentStates]
+ const std::set<const RBAContentState*>& getActiveContentStates() const;
+ const std::list<const RBAViewContentState*>& getActiveViewContentStates() const;
+ const std::list<const RBASoundContentState*>& getActiveSoundContentStates() const;
+
+ // Impl [get Active Scenes]
+ const std::list<const RBAScene*>& getActiveScenes() const;
+
+ // Impl [get InvisibleAreas/UnsoundingZone]
+ const std::list<const RBAArea*>& getInvisibleAreas() const;
+ const std::list<const RBAZone*>& getUnsoundingZones() const;
+
+ // Impl [get HiddenAreas/MuteZones]
+ const std::list<const RBAArea*>& getHiddenAreas() const;
+ const std::list<const RBAZone*>& getMuteZones() const;
+
+ // Impl [get Attenuated]
+ const std::list<const RBAZone*>& getAttenuatedZones() const;
+
+ // Impl [get Canceled Contents]
+ const std::list<const RBAViewContent*>& getCanceledViewContents() const;
+ const std::list<const RBASoundContent*>& getCanceledSoundContents() const;
+
+ // Impl [get Standby Contents]
+ const std::list<const RBAViewContent*>& getStandbyViewContents() const;
+ const std::list<const RBASoundContent*>& getStandbySoundContents() const;
+
+ // Impl [get ContentStates]
+ const RBAContentState* getContentState(const RBAAllocatable* const alloc) const;
+ const RBAContentState* getDirectContentState(const RBAAllocatable* const alloc) const;
+
+ // Impl [get Areas/Zones by ConentState]
+ void getAlloc(const RBAContentState* const state,
+ std::list<const RBAAllocatable*>& allocList) const;
+ void getArea(const RBAViewContentState* const state,
+ std::list<const RBAArea*>& areaList) const;
+ void getZone(const RBASoundContentState* const state,
+ std::list<const RBAZone*>& zoneList) const;
+
+ // Impl [get Areas/Zones by Content]
+ void getArea(const RBAViewContent* const content,
+ std::list<const RBAArea*>& areaList) const;
+ void getZone(const RBASoundContent* const content,
+ std::list<const RBAZone*>& zoneList) const;
+
+ // Impl [get Size]
+ const RBASize* getSize(const RBAArea* const area) const;
+
+ // Impl [check Active Scene/Content/ContentState]
+ bool isActive(const RBAScene* const scene) const;
+ bool isActive(const RBAContent* const content) const;
+ bool isActive(const RBAContentState* const state) const;
+ const RBAContentState* getReqestState(const RBAContent* const content) const;
+
+ // Impl [check Outputting Allocatable/ContentState]
+ bool isOutputting(const RBAAllocatable* const alloc) const;
+ bool isOutputting(const RBAContentState* const state) const;
+
+ // Impl [check Hidden]
+ bool isHidden(const RBAAllocatable* const alloc) const;
+
+ // Impl [check Attenuated Zone]
+ bool isAttenuated(const RBAZone* const zone) const;
+
+ // Impl [check Cancel ContentState]
+ bool isCancel(const RBAContentState* const state) const;
+
+ // Impl [check Aleady OutPutting]
+ bool isAlreadyOutputting(const RBAContentState* const state) const;
+
+ // Impl [set Active Scene/ContentState]
+ void setActive(const RBAScene* const scene, const bool newActive);
+ void setActive(const RBAContentState* const state, const bool newActive);
+
+ // [cancel ContentState]
+ void cancelContentState(const RBAContentState* const state);
+
+ // Impl [set Cancel ContentState]
+ void setCancel(const RBAContentState* const state, const bool checked);
+
+ // Impl [set ContentState]
+ void setContentState(const RBAAllocatable* const alloc, const RBAContentState* const state);
+
+ // Impl [add Outputting ContentState]
+ void addOutputtingContentState(const RBAContentState* const state);
+
+ // Impl [add Standby Content]
+ void addStandbyContent(const RBAContent* const content);
+
+ // [activeView]
+ void copyActives(const std::unique_ptr<RBAResultSet>& resultSet);
+ void updateActiveContentStates();
+
+ // [Property]
+ void copyProperties(const std::unique_ptr<RBAResultSet>& resultSet);
+ void setSceneProperty(const RBAScene* const scene,
+ const std::string& propertyName,
+ const std::int32_t value);
+ void setSceneProperty(const RBAAbstractProperty* const property,
+ const std::int32_t value);
+ std::int32_t getSceneProperty(const RBAAbstractProperty* const property) const;
+
+ // [EventProcessing]
+ void setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing,
+ const RBAContent* const content);
+ const RBAContent* getContentOfEventProcessing(const RBAEventProcessing* const eventProcessing) const;
+
+ // [DisplayContents]
+ bool hasDisplayingArea(const RBADisplay* const display) const;
+
+ // common
+ bool isLater(const RBAContent* const target, const RBAContent* const comparisonTarget) const;
+ std::set<const RBASceneImpl*>& getDifferentConditionScenes(const RBAResultSet& target);
+ void updateRequestStatus(const RBAContent* const content, const bool isOnRequest);
+ void setStatusType(const RBAContent* const content, const RBAContentStatusType type);
+ RBAContentStatusType getStatusType(const RBAContent* const content) const;
+ bool isOutput(const RBAContent* const content) const;
+ bool isStandby(const RBAContent* const content) const;
+ bool hasBeenCanceled(const RBAContent* const content) const;
+ bool hasBeenDisplayed(const RBAContent* const content) const;
+ std::unordered_map<const RBAContent*, RBAContentStatus>* getStatus() const;
+#ifdef RBA_USE_LOG
+ void addFailedConstraint(const RBAConstraint* constraint);
+ const std::list<const RBAConstraint*>& getFailedConstraints();
+#endif
+
+private:
+ const std::unordered_map<const RBAAbstractProperty*, std::int32_t>& getScenePropertyMap() const;
+ void setOrder(const RBAContentState* const state, const std::int32_t newOrder) const;
+
+ std::set<const RBAAllocatable*> outputtingAllocs_;
+ std::set<const RBAAllocatable*> hiddenAllocs_;
+ std::set<const RBAContentState*> activeContentStates_;
+ std::set<const RBAContentState*> canceledContentStates_;
+ std::unordered_map<const RBAAllocatable*, const RBAContentState*> allocToContentState_;
+
+ // The lists for getList type acquisition function
+ std::list<const RBAArea*> visibleAreas_;
+ std::list<const RBAZone*> soundingZones_;
+ std::list<const RBAArea*> invisibleAreas_;
+ std::list<const RBAZone*> unsoundingZones_;
+ std::list<const RBAArea*> hiddenAreas_;
+ std::list<const RBAZone*> muteZones_;
+ std::list<const RBAZone*> attenuatedZones_;
+ std::list<const RBAViewContent*> canceledViewContents_;
+ std::list<const RBASoundContent*> canceledSoundContents_;
+ std::list<const RBAViewContent*> standbyViewContents_;
+ std::list<const RBASoundContent*> standbySoundContents_;
+ std::list<const RBAViewContentState*> visibleContentStates_;
+ std::list<const RBASoundContentState*> soundingContentStates_;
+ std::list<const RBAViewContentState*> activeViewContentStates_;
+ std::list<const RBASoundContentState*> activeSoundContentStates_;
+
+ // common
+ std::int32_t requestOrderView_ {1};
+ std::int32_t requestOrderSound_ {1};
+ std::list<const RBAScene*> activeScenes_;
+ std::unordered_map<const RBAAbstractProperty*, std::int32_t> propertyMap_;
+ std::unordered_map<const RBAEventProcessing*, const RBAContent*> event_content_;
+ mutable std::unordered_map<const RBAContent*, RBAContentStatus> contentToStatus_;
+ std::set<const RBASceneImpl*> differentConditionScenes_;
+
+ mutable std::unordered_map<const RBAContent*, const RBAContentState*> requestContentStateMap_;
+
+ mutable std::mutex mutex_;
+#ifdef RBA_USE_LOG
+ std::list<const RBAConstraint*> failedConstraints_;
+#endif
+
+};
+
+}
+#endif
diff --git a/src/core/logic/RBARollbacker.cpp b/src/core/logic/RBARollbacker.cpp
new file mode 100644
index 0000000..9870fa9
--- /dev/null
+++ b/src/core/logic/RBARollbacker.cpp
@@ -0,0 +1,95 @@
+/**
+ * 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.
+ */
+
+/**
+ * Rollbacker (rollback of arbitration results) class implementation
+ */
+
+#include "RBARollbacker.hpp"
+#include "RBAModelImpl.hpp"
+#include "RBABackUpAllocatable.hpp"
+#include "RBAArbitrator.hpp"
+
+namespace rba
+{
+
+RBARollbacker::~RBARollbacker() noexcept
+{
+ children_.clear();
+}
+
+void
+RBARollbacker::addChild(const std::shared_ptr<RBARollbacker> child)
+{
+ children_.push_back(child);
+}
+
+void
+RBARollbacker::removeChild(const std::shared_ptr<RBARollbacker> child)
+{
+ children_.remove(child);
+}
+
+void
+RBARollbacker::backup(std::list<const RBAAllocatable*>& backuplist)
+{
+ backupMap_.clear();
+ for(const RBAAllocatable* const original : backuplist) {
+ std::unique_ptr<RBAAllocatable> backupObj
+ {std::make_unique<RBABackUpAllocatable>("backup_"
+ + original->getElementName())};
+ copyAllocatable(original, backupObj.get());
+ backupMap_[original] = std::move(backupObj);
+ }
+}
+
+void
+RBARollbacker::rollback()
+{
+ for (auto& Child : children_) {
+ // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2)
+ // [Contents that deviate from the rules]
+ // rollback() is called recursively
+ // [Explanation that there is no problem if you deviate from the rules]
+ // RBARollbacker is created each time the re-arbitration nest becomes
+ // deeper, but since the infinite loop prevention process is implemented
+ // in re-arbitration, stack overflow does not occur.
+ Child->rollback();
+ }
+ for(auto itr = backupMap_.begin(); itr != backupMap_.end(); ++itr) {
+ const RBAAllocatable* const original {itr->first};
+ const RBAAllocatable* const backupVal {itr->second.get()};
+ copyAllocatable(backupVal, const_cast<RBAAllocatable*>(original));
+ }
+}
+
+void
+RBARollbacker::copyAllocatable(const RBAAllocatable* const from,
+ RBAAllocatable* const to)
+{
+ to->setHiddenChecked(from->isHiddenChecked());
+ to->setHidden(from->isHidden());
+ to->setChecked(from->isChecked());
+ to->setState(from->getState());
+ to->clearAllocatablesAffectedByYou();
+ for(const RBAAllocatable* const allocatable : from->getAllocatablesAffectedByYou()) {
+ to->addAllocatableWhichHasBeenAffectedByYou(allocatable);
+ }
+ to->setAttenuateChecked(from->isAttenuateChecked());
+ to->setAttenuated(from->isAttenuated());
+}
+
+}
diff --git a/src/core/logic/RBARollbacker.hpp b/src/core/logic/RBARollbacker.hpp
new file mode 100644
index 0000000..08ee4e9
--- /dev/null
+++ b/src/core/logic/RBARollbacker.hpp
@@ -0,0 +1,84 @@
+/**
+ * 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.
+ */
+
+/**
+ * Rollbacker (rollback of arbitration results) class header
+ */
+
+#ifndef RBARROLLBACKER_HPP
+#define RBARROLLBACKER_HPP
+
+#include <unordered_map>
+#include <memory>
+#include <list>
+
+namespace rba
+{
+class RBAModel;
+class RBAAllocatable;
+class RBAArbitrator;
+
+class RBARollbacker
+{
+ public:
+ RBARollbacker()=default;
+ RBARollbacker(const RBARollbacker&)=delete;
+ RBARollbacker(const RBARollbacker&&)=delete;
+ RBARollbacker& operator=(const RBARollbacker&)=delete;
+ RBARollbacker& operator=(const RBARollbacker&&)=delete;
+ virtual ~RBARollbacker() noexcept;
+
+ /**
+ * Register a backup for child re-arbitration when execute re-arbitration
+ * during re-arbitration.
+ * Restore child backup when rolling back
+ */
+ void addChild(const std::shared_ptr<RBARollbacker> child);
+
+ void removeChild(const std::shared_ptr<RBARollbacker> child);
+
+ /**
+ * Back up arbitration status and impact information.
+ * (Only "Allocatable" that directly arbitration is backed up)
+ * Child will back up re-arbitraion during execution of re-aribitration.
+ *
+ * Backing up all "Allocatable" on a model is inefficient,
+ * so back up only those that execute re-arbitration
+ */
+ void backup(std::list<const RBAAllocatable*>& backuplist);
+
+ /**
+ * Roll back the arbitration state and impact information to
+ * the state when the instance was created
+ */
+ void rollback();
+
+ private:
+ /**
+ * @brief Copy Allocable arbitration state
+ * @param from source of copy
+ * @param to destination of copy
+ */
+ void copyAllocatable(const RBAAllocatable* const from, RBAAllocatable* const to);
+
+ std::list<std::shared_ptr<RBARollbacker>> children_;
+ // Rollback information when arbitration fails
+ std::unordered_map<const RBAAllocatable*, std::unique_ptr<RBAAllocatable>> backupMap_;
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAViewAction.cpp b/src/core/logic/RBAViewAction.cpp
new file mode 100644
index 0000000..54553dc
--- /dev/null
+++ b/src/core/logic/RBAViewAction.cpp
@@ -0,0 +1,88 @@
+/**
+ * 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.
+ */
+
+/**
+ * ViewAction Class implementation
+ */
+
+#include "RBAArea.hpp"
+#include "RBAViewContent.hpp"
+#include "RBAViewContentState.hpp"
+#include "RBAViewAction.hpp"
+#include "RBAViewMove.hpp"
+#include "RBAViewTransition.hpp"
+
+namespace rba {
+
+const RBAArea*
+RBAViewAction::getArea() const
+{
+ return nullptr;
+}
+
+const RBAViewContent*
+RBAViewAction::getFromContent() const
+{
+ return nullptr;
+}
+
+const RBAViewContent*
+RBAViewAction::getToContent() const
+{
+ return nullptr;
+}
+
+const RBAViewContentState*
+RBAViewAction::getFromContentState() const
+{
+ return nullptr;
+}
+
+const RBAViewContentState*
+RBAViewAction::getToContentState() const
+{
+ return nullptr;
+}
+
+const RBAArea*
+RBAViewAction::getFromArea() const
+{
+ return nullptr;
+}
+
+const RBAArea*
+RBAViewAction::getToArea() const
+{
+ return nullptr;
+}
+
+const RBAViewContent*
+RBAViewAction::getContent() const
+{
+ // This function is never called because the function of the derived class
+ // is always called
+ return nullptr;
+}
+
+const RBAViewContentState*
+RBAViewAction::getContentState() const
+{
+ // This function is never called because the function of the derived class
+ // is always called
+ return nullptr;
+}
+
+}
diff --git a/src/core/logic/RBAViewMove.cpp b/src/core/logic/RBAViewMove.cpp
new file mode 100644
index 0000000..7e40043
--- /dev/null
+++ b/src/core/logic/RBAViewMove.cpp
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBAViewMove.cpp
+ */
+
+#include "RBAArea.hpp"
+#include "RBAViewContent.hpp"
+#include "RBAViewContentState.hpp"
+#include "RBAViewMove.hpp"
+
+namespace rba {
+
+RBAViewMove::RBAViewMove(const RBAArea* const newFromArea, const RBAArea* const newToArea,
+ const RBAViewContentState* const newContentState)
+ : RBAViewAction{}
+{
+ fromArea_ = newFromArea;
+ toArea_ = newToArea;
+ contentState_ = newContentState;
+}
+
+RBAViewMove::RBAViewMove(const RBAViewMove& viewMove)
+ : RBAViewAction{viewMove}
+{
+ fromArea_ = viewMove.fromArea_;
+ toArea_ = viewMove.toArea_;
+ contentState_ = viewMove.contentState_;
+}
+
+bool
+RBAViewMove::operator==(const RBAViewAction& viewAction)
+{
+ if(getViewActionType() != viewAction.getViewActionType()) {
+ // False if the view action types do not match
+ return false;
+ }
+
+ const RBAViewMove* const viewMove {dynamic_cast<const RBAViewMove*>(&viewAction)};
+ return ((fromArea_ == viewMove->fromArea_) &&
+ (toArea_ == viewMove->toArea_) &&
+ (contentState_ == viewMove->contentState_));
+}
+
+const RBAArea*
+RBAViewMove::getFromArea() const
+{
+ return fromArea_;
+}
+
+const RBAArea*
+RBAViewMove::getToArea() const
+{
+ return toArea_;
+}
+
+const RBAViewContent*
+RBAViewMove::getContent() const
+{
+ return contentState_->getOwner();
+}
+
+const RBAViewContentState*
+RBAViewMove::getContentState() const
+{
+ return contentState_;
+}
+
+RBAViewActionType
+RBAViewMove::getViewActionType() const
+{
+ return RBAViewActionType::MOVE;
+}
+
+}
diff --git a/src/core/logic/RBAViewMove.hpp b/src/core/logic/RBAViewMove.hpp
new file mode 100644
index 0000000..2b8db08
--- /dev/null
+++ b/src/core/logic/RBAViewMove.hpp
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+/**
+ * RBAViewMove.hpp
+ */
+
+#ifndef RBAVIEWMOVE_HPP
+#define RBAVIEWMOVE_HPP
+
+#include "RBAViewActionType.hpp"
+#include "RBAViewAction.hpp"
+
+namespace rba {
+
+class RBAArea;
+class RBAViewContent;
+class RBAViewContentState;
+
+class DLL_EXPORT RBAViewMove : public RBAViewAction
+{
+public:
+ RBAViewMove(const RBAArea* const newFromArea, const RBAArea* const newToArea,
+ const RBAViewContentState* const newContentState);
+ RBAViewMove(const RBAViewMove& viewMove);
+ RBAViewMove(const RBAViewMove&&)=delete;
+ RBAViewMove& operator=(const RBAViewMove&)=delete;
+ RBAViewMove& operator=(const RBAViewMove&&)=delete;
+ virtual ~RBAViewMove()=default;
+
+ bool operator==(const RBAViewAction& viewAction) override;
+
+public:
+ const RBAArea* getFromArea() const override;
+ const RBAArea* getToArea() const override;
+ const RBAViewContent* getContent() const override;
+ const RBAViewContentState* getContentState() const override;
+ RBAViewActionType getViewActionType() const override;
+
+private:
+ const RBAArea* fromArea_ {nullptr};
+ const RBAArea* toArea_ {nullptr};
+ const RBAViewContentState* contentState_ {nullptr};
+
+};
+
+}
+
+#endif
diff --git a/src/core/logic/RBAViewTransition.cpp b/src/core/logic/RBAViewTransition.cpp
new file mode 100644
index 0000000..93b86a7
--- /dev/null
+++ b/src/core/logic/RBAViewTransition.cpp
@@ -0,0 +1,137 @@
+/**
+ * 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.
+ */
+
+/**
+ * RBAViewTransition.cpp
+ */
+
+#include "RBAArea.hpp"
+#include "RBAViewContent.hpp"
+#include "RBAViewContentState.hpp"
+#include "RBAViewTransition.hpp"
+
+namespace rba {
+
+RBAViewTransition::RBAViewTransition(
+ const RBAViewActionType newViewActionType, const RBAArea* const newArea,
+ const RBAViewContentState* const newContentState1,
+ const RBAViewContentState* const newContentState2)
+ : RBAViewAction(),
+ viewActionType_{newViewActionType},
+ area_{newArea},
+ contentState1_{newContentState1},
+ contentState2_{newContentState2}
+{
+}
+
+RBAViewTransition::RBAViewTransition(const RBAViewTransition& viewTrans)
+ : RBAViewAction{viewTrans}
+{
+ viewActionType_ = viewTrans.viewActionType_;
+ area_ = viewTrans.area_;
+ contentState1_ = viewTrans.contentState1_;
+ contentState2_ = viewTrans.contentState2_;
+}
+
+bool
+RBAViewTransition::operator==(const RBAViewAction& viewAction)
+{
+ if(getViewActionType() != viewAction.getViewActionType()) {
+ // False if the view action types do not match
+ return false;
+ }
+
+ const RBAViewTransition* const viewTran
+ {dynamic_cast<const RBAViewTransition*>(&viewAction)};
+ return ((area_ == viewTran->area_) &&
+ (contentState1_ == viewTran->contentState1_) &&
+ (contentState2_ == viewTran->contentState2_));
+}
+
+const RBAArea*
+RBAViewTransition::getArea() const
+{
+ return area_;
+}
+
+const RBAViewContent*
+RBAViewTransition::getFromContent() const
+{
+ if((contentState1_ == nullptr) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_ADD) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) {
+ return nullptr;
+ }
+ return contentState1_->getOwner();
+}
+
+const RBAViewContent*
+RBAViewTransition::getToContent() const
+{
+ if((contentState2_ == nullptr) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_ADD) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) {
+ return nullptr;
+ }
+ return contentState2_->getOwner();
+}
+
+const RBAViewContentState*
+RBAViewTransition::getFromContentState() const
+{
+ if((viewActionType_ == RBAViewActionType::TRANSITION_ADD) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) {
+ return nullptr;
+ }
+ return contentState1_;
+}
+
+const RBAViewContentState*
+RBAViewTransition::getToContentState() const
+{
+ if((viewActionType_ == RBAViewActionType::TRANSITION_ADD) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) {
+ return nullptr;
+ }
+ return contentState2_;
+}
+
+const RBAViewContent*
+RBAViewTransition::getContent() const
+{
+ if((contentState1_ == nullptr) ||
+ (viewActionType_ == RBAViewActionType::TRANSITION_REPLACE)) {
+ return nullptr;
+ }
+ return contentState1_->getOwner();
+}
+
+const RBAViewContentState*
+RBAViewTransition::getContentState() const
+{
+ if(viewActionType_ == RBAViewActionType::TRANSITION_REPLACE) {
+ return nullptr;
+ }
+ return contentState1_;
+}
+
+RBAViewActionType
+RBAViewTransition::getViewActionType() const
+{
+ return viewActionType_;
+}
+
+}
diff --git a/src/core/logic/RBAViewTransition.hpp b/src/core/logic/RBAViewTransition.hpp
new file mode 100644
index 0000000..1b9338f
--- /dev/null
+++ b/src/core/logic/RBAViewTransition.hpp
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+ /**
+ * RBAViewTransition.hpp
+ */
+
+#ifndef RBAVIEWTRANSITION_HPP
+#define RBAVIEWTRANSITION_HPP
+
+#include "RBAViewAction.hpp"
+
+namespace rba {
+
+class RBAArea;
+
+class DLL_EXPORT RBAViewTransition : public RBAViewAction
+{
+public:
+ RBAViewTransition(const RBAViewActionType newViewActionType, const RBAArea* const newArea,
+ const RBAViewContentState* const newContentState1,
+ const RBAViewContentState* const newContentState2 = nullptr);
+ RBAViewTransition(const RBAViewTransition& viewTrans);
+ RBAViewTransition(const RBAViewTransition&&)=delete;
+ RBAViewTransition& operator=(const RBAViewTransition&)=delete;
+ RBAViewTransition& operator=(const RBAViewTransition&&)=delete;
+ virtual ~RBAViewTransition()=default;
+
+ bool operator==(const RBAViewAction& viewAction) override;
+
+public:
+ const RBAArea* getArea() const override;
+
+ const RBAViewContent* getFromContent() const override;
+ const RBAViewContent* getToContent() const override;
+ const RBAViewContentState* getFromContentState() const override;
+ const RBAViewContentState* getToContentState() const override;
+ const RBAViewContent* getContent() const override;
+ const RBAViewContentState* getContentState() const override;
+ RBAViewActionType getViewActionType() const override;
+
+private:
+ RBAViewActionType viewActionType_;
+ const RBAArea* area_;
+ const RBAViewContentState* contentState1_;
+ const RBAViewContentState* contentState2_;
+};
+
+}
+
+#endif