diff options
author | Kenji Hosokawa <khosokawa@jp.adit-jv.com> | 2020-08-24 21:58:42 +0900 |
---|---|---|
committer | Kenji Hosokawa <khosokawa@jp.adit-jv.com> | 2020-08-24 21:58:42 +0900 |
commit | 2b4ae7fde370bc3316ab30cc38b74d23e785b360 (patch) | |
tree | 41b6eb70b3419c2fbd192ed133c5890a985eddec /include | |
parent | 6694a4d2952ebd171564932200cac00d6e5792f4 (diff) |
First commitjellyfish_9.99.4jellyfish/9.99.49.99.4
Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Change-Id: I381abb0a6521f5349768a76ef7ceecbce4b2d701
Diffstat (limited to 'include')
-rw-r--r-- | include/rba/RBAArbitrationPolicy.hpp | 48 | ||||
-rw-r--r-- | include/rba/RBAArbitrator.hpp | 600 | ||||
-rw-r--r-- | include/rba/RBAArea.hpp | 92 | ||||
-rw-r--r-- | include/rba/RBABasePoint.hpp | 75 | ||||
-rw-r--r-- | include/rba/RBAContentLoserType.hpp | 36 | ||||
-rw-r--r-- | include/rba/RBADisplay.hpp | 56 | ||||
-rw-r--r-- | include/rba/RBAJsonParser.hpp | 85 | ||||
-rw-r--r-- | include/rba/RBAModel.hpp | 241 | ||||
-rw-r--r-- | include/rba/RBAPositionContainer.hpp | 72 | ||||
-rw-r--r-- | include/rba/RBAResult.hpp | 861 | ||||
-rw-r--r-- | include/rba/RBAResultStatusType.hpp | 42 | ||||
-rw-r--r-- | include/rba/RBAScene.hpp | 74 | ||||
-rw-r--r-- | include/rba/RBASize.hpp | 74 | ||||
-rw-r--r-- | include/rba/RBASoundContent.hpp | 83 | ||||
-rw-r--r-- | include/rba/RBASoundContentState.hpp | 119 | ||||
-rw-r--r-- | include/rba/RBAViewAction.hpp | 147 | ||||
-rw-r--r-- | include/rba/RBAViewActionType.hpp | 41 | ||||
-rw-r--r-- | include/rba/RBAViewContent.hpp | 89 | ||||
-rw-r--r-- | include/rba/RBAViewContentState.hpp | 119 | ||||
-rw-r--r-- | include/rba/RBAZone.hpp | 72 |
20 files changed, 3026 insertions, 0 deletions
diff --git a/include/rba/RBAArbitrationPolicy.hpp b/include/rba/RBAArbitrationPolicy.hpp new file mode 100644 index 0000000..42d49f6 --- /dev/null +++ b/include/rba/RBAArbitrationPolicy.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Arbitration policy class + */ + +#ifndef RBAARBITRATIONPOLICY_HPP +#define RBAARBITRATIONPOLICY_HPP + +namespace rba +{ + +/** + * @enum RBAArbitrationPolicy + * Type of arbitration policy. + */ +enum class RBAArbitrationPolicy : std::uint8_t +{ + /** + * @brief Same PRIORITY_LAST_COME_FIRST. + */ + DEFAULT, + /** + * @brief First Come First Arbitration. + * @details give priority to first come request. + */ + FIRST_COME_FIRST, + /** + * @brief Last Come First Arbitration. + * @details give priority to last come request. + */ + LAST_COME_FIRST, + /** + * @brief Priority and First Come First Arbitration. + * @details Follow the Priority of Contents. + * If same priority then give priority to first come request. + */ + PRIORITY_FIRST_COME_FIRST, + /** + * @brief Priority and Last Come First Arbitration. + * @details Follow the Priority of Contents. + * If same priority then give priority to last come request. + */ + PRIORITY_LAST_COME_FIRST +}; + +} + +#endif diff --git a/include/rba/RBAArbitrator.hpp b/include/rba/RBAArbitrator.hpp new file mode 100644 index 0000000..c7c2761 --- /dev/null +++ b/include/rba/RBAArbitrator.hpp @@ -0,0 +1,600 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Arbitrator Logic class + */ + +#ifndef RBAARBITORATOR_HPP +#define RBAARBITORATOR_HPP + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +#include <string> +#include <list> +#include <memory> +#include <mutex> +#include <deque> +#include "RBAModel.hpp" +#include "RBAResult.hpp" +#include "RBARequestQueMember.hpp" +#include "RBAResultSet.hpp" +#include "RBAResultImpl.hpp" + +/** + * @namespace rba + * @brief The namespace defined by Rule Based Arbitration Framework. + */ +namespace rba +{ + +// internal { +#ifdef RBA_USE_LOG +class RBALogManager; +#endif + +class RBARuleObject; +class RBAExpression; +class RBAModelImpl; +class RBAAffectInfo; +class RBARollbacker; +class RBAWindowRouter; +class RBAConstraintImpl; +// } + +/** + * @class RBAArbitrator + * An object that performs arbitration processing based on rules + * generated from a model.<br> + * Set the model generated using rba::RBAJsonParser in the constructor. + */ +class DLL_EXPORT RBAArbitrator +{ +public: + /** + * @brief Arbitrator logic constractor. + * @param newModel Processing model. + * The model is generated by rba::RBAJsonParser. + */ + RBAArbitrator()=default; + RBAArbitrator(RBAModel* newModel); + + /** + * @brief Arbitrator logic destractor. + */ + RBAArbitrator(const RBAArbitrator&)=delete; + RBAArbitrator(const RBAArbitrator&&)=delete; + RBAArbitrator& operator=(const RBAArbitrator&)=delete; + RBAArbitrator& operator=(const RBAArbitrator&&)=delete; + virtual ~RBAArbitrator() noexcept; + +public: + + /** + * @brief Sets the model for arbitration + * The model is generated by rba::RBAJsonParser. + * @param newModel The model for arbitration + * @details Replace the model with newModel. An arbitrator has only one model at all times. + * Model can be generated by using rba::RBAJsonParser. + * nullptr can not be set. + */ + void setModel(RBAModel* newModel); + + /** + * @brief Returns the model for arbitration + * @return model The model for arbitration + * @details Because the arbitrator always has a model, this API never returns nullptr. + */ + const RBAModel* getModel() const; + + /** + * @brief Set initial requirements of contents and scenes + * @param contexts Context list of contents and scenes requests. + * + * Following is the structure of context name.\n + * *<CONTENT_NAME>* / *<STATE_NAME>* \n\n + * Example of context name: \n + * TEL/Calling\n + * TPMS/NORMAL\n + * AutoDriveScene\n\n + * You can omit "/ <STATE_NAME>" if content has only one state. + * @details After arbitrator creation or calling clearArbitration(), + * you can set initial state of contents and scenes for first arbitration. + * This API does not execute arbitration. + * The information of arbitration result will be empty. + * Don't call this API after starting arbitration until calling clearArbitration(). + * @details + * **Example** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * + * std::list<std::string> defaultContents = { + * "CONTENT_A/NORMAL", + * "CONTENT_B/NORMAL", + * "CONTENT_C/NORMAL", + * "CONTENT_D/NORMAL", + * }; + * arb->initialize(defaultContents); + * std::unique_ptr<RBAResult> result = arb->execute(); + * ``` + */ + void initialize(std::list<std::string>& contexts); + + /** + * @brief Executes arbitration with one requirement\n + * @param contextName + * Context string of arbitration request.\n + * Display request or sound request : "<CONTENT_NAME>/<STATE_NAME>"\n + * If the content has only one state, the <STATE> can be omitted.\n + * \n + * Scene request : ”<SCENE_NAME>” + * @param require + * true : request displaying / outputting content or scene on (default)\n + * false : withdraw a request or scene off. + * + * @return The result of arbitration. + * @details + * Execute Arbitration with one requirement of a content or scene without properties. \n + * The arbitration result as the return value will be generated at every arbitration and + * will not be changed by another arbitration. + * \n + * Context indicates a content state or a scene. + * If the content or scene is not defined in the model, the arbitration will not executed + * and the state of the arbitration result will be UNKNWON_CONTENT_STATE. + * In this case, other property values are undefined.\n + * If the context is empty, this API just execute arbitration. + * \n + * **Exapmle** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * std::unique_ptr<RBAResult> result = arb->execute("CONTENT_A/NORMAL", true); + * + * if(result->getStatusType() != rba::RBAResultStatusType::SUCCESS) { + * std::cout << "ERROR: Unknown context" << std::endl; + * } + * ``` + * + */ + std::unique_ptr<RBAResult> execute(const std::string& contextName="", + bool require=true); + + /** + * @brief Executes arbitration with multiple requirements\n + * @param contexts List of contexts. + * @param require + * true : request displaying / outputting content or scene on (default)\n + * false : withdraw a request or scene off. + * @return The result of arbitration. + * @details + * \n + * Execute Arbitration with multiple requirements of contents or scenes. \n + * Contents and Scenes can be mixed in the list. + * Display / Outputting request and withdraw request, scene on and scene off request can not be mixed. + * The arbitration result as the return value will be generated at every arbitration and + * will not be changed by another arbitration. + * \n + * Context indicates a content state or a scene. + * If the content or scene is not defined in the model, the arbitration will not executed + * and the state of the arbitration result will be UNKNWON_CONTENT_STATE.\n + * In this case, other property values are undefined.\n + * If the context is empty, this API just execute arbitration. + * \n + * Request order is the with the list. Beginning of the list will be treated as the first coming request. + * \n + * **Exapmle** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * std::list<std::string> contents = { + * "CONTENT_A/NORMAL", + * "CONTENT_B/NORMAL", + * "CONTENT_C/NORMAL", + * "CONTENT_D/NORMAL", + * }; + * std::unique_ptr<RBAResult> result = arb->execute(contents, true); + * + * if(result->getStatusType() != rba::RBAResultStatusType::SUCCESS) { + * std::cout << "ERROR: Unknown context" << std::endl; + * } + * ``` + * + */ + std::unique_ptr<RBAResult> execute(std::list<std::string>& contexts, + bool require=true); + + /** + * @brief Executes arbitration with a requirement of scene and scene properties. + * @param sceneName The Scene name of arbitration reauest.\n + * @param properties The list of pairs of property name and value. + * @return The result of arbitration. + * @details + * \n + * Sets the scene indicated by sceneName to the property specified + * by properties, and execute arbitration processing.\n + * If sceneName is empty, this API just execute arbitration. + * If the required scene is not defined in the model, the arbitration will not executed + * and the state of the arbitration result will be UNKNWON_CONTENT_STATE.\n + * Even If there is a property not defined in the model, the arbitration will be executed. + * \n + * @note + * You cannot set scene off and property at the same time, by this API.\n + * Use setScene() to set scene off and properties, + * and then call execute(const std::string&,bool) without specifying arguments.\n + * Or Use setScene() to set properties, + * and then call execute(scene name,false).\n + * \n + * @details + * **Example** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * std::list<std::pair<std::string, std::int32_t>> properties; + * properties.push_back(std::make_pair("Prop1", 10)); + * properties.push_back(std::make_pair("Prop2", 20)); + * std::unique_ptr<RBAResult> result = arb->execute("Scene1", properties); + * + * if(result->getStatusType() != rba::RBAResultStatusType::SUCCESS) { + * std::cout << "ERROR: Unknown context" << std::endl; + * } + * ``` + */ + std::unique_ptr<RBAResult> execute(const std::string& sceneName, + std::list<std::pair<std::string,std::int32_t>>& properties); + + /** + * @brief Replaces the result of arbitration + * @param allocatableName area or zone name + * @param contextName Context string of arbitration request. + * @return The result of arbitration. + * @details + * \n + * Replace allocated a content state to area or zone of the last arbitration result.\n + * If the allocatableName or contextName is undefined, return the errror + * code from the method getStatusType() of result.\n + * If the contextName is non-active, activate the content request. + * This API execute the "Request handling on lost" process and the + * "Execution expression" process, and doesn't execute the check of + * constraint expression process. + * Therefore, this API can lead the result that does not satisfy the constraints\n + * If the specified area or zone by allocatableName is hidden, mute or + * attenuated, these statuses will be kept. + * @deprecated Because there is a possibility that the result does not satisfy + * the constraints, please use execute() + * instead of this API.\n + * \n + * @details + * **Example** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * std::unique_ptr<RBAResult> result = arb->execute("CONTENT_A/NORMAL", true); + * std::unique_ptr<RBAResult> result_replaced = arb->setResultContentState("AREA_A", "CONTENT_B/NORMAL"); + * + * if(result_replaced->getStatusType() != rba::RBAResultStatusType::SUCCESS) { + * std::cout << "ERROR" << std::endl; + * } + * ``` + */ + std::unique_ptr<RBAResult> + setResultContentState(const std::string& allocatableName, + const std::string& contextName); + + /** + * @brief Cancel last arbitration + * @return The result of arbitration. + * @details + * \n + * Cancel last arbitration and restore internal state immediately.\n + * This API returns the restored result but the ViewActions will be empty.\n + * Do not execute this function more than once continuously. In that case, + * an error occurs.\n + * Even when executed without performing arbitration processing, + * an error occurs.\n + * In case of error, the status of the arbitration result is set to + * CANCEL_ERROR.\n + * \n + * @details + * **Example** + * + * ``` + * RBAJsonParser parser; + * rba::RBAModel* model = parser.parse(JSONFILE_PATH); + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * std::unique_ptr<RBAResult> result = arb->execute("CONTENT_A/NORMAL", true); + * std::unique_ptr<RBAResult> result_back = arb->cancelArbitration() + * + * if(result_replaced->getStatusType() != rba::RBAResultStatusType::SUCCESS) { + * std::cout << "ERROR" << std::endl; + * } + * ``` + */ + std::unique_ptr<RBAResult> cancelArbitration(); + + /** + * @brief Clear internal states of arbitration. + * @details + * \n + * Initialize internal states of arbitration (ex. Previous arbitration + * result, request of content states, etc...) and set to the initial state.\n + * \n + * @note + * This API is intended for setting up initial state of unit tests.\n + * \n + * @details + * **Example** + * + * ``` + * std::unique_ptr<RBAResult> result1 = arb->execute("CONTENT_A/NORMAL", true); + * std::unique_ptr<RBAResult> result2 = arb->execute("CONTENT_B/NORMAL", true); + * // reset display requests + * arb->clearArbitration(); + * std::unique_ptr<RBAResult> result2 = arb->execute("CONTENT_C/NORMAL", true); + * std::unique_ptr<RBAResult> result3 = arb->execute("CONTENT_D/NORMAL", true); + + * + * ``` + */ + void clearArbitration(); + + /** + * @brief Sets scene ON/OFF requests and properties. + * @param sceneName The Scene name of arbitration reauest.\n + * @param require true : Valid request.\n + * false : Invalid request. + * @param properties The pair of property name and value.\n + * @return true: Success\n + * @return false: Unknown scene\n + * @details + * \n + * Sets the scene indicated by sceneName to the property specified + * by properties, and without execute arbitration processing.\n + * Returns true if the scene set succeeded. If an unknown scene name is + * specified, false is returned.\n + * \n + * @note + * This API is intended for setting up initial state of unit tests\n + * or setting global scene and scene properties.\n + * \n + * @details + * **Example** + * + * ``` + * std::list<std::pair<std::string, std::int32_t>> props; + * props.push_back(std::make_pair("PropertyA", 10); + * props.push_back(std::make_pair("PropertyB", -3); + * res = arb->setScene("SCENE_A", true, props); + * if(res == false) { + * // Unknwon scene + * } + * ``` + */ + bool setScene(const std::string& sceneName, bool require, + std::list<std::pair<std::string, std::int32_t>>& properties); + + /** + * @brief Sets content requests or scene ON/OFF request. + * @param contextName Context string of arbitration request.\n + * @param require + * true : request displaying / outputting content or scene on (default)\n + * false : withdraw a request or scene off. + * @return true: Success\n + * @return false: Unknown context\n + * @details + * \n + * Sets a display request for the context without arbitration.\n + * Returns true if the request setting is succeeded. If an unknown context + * name is specified, false is returned.\n + * \n + * @note + * This API is intended for setting up initial state of unit tests.\n + * While initialize() has only the function to turn on the request, + * this API can turn off the request. It is used for switch of each + * requests when initialization setting of unit test.\n + * \n + * @details + * **Example** + * + * ``` + * res = arb->setContentState("ContentA/NORMAL", true); + * if(res == false) { + * // Unknwon context + * } + * ``` + */ + bool setContentState(const std::string& contextName, bool require); + + /** + * @brief Allocates content state to area or zone. + * @param allocatableName Name of area or zone + * @param contextName Context string of content state.\n + * contextName : "<CONTENT_NAME>/<STATE_NAME>"\n + * If the content has only one state, the <STATE> can be omitted.\n + * \n + * @return true: Success\n + * @return false: Unknown area, zone or context\n + * @details + * \n + * Allocates the content state to the area or zone. Arbitration and + * post arbitration will not be executed.\n + * The display / outputting request of the specified content state will be active. + * The statuses of hidden, mute and attenuated will not be changed.\n + * Returns true if the request setting is succeeded. If an unknown context + * name is specified, false is returned.\n + * + * @note + * This API is intended for setting up initial state of unit tests.\n + * In setResultContentState(), in addition to content state assignment, + * evaluation of the action determination process at the time of arbitration + * losing and control execution expression is performed, whereas in this + * API only content state assignment is performed.\n + * \n + * @deprecated + * Since there is a possibility of contradiction with the + * constraint, it is recommended not to use it except unit test. + * \n + * @details + * **Example** + * + * ``` + * res = arb->setAllocatableResult("AreaA", "ContentA/NORMAL"); + * if(res == false) { + * // Unknwon area, zone or context + * } + * ``` + */ + bool setAllocatableResult(const std::string& allocatableName, + const std::string& contextName); + // internal { +#ifdef RBA_USE_LOG + RBAArbitrator(RBAModel* newModel, RBALogManager* logManager); +#endif + bool evaluate(RBAExpression* expression); + const RBARuleObject* evaluateObject(RBAExpression* expression); + int32_t evaluateValue(RBAExpression* expression); + + // } + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +private: + bool isValidContext(const std::string& context); + bool isValidContext(std::list<std::string>& contexts); + bool setRequestData( + const std::string& context, bool require, + std::list<std::pair<std::string, std::int32_t>>* const properties = nullptr, + std::uint32_t syncIndex = 0xFFFFU); + void setRequestData(const RBAContentState* state, bool require); + void setRequestData(const RBAContent* const content, bool require); + void setActive(const RBASceneImpl* const scene, const bool require); + void setSceneProperty(const RBAAbstractProperty* const prop, const std::int32_t value); + void setRequestData(std::list<std::string>& contexts, const bool require); + +#ifdef RBA_USE_LOG + void checkAllConstraints(); +#endif + void updateResult(); + void checkCancelContent() const; + void createResultData(); + +public: + bool satisfiesConstraints() const; + +private: + std::unique_ptr<RBAResult> arbitrateMain(); + void arbitrate(std::list<RBAAllocatable*>& allocatables); + void arbitrateAllocatable(RBAAllocatable* allocatable, + std::set<const RBAAllocatable*>& revisited, + const std::int32_t nest, RBAAffectInfo* const affectInfo, + RBARollbacker* const parentRollbacker); + + bool sortContentStates(const RBAAllocatable* const allocatable, + std::list<const RBAContentState*>& states) const; + void postArbitrate(); + void changeContentStateCancelWithPolicy(const RBAContentState* const state); + void collectRevisitAllocatable( + std::list<const RBAAllocatable*>* const totalRevisitAllocatables, + RBAAllocatable*& allocatable, + std::list<RBAConstraintImpl*>& falseConstraints, + std::set<const RBAAllocatable*>& revisited); + + static std::int32_t getViewActionPriority(const RBAViewActionType viewActionType); + static bool compareViewAction(const std::unique_ptr<RBAViewAction>& lhs, + const std::unique_ptr<RBAViewAction>& rhs); + +public: + RBAResultImpl* getResult() const; /// Used by rba_tool + bool isCancel(const RBAContentState* const state) const; + +private: + void differenceArbitrate(); + bool checkConstraints(std::list<RBAConstraintImpl*>& constraints, + std::list<RBAConstraintImpl*>& falseConstraints, + const RBAAllocatable* const allocatable); + bool 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); + void setCancel(const RBAContentState* const state, const bool checked); + void getSortedContentStates( + const RBAAllocatable* const allocatable, + std::list<const RBAContentState*>& contentStates) const; + +#ifdef RBA_USE_LOG + void logRequestArbitration(); + void logPreResultArbitration(); + void logRequestForCoverage(); + void logResultArbitration(); + void logResultForCoverage(); + void setLogToResult(); +#endif + +public: + std::set<const RBAContentState*>& getCancelChecked(); + std::unique_ptr<RBAResultImpl>& getResultRef() const; + void setResult(std::unique_ptr<RBAResultImpl> result); + std::unique_ptr<RBAResultSet>& getNextResultSet(); + void setNextResultSet(std::unique_ptr<RBAResultSet> nextResultSet); + std::unique_ptr<RBAResultSet>& getBackupResultSet(); + void setBackupResultSet(std::unique_ptr<RBAResultSet> backupResultSet); + std::unique_ptr<RBAResultSet>& getReservedResultSet(); + void setReservedResultSet(std::unique_ptr<RBAResultSet> reservedResultSet); + std::recursive_mutex& getMutex() const; +#ifdef RBA_USE_LOG + void setSimulationMode(bool simulationMode); +#endif + std::deque<std::unique_ptr<RBARequestQueMember>>& getRequestQue(); + +private: + RBAModelImpl* model_ {nullptr}; + std::set<const RBAContentState*> cancelChecked_; + + mutable std::unique_ptr<RBAResultImpl> result_; + // ResultSet to use as CurrentResultSet in next arbitration + std::unique_ptr<RBAResultSet> nextResultSet_; + // ResultSet to use as PreviousResultSet in next arbitration + std::unique_ptr<RBAResultSet> backupResultSet_; + // ResultSet to be used as CurrentResultSet in cancelArbitration() + std::unique_ptr<RBAResultSet> reservedResultSet_; + // ResultSet to use as CurrentResultSet in satisfiesConstraints() + std::unique_ptr<RBAResultSet> resultSetForSatisfiesConstraints_; + mutable std::recursive_mutex mutex_; +#ifdef RBA_USE_LOG + bool simulationMode_ = false; +#endif + std::deque<std::unique_ptr<RBARequestQueMember>> requestQue_; + +public: + void setModel(RBAModelImpl* const newModel); +}; + +} + +#endif diff --git a/include/rba/RBAArea.hpp b/include/rba/RBAArea.hpp new file mode 100644 index 0000000..c5afc7e --- /dev/null +++ b/include/rba/RBAArea.hpp @@ -0,0 +1,92 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Area class + */ + +#ifndef RBAAREA_HPP +#define RBAAREA_HPP + +#include <list> +#include <string> +#include "RBAArbitrationPolicy.hpp" + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +class RBASize; +class RBAViewContent; + +/** + * @class RBAArea + * Defines a Frame for displaying the view content.<br> + * At run time, at most one view content is allocated to one area. + */ +class DLL_EXPORT RBAArea +{ +protected: + RBAArea()=default; + RBAArea(const RBAArea&)=delete; + RBAArea(RBAArea&&)=delete; + RBAArea& operator=(const RBAArea&)=delete; + RBAArea& operator=(RBAArea&&)=delete; + ~RBAArea()=default; + +public: + /** + * @brief Returns the name of the area. + * @return Area name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the x-axis value of the base point of the area + * @return X-axis Value of the base point + */ + virtual std::int32_t getX() const=0; + + /** + * @brief Returns the y-axis value of the base point of the area + * @return Y-axis Value of the base point + */ + virtual std::int32_t getY() const=0; + + /** + * @brief Returns the z-order value. + * An area with a large z-order value is displayed on the front of an area with small z-order value. + * @return Z-order value + */ + virtual std::int32_t getZorder() const=0; + + /** + * @brief Returns the list of content which can be displayed on this area. + * @return list of content + */ + virtual const std::list<const RBAViewContent*>& getContents() const=0; + + /** + * @brief Returns the list of size defined to this area . + * Since multiple size can be defined, returns a list of size. + * @return list of size + */ + virtual const std::list<const RBASize*>& getSizes() const=0; + + /** + * @brief Returns the arbitration policy value defined to this area. + * @return arbitration policy value + */ + virtual RBAArbitrationPolicy getArbitrationPolicy() const=0; +}; + +} + +#endif diff --git a/include/rba/RBABasePoint.hpp b/include/rba/RBABasePoint.hpp new file mode 100644 index 0000000..dd971e0 --- /dev/null +++ b/include/rba/RBABasePoint.hpp @@ -0,0 +1,75 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Base point class + */ + +#ifndef RBABASEPOINT_HPP +#define RBABASEPOINT_HPP + +namespace rba +{ + +/** + * @enum RBABasePoint + * Base point for object having size. For example Area. + */ +enum class RBABasePoint : std::uint8_t +{ + /** + * @brief Defines Left-Top coordinate as the base point of (x, y) + * The rectangle is represented by (x, y)-(x+width, y+height) + */ + LEFT_TOP, + + /** + * @brief Defines Left-Middle coordinate as the base point of (x, y) + * The rectangle is represented by (x, y-height/2)-(x+width, y+height/2) + */ + LEFT_MIDDLE, + + /** + * @brief Defines Left-Bottom coordinate as the base point of (x, y) + * The rectangle is represented by (x, y-height)-(x+width, y) + */ + LEFT_BOTTOM, + + /** + * @brief Defines Right-Top coordinate as the base point of (x, y) + * The rectangle is represented by (x-width, y)-(x, y+height) + */ + RIGHT_TOP, + + /** + * @brief Defines Right-Middle coordinate as the base point of (x, y) + * The rectangle is represented by (x-width, y-height/2)-(x, y+height/2) + */ + RIGHT_MIDDLE, + + /** + * @brief Defines Right-Bottom coordinate as the base point of (x, y) + * The rectangle is represented by (x-width, y-height)-(x, y) + */ + RIGHT_BOTTOM, + + /** + * @brief Defines Center-Top coordinate as the base point of (x, y) + * The rectangle is represented by (x-width/2, y)-(x+width/2, y+height) + */ + CENTER_TOP, + + /** + * @brief Defines Center-Middle coordinate as the base point of (x, y) + * The rectangle is represented by (x-width/2, y-height/2)-(x+width/2, y+height/2) + */ + CENTER_MIDDLE, + + /** + * @brief Defines Center-Bottom coordinate as the base point of (x, y) + * The rectangle is represented by (x-width/2, y-height)-(x+width/2, y) + */ + CENTER_BOTTOM +}; + +} + +#endif diff --git a/include/rba/RBAContentLoserType.hpp b/include/rba/RBAContentLoserType.hpp new file mode 100644 index 0000000..0ddb76e --- /dev/null +++ b/include/rba/RBAContentLoserType.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Good loser type class + */ + +#ifndef RBACONTENTLOSERTYPE_HPP +#define RBACONTENTLOSERTYPE_HPP + +namespace rba +{ + +/** + * @enum RBAContentLoserType + * Type of behavior when content loses the arbitration + */ +enum class RBAContentLoserType : std::uint8_t +{ + /** + * @brief Always cancels its request when losing arbitration. + */ + GOOD_LOSER=0, + + /** + * @brief Cancels its request only if it lost the arbitration in the displaying state. + */ + DO_NOT_GIVEUP_UNTIL_WIN, + + /** + * @brief Never cancels its request. + */ + NEVER_GIVEUP +}; + +} + +#endif diff --git a/include/rba/RBADisplay.hpp b/include/rba/RBADisplay.hpp new file mode 100644 index 0000000..1c2be8e --- /dev/null +++ b/include/rba/RBADisplay.hpp @@ -0,0 +1,56 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Display class + */ + +#ifndef RBADISPLAY_HPP +#define RBADISPLAY_HPP + +#include <list> +#include <string> + +namespace rba { + +class RBAArea; +class RBASize; + +/** + * @class RBADisplay + * Defines a screen layout of the display.<br> + * You can define multiple displays for Multi-Display products. + * Display defines a set of areas which are laid out on it. + */ +class RBADisplay +{ +protected: + RBADisplay()=default; + RBADisplay(const RBADisplay&)=delete; + RBADisplay(RBADisplay&&)=delete; + RBADisplay& operator=(const RBADisplay&)=delete; + RBADisplay& operator=(RBADisplay&&)=delete; + ~RBADisplay()=default; + +public: + /** + * @brief Returns the name of display + * @return Display name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the size of display + * @return Size + */ + virtual const RBASize* getSize() const=0; + + /** + * @brief Returns areas which are allocated to the display + * @return List of area + */ + virtual const std::list<const RBAArea*>& getAreas() const=0; + +}; + +} + +#endif diff --git a/include/rba/RBAJsonParser.hpp b/include/rba/RBAJsonParser.hpp new file mode 100644 index 0000000..7cc992d --- /dev/null +++ b/include/rba/RBAJsonParser.hpp @@ -0,0 +1,85 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * JSON parser class + */ + +#ifndef RBAJSONPARSER_HPP +#define RBAJSONPARSER_HPP + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +#include <memory> +#include "RBAModel.hpp" + +namespace rba +{ + +class RBAModel; +// internal { +class RBAExpression; +class RBAModelFactory; +// } + +/** + * @class RBAJsonParser + * Provides the facility that loads a model file in JSON format and generate a Model object. + */ +class DLL_EXPORT RBAJsonParser +{ +public: + RBAJsonParser(); + RBAJsonParser(const RBAJsonParser&)=delete; + RBAJsonParser(const RBAJsonParser&&)=delete; + RBAJsonParser& operator=(const RBAJsonParser&)=delete; + RBAJsonParser& operator=(const RBAJsonParser&&)=delete; + virtual ~RBAJsonParser() noexcept; + +public: + /** + * @brief Loads a JSON file and generates a model object. + * @param filename Path of JSON file + * @return Model + * If the file is not found, returns nullptr. + * + * **Example** + * + * ``` + * rba::RBAJsonParser parser; + * rba::RBAModel* model = parser.parse("RBAModel.json"); + * if(model == nullptr) { + * std::cout << "ERRROR: Could not read JSON file" << std::endl; + * return 1; + * } + * rba::RBAArbitrator* arb = new rba::RBAArbitrator(model); + * ``` + */ + RBAModel* parse(const std::string& filename); + + // internal { + RBAJsonParser(RBAModelFactory* factory); + // } + +private: + class Impl; +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr<Impl> impl_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/include/rba/RBAModel.hpp b/include/rba/RBAModel.hpp new file mode 100644 index 0000000..ad3f97b --- /dev/null +++ b/include/rba/RBAModel.hpp @@ -0,0 +1,241 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Model class + */ + +#ifndef RBAMODEL_HPP +#define RBAMODEL_HPP + +#include <string> +#include "RBAArea.hpp" +#include "RBAViewContent.hpp" +#include "RBAViewContentState.hpp" +#include "RBASize.hpp" +#include "RBAZone.hpp" +#include "RBASoundContent.hpp" +#include "RBASoundContentState.hpp" +#include "RBAScene.hpp" +#include "RBADisplay.hpp" +#include "RBAPositionContainer.hpp" +#include "RBAJsonParser.hpp" +// internal { +#include "RBAAreaSet.hpp" +#include "RBAViewContentSet.hpp" +#include "RBAZoneSet.hpp" +#include "RBASoundContentSet.hpp" +#include "RBAConstraint.hpp" +// } + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +/** + * @class RBAModel + * Defines the arbitration rule model which is used by Arbitrator.<br> + * The model consists of model elements such as areas, zones, contens, scenes, + * constraint expressions, and so on. + * Elements can be searched by name, and the list of elements for each type can be retrieved. + */ +class DLL_EXPORT RBAModel +{ +public: + RBAModel()=default; + RBAModel(const RBAModel&)=delete; + RBAModel(RBAModel&&)=delete; + RBAModel& operator=(const RBAModel&)=delete; + RBAModel& operator=(RBAModel&&)=delete; + virtual ~RBAModel()=default; + +public: + /** + * @brief Search for area with a name + * @param areaName Area name + * @return Area + * + * If the area name does not exist, returns nullptr. + */ + virtual const RBAArea* findArea(const std::string& areaName) const=0; + + /** + * @brief Search for view content with a name. + * @param contName Content name + * @return Content + * + * If the content name does not exist, returns nullptr. + */ + virtual const RBAViewContent* findViewContent(const std::string& contName) const=0; + + /** + * @brief Search for view content state with a name. + * @param stateName Content state name + * @return State of view content + * + * If the content state name does not exist, returns nullptr. + */ + virtual const RBAViewContentState* findViewContentState(const std::string& stateName) const=0; + + /** + * @brief Search for size with a name. + * @param sizeName Name of the search size + * @return Size + * + * Specify the name of the search size as follows.\n + * In the case of the size linked to the area: + * <area_name>/<size_name> + * In the case of the size linked to the content: + * <content_name>/<size_name> + * \n + * If the name of the search size does not exist, returns nullptr. + */ + virtual const RBASize* findSize(const std::string& sizeName) const=0; + + /** + * @brief Search for zone with a name. + * @param zoneName Zone name + * @return Zone + * + * If the zone name does not exist, returns nullptr. + */ + virtual const RBAZone* findZone(const std::string& zoneName) const=0; + + /** + * @brief Search for sound content with a name. + * @param contName Content name + * @return Sound content + * + * If the content name does not exist, returns nullptr. + */ + virtual const RBASoundContent* findSoundContent(const std::string& contName) const=0; + + /** + * @brief Search for sound content state with a name. + * @param stateName Content state name + * @return Sound content state + * + * If the content state name does not exist, returns nullptr. + */ + virtual const RBASoundContentState* findSoundContentState(const std::string& stateName) const=0; + + /** + * @brief Search for scene with a name. + * @param sceneName Scene name + * @return Scene + * + * If the scene name does not exist, returns nullptr. + */ + virtual const RBAScene* findScene(const std::string& sceneName) const=0; + + /** + * @brief Search for display with a name. + * @param displayName Display name. + * @return Display + * + * If the display name does not exist, returns nullptr. + */ + virtual const RBADisplay* findDisplay(const std::string& displayName) const=0; + + /** + * @brief Returns all the areas. + * @return List of areas + */ + virtual const std::list<const RBAArea*>& getAreas() const=0; + + /** + * @brief Returns all the view contents. + * @return List of contents + */ + virtual const std::list<const RBAViewContent*>& getViewContents() const=0; + + /** + * @brief Returns all the view content states. + * @return List of view content states + */ + virtual const std::list<const RBAViewContentState*>& getViewContentStates() const=0; + + /** + * @brief Returns all the sizes. + * @return List of sizes + */ + virtual const std::list<const RBASize*>& getSizes() const=0; + + /** + * @brief Returns all the zones. + * @return List of zones + */ + virtual const std::list<const RBAZone*>& getZones() const=0; + + /** + * @brief Returns all the sound contents. + * @return List of sound contents + */ + virtual const std::list<const RBASoundContent*>& getSoundContents() const=0; + + /** + * @brief Returns all the sound content states. + * @return List of sound content states + */ + virtual const std::list<const RBASoundContentState*>& getSoundContentStates() const=0; + + /** + * @brief Returns all the scenes. + * @return List of scenes + */ + virtual const std::list<const RBAScene*>& getScenes() const=0; + + /** + * @brief Returns all the displays. + * @return List of displays + */ + virtual const std::list<const RBADisplay*>& getDisplays() const=0; + + // internal { + /** + * @brief Search for Model element with a name. + * @param elementName Model element name. + * @return Model element + * + * If the Model element name does not exist, returns nullptr. + */ + virtual const RBAModelElement* findModelElement(const std::string& elementName) const=0; + + /** + * @brief Returns all the sets of areas. + * @return List of sets of areas + */ + virtual const std::list<const RBAAreaSet*>& getAreaSets() const=0; + + /** + * @brief Returns all the sets of view contents. + * @return List of sets of view contents + */ + virtual const std::list<const RBAViewContentSet*>& getViewContentSets() const=0; + + /** + * @brief Returns all the position containers. + * @return List of sets of position containers + */ + virtual const std::list<const RBAPositionContainer*>& getPositionContainers() const=0; + + /** + * @brief Returns all the constraints. + * @return List of constraints + */ + virtual std::list<RBAConstraint*>& getConstraints()=0; + + // } + +}; + +} + +#endif diff --git a/include/rba/RBAPositionContainer.hpp b/include/rba/RBAPositionContainer.hpp new file mode 100644 index 0000000..2340840 --- /dev/null +++ b/include/rba/RBAPositionContainer.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Position container class + */ + +#ifndef RBAPOSITIONCONTAINER_HPP +#define RBAPOSITIONCONTAINER_HPP + +#include <cstdint> +#include "RBABasePoint.hpp" + +namespace rba +{ + +class RBAArea; + +class RBAPositionContainer +{ +protected: + RBAPositionContainer()=default; + RBAPositionContainer(const RBAPositionContainer&)=delete; + RBAPositionContainer(RBAPositionContainer&&)=delete; + RBAPositionContainer& operator=(const RBAPositionContainer&)=delete; + RBAPositionContainer& operator=(RBAPositionContainer&&)=delete; + ~RBAPositionContainer()=default; + +public: + /** + * @brief Get X coordinate + * @return X coordinate + */ + virtual std::int32_t getX() const=0; + + /** + * @brief Get Y coordinate + * @return Y coordinate + */ + virtual std::int32_t getY() const=0; + + /** + * @brief Get base point + * @return Base point + */ + virtual RBABasePoint getBasePoint() const=0; + + /** + * @brief Get assigned area + * @return assigned area + */ + virtual const RBAArea* getArea() const=0; + +public: + /** + * @brief default X coordinate + */ + const static std::int32_t X_EDEFAULT=0; + + /** + * @brief default Y coordinate + */ + const static std::int32_t Y_EDEFAULT=0; + + /** + * @brief default base point + */ + const static RBABasePoint BASE_POINT_EDEFAULT=RBABasePoint::LEFT_TOP; + +}; + +} + +#endif diff --git a/include/rba/RBAResult.hpp b/include/rba/RBAResult.hpp new file mode 100644 index 0000000..4a6766b --- /dev/null +++ b/include/rba/RBAResult.hpp @@ -0,0 +1,861 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Arbitration result class + */ + +#ifndef RBARESULT_HPP +#define RBARESULT_HPP + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +#include <memory> +#include <list> +#include "RBAResultStatusType.hpp" +#include "RBAViewAction.hpp" +#include "RBAScene.hpp" + +namespace rba +{ + +class RBAArea; +class RBAViewContent; +class RBAViewContentState; +class RBAScene; +class RBASize; +class RBAZone; +class RBASoundContent; +class RBASoundContentState; +// internal { +class RBADisplay; +// } + +/** + * @class RBAResult + * Stores an arbitration result.<br> + * The Arbitrator allocates Contents to Areas. Related + * information of those can be acquired from RBAResult.\n + * The arbitration result indicates which content is allocated to each + * area / zone. + * Also, snapshot information and view action information (only display + * results) indicating the difference from the last arbitration are included. + */ +class DLL_EXPORT RBAResult +{ +public: + RBAResult()=default; + RBAResult(const RBAResult&)=delete; + RBAResult(RBAResult&&)=delete; + RBAResult& operator=(const RBAResult&)=delete; + RBAResult& operator=(RBAResult&&)=delete; + virtual ~RBAResult()=default; + +public: + + // [VisibleArea/SoundingZone] + + /** + * @brief Returns the displaying areas determined by the last arbitration. + * @return List of visible areas. + */ + virtual const std::list<const RBAArea*>& getVisibleAreas() const=0; + + /** + * @brief Returns the outputting zones determined by the last arbitration. + * @return List of sounding zones. + */ + virtual const std::list<const RBAZone*>& getSoundingZones() const=0; + + // [Visible/Sounding ContentStates] + + /** + * @brief Returns the view content states to be displayed determined by the last arbitration. + * @return List of visible view content states. + */ + virtual const std::list<const RBAViewContentState*>& getVisibleContentStates() const=0; + + /** + * @brief Returns the sound content states to be output determined by the last arbitration. + * @return List of sound content states to be output. + * @details The list contains sound contents to be attenuated. + */ + virtual const std::list<const RBASoundContentState*>& getSoundingContentStates() const=0; + + // [Active View/Sound ContentStates] + + /** + * @brief Returns the active view content states at the last arbitration + * result. + * @return List of active view content states. + * @details + * The active view content states are those that have been requested to + * display so far. They do not include the view content state whose request + * has been withdrawn or canceled. + */ + virtual const std::list<const RBAViewContentState*>& getActiveViewContentStates() const=0; + + /** + * @brief Returns the active sound content states at the last arbitration + * result. + * @return List of active sound content states. + * @details + * The active sound content states are those that have been requested to + * output so far. They do not include the sound content state whose request + * has been withdrawn or canceled. + */ + virtual const std::list<const RBASoundContentState*>& getActiveSoundContentStates() const=0; + + // [Active Scenes] + + /** + * @brief Returns the active scenes at the last arbitration. + * @return List of active scenes. + * @details + * The active scenes are those that have been requested for ON so far. + * They do not include scenes requested for OFF afterwards. + */ + virtual const std::list<const RBAScene*>& getActiveScenes() const=0; + + // [InvisibleAreas/UnsoundingZone] + + /** + * @brief Returns the invisible areas determined by the last arbitration. + * @return List of invisible areas. + * @details + * Returns the areas which are not displayed out of all areas.\n + * The list contains areas to be hidden. + */ + virtual const std::list<const RBAArea*>& getInvisibleAreas() const=0; + + /* + * @brief Returns the unsounding zones determined by the last arbitration. + * @return List of unsounding zones. + * @details + * Returns the zones which are not output out of all zones. + * The list contains zones to be muted. + */ + virtual const std::list<const RBAZone*>& getUnsoundingZones() const=0; + + // [HiddenAreas/MuteZones] + + /** + * @brief Returns the area that is hidden state and content has been + * allocated.\n + * The hidden state is a state in which the area must be hidden by a + * constraint expression. + * @return List of areas. + * Returns the area which become to be invisible. + * The area invisible in the previous time is not included. + */ + virtual const std::list<const RBAArea*>& getHiddenAreas() const=0; + + /** + * @brief Returns the zone that is muted state and content has been + * allocated.\n + * The muted state is a state in which the zone must be muted by a + * constraint expression. + * @return List of muted zones. + * + * Retuens the zones that is defeted and canceled sound contents. + */ + virtual const std::list<const RBAZone*>& getMuteZones() const=0; + + // [get Attenuated] + + /** + * @brief Returns the attenuated zones determined by the last arbitration. + * @return List of attenuated zones. + */ + virtual const std::list<const RBAZone*>& getAttenuatedZones() const=0; + + // [Canceled Contents] + + /** + * @brief Returns the canceled view contents determined by the last arbitration. + * @return List of canceled view contents. + * @details + * Reterns list of view contents which are canceled by Request handling on lost definition\n + * such as Loser Type and Post Constraints.\n + * The list does not contain contents which are withdrawn. + */ + virtual const std::list<const RBAViewContent*>& getCanceledViewContents() const=0; + + /** + * @brief Returns the canceled sound contents determined by the last arbitration. + * @return List of canceled sound contents. + * @details + * Reterns list of sound contents which are canceled by Request handling on lost definition\n + * such as Loser Type and Post Constraints.\n + * The list does not contain contents which are withdrawn. + */ + virtual const std::list<const RBASoundContent*>& getCanceledSoundContents() const=0; + + // [Standby Contents] + + /** + * @brief Returns the stand by view contents due to defeated at the last + * arbitration. + * @return List of stand by view contents. + * @details + * Returns list of view contents which are active but not allocated to any area. + * The list does not contains which are canceled contents or are allocated to hidden area. + */ + virtual const std::list<const RBAViewContent*>& getStandbyViewContents() const=0; + + /** + * @brief Returns the stand by sound contents due to defeated at the last + * arbitration. + * @return List of stand by sound contents. + * @details + * Returns list of sound contents which are active but not allocated to any area. + * The list does not contains which are canceled contents or are allocated to muted area. + */ + virtual const std::list<const RBASoundContent*>& getStandbySoundContents() const=0; + + // [ContentStates] + + /** + * @brief Returns the view content state assigned to the area of the last + * arbitration. + * @param area Area + * @return The view content state assign to the area. + * @details + * If no view content state is allocated to the area, nullptr is returnd.\n + * If area is not defined in the Model or nullptr, nullptr is returnd. + */ + virtual const RBAViewContentState* getContentState(const RBAArea* area) const=0; + + /** + * @brief Returns the sound content state assigned to the zone of the last + * arbitration. + * @param zone Zone + * @return The sound content state assign to the zone. + * @details + * If no sound content state is allocated to the zone, nullptr is returned.\n + * If zone is not defined in the Model or nullptr, nullptr is returnd. + */ + virtual const RBASoundContentState* getContentState(const RBAZone* zone) const=0; + + // [Areas/Zones by ConentState] + + /** + * @brief Returns the area to which the view content state is allocated at the + * last arbitration. + * @param state View content state + * @return The areas to which the view content state. + * @details + * If the view content state is not assigned to any area, empty list is returned.\n + * If state is not defined in the Model or nullptr, empty list is returned. + */ + virtual const std::list<const RBAArea*> getArea(const RBAViewContentState* state) const=0; + + /** + * @brief Get the zone to which the sound content state is allocated of the + * last arbitration. + * @param state Sound content state + * @return The zones to which the sound content state is allocated. + * @details + * If the sound content state is not assigned to any zone, + * empty list is retuened.\n + * If state is not defined in the Model or nullptr, empty list is returned. + */ + virtual const std::list<const RBAZone*> getZone(const RBASoundContentState* state) const=0; + + // [Areas/Zones by Content] + + /** + * @brief Returns the area to which the view content is allocated of the + * last arbitration. + * @param content View content + * @return The areas to which the view content is allocated. + * @details + * If the view content is not assigned to any area, empty list is returned.\n + * If content is not defined in the Model or nullptr, empty list is returned.\n + * This API is the same as getArea(RBAViewContentState*) \n + * except for the type of argument. + */ + virtual const std::list<const RBAArea*> getArea(const RBAViewContent* content)const=0; + + /** + * @brief Returns the zone to which the sound content state is allocated of the + * last arbitration. + * @param content Sound content + * @return The zones to which the sound content is allocated. + * @details + * If the sound content is not assigned to any area, nullptr is returned.\n + * If content is not defined in the Model or nullptr, empty list is returned.\n + * This API is the same as getZone(RBASoundContentState*) \n + * except for the type of argument. + */ + virtual const std::list<const RBAZone*> getZone(const RBASoundContent* content) const=0; + + // [Size] + + /** + * @brief Returns the size of the area determined in the last arbitration. + * @param area Area + * @return The size of the area. + * @details + * Area may have multiple sizes and its size will vary by the allocated content.\n + * This API returns the size which are matched with allocated content.\n + * If no content is allocated to the area, returns nullptr.\n + * If area is not defined in the Model or nullptr, returns nullptr. + */ + virtual const RBASize* getSize(const RBAArea* area) const=0; + + // [Active check Scene] + + /** + * @brief Returns true if the scene is ON at the last arbitration. + * @param scene Reference scene to be checked. + * @return true: the scene is ON + * @return false: the scene is OFF + * @details + * If scene is not defined in the Model or nullptr, returns false. + */ + virtual bool isActive(const RBAScene* scene) const=0; + + // [Active check ContentState] + + /** + * @brief Returns true if the view content is active. + * @param state Reference view content to be checked. + * @return true: Active + * @return false: Not active + * @details + * If content is not defined in the Model or nullptr, returns false. + */ + virtual bool isActive(const RBAViewContent* content) const=0; + + /** + * @brief Returns true if the sound content is active. + * @param state Reference sound content to be checked. + * @return true: Active + * @return false: Not active + * @details + * If content is not defined in the Model or nullptr, returns false. + */ + virtual bool isActive(const RBASoundContent* content) const=0; + + // [Visible/Sounding Area/Zonecheck] + + /** + * @brief Returns true if the area is visible of the last arbitration. + * @param area Reference area to be checked. + * @return true: Visible + * @return false: Not visible + * @details + * Returns false if the area is hidden.\n + * If area is not defined in the Model or nullptr, returns false. + */ + virtual bool isVisible(const RBAArea* area) const=0; + + /** + * @brief Returns true if the zone is sounding of the last arbitration. + * @param zone Reference zone to be checked. + * @return true: Sounding + * @return false: Not sounding + * @details + * Returns false if the zone is muted.\n + * If zone is not defined in the Model or nullptr, returns false. + */ + virtual bool isSounding(const RBAZone* zone) const=0; + + // [Visible/Sounding ContentState check] + + /** + * @brief Returns true if the view content state is visible + * of the last arbitration. + * @param state Reference view content state to be checked. + * @return true: state is allocated to visible area. + * @return false: state is not allocated to visible area. + * @details + * If all of the areas to which the content is allocated are hidden, returns false\n + * If state is not defined in the Model or nullptr, returns false. + */ + virtual bool isVisible(const RBAViewContentState* state) const=0; + + /** + * @brief Returns true if the sound content state is sounding + * of the last arbitration. + * @param state Reference sound content state to be check. + * @return true: state is allocated to outputting zone. + * @return false: state is not allocated to outputting zone. + * @details + * If all of the zones to which the content is allocated are muted, returns false\n + * If state is not defined in the Model or nullptr, returns false. + */ + virtual bool isSounding(const RBASoundContentState* state) const=0; + + // [View/Sound ContentState] + + /** + * @brief Returns the view content state allocated to the area + * of the last arbitration. + * @param area Area + * @return The view content state allocated to the area. + * @details + * Even if the area is hidden, Returns the allocated content state.\n + * If no visible view content state is allocated the area, nullptr is returnd.\n + * If area is not defined in the Model or nullptr, returns nullptr. + */ + virtual const RBAViewContentState* getViewContentState(const RBAArea* area) const=0; + + /** + * @brief Returns the sounding sound content state assigned to the zone + * of the last arbitration. + * @param zone Zone + * @return The sounding sound content state assign to the zone. + * @details + * Even if the zone is muted, Returns the allocated content state.\n + * If no sounding sound content state is allocated the area, + * nullptr is returnd.\n + * If zone is not defined in the Model or nullptr, returns nullptr. + */ + virtual const RBASoundContentState* getSoundContentState(const RBAZone* zone) const=0; + + // [Hidden/Mute check] + + /** + * @brief Returns true if the area is hidden state of the last arbitration.\n + * The hidden state is a state in which the area must be hidden by a + * constraint expression.\n + * In the hidden state, it returns true even if the content is not assigned. + * @param area Reference area to be checked. + * @return true: Hidden + * @return false: Not hidden + * @details + * If area is not defined in the Model or nullptr, returns nullptr. + */ + virtual bool isHidden(const RBAArea* area) const=0; + + /** + * @brief Returns true if the zone is muted state of the last arbitration.\n + * The muted state is a state in which the zone must be muted by a + * constraint expression.\n + * In the muted state, it returns true even if the content is not assigned. + * @param zone Reference zone to be checked. + * @return true: Muted + * @return false: Not muted + * @details + * If zone is not defined in the Model or nullptr, returns nullptr. + */ + virtual bool isMute(const RBAZone* zone) const=0; + + // [Check Attenuated] + + /** + * @brief Returns true if the zone is attenuated + * of the last arbitration. + * @param zone Reference zone to be check. + * @return true: Attenuated + * @return false: Not attenuated + * @details + * If zone is not defined in the Model or nullptr, returns nullptr. + */ + virtual bool isAttenuated(const RBAZone* zone) const=0; + + // [Cancel check] + + /** + * @brief Returns true if the view content state is canceled + * at the last arbitration. + * @param state Reference view content state to be checked. + * @return true: Canceled + * @return false: Not canceled or Not request view content state + * @details + * If state is not active, returns false.\n + * If state is not defined in the Model or nullptr, returns false. + */ + virtual bool isCancel(const RBAViewContentState* state) const=0; + + /** + * @brief Returns true if the sound content state is canceled + * at the last arbitration. + * @param state Reference view content state to be checked. + * @return true: Canceled + * @return false: Not canceled + * @details + * If state is not active, returns false.\n + * If state is not defined in the Model or nullptr, returns false. + */ + virtual bool isCancel(const RBASoundContentState* state) const=0; + + // common + + /** + * @brief Returns information of view status changes + * (the view actions) of the last arbitration. + * @return List of view actions. + * @details + * ViewAction is an information of differences \n + * between the last arbitration result and its previous result.\ + * There is no difference between hidden and not displayed for visible status.\n + */ + virtual const std::list<const RBAViewAction*>& getViewActions() const=0; + + /** + * @brief Returns the result status type of the last arbitration. + * @return SUCCESS: Success + * @return UNKNOWN_CONTENT_STATE: Failed (The reuqest is unknown) + * @return CANCEL_ERROR: Cancel arbitrration error + * @endcond + virtual RBAResultStatusType getStatusType() const=0; + + /** + * @brief Returns satisfied status of all online constraints. + * @return true:All online constraints check result is OK, and arbitration finished. + * @return false:All online constraints check result is NG, and arbitration finished. + */ + virtual bool satisfiesConstraints() const=0; + + /** + * @brief Returns the property value of scene. + * @return Property value + * @details + * If the scene or propertyName is not defined in the Model, returns -99.\n + * @endcond + virtual std::int32_t getSceneProperty(const RBAScene* scene, const std::string& propertyName) const=0; + + // internal { + /** + * @brief Returns the displaying areas of the previous arbitration. + * @return List of visible areas. + */ + virtual const std::list<const RBAArea*>& getPreVisibleAreas() const=0; + + /** + * @brief Returns the outputting sounding zones of the previous arbitration. + * @return List of sounding zones. + */ + virtual const std::list<const RBAZone*>& getPreSoundingZones() const=0; + + /** + * @brief Returns the view content states to be displayed of the previous arbitration. + * @return List of visible view content states. + */ + virtual const std::list<const RBAViewContentState*>& getPreVisibleContentStates() const=0; + + /** + * @brief Returns the sound content states to be outputted of the previous arbitration. + * @return List of sounding sound content states. + * @details The list contains attenuated content states. + */ + virtual const std::list<const RBASoundContentState*>& getPreSoundingContentStates() const=0; + + /** + * @brief Returns the active view content states of the previous arbitration + * result. + * @return List of active view content states. + * @details + * The active view content states are those that have been requested to + * display so far. They do not include the view content state whose request + * has been withdrawn or canceled. + */ + virtual const std::list<const RBAViewContentState*>& getPreActiveViewContentStates() const=0; + + /** + * @brief Returns the active sound content states of the previous arbitration + * result. + * @return List of active sound content states. + * @details + * The active sound content states are those that have been requested to + * output so far. They do not include the sound content state whose request + * has been withdrawn or canceled. + */ + virtual const std::list<const RBASoundContentState*>& getPreActiveSoundContentStates() const=0; + + /** + * @brief Returns the active scenes of the previous arbitration. + * @return List of active scenes. + * @details + * The active scenes are those that have been requested for ON so far. + * They do not include scenes requested for OFF afterwards. + */ + virtual const std::list<const RBAScene*>& getPreActiveScenes() const=0; + + /** + * @brief Returns the invisible areas of the previous arbitration. + * @return List of invisible areas. + * @details + * Returns the areas which are not displayed out of all areas. + */ + virtual const std::list<const RBAArea*>& getPreInvisibleAreas() const=0; + + /* + * @brief Returns the unsounding zones of the previous arbitration. + * @return List of unsounding zones. + * @details + * Returns the zones which are not outputted out of all zones. + */ + virtual const std::list<const RBAZone*>& getPreUnsoundingZones() const=0; + + /** + * @brief Returns the areas which have become invisible at the previous arbitration. + * @return List of areas. + * + * Returns the area which become to be invisible. + */ + virtual const std::list<const RBAArea*>& getPreHiddenAreas() const=0; + + /** + * @brief Get the muted zones of the previous arbitration. + * @return List of muted zones. + * + * Retuens the zones that is defeted and canceled sound contents. + */ + virtual const std::list<const RBAZone*>& getPreMuteZones() const=0; + + /** + * @brief Returns the attenuated zones of the previous arbitration. + * @return List of attenuated zones. + */ + virtual const std::list<const RBAZone*>& getPreAttenuatedZones() const=0; + + /** + * @brief Returns the canceled view contents of the previous arbitration. + * @return List of canceled view contents. + */ + virtual const std::list<const RBAViewContent*>& getPreCanceledViewContents() const=0; + + /** + * @brief Returns the canceled sound contents of the previous arbitration. + * @return List of canceled sound contents. + */ + virtual const std::list<const RBASoundContent*>& getPreCanceledSoundContents() const=0; + + /** + * @brief Returns the stand by view contents due to defeated at the previous + * arbitration. + * @return List of stand by view contents. + */ + virtual const std::list<const RBAViewContent*>& getPreStandbyViewContents() const=0; + + /** + * @brief Returns the stand by sound contents due to defeated at previous + * arbitration. + * @return List of stand by sound contents. + */ + virtual const std::list<const RBASoundContent*>& getPreStandbySoundContents() const=0; + + /** + * @brief Returns the view content state assigned to the area of the previous + * arbitration. + * @param area Area + * @return The view content state assign to the area. + * + * If no view content state is allocated to the area, nullptr is returnd. + */ + virtual const RBAViewContentState* getPreContentState(const RBAArea* area) const=0; + + /** + * @brief Returns the sound content state assigned to the zone of the previous + * arbitration. + * @param zone Zone + * @return The sound content state assign to the zone. + * + * If no sound content state is allocated to the zone, nullptr is returned. + */ + virtual const RBASoundContentState* getPreContentState(const RBAZone* zone) const=0; + + /** + * @brief Returns the area to which the view content state is allocated of the + * previous arbitration. + * @param state View content state + * @return The areas to which the view content state. + * + * If the view content state is not assigned to any area, nullptr is returned. + */ + virtual const std::list<const RBAArea*> getPreArea(const RBAViewContentState* state) const=0; + + /** + * @brief Get the zone to which the sound content state is allocated of the + * previous arbitration. + * @param state Sound content state + * @return The zones to which the sound content state is allocated. + * + * If the sound content state is not assigned to any zone, + * null ptr is retuened. + */ + virtual const std::list<const RBAZone*> getPreZone(const RBASoundContentState* state) const=0; + + /** + * @brief Returns the area to which the view content is allocated of the + * previous arbitration. + * @param content View content + * @return The areas to which the view content is allocated. + * + * If the view content is not assigned to any area, nullptr is returned. + */ + virtual const std::list<const RBAArea*> getPreArea(const RBAViewContent* content) const=0; + + /** + * @brief Returns the zone to which the sound content state is allocated of the + * previous arbitration. + * @param content Sound content + * @return The zones to which the sound content is allocated. + * + * If the sound content is not assigned to any area, nullptr is returned. + */ + virtual const std::list<const RBAZone*> getPreZone(const RBASoundContent* content) const=0; + + /** + * @brief Returns the size of the area + * determined in the previous arbitration. + * @param area Area + * @return The size of the area. + */ + virtual const RBASize* getPreSize(const RBAArea* area) const=0; + + /** + * @brief Returns true if the scene is active + * of the previous arbitration. + * @param scene Reference scene to be checked. + * @return true: Active + * @return false: Not active + * + * The active scene is the scene requested to ON. + */ + virtual bool isPreActive(const RBAScene* scene) const=0; + + /** + * @brief Returns true if the view content is active + * of the previous arbitration. + * @param state Reference view content to be checked. + * @return true: Active + * @return false: Not active + * + * The active view content is the content requested to be displayed. + */ + virtual bool isPreActive(const RBAViewContent* content) const=0; + + /** + * @brief Returns true if the sound content is active + * of the previous arbitration. + * @param state Reference sound content to be checked. + * @return true: Active + * @return false: Not active + * + * The active sound content is the content requested to be outputted. + */ + virtual bool isPreActive(const RBASoundContent* content) const=0; + + /** + * @brief Returns true if the area is visible + * of the previous arbitration. + * @param area Reference area to be checked. + * @return true: Visible + * @return false: Not visible + */ + virtual bool isPreVisible(const RBAArea* area) const=0; + + /** + * @brief Returns true if the zone is sounding + * of the previous arbitration. + * @param zone Reference zone to be checked. + * @return true: Sounding + * @return false: Not sounding + */ + virtual bool isPreSounding(const RBAZone* zone) const=0; + + /** + * @brief Returns true if the view content state is visible + * of the previous arbitration. + * @param state Reference view content state to be checked. + * @return true: state is allocated to visible area. + * @return false: state is not allocated to visible area. + */ + virtual bool isPreVisible(const RBAViewContentState* state) const=0; + + /** + * @brief Returns true if the sound content state is sounding + * of the previous arbitration. + * @param state Reference sound content state to check. + * @return true: state is allocated to outputting zone. + * @return false: state is not allocated to outputting zone. + */ + virtual bool isPreSounding(const RBASoundContentState* state) const=0; + + /** + * @brief Returns the sounding sound content state assigned to the zone + * of the previous arbitration. + * @param zone Zone + * @return The sounding sound content state assign to the zone. + * + * When a zone is muted, Returns the content state. + * If no sounding sound content state is allocated the area, + * nullptr is returnd. + */ + virtual const RBASoundContentState* getPreSoundContentState(const RBAZone* zone) const=0; + + /** + * @brief Returns true if the area is hidden + * of the previous arbitration. + * @param area Reference area to be checked. + * @return true: Hidden + * @return false: Not hidden + */ + virtual bool isPreHidden(const RBAArea* area) const=0; + + /** + * @brief Returns true if the zone is muted of the previous arbitration. + * @param zone Reference zone to be checked. + * @return true: Muted + * @return false: Not muted + */ + virtual bool isPreMute(const RBAZone* zone) const=0; + + /** + * @brief Returns true if the zone is attenuated + * of the previous arbitration. + * @param zone Reference zone to be checked. + * @return true: Attenuated + * @return false: Not attenuated + */ + virtual bool isPreAttenuated(const RBAZone* zone) const=0; + + /** + * @brief Returns true if the view content state is canceled + * of the previous arbitration. + * @param state Reference view content state to be checked. + * @return true: Canceled + * @return false: Not canceled or Not request view content state + */ + virtual bool isPreCancel(const RBAViewContentState* state) const=0; + + /** + * @brief Returns true if the sound content state is canceled + * of the previous arbitration. + * @param state Reference view content state to be checked. + * @return true: Canceled + * @return false: Not canceled + */ + virtual bool isPreCancel(const RBASoundContentState* state) const=0; + + /** + * @brief Returns the log of the last arbitration. + * @return Log string + */ + virtual std::string getLog() const=0; + + /** + * @brief Returns displaying status + * @param display to be checked display + * @return true: something is displayed + * @return false: nothing is displayed + */ + virtual bool hasDisplayingArea(const RBADisplay* display) const=0; + // } + +}; + +} + +#endif diff --git a/include/rba/RBAResultStatusType.hpp b/include/rba/RBAResultStatusType.hpp new file mode 100644 index 0000000..09c30d9 --- /dev/null +++ b/include/rba/RBAResultStatusType.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Result status type cluss + */ + +#ifndef RBARESULTSTATUSTYPE_HPP +#define RBARESULTSTATUSTYPE_HPP + +namespace rba +{ + +/** + * @enum RBAResultStatusType + * Status of the arbitration result. + */ +enum class RBAResultStatusType : std::uint8_t +{ + /** + * @brief Success + */ + SUCCESS, + + /** + * @brief Failed + */ + FAILED, + + /** + * @brief Unknown context or content state + */ + UNKNOWN_CONTENT_STATE, + + /** + * @brief Cancel arbitration error + */ + CANCEL_ERROR + +}; + +} + +#endif diff --git a/include/rba/RBAScene.hpp b/include/rba/RBAScene.hpp new file mode 100644 index 0000000..5bb1e66 --- /dev/null +++ b/include/rba/RBAScene.hpp @@ -0,0 +1,74 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Scene class + */ + +#ifndef RBASCENE_HPP +#define RBASCENE_HPP + +#include <cstdint> +#include <list> +#include <string> + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +/** + * @class RBAScene + * Express the state(Including system state) at that time comprehensively.<br> + * Used scene for switch area/zone and view/sound content state. + * And plural RBA model(project) can share arbitration result by definitions global scene. + */ +class RBAScene +{ +protected: + RBAScene()=default; + RBAScene(const RBAScene&)=delete; + RBAScene(RBAScene&&)=delete; + RBAScene& operator=(const RBAScene&)=delete; + RBAScene& operator=(RBAScene&&)=delete; + +public: + virtual ~RBAScene()=default; + +public: + /** + * @brief Returns the scene name + * @return Scene name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the global scene status. + * @return global scene status. + */ + virtual bool isGlobal() const=0; + + /** + * @brief Returns List of the scene property name. + * @return List of the scene property name + */ + virtual const std::list<std::string>& getPropertyNames() const=0; + + /** + * @brief Returns Default value of the scene property. + * @param propertyName Scene property name + * @return Default value of the scene property + */ + virtual std::int32_t getPropertyValue(const std::string& propertyName) const=0; + +}; + +} + +#endif diff --git a/include/rba/RBASize.hpp b/include/rba/RBASize.hpp new file mode 100644 index 0000000..84c9ba7 --- /dev/null +++ b/include/rba/RBASize.hpp @@ -0,0 +1,74 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Size class + */ + +#ifndef RBASIZE_HPP +#define RBASIZE_HPP + +#include <string> + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +/** + * @class RBASize + * Size definitions for object such as areas or view contents.<br> + * Each object can define plural size. + * Can refer to size from object. + */ +class DLL_EXPORT RBASize +{ +protected: + RBASize()=default; + RBASize(const RBASize&)=delete; + RBASize(RBASize&&)=delete; + RBASize& operator=(const RBASize&)=delete; + RBASize& operator=(RBASize&&)=delete; + ~RBASize()=default; + +public: + /** + * @brief Returns the name of the size. + * @return Size name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the width of the size. + * @return Width of the size + */ + virtual std::int32_t getWidth() const=0; + + /** + * @brief Returns the height of the size. + * @return Height of the size + */ + virtual std::int32_t getHeight() const=0; + +public: + /** + * @brief Default width of size + */ + const static std::int32_t WIDTH_EDEFAULT = 0; + + /** + * @brief Default height of size + */ + const static std::int32_t HEIGHT_EDEFAULT = 0; + +}; + +} + +#endif diff --git a/include/rba/RBASoundContent.hpp b/include/rba/RBASoundContent.hpp new file mode 100644 index 0000000..336b462 --- /dev/null +++ b/include/rba/RBASoundContent.hpp @@ -0,0 +1,83 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Sound content class + */ + +#ifndef RBASOUNDCONTENT_HPP +#define RBASOUNDCONTENT_HPP + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +#include <list> +#include <string> +#include "RBAContentLoserType.hpp" + +namespace rba +{ + +class RBASoundContentState; +class RBAZone; + +/** + * @class RBASoundContent + * Define the object of sound content.<br> + * Sound content has plural status. + * When sound contents connected to a zone, active status is output. + * Object has zone definitions, that can output itself. + * Each object can define plural zone which can output sound contents. + */ +class DLL_EXPORT RBASoundContent +{ +protected: + RBASoundContent()=default; + RBASoundContent(const RBASoundContent&)=delete; + RBASoundContent(RBASoundContent&&)=delete; + RBASoundContent& operator=(const RBASoundContent&)=delete; + RBASoundContent& operator=(RBASoundContent&&)=delete; + ~RBASoundContent()=default; + +public: + /** + * @brief Returns the name of the sound content. + * @return Sound content name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the state of the sound content. + * @return List of the sound content state + */ + virtual const std::list<const RBASoundContentState*>& getContentStates() const=0; + + /** + * @brief Returns the zone of the sound content. + * @return List of the zone + */ + virtual const std::list<const RBAZone*>& getZones() const=0; + + /** + * @brief Returns the loser type. + * @return Loser type + */ + virtual RBAContentLoserType getLoserType() const=0; + +public: + /** + * @brief Defines the default loser type. + */ + const static RBAContentLoserType LOSER_TYPE_EDEFAULT = + RBAContentLoserType::NEVER_GIVEUP; + +}; + +} + +#endif diff --git a/include/rba/RBASoundContentState.hpp b/include/rba/RBASoundContentState.hpp new file mode 100644 index 0000000..fdd22f5 --- /dev/null +++ b/include/rba/RBASoundContentState.hpp @@ -0,0 +1,119 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Sound content state class + */ + +#ifndef RBASOUNDCONTENTSTATE_HPP +#define RBASOUNDCONTENTSTATE_HPP + +#include <string> + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +class RBASoundContent; + +/** + * @class RBASoundContentState + * Define the state of sound contents. + */ +class DLL_EXPORT RBASoundContentState +{ +protected: + RBASoundContentState()=default; + RBASoundContentState(const RBASoundContentState&)=delete; + RBASoundContentState(RBASoundContentState&&)=delete; + RBASoundContentState& operator=(const RBASoundContentState&)=delete; + RBASoundContentState& operator=(RBASoundContentState&&)=delete; + ~RBASoundContentState()=default;音声コンテントクラス + +public: + /** + * @brief Returns the name of the sound contents state. + * @return sound contents state name. + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the priority. + * @return priority value + */ + virtual std::int32_t getPriority() const=0; + + /** + * @brief Returns the sound content. + * @return sound content + */ + virtual const RBASoundContent* getOwner() const=0; + + /** + * @brief Returns the order. + * @return order value + * @detail The order is a number of sequence of the entry sound content state + * by request. The order value is an integer value starting from 1 and + * incremented in order, and the order value of the sound content state + * without sound request is set to 0.\n + * The order of the sound content state does not include the output request + * of the view content state. + */ + virtual std::int32_t getOrder() con音声コンテントクラスst=0; + + /** + * @brief Returns the unique character string of the sound contents state. + * @return Unique character string of the sound contents state. + * + * Unique character string is + * sound content name + CONTEXT_SEPARATER + sound content state name. + * Use the unique character string as a context name. + */ + virtual std::string getUniqueName() const=0; + + /** + * @brief Returns the name of the sound content from context name. + * @param context the context name + * @return name of the sound content + */ + static std::string getContentNameByContext(const std::string& context); + + /** + * @brief Returns the state of the sound content from context name. + * @param context the context name + * @return state of the sound content + */ + static std::string getContentStateNameByContext(const std::string& context); + + /** + * @brief Check if argument is The unique character string(context name). + * @param context the context name + * @return true: unique character string(context name) + * @return false: Not unique character string(context name) + */ + static bool isUniqueName(const std::string& context); + +public: + /** + * @brief Defines the default priority value. + */ + const static std::int32_t PRIORITY_EDEFAULT = 0; + + /** + * @brief Defines the separator for separating sound content name and sound content state name. + * And be the character to connect it. + */ + const static char CONTEXT_SEPARATER = '/'; + +}; + +} + +#endif diff --git a/include/rba/RBAViewAction.hpp b/include/rba/RBAViewAction.hpp new file mode 100644 index 0000000..5d09c39 --- /dev/null +++ b/include/rba/RBAViewAction.hpp @@ -0,0 +1,147 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * VIew action class + */ + +#ifndef RBAVIEWACTION_HPP +#define RBAVIEWACTION_HPP + +#include "RBAViewActionType.hpp" + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba { + +class RBAArea; +class RBAViewContent; +class RBAViewContentState; + +/** + * @class RBAViewAction + * Define the change information of view contents.<br> + * Change information has 2 type. + * The contents transition, that view contents change for an area. + * The contents move, that the view content displayed area changes. + */ +class DLL_EXPORT RBAViewAction +{ +public: + RBAViewAction()=default; + RBAViewAction(RBAViewAction&&)=delete; + RBAViewAction& operator=(const RBAViewAction&)=delete; + RBAViewAction& operator=(RBAViewAction&&)=delete; + virtual ~RBAViewAction()=default; + +protected: + // Copy constructor is defined in default because it is used in another class + RBAViewAction(const RBAViewAction&)=default; + +public: + /** + * @brief Returns the area of the contents transition. + * @return Area of the contents transition + */ + virtual const RBAArea* getArea() const; + + /** + * @brief Returns previously displayed the view content. + * Used when change information type is the contents transition(TRANSITION_REPLACE). + * @return Previously displayed the view content + * + * * If the change information type is not the contents transition(TRANSITION_REPLACE), returns nullptr. + */ + virtual const RBAViewContent* getFromContent() const; + + /** + * @brief Returns subsequently displayed the view content. + * Used when change information type is the contents transition(TRANSITION_REPLACE). + * @return Subsequently displayed the view content. + * + * * If the change information type is not the contents transition(TRANSITION_REPLACE), returns nullptr. + */ + virtual const RBAViewContent* getToContent() const; + + /** + * @brief Returns previously displayed the view content state. + * Used when change information type is the contents transition(TRANSITION_REPLACE). + * @return Previously displayed the view content state + * + * * If the change information type is not the contents transition(TRANSITION_REPLACE), returns nullptr. + */ + virtual const RBAViewContentState* getFromContentState() const; + + /** + * @brief Returns subsequently displayed the view content state. + * Used when change information type is the contents transition(TRANSITION_REPLACE). + * @return Subsequently displayed the view content state. + * + * * If the change information type is not the contents transition(TRANSITION_REPLACE), returns nullptr. + */ + virtual const RBAViewContentState* getToContentState() const; + + /** + * @brief Returns previously displayed the area. + * Used when change information type is the contents move(MOVE). + * @return Previously displayed the area + * + * * If the change information type is not the contents move(MOVE), returns nullptr. + */ + virtual const RBAArea* getFromArea() const; + + /** + * @brief Returns subsequently displayed the area. + * Used when change information type is the contents move(MOVE). + * @return Subsequently displayed the area + * + * * If the change information type is not the contents move(MOVE), returns nullptr. + */ + virtual const RBAArea* getToArea() const; + + /** + * @brief Returns view content of change information. + * @return View content of change information + * + * * If getViewActionType() == TRANSITION_ADD, returns display view content. + * * If getViewActionType() == TRANSITION_REMOVE, returns hide view content. + * * If getViewActionType() == TRANSITION_REPLACE, returns nullptr. + * * If getViewActionType() == MOVE, returns view content which changes the area. + */ + virtual const RBAViewContent* getContent() const; + + /** + * @brief Returns view content state of change information. + * @return View content state of change information + * + * * If getViewActionType() == TRANSITION_ADD, returns display view content state. + * * If getViewActionType() == TRANSITION_REMOVE, returns hide view content state. + * * If getViewActionType() == TRANSITION_REPLACE, returns nullptr. + * * If getViewActionType() == MOVE, returns view content state which changes the area. + */ + virtual const RBAViewContentState* getContentState() const; + + /** + * @brief Returns view action type. + * @return View action type + */ + virtual RBAViewActionType getViewActionType() const=0; + + /** + * @brief Equal operator + * @return true: equal + * @return false: not equal + */ + virtual bool operator==(const RBAViewAction& viewAction)=0; + +}; + +} + +#endif diff --git a/include/rba/RBAViewActionType.hpp b/include/rba/RBAViewActionType.hpp new file mode 100644 index 0000000..6d1f56d --- /dev/null +++ b/include/rba/RBAViewActionType.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * View action type class + */ + +#ifndef RBAVIEWACTIONTYPE_HPP +#define RBAVIEWACTIONTYPE_HPP + +namespace rba +{ + +/** + * @enum RBAViewActionType + * type of view action + */ +enum class RBAViewActionType : std::uint8_t +{ + /** + * @brief The content transition(ADD) : content is displayed in the area. + */ + TRANSITION_ADD, + + /** + * @brief The content transition(REMOVE) : content is deleted from the area. + */ + TRANSITION_REMOVE, + + /** + * @brief The content transition(REPLACE) : content is replaced on the area. + */ + TRANSITION_REPLACE, + + /** + * @brief The content move(MOVE) : The display of content changes to another area. + */ + MOVE +}; + +} + +#endif diff --git a/include/rba/RBAViewContent.hpp b/include/rba/RBAViewContent.hpp new file mode 100644 index 0000000..e5847e9 --- /dev/null +++ b/include/rba/RBAViewContent.hpp @@ -0,0 +1,89 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * View content class + */ + +#ifndef RBAVIEWCONTENT_HPP +#define RBAVIEWCONTENT_HPP + +#include <list> +#include <string> +#include "RBAContentLoserType.hpp" + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +class RBAViewContentState; +class RBAArea; +class RBASize; + +/** + * @class RBAViewContent + * Define the object of view content.<br> + * View content has plural status. + * When view contents connected to a area, active status is displayed. + * Each object can define plural area which can displayed view contents. + */ +class DLL_EXPORT RBAViewContent +{ +protected: + RBAViewContent()=default; + RBAViewContent(const RBAViewContent&)=delete; + RBAViewContent(RBAViewContent&&)=delete; + RBAViewContent& operator=(const RBAViewContent&)=delete; + RBAViewContent& operator=(RBAViewContent&&)=delete; + ~RBAViewContent()=default; + +public: + /** + * @brief Returns the name of the view content. + * @return View content name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the state of the view content. + * @return List of view content state + */ + virtual const std::list<const RBAViewContentState*>& getContentStates() const=0; + + /** + * @brief Returns the area of the view content. + * @return List of the area + */ + virtual const std::list<const RBAArea*>& getAreas() const=0; + + /** + * @brief Returns the list of size assignment to this content. + * @return List of size + */ + virtual const std::list<const RBASize*>& getSizes() const=0; + + /** + * @brief Returns the loser type. + * @return Loser type + */ + virtual RBAContentLoserType getLoserType() const=0; + +public: + /** + * @brief Defines the default loser type. + */ + const static RBAContentLoserType LOSER_TYPE_EDEFAULT = + RBAContentLoserType::NEVER_GIVEUP; + +}; + +} + +#endif diff --git a/include/rba/RBAViewContentState.hpp b/include/rba/RBAViewContentState.hpp new file mode 100644 index 0000000..be15d02 --- /dev/null +++ b/include/rba/RBAViewContentState.hpp @@ -0,0 +1,119 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * VIew content state class + */ + +#ifndef RBAVIEWCONTENTSTATE_HPP +#define RBAVIEWCONTENTSTATE_HPP + +#include <string> + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +namespace rba +{ + +class RBAViewContent; + +/** + * @class RBAViewContentState + * Define the state of view contents. + */ +class DLL_EXPORT RBAViewContentState +{ +protected: + RBAViewContentState()=default; + RBAViewContentState(const RBAViewContentState&)=delete; + RBAViewContentState(RBAViewContentState&&)=delete; + RBAViewContentState& operator=(const RBAViewContentState&)=delete; + RBAViewContentState& operator=(RBAViewContentState&&)=delete; + ~RBAViewContentState()=default; + +public: + /** + * @brief Returns the name of the view contents state. + * @return view contents state name. + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the priority. + * @return priority value + */ + virtual std::int32_t getPriority() const=0; + + /** + * @brief Returns the view content. + * @return view content + */ + virtual const RBAViewContent* getOwner() const=0; + + /** + * @brief Returns the order. + * @return order value + * @detail The order is a number of sequence of the entry view content state + * by request. The order value is an integer value starting from 1 and + * incremented in order, and the order value of the view content state + * without view request is set to 0.\n + * The order of the view content state does not include the output request + * of the sound content state. + */ + virtual std::int32_t getOrder() const=0; + + /** + * @brief Returns the unique character string of the view contents state. + * @return Unique character string of the view contents state. + * + * Unique character string is + * view content name + CONTEXT_SEPARATER + view content state name. + * Use the unique character string as a context name. + */ + virtual std::string getUniqueName() const=0; + + /** + * @brief Returns the name of the view content from context name. + * @param context the context name + * @return name of the view content + */ + static std::string getContentNameByContext(const std::string& context); + + /** + * @brief Returns the state of the view content from context name. + * @param context the context name + * @return state of the view content + */ + static std::string getContentStateNameByContext(const std::string& context); + + /** + * @brief Check if argument is The unique character string(context name). + * @param context the context name + * @return true: unique character string(context name) + * @return false: Not unique character string(context name) + */ + static bool isUniqueName(const std::string& context); + +public: + /** + * @brief Defines the default priority value. + */ + const static std::int32_t PRIORITY_EDEFAULT = 0; + + /** + * @brief Defines the separator for separating view content name and view content state name. + * And be the character to connect it. + */ + const static char CONTEXT_SEPARATER = '/'; + +}; + +} + +#endif diff --git a/include/rba/RBAZone.hpp b/include/rba/RBAZone.hpp new file mode 100644 index 0000000..2bf613c --- /dev/null +++ b/include/rba/RBAZone.hpp @@ -0,0 +1,72 @@ +// Copyright (c) 2018 DENSO CORPORATION. All rights reserved. +/** + * Zone class + */ + +#ifndef RBAZONE_HPP +#define RBAZONE_HPP + +#ifdef _MSC_VER +#ifdef _WINDLL +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __declspec(dllimport) +#endif +#else +#define DLL_EXPORT +#endif + +#include <list> +#include <string> +#include "RBAArbitrationPolicy.hpp" + +namespace rba +{ + +class RBASoundContent; + +/** + * @class RBAZone + * Defines a Frame for outputting sound content.<br> + * At run time, at most one sound content is allocated to one zone. + * This class has arbitration policy definitions, because it is executed for each zone. + */ +class DLL_EXPORT RBAZone +{ +protected: + RBAZone()=default; + RBAZone(const RBAZone&)=delete; + RBAZone(RBAZone&&)=delete; + RBAZone& operator=(const RBAZone&)=delete; + RBAZone& operator=(RBAZone&&)=delete; + ~RBAZone()=default; + +public: + /** + * @brief Returns the name of the zone. + * @return Zone name + */ + virtual std::string getName() const=0; + + /** + * @brief Returns the priority. + * @return Priority value + */ + virtual std::int32_t getPriority() const=0; + + /** + * @brief Returns the list of content which can be output in this zone. + * @return List of content + */ + virtual const std::list<const RBASoundContent*>& getContents() const=0; + + /** + * @brief Returns the arbitration policy value defined to this zone. + * @return arbitration policy value + */ + virtual RBAArbitrationPolicy getArbitrationPolicy() const=0; +}; + +} + +#endif |