From 2b4ae7fde370bc3316ab30cc38b74d23e785b360 Mon Sep 17 00:00:00 2001 From: Kenji Hosokawa Date: Mon, 24 Aug 2020 21:58:42 +0900 Subject: First commit Signed-off-by: Kenji Hosokawa Change-Id: I381abb0a6521f5349768a76ef7ceecbce4b2d701 --- src/BUILD.md | 75 + src/CMakeLists.txt | 109 + src/CMakeSettings.json | 56 + src/LICENSE | 180 ++ src/README.md | 4 + src/core/expression/RBAActionOperator.cpp | 35 + src/core/expression/RBAActionOperator.hpp | 48 + src/core/expression/RBAActiveContents.cpp | 108 + src/core/expression/RBAActiveContents.hpp | 54 + src/core/expression/RBAActiveContentsMaker.cpp | 38 + src/core/expression/RBAActiveContentsMaker.hpp | 50 + src/core/expression/RBAActiveState.cpp | 83 + src/core/expression/RBAActiveState.hpp | 50 + src/core/expression/RBAActiveStateMaker.cpp | 37 + src/core/expression/RBAActiveStateMaker.hpp | 50 + src/core/expression/RBAAllocatableOperator.cpp | 39 + src/core/expression/RBAAllocatableOperator.hpp | 49 + src/core/expression/RBAAllocatedContent.cpp | 118 + src/core/expression/RBAAllocatedContent.hpp | 54 + src/core/expression/RBAAllocatedContentMaker.cpp | 37 + src/core/expression/RBAAllocatedContentMaker.hpp | 49 + src/core/expression/RBAAndOperator.cpp | 113 + src/core/expression/RBAAndOperator.hpp | 53 + src/core/expression/RBAAndOperatorMaker.cpp | 37 + src/core/expression/RBAAndOperatorMaker.hpp | 49 + src/core/expression/RBAArithmeticOperator.cpp | 26 + src/core/expression/RBAArithmeticOperator.hpp | 42 + src/core/expression/RBAContentOperator.cpp | 40 + src/core/expression/RBAContentOperator.hpp | 49 + src/core/expression/RBAContentValue.cpp | 116 + src/core/expression/RBAContentValue.hpp | 54 + src/core/expression/RBAContentValueMaker.cpp | 38 + src/core/expression/RBAContentValueMaker.hpp | 49 + src/core/expression/RBAExecuteResult.hpp | 40 + src/core/expression/RBAExistsOperator.cpp | 175 ++ src/core/expression/RBAExistsOperator.hpp | 56 + src/core/expression/RBAExistsOperatorMaker.cpp | 58 + src/core/expression/RBAExistsOperatorMaker.hpp | 63 + src/core/expression/RBAExpression.cpp | 156 ++ src/core/expression/RBAExpression.hpp | 91 + src/core/expression/RBAExpressionMaker.cpp | 55 + src/core/expression/RBAExpressionMaker.hpp | 57 + src/core/expression/RBAExpressionType.hpp | 56 + src/core/expression/RBAExpressionVisitor.hpp | 168 ++ src/core/expression/RBAForAllOperator.cpp | 173 ++ src/core/expression/RBAForAllOperator.hpp | 56 + src/core/expression/RBAForAllOperatorMaker.cpp | 58 + src/core/expression/RBAForAllOperatorMaker.hpp | 63 + src/core/expression/RBAGetAllocatables.cpp | 95 + src/core/expression/RBAGetAllocatables.hpp | 56 + src/core/expression/RBAGetAllocatablesMaker.cpp | 37 + src/core/expression/RBAGetAllocatablesMaker.hpp | 49 + src/core/expression/RBAGetContentsList.cpp | 86 + src/core/expression/RBAGetContentsList.hpp | 54 + src/core/expression/RBAGetContentsListMaker.cpp | 37 + src/core/expression/RBAGetContentsListMaker.hpp | 49 + src/core/expression/RBAGetProperty.cpp | 101 + src/core/expression/RBAGetProperty.hpp | 57 + src/core/expression/RBAGetPropertyMaker.cpp | 37 + src/core/expression/RBAGetPropertyMaker.hpp | 49 + src/core/expression/RBAHasBeenDisplayed.cpp | 102 + src/core/expression/RBAHasBeenDisplayed.hpp | 52 + src/core/expression/RBAHasBeenDisplayedMaker.cpp | 37 + src/core/expression/RBAHasBeenDisplayedMaker.hpp | 49 + src/core/expression/RBAHasComeEarlierThan.cpp | 151 ++ src/core/expression/RBAHasComeEarlierThan.hpp | 56 + src/core/expression/RBAHasComeEarlierThanMaker.cpp | 37 + src/core/expression/RBAHasComeEarlierThanMaker.hpp | 49 + src/core/expression/RBAHasComeLaterThan.cpp | 153 ++ src/core/expression/RBAHasComeLaterThan.hpp | 55 + src/core/expression/RBAHasComeLaterThanMaker.cpp | 37 + src/core/expression/RBAHasComeLaterThanMaker.hpp | 49 + src/core/expression/RBAIfStatement.cpp | 268 ++ src/core/expression/RBAIfStatement.hpp | 73 + src/core/expression/RBAIfStatementMaker.cpp | 78 + src/core/expression/RBAIfStatementMaker.hpp | 58 + src/core/expression/RBAImpliesOperator.cpp | 145 ++ src/core/expression/RBAImpliesOperator.hpp | 54 + src/core/expression/RBAImpliesOperatorMaker.cpp | 37 + src/core/expression/RBAImpliesOperatorMaker.hpp | 49 + src/core/expression/RBAIntegerValue.cpp | 79 + src/core/expression/RBAIntegerValue.hpp | 62 + src/core/expression/RBAIntegerValueMaker.cpp | 64 + src/core/expression/RBAIntegerValueMaker.hpp | 58 + src/core/expression/RBAIsActive.cpp | 113 + src/core/expression/RBAIsActive.hpp | 54 + src/core/expression/RBAIsActiveMaker.cpp | 37 + src/core/expression/RBAIsActiveMaker.hpp | 49 + src/core/expression/RBAIsEqualToOperator.cpp | 105 + src/core/expression/RBAIsEqualToOperator.hpp | 52 + src/core/expression/RBAIsEqualToOperatorMaker.cpp | 37 + src/core/expression/RBAIsEqualToOperatorMaker.hpp | 49 + .../expression/RBAIsGreaterThanEqualOperator.cpp | 105 + .../expression/RBAIsGreaterThanEqualOperator.hpp | 52 + .../RBAIsGreaterThanEqualOperatorMaker.cpp | 37 + .../RBAIsGreaterThanEqualOperatorMaker.hpp | 49 + src/core/expression/RBAIsGreaterThanOperator.cpp | 105 + src/core/expression/RBAIsGreaterThanOperator.hpp | 52 + .../expression/RBAIsGreaterThanOperatorMaker.cpp | 37 + .../expression/RBAIsGreaterThanOperatorMaker.hpp | 49 + .../expression/RBAIsLowerThanEqualOperator.cpp | 106 + .../expression/RBAIsLowerThanEqualOperator.hpp | 52 + .../RBAIsLowerThanEqualOperatorMaker.cpp | 37 + .../RBAIsLowerThanEqualOperatorMaker.hpp | 49 + src/core/expression/RBAIsLowerThanOperator.cpp | 105 + src/core/expression/RBAIsLowerThanOperator.hpp | 52 + .../expression/RBAIsLowerThanOperatorMaker.cpp | 36 + .../expression/RBAIsLowerThanOperatorMaker.hpp | 49 + src/core/expression/RBAIsOn.cpp | 132 + src/core/expression/RBAIsOn.hpp | 56 + src/core/expression/RBAIsOnMaker.cpp | 37 + src/core/expression/RBAIsOnMaker.hpp | 50 + src/core/expression/RBAIsTypeOfOperator.cpp | 102 + src/core/expression/RBAIsTypeOfOperator.hpp | 66 + src/core/expression/RBAIsTypeOfOperatorMaker.cpp | 70 + src/core/expression/RBAIsTypeOfOperatorMaker.hpp | 58 + src/core/expression/RBALambdaContext.cpp | 92 + src/core/expression/RBALambdaContext.hpp | 57 + src/core/expression/RBALambdaContextMaker.cpp | 65 + src/core/expression/RBALambdaContextMaker.hpp | 60 + src/core/expression/RBALambdaExpression.cpp | 139 + src/core/expression/RBALambdaExpression.hpp | 77 + src/core/expression/RBALambdaExpressionMaker.cpp | 75 + src/core/expression/RBALambdaExpressionMaker.hpp | 58 + src/core/expression/RBALetStatement.cpp | 68 + src/core/expression/RBALetStatement.hpp | 54 + src/core/expression/RBALetStatementMaker.cpp | 67 + src/core/expression/RBALetStatementMaker.hpp | 58 + src/core/expression/RBALogicalOperator.cpp | 73 + src/core/expression/RBALogicalOperator.hpp | 50 + src/core/expression/RBAMaxOperator.cpp | 135 + src/core/expression/RBAMaxOperator.hpp | 53 + src/core/expression/RBAMaxOperatorMaker.cpp | 60 + src/core/expression/RBAMaxOperatorMaker.hpp | 63 + .../expression/RBAMemberFeatureReferenceMaker.cpp | 94 + .../expression/RBAMemberFeatureReferenceMaker.hpp | 62 + src/core/expression/RBAMinOperator.cpp | 135 + src/core/expression/RBAMinOperator.hpp | 51 + src/core/expression/RBAMinOperatorMaker.cpp | 60 + src/core/expression/RBAMinOperatorMaker.hpp | 63 + src/core/expression/RBANotOperator.cpp | 99 + src/core/expression/RBANotOperator.hpp | 55 + src/core/expression/RBANotOperatorMaker.cpp | 37 + src/core/expression/RBANotOperatorMaker.hpp | 49 + src/core/expression/RBAObjectCompare.cpp | 165 ++ src/core/expression/RBAObjectCompare.hpp | 57 + src/core/expression/RBAObjectCompareMaker.cpp | 37 + src/core/expression/RBAObjectCompareMaker.hpp | 49 + src/core/expression/RBAObjectReference.cpp | 133 + src/core/expression/RBAObjectReference.hpp | 63 + src/core/expression/RBAObjectReferenceMaker.cpp | 77 + src/core/expression/RBAObjectReferenceMaker.hpp | 58 + src/core/expression/RBAOperator.cpp | 99 + src/core/expression/RBAOperator.hpp | 67 + src/core/expression/RBAOperatorMaker.cpp | 61 + src/core/expression/RBAOperatorMaker.hpp | 53 + src/core/expression/RBAOrOperator.cpp | 100 + src/core/expression/RBAOrOperator.hpp | 53 + src/core/expression/RBAOrOperatorMaker.cpp | 37 + src/core/expression/RBAOrOperatorMaker.hpp | 49 + src/core/expression/RBAPlusOperator.cpp | 33 + src/core/expression/RBAPlusOperator.hpp | 46 + src/core/expression/RBAPlusOperatorMaker.cpp | 37 + src/core/expression/RBAPlusOperatorMaker.hpp | 49 + src/core/expression/RBAPreviousModifier.cpp | 97 + src/core/expression/RBAPreviousModifier.hpp | 75 + src/core/expression/RBAPreviousModifierMaker.cpp | 67 + src/core/expression/RBAPreviousModifierMaker.hpp | 58 + src/core/expression/RBAPreviousObjectWrapper.cpp | 45 + src/core/expression/RBAPreviousObjectWrapper.hpp | 52 + src/core/expression/RBAPropertyOperator.hpp | 46 + src/core/expression/RBASceneCondition.hpp | 44 + src/core/expression/RBASceneOperator.hpp | 45 + src/core/expression/RBASelectOperator.cpp | 140 + src/core/expression/RBASelectOperator.hpp | 59 + src/core/expression/RBASelectOperatorMaker.cpp | 60 + src/core/expression/RBASelectOperatorMaker.hpp | 63 + src/core/expression/RBASetExpression.hpp | 44 + src/core/expression/RBASetOfOperator.cpp | 194 ++ src/core/expression/RBASetOfOperator.hpp | 73 + src/core/expression/RBASetOfOperatorMaker.cpp | 39 + src/core/expression/RBASetOfOperatorMaker.hpp | 49 + src/core/expression/RBASetOperator.hpp | 44 + src/core/expression/RBASizeOperator.cpp | 84 + src/core/expression/RBASizeOperator.hpp | 51 + src/core/expression/RBASizeOperatorMaker.cpp | 37 + src/core/expression/RBASizeOperatorMaker.hpp | 49 + src/core/expression/RBAStateValue.cpp | 107 + src/core/expression/RBAStateValue.hpp | 53 + src/core/expression/RBAStateValueMaker.cpp | 37 + src/core/expression/RBAStateValueMaker.hpp | 49 + src/core/expression/RBAValueExpression.hpp | 44 + src/core/expression/RBAVariable.cpp | 79 + src/core/expression/RBAVariable.hpp | 65 + src/core/expression/RBAVariableMaker.cpp | 64 + src/core/expression/RBAVariableMaker.hpp | 70 + src/core/logic/RBAAffectInfo.cpp | 67 + src/core/logic/RBAAffectInfo.hpp | 58 + src/core/logic/RBAArbitrator.cpp | 1987 ++++++++++++++ src/core/logic/RBABackUpAllocatable.cpp | 33 + src/core/logic/RBABackUpAllocatable.hpp | 42 + src/core/logic/RBACommonMakerTable.cpp | 126 + src/core/logic/RBACommonMakerTable.hpp | 52 + src/core/logic/RBAConstraintInfo.cpp | 695 +++++ src/core/logic/RBAConstraintInfo.hpp | 119 + src/core/logic/RBAConstraintMap.hpp | 38 + src/core/logic/RBAContentStatus.cpp | 72 + src/core/logic/RBAContentStatus.hpp | 58 + src/core/logic/RBARequest.cpp | 44 + src/core/logic/RBARequest.hpp | 59 + src/core/logic/RBARequestQueMember.cpp | 48 + src/core/logic/RBARequestQueMember.hpp | 64 + src/core/logic/RBAResultImpl.cpp | 1088 ++++++++ src/core/logic/RBAResultImpl.hpp | 343 +++ src/core/logic/RBAResultSet.cpp | 996 +++++++ src/core/logic/RBAResultSet.hpp | 246 ++ src/core/logic/RBARollbacker.cpp | 95 + src/core/logic/RBARollbacker.hpp | 84 + src/core/logic/RBAViewAction.cpp | 88 + src/core/logic/RBAViewMove.cpp | 89 + src/core/logic/RBAViewMove.hpp | 62 + src/core/logic/RBAViewTransition.cpp | 137 + src/core/logic/RBAViewTransition.hpp | 64 + src/core/model/RBAAbstractAllocatable.cpp | 56 + src/core/model/RBAAbstractAllocatable.hpp | 65 + src/core/model/RBAAbstractAllocatableMaker.cpp | 52 + src/core/model/RBAAbstractAllocatableMaker.hpp | 53 + src/core/model/RBAAbstractConstraint.cpp | 81 + src/core/model/RBAAbstractConstraint.hpp | 71 + src/core/model/RBAAbstractConstraintMaker.cpp | 52 + src/core/model/RBAAbstractConstraintMaker.hpp | 54 + src/core/model/RBAAbstractContent.cpp | 31 + src/core/model/RBAAbstractContent.hpp | 45 + src/core/model/RBAAbstractContentMaker.cpp | 53 + src/core/model/RBAAbstractContentMaker.hpp | 53 + src/core/model/RBAAbstractProperty.cpp | 46 + src/core/model/RBAAbstractProperty.hpp | 61 + src/core/model/RBAAllocatable.cpp | 387 +++ src/core/model/RBAAllocatable.hpp | 131 + src/core/model/RBAAllocatableMaker.cpp | 82 + src/core/model/RBAAllocatableMaker.hpp | 54 + src/core/model/RBAAllocatableSet.cpp | 65 + src/core/model/RBAAllocatableSet.hpp | 59 + src/core/model/RBAAllocatableSetMaker.cpp | 57 + src/core/model/RBAAllocatableSetMaker.hpp | 53 + src/core/model/RBAConstraint.hpp | 45 + src/core/model/RBAConstraintImpl.cpp | 96 + src/core/model/RBAConstraintImpl.hpp | 56 + src/core/model/RBAConstraintMaker.cpp | 63 + src/core/model/RBAConstraintMaker.hpp | 58 + src/core/model/RBAContent.cpp | 107 + src/core/model/RBAContent.hpp | 87 + src/core/model/RBAContentMaker.cpp | 126 + src/core/model/RBAContentMaker.hpp | 53 + src/core/model/RBAContentSet.cpp | 66 + src/core/model/RBAContentSet.hpp | 61 + src/core/model/RBAContentSetMaker.cpp | 55 + src/core/model/RBAContentSetMaker.hpp | 52 + src/core/model/RBAContentState.cpp | 133 + src/core/model/RBAContentState.hpp | 74 + src/core/model/RBAContentStateMaker.cpp | 79 + src/core/model/RBAContentStateMaker.hpp | 58 + src/core/model/RBAContentStatusType.hpp | 36 + src/core/model/RBAIntegerProperty.cpp | 48 + src/core/model/RBAIntegerProperty.hpp | 53 + src/core/model/RBAModelElement.cpp | 47 + src/core/model/RBAModelElement.hpp | 52 + src/core/model/RBAModelElementMaker.cpp | 122 + src/core/model/RBAModelElementMaker.hpp | 135 + src/core/model/RBAModelElementType.hpp | 116 + src/core/model/RBAModelImpl.cpp | 823 ++++++ src/core/model/RBAModelImpl.hpp | 221 ++ src/core/model/RBANamedElement.cpp | 54 + src/core/model/RBANamedElement.hpp | 60 + src/core/model/RBARuleObject.cpp | 105 + src/core/model/RBARuleObject.hpp | 73 + src/core/model/RBARuleObjectMaker.cpp | 62 + src/core/model/RBARuleObjectMaker.hpp | 52 + src/core/model/RBASceneImpl.cpp | 113 + src/core/model/RBASceneImpl.hpp | 65 + src/core/model/RBASceneMaker.cpp | 74 + src/core/model/RBASceneMaker.hpp | 57 + src/doc/ArbitrationFW.md | 99 + src/doc/Doxygen | 2473 ++++++++++++++++++ src/doc/RBA_IF_Specification.md | 2721 ++++++++++++++++++++ src/doc/images/ArbitrationFW.png | Bin 0 -> 80336 bytes src/doc/images/ArbitrationFW.pu | 80 + src/doc/images/JSON_configuration1.png | Bin 0 -> 91233 bytes src/doc/images/JSON_configuration2.png | Bin 0 -> 127114 bytes src/doc/images/JSON_configuration3.png | Bin 0 -> 54932 bytes src/doc/images/JSON_configuration4.png | Bin 0 -> 50846 bytes src/doc/images/JSON_configuration5.png | Bin 0 -> 37281 bytes src/doc/images/JSON_configuration6.png | Bin 0 -> 66644 bytes src/doc/mkdoc.sh | 36 + src/factory/RBAAbstractMakerTable.cpp | 38 + src/factory/RBAAbstractMakerTable.hpp | 60 + src/factory/RBAJsonElement.cpp | 271 ++ src/factory/RBAJsonElement.hpp | 148 ++ src/factory/RBAJsonParser.cpp | 48 + src/factory/RBAJsonParserImpl.cpp | 315 +++ src/factory/RBAJsonParserImpl.hpp | 70 + src/factory/RBAModelFactory.cpp | 201 ++ src/factory/RBAModelFactory.hpp | 101 + src/include/rba/RBAArbitrationPolicy.hpp | 48 + src/include/rba/RBAArbitrator.hpp | 600 +++++ src/include/rba/RBAArea.hpp | 92 + src/include/rba/RBABasePoint.hpp | 75 + src/include/rba/RBAContentLoserType.hpp | 36 + src/include/rba/RBADisplay.hpp | 56 + src/include/rba/RBAJsonParser.hpp | 85 + src/include/rba/RBAModel.hpp | 241 ++ src/include/rba/RBAPositionContainer.hpp | 72 + src/include/rba/RBAResult.hpp | 861 +++++++ src/include/rba/RBAResultStatusType.hpp | 42 + src/include/rba/RBAScene.hpp | 74 + src/include/rba/RBASize.hpp | 74 + src/include/rba/RBASoundContent.hpp | 83 + src/include/rba/RBASoundContentState.hpp | 119 + src/include/rba/RBAViewAction.hpp | 147 ++ src/include/rba/RBAViewActionType.hpp | 41 + src/include/rba/RBAViewContent.hpp | 89 + src/include/rba/RBAViewContentState.hpp | 119 + src/include/rba/RBAZone.hpp | 72 + src/lib/.gitkeep | 0 src/log/RBACoverageLog.cpp | 357 +++ src/log/RBACoverageLog.hpp | 118 + src/log/RBAILogCollector.cpp | 26 + src/log/RBAILogCollector.hpp | 47 + src/log/RBALog.cpp | 43 + src/log/RBALog.hpp | 51 + src/log/RBALogManager.cpp | 863 +++++++ src/log/RBALogManager.hpp | 232 ++ src/optimize/RBAAbstractCollector.cpp | 598 +++++ src/optimize/RBAAbstractCollector.hpp | 160 ++ .../RBAAllwaysCheckConstraintCollector.cpp | 52 + .../RBAAllwaysCheckConstraintCollector.hpp | 51 + src/project/msvc/rba.sln | 31 + src/project/msvc/rba/rba.vcxproj | 352 +++ src/public/RBAArea.cpp | 26 + src/public/RBADisplay.cpp | 26 + src/public/RBADllExport.hpp | 35 + src/public/RBAModel.cpp | 26 + src/public/RBAPositionContainer.cpp | 26 + src/public/RBAResult.cpp | 25 + src/public/RBAScene.cpp | 26 + src/public/RBASize.cpp | 26 + src/public/RBAZone.cpp | 26 + src/script/conv_release.py | 23 + src/script/make_dll_x64.bat | 50 + src/script/make_dll_x64_log.bat | 50 + src/script/make_dll_x86.bat | 50 + src/script/make_dll_x86_log.bat | 50 + src/script/make_release.sh | 98 + src/script/remove_comment.py | 23 + src/script/remove_internal.py | 23 + src/sound/RBAAllInstanceOfSoundContent.cpp | 76 + src/sound/RBAAllInstanceOfSoundContent.hpp | 59 + src/sound/RBAAllInstanceOfSoundContentMaker.cpp | 56 + src/sound/RBAAllInstanceOfSoundContentMaker.hpp | 60 + src/sound/RBAAllInstanceOfZone.cpp | 76 + src/sound/RBAAllInstanceOfZone.hpp | 60 + src/sound/RBAAllInstanceOfZoneMaker.cpp | 56 + src/sound/RBAAllInstanceOfZoneMaker.hpp | 61 + src/sound/RBAIsAttenuated.cpp | 135 + src/sound/RBAIsAttenuated.hpp | 55 + src/sound/RBAIsAttenuatedMaker.cpp | 41 + src/sound/RBAIsAttenuatedMaker.hpp | 52 + src/sound/RBAIsMuted.cpp | 124 + src/sound/RBAIsMuted.hpp | 56 + src/sound/RBAIsMutedMaker.cpp | 40 + src/sound/RBAIsMutedMaker.hpp | 52 + src/sound/RBAIsOutputted.cpp | 144 ++ src/sound/RBAIsOutputted.hpp | 56 + src/sound/RBAIsOutputtedMaker.cpp | 42 + src/sound/RBAIsOutputtedMaker.hpp | 52 + src/sound/RBAIsSounding.cpp | 161 ++ src/sound/RBAIsSounding.hpp | 52 + src/sound/RBAIsSoundingMaker.cpp | 40 + src/sound/RBAIsSoundingMaker.hpp | 52 + src/sound/RBAOutputtingSound.cpp | 139 + src/sound/RBAOutputtingSound.hpp | 56 + src/sound/RBAOutputtingSoundMaker.cpp | 40 + src/sound/RBAOutputtingSoundMaker.hpp | 52 + src/sound/RBASoundContent.cpp | 25 + src/sound/RBASoundContentImpl.cpp | 95 + src/sound/RBASoundContentImpl.hpp | 75 + src/sound/RBASoundContentMaker.cpp | 58 + src/sound/RBASoundContentMaker.hpp | 61 + src/sound/RBASoundContentOperator.cpp | 26 + src/sound/RBASoundContentOperator.hpp | 45 + src/sound/RBASoundContentSet.cpp | 60 + src/sound/RBASoundContentSet.hpp | 62 + src/sound/RBASoundContentSetMaker.cpp | 56 + src/sound/RBASoundContentSetMaker.hpp | 57 + src/sound/RBASoundContentState.cpp | 50 + src/sound/RBASoundContentStateImpl.cpp | 77 + src/sound/RBASoundContentStateImpl.hpp | 55 + src/sound/RBASoundContentStateMaker.cpp | 59 + src/sound/RBASoundContentStateMaker.hpp | 61 + src/sound/RBASoundMakerTable.cpp | 70 + src/sound/RBASoundMakerTable.hpp | 45 + src/sound/RBAZoneImpl.cpp | 96 + src/sound/RBAZoneImpl.hpp | 74 + src/sound/RBAZoneMaker.cpp | 58 + src/sound/RBAZoneMaker.hpp | 57 + src/sound/RBAZoneOperator.cpp | 25 + src/sound/RBAZoneOperator.hpp | 44 + src/sound/RBAZoneSet.cpp | 60 + src/sound/RBAZoneSet.hpp | 61 + src/sound/RBAZoneSetMaker.cpp | 56 + src/sound/RBAZoneSetMaker.hpp | 57 + src/view/RBAAllInstanceOfArea.cpp | 75 + src/view/RBAAllInstanceOfArea.hpp | 57 + src/view/RBAAllInstanceOfAreaMaker.cpp | 55 + src/view/RBAAllInstanceOfAreaMaker.hpp | 62 + src/view/RBAAllInstanceOfViewContent.cpp | 74 + src/view/RBAAllInstanceOfViewContent.hpp | 58 + src/view/RBAAllInstanceOfViewContentMaker.cpp | 55 + src/view/RBAAllInstanceOfViewContentMaker.hpp | 61 + src/view/RBAAreaImpl.cpp | 222 ++ src/view/RBAAreaImpl.hpp | 96 + src/view/RBAAreaMaker.cpp | 90 + src/view/RBAAreaMaker.hpp | 58 + src/view/RBAAreaOperator.cpp | 25 + src/view/RBAAreaOperator.hpp | 41 + src/view/RBAAreaSet.cpp | 60 + src/view/RBAAreaSet.hpp | 61 + src/view/RBAAreaSetMaker.cpp | 56 + src/view/RBAAreaSetMaker.hpp | 57 + src/view/RBADisplayImpl.cpp | 69 + src/view/RBADisplayImpl.hpp | 59 + src/view/RBADisplayMaker.cpp | 72 + src/view/RBADisplayMaker.hpp | 61 + src/view/RBADisplayingContent.cpp | 138 + src/view/RBADisplayingContent.hpp | 56 + src/view/RBADisplayingContentMaker.cpp | 41 + src/view/RBADisplayingContentMaker.hpp | 52 + src/view/RBAIsDisplayed.cpp | 146 ++ src/view/RBAIsDisplayed.hpp | 53 + src/view/RBAIsDisplayedMaker.cpp | 41 + src/view/RBAIsDisplayedMaker.hpp | 52 + src/view/RBAIsHidden.cpp | 124 + src/view/RBAIsHidden.hpp | 54 + src/view/RBAIsHiddenMaker.cpp | 41 + src/view/RBAIsHiddenMaker.hpp | 52 + src/view/RBAIsVisible.cpp | 157 ++ src/view/RBAIsVisible.hpp | 54 + src/view/RBAIsVisibleMaker.cpp | 41 + src/view/RBAIsVisibleMaker.hpp | 52 + src/view/RBAPositionContainerImpl.cpp | 103 + src/view/RBAPositionContainerImpl.hpp | 70 + src/view/RBAPositionContainerMaker.cpp | 125 + src/view/RBAPositionContainerMaker.hpp | 61 + src/view/RBASizeImpl.cpp | 76 + src/view/RBASizeImpl.hpp | 57 + src/view/RBASizeMaker.cpp | 69 + src/view/RBASizeMaker.hpp | 72 + src/view/RBAViewContent.cpp | 25 + src/view/RBAViewContentImpl.cpp | 112 + src/view/RBAViewContentImpl.hpp | 78 + src/view/RBAViewContentMaker.cpp | 67 + src/view/RBAViewContentMaker.hpp | 57 + src/view/RBAViewContentOperator.cpp | 26 + src/view/RBAViewContentOperator.hpp | 45 + src/view/RBAViewContentSet.cpp | 60 + src/view/RBAViewContentSet.hpp | 62 + src/view/RBAViewContentSetMaker.cpp | 56 + src/view/RBAViewContentSetMaker.hpp | 57 + src/view/RBAViewContentState.cpp | 50 + src/view/RBAViewContentStateImpl.cpp | 75 + src/view/RBAViewContentStateImpl.hpp | 56 + src/view/RBAViewContentStateMaker.cpp | 41 + src/view/RBAViewContentStateMaker.hpp | 52 + src/view/RBAViewMakerTable.cpp | 75 + src/view/RBAViewMakerTable.hpp | 52 + 475 files changed, 46683 insertions(+) create mode 100644 src/BUILD.md create mode 100644 src/CMakeLists.txt create mode 100644 src/CMakeSettings.json create mode 100644 src/LICENSE create mode 100644 src/README.md create mode 100644 src/core/expression/RBAActionOperator.cpp create mode 100644 src/core/expression/RBAActionOperator.hpp create mode 100644 src/core/expression/RBAActiveContents.cpp create mode 100644 src/core/expression/RBAActiveContents.hpp create mode 100644 src/core/expression/RBAActiveContentsMaker.cpp create mode 100644 src/core/expression/RBAActiveContentsMaker.hpp create mode 100644 src/core/expression/RBAActiveState.cpp create mode 100644 src/core/expression/RBAActiveState.hpp create mode 100644 src/core/expression/RBAActiveStateMaker.cpp create mode 100644 src/core/expression/RBAActiveStateMaker.hpp create mode 100644 src/core/expression/RBAAllocatableOperator.cpp create mode 100644 src/core/expression/RBAAllocatableOperator.hpp create mode 100644 src/core/expression/RBAAllocatedContent.cpp create mode 100644 src/core/expression/RBAAllocatedContent.hpp create mode 100644 src/core/expression/RBAAllocatedContentMaker.cpp create mode 100644 src/core/expression/RBAAllocatedContentMaker.hpp create mode 100644 src/core/expression/RBAAndOperator.cpp create mode 100644 src/core/expression/RBAAndOperator.hpp create mode 100644 src/core/expression/RBAAndOperatorMaker.cpp create mode 100644 src/core/expression/RBAAndOperatorMaker.hpp create mode 100644 src/core/expression/RBAArithmeticOperator.cpp create mode 100644 src/core/expression/RBAArithmeticOperator.hpp create mode 100644 src/core/expression/RBAContentOperator.cpp create mode 100644 src/core/expression/RBAContentOperator.hpp create mode 100644 src/core/expression/RBAContentValue.cpp create mode 100644 src/core/expression/RBAContentValue.hpp create mode 100644 src/core/expression/RBAContentValueMaker.cpp create mode 100644 src/core/expression/RBAContentValueMaker.hpp create mode 100644 src/core/expression/RBAExecuteResult.hpp create mode 100644 src/core/expression/RBAExistsOperator.cpp create mode 100644 src/core/expression/RBAExistsOperator.hpp create mode 100644 src/core/expression/RBAExistsOperatorMaker.cpp create mode 100644 src/core/expression/RBAExistsOperatorMaker.hpp create mode 100644 src/core/expression/RBAExpression.cpp create mode 100644 src/core/expression/RBAExpression.hpp create mode 100644 src/core/expression/RBAExpressionMaker.cpp create mode 100644 src/core/expression/RBAExpressionMaker.hpp create mode 100644 src/core/expression/RBAExpressionType.hpp create mode 100644 src/core/expression/RBAExpressionVisitor.hpp create mode 100644 src/core/expression/RBAForAllOperator.cpp create mode 100644 src/core/expression/RBAForAllOperator.hpp create mode 100644 src/core/expression/RBAForAllOperatorMaker.cpp create mode 100644 src/core/expression/RBAForAllOperatorMaker.hpp create mode 100644 src/core/expression/RBAGetAllocatables.cpp create mode 100644 src/core/expression/RBAGetAllocatables.hpp create mode 100644 src/core/expression/RBAGetAllocatablesMaker.cpp create mode 100644 src/core/expression/RBAGetAllocatablesMaker.hpp create mode 100644 src/core/expression/RBAGetContentsList.cpp create mode 100644 src/core/expression/RBAGetContentsList.hpp create mode 100644 src/core/expression/RBAGetContentsListMaker.cpp create mode 100644 src/core/expression/RBAGetContentsListMaker.hpp create mode 100644 src/core/expression/RBAGetProperty.cpp create mode 100644 src/core/expression/RBAGetProperty.hpp create mode 100644 src/core/expression/RBAGetPropertyMaker.cpp create mode 100644 src/core/expression/RBAGetPropertyMaker.hpp create mode 100644 src/core/expression/RBAHasBeenDisplayed.cpp create mode 100644 src/core/expression/RBAHasBeenDisplayed.hpp create mode 100644 src/core/expression/RBAHasBeenDisplayedMaker.cpp create mode 100644 src/core/expression/RBAHasBeenDisplayedMaker.hpp create mode 100644 src/core/expression/RBAHasComeEarlierThan.cpp create mode 100644 src/core/expression/RBAHasComeEarlierThan.hpp create mode 100644 src/core/expression/RBAHasComeEarlierThanMaker.cpp create mode 100644 src/core/expression/RBAHasComeEarlierThanMaker.hpp create mode 100644 src/core/expression/RBAHasComeLaterThan.cpp create mode 100644 src/core/expression/RBAHasComeLaterThan.hpp create mode 100644 src/core/expression/RBAHasComeLaterThanMaker.cpp create mode 100644 src/core/expression/RBAHasComeLaterThanMaker.hpp create mode 100644 src/core/expression/RBAIfStatement.cpp create mode 100644 src/core/expression/RBAIfStatement.hpp create mode 100644 src/core/expression/RBAIfStatementMaker.cpp create mode 100644 src/core/expression/RBAIfStatementMaker.hpp create mode 100644 src/core/expression/RBAImpliesOperator.cpp create mode 100644 src/core/expression/RBAImpliesOperator.hpp create mode 100644 src/core/expression/RBAImpliesOperatorMaker.cpp create mode 100644 src/core/expression/RBAImpliesOperatorMaker.hpp create mode 100644 src/core/expression/RBAIntegerValue.cpp create mode 100644 src/core/expression/RBAIntegerValue.hpp create mode 100644 src/core/expression/RBAIntegerValueMaker.cpp create mode 100644 src/core/expression/RBAIntegerValueMaker.hpp create mode 100644 src/core/expression/RBAIsActive.cpp create mode 100644 src/core/expression/RBAIsActive.hpp create mode 100644 src/core/expression/RBAIsActiveMaker.cpp create mode 100644 src/core/expression/RBAIsActiveMaker.hpp create mode 100644 src/core/expression/RBAIsEqualToOperator.cpp create mode 100644 src/core/expression/RBAIsEqualToOperator.hpp create mode 100644 src/core/expression/RBAIsEqualToOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsEqualToOperatorMaker.hpp create mode 100644 src/core/expression/RBAIsGreaterThanEqualOperator.cpp create mode 100644 src/core/expression/RBAIsGreaterThanEqualOperator.hpp create mode 100644 src/core/expression/RBAIsGreaterThanEqualOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsGreaterThanEqualOperatorMaker.hpp create mode 100644 src/core/expression/RBAIsGreaterThanOperator.cpp create mode 100644 src/core/expression/RBAIsGreaterThanOperator.hpp create mode 100644 src/core/expression/RBAIsGreaterThanOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsGreaterThanOperatorMaker.hpp create mode 100644 src/core/expression/RBAIsLowerThanEqualOperator.cpp create mode 100644 src/core/expression/RBAIsLowerThanEqualOperator.hpp create mode 100644 src/core/expression/RBAIsLowerThanEqualOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsLowerThanEqualOperatorMaker.hpp create mode 100644 src/core/expression/RBAIsLowerThanOperator.cpp create mode 100644 src/core/expression/RBAIsLowerThanOperator.hpp create mode 100644 src/core/expression/RBAIsLowerThanOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsLowerThanOperatorMaker.hpp create mode 100644 src/core/expression/RBAIsOn.cpp create mode 100644 src/core/expression/RBAIsOn.hpp create mode 100644 src/core/expression/RBAIsOnMaker.cpp create mode 100644 src/core/expression/RBAIsOnMaker.hpp create mode 100644 src/core/expression/RBAIsTypeOfOperator.cpp create mode 100644 src/core/expression/RBAIsTypeOfOperator.hpp create mode 100644 src/core/expression/RBAIsTypeOfOperatorMaker.cpp create mode 100644 src/core/expression/RBAIsTypeOfOperatorMaker.hpp create mode 100644 src/core/expression/RBALambdaContext.cpp create mode 100644 src/core/expression/RBALambdaContext.hpp create mode 100644 src/core/expression/RBALambdaContextMaker.cpp create mode 100644 src/core/expression/RBALambdaContextMaker.hpp create mode 100644 src/core/expression/RBALambdaExpression.cpp create mode 100644 src/core/expression/RBALambdaExpression.hpp create mode 100644 src/core/expression/RBALambdaExpressionMaker.cpp create mode 100644 src/core/expression/RBALambdaExpressionMaker.hpp create mode 100644 src/core/expression/RBALetStatement.cpp create mode 100644 src/core/expression/RBALetStatement.hpp create mode 100644 src/core/expression/RBALetStatementMaker.cpp create mode 100644 src/core/expression/RBALetStatementMaker.hpp create mode 100644 src/core/expression/RBALogicalOperator.cpp create mode 100644 src/core/expression/RBALogicalOperator.hpp create mode 100644 src/core/expression/RBAMaxOperator.cpp create mode 100644 src/core/expression/RBAMaxOperator.hpp create mode 100644 src/core/expression/RBAMaxOperatorMaker.cpp create mode 100644 src/core/expression/RBAMaxOperatorMaker.hpp create mode 100644 src/core/expression/RBAMemberFeatureReferenceMaker.cpp create mode 100644 src/core/expression/RBAMemberFeatureReferenceMaker.hpp create mode 100644 src/core/expression/RBAMinOperator.cpp create mode 100644 src/core/expression/RBAMinOperator.hpp create mode 100644 src/core/expression/RBAMinOperatorMaker.cpp create mode 100644 src/core/expression/RBAMinOperatorMaker.hpp create mode 100644 src/core/expression/RBANotOperator.cpp create mode 100644 src/core/expression/RBANotOperator.hpp create mode 100644 src/core/expression/RBANotOperatorMaker.cpp create mode 100644 src/core/expression/RBANotOperatorMaker.hpp create mode 100644 src/core/expression/RBAObjectCompare.cpp create mode 100644 src/core/expression/RBAObjectCompare.hpp create mode 100644 src/core/expression/RBAObjectCompareMaker.cpp create mode 100644 src/core/expression/RBAObjectCompareMaker.hpp create mode 100644 src/core/expression/RBAObjectReference.cpp create mode 100644 src/core/expression/RBAObjectReference.hpp create mode 100644 src/core/expression/RBAObjectReferenceMaker.cpp create mode 100644 src/core/expression/RBAObjectReferenceMaker.hpp create mode 100644 src/core/expression/RBAOperator.cpp create mode 100644 src/core/expression/RBAOperator.hpp create mode 100644 src/core/expression/RBAOperatorMaker.cpp create mode 100644 src/core/expression/RBAOperatorMaker.hpp create mode 100644 src/core/expression/RBAOrOperator.cpp create mode 100644 src/core/expression/RBAOrOperator.hpp create mode 100644 src/core/expression/RBAOrOperatorMaker.cpp create mode 100644 src/core/expression/RBAOrOperatorMaker.hpp create mode 100644 src/core/expression/RBAPlusOperator.cpp create mode 100644 src/core/expression/RBAPlusOperator.hpp create mode 100644 src/core/expression/RBAPlusOperatorMaker.cpp create mode 100644 src/core/expression/RBAPlusOperatorMaker.hpp create mode 100644 src/core/expression/RBAPreviousModifier.cpp create mode 100644 src/core/expression/RBAPreviousModifier.hpp create mode 100644 src/core/expression/RBAPreviousModifierMaker.cpp create mode 100644 src/core/expression/RBAPreviousModifierMaker.hpp create mode 100644 src/core/expression/RBAPreviousObjectWrapper.cpp create mode 100644 src/core/expression/RBAPreviousObjectWrapper.hpp create mode 100644 src/core/expression/RBAPropertyOperator.hpp create mode 100644 src/core/expression/RBASceneCondition.hpp create mode 100644 src/core/expression/RBASceneOperator.hpp create mode 100644 src/core/expression/RBASelectOperator.cpp create mode 100644 src/core/expression/RBASelectOperator.hpp create mode 100644 src/core/expression/RBASelectOperatorMaker.cpp create mode 100644 src/core/expression/RBASelectOperatorMaker.hpp create mode 100644 src/core/expression/RBASetExpression.hpp create mode 100644 src/core/expression/RBASetOfOperator.cpp create mode 100644 src/core/expression/RBASetOfOperator.hpp create mode 100644 src/core/expression/RBASetOfOperatorMaker.cpp create mode 100644 src/core/expression/RBASetOfOperatorMaker.hpp create mode 100644 src/core/expression/RBASetOperator.hpp create mode 100644 src/core/expression/RBASizeOperator.cpp create mode 100644 src/core/expression/RBASizeOperator.hpp create mode 100644 src/core/expression/RBASizeOperatorMaker.cpp create mode 100644 src/core/expression/RBASizeOperatorMaker.hpp create mode 100644 src/core/expression/RBAStateValue.cpp create mode 100644 src/core/expression/RBAStateValue.hpp create mode 100644 src/core/expression/RBAStateValueMaker.cpp create mode 100644 src/core/expression/RBAStateValueMaker.hpp create mode 100644 src/core/expression/RBAValueExpression.hpp create mode 100644 src/core/expression/RBAVariable.cpp create mode 100644 src/core/expression/RBAVariable.hpp create mode 100644 src/core/expression/RBAVariableMaker.cpp create mode 100644 src/core/expression/RBAVariableMaker.hpp create mode 100644 src/core/logic/RBAAffectInfo.cpp create mode 100644 src/core/logic/RBAAffectInfo.hpp create mode 100644 src/core/logic/RBAArbitrator.cpp create mode 100644 src/core/logic/RBABackUpAllocatable.cpp create mode 100644 src/core/logic/RBABackUpAllocatable.hpp create mode 100644 src/core/logic/RBACommonMakerTable.cpp create mode 100644 src/core/logic/RBACommonMakerTable.hpp create mode 100644 src/core/logic/RBAConstraintInfo.cpp create mode 100644 src/core/logic/RBAConstraintInfo.hpp create mode 100644 src/core/logic/RBAConstraintMap.hpp create mode 100644 src/core/logic/RBAContentStatus.cpp create mode 100644 src/core/logic/RBAContentStatus.hpp create mode 100644 src/core/logic/RBARequest.cpp create mode 100644 src/core/logic/RBARequest.hpp create mode 100644 src/core/logic/RBARequestQueMember.cpp create mode 100644 src/core/logic/RBARequestQueMember.hpp create mode 100644 src/core/logic/RBAResultImpl.cpp create mode 100644 src/core/logic/RBAResultImpl.hpp create mode 100644 src/core/logic/RBAResultSet.cpp create mode 100644 src/core/logic/RBAResultSet.hpp create mode 100644 src/core/logic/RBARollbacker.cpp create mode 100644 src/core/logic/RBARollbacker.hpp create mode 100644 src/core/logic/RBAViewAction.cpp create mode 100644 src/core/logic/RBAViewMove.cpp create mode 100644 src/core/logic/RBAViewMove.hpp create mode 100644 src/core/logic/RBAViewTransition.cpp create mode 100644 src/core/logic/RBAViewTransition.hpp create mode 100644 src/core/model/RBAAbstractAllocatable.cpp create mode 100644 src/core/model/RBAAbstractAllocatable.hpp create mode 100644 src/core/model/RBAAbstractAllocatableMaker.cpp create mode 100644 src/core/model/RBAAbstractAllocatableMaker.hpp create mode 100644 src/core/model/RBAAbstractConstraint.cpp create mode 100644 src/core/model/RBAAbstractConstraint.hpp create mode 100644 src/core/model/RBAAbstractConstraintMaker.cpp create mode 100644 src/core/model/RBAAbstractConstraintMaker.hpp create mode 100644 src/core/model/RBAAbstractContent.cpp create mode 100644 src/core/model/RBAAbstractContent.hpp create mode 100644 src/core/model/RBAAbstractContentMaker.cpp create mode 100644 src/core/model/RBAAbstractContentMaker.hpp create mode 100644 src/core/model/RBAAbstractProperty.cpp create mode 100644 src/core/model/RBAAbstractProperty.hpp create mode 100644 src/core/model/RBAAllocatable.cpp create mode 100644 src/core/model/RBAAllocatable.hpp create mode 100644 src/core/model/RBAAllocatableMaker.cpp create mode 100644 src/core/model/RBAAllocatableMaker.hpp create mode 100644 src/core/model/RBAAllocatableSet.cpp create mode 100644 src/core/model/RBAAllocatableSet.hpp create mode 100644 src/core/model/RBAAllocatableSetMaker.cpp create mode 100644 src/core/model/RBAAllocatableSetMaker.hpp create mode 100644 src/core/model/RBAConstraint.hpp create mode 100644 src/core/model/RBAConstraintImpl.cpp create mode 100644 src/core/model/RBAConstraintImpl.hpp create mode 100644 src/core/model/RBAConstraintMaker.cpp create mode 100644 src/core/model/RBAConstraintMaker.hpp create mode 100644 src/core/model/RBAContent.cpp create mode 100644 src/core/model/RBAContent.hpp create mode 100644 src/core/model/RBAContentMaker.cpp create mode 100644 src/core/model/RBAContentMaker.hpp create mode 100644 src/core/model/RBAContentSet.cpp create mode 100644 src/core/model/RBAContentSet.hpp create mode 100644 src/core/model/RBAContentSetMaker.cpp create mode 100644 src/core/model/RBAContentSetMaker.hpp create mode 100644 src/core/model/RBAContentState.cpp create mode 100644 src/core/model/RBAContentState.hpp create mode 100644 src/core/model/RBAContentStateMaker.cpp create mode 100644 src/core/model/RBAContentStateMaker.hpp create mode 100644 src/core/model/RBAContentStatusType.hpp create mode 100644 src/core/model/RBAIntegerProperty.cpp create mode 100644 src/core/model/RBAIntegerProperty.hpp create mode 100644 src/core/model/RBAModelElement.cpp create mode 100644 src/core/model/RBAModelElement.hpp create mode 100644 src/core/model/RBAModelElementMaker.cpp create mode 100644 src/core/model/RBAModelElementMaker.hpp create mode 100644 src/core/model/RBAModelElementType.hpp create mode 100644 src/core/model/RBAModelImpl.cpp create mode 100644 src/core/model/RBAModelImpl.hpp create mode 100644 src/core/model/RBANamedElement.cpp create mode 100644 src/core/model/RBANamedElement.hpp create mode 100644 src/core/model/RBARuleObject.cpp create mode 100644 src/core/model/RBARuleObject.hpp create mode 100644 src/core/model/RBARuleObjectMaker.cpp create mode 100644 src/core/model/RBARuleObjectMaker.hpp create mode 100644 src/core/model/RBASceneImpl.cpp create mode 100644 src/core/model/RBASceneImpl.hpp create mode 100644 src/core/model/RBASceneMaker.cpp create mode 100644 src/core/model/RBASceneMaker.hpp create mode 100644 src/doc/ArbitrationFW.md create mode 100755 src/doc/Doxygen create mode 100644 src/doc/RBA_IF_Specification.md create mode 100644 src/doc/images/ArbitrationFW.png create mode 100644 src/doc/images/ArbitrationFW.pu create mode 100644 src/doc/images/JSON_configuration1.png create mode 100644 src/doc/images/JSON_configuration2.png create mode 100644 src/doc/images/JSON_configuration3.png create mode 100644 src/doc/images/JSON_configuration4.png create mode 100644 src/doc/images/JSON_configuration5.png create mode 100644 src/doc/images/JSON_configuration6.png create mode 100755 src/doc/mkdoc.sh create mode 100644 src/factory/RBAAbstractMakerTable.cpp create mode 100644 src/factory/RBAAbstractMakerTable.hpp create mode 100644 src/factory/RBAJsonElement.cpp create mode 100644 src/factory/RBAJsonElement.hpp create mode 100644 src/factory/RBAJsonParser.cpp create mode 100644 src/factory/RBAJsonParserImpl.cpp create mode 100644 src/factory/RBAJsonParserImpl.hpp create mode 100644 src/factory/RBAModelFactory.cpp create mode 100644 src/factory/RBAModelFactory.hpp create mode 100644 src/include/rba/RBAArbitrationPolicy.hpp create mode 100644 src/include/rba/RBAArbitrator.hpp create mode 100644 src/include/rba/RBAArea.hpp create mode 100644 src/include/rba/RBABasePoint.hpp create mode 100644 src/include/rba/RBAContentLoserType.hpp create mode 100644 src/include/rba/RBADisplay.hpp create mode 100644 src/include/rba/RBAJsonParser.hpp create mode 100644 src/include/rba/RBAModel.hpp create mode 100644 src/include/rba/RBAPositionContainer.hpp create mode 100644 src/include/rba/RBAResult.hpp create mode 100644 src/include/rba/RBAResultStatusType.hpp create mode 100644 src/include/rba/RBAScene.hpp create mode 100644 src/include/rba/RBASize.hpp create mode 100644 src/include/rba/RBASoundContent.hpp create mode 100644 src/include/rba/RBASoundContentState.hpp create mode 100644 src/include/rba/RBAViewAction.hpp create mode 100644 src/include/rba/RBAViewActionType.hpp create mode 100644 src/include/rba/RBAViewContent.hpp create mode 100644 src/include/rba/RBAViewContentState.hpp create mode 100644 src/include/rba/RBAZone.hpp create mode 100644 src/lib/.gitkeep create mode 100644 src/log/RBACoverageLog.cpp create mode 100644 src/log/RBACoverageLog.hpp create mode 100644 src/log/RBAILogCollector.cpp create mode 100644 src/log/RBAILogCollector.hpp create mode 100644 src/log/RBALog.cpp create mode 100644 src/log/RBALog.hpp create mode 100644 src/log/RBALogManager.cpp create mode 100644 src/log/RBALogManager.hpp create mode 100644 src/optimize/RBAAbstractCollector.cpp create mode 100644 src/optimize/RBAAbstractCollector.hpp create mode 100644 src/optimize/RBAAllwaysCheckConstraintCollector.cpp create mode 100644 src/optimize/RBAAllwaysCheckConstraintCollector.hpp create mode 100644 src/project/msvc/rba.sln create mode 100644 src/project/msvc/rba/rba.vcxproj create mode 100644 src/public/RBAArea.cpp create mode 100644 src/public/RBADisplay.cpp create mode 100644 src/public/RBADllExport.hpp create mode 100644 src/public/RBAModel.cpp create mode 100644 src/public/RBAPositionContainer.cpp create mode 100644 src/public/RBAResult.cpp create mode 100644 src/public/RBAScene.cpp create mode 100644 src/public/RBASize.cpp create mode 100644 src/public/RBAZone.cpp create mode 100644 src/script/conv_release.py create mode 100644 src/script/make_dll_x64.bat create mode 100644 src/script/make_dll_x64_log.bat create mode 100644 src/script/make_dll_x86.bat create mode 100644 src/script/make_dll_x86_log.bat create mode 100644 src/script/make_release.sh create mode 100644 src/script/remove_comment.py create mode 100644 src/script/remove_internal.py create mode 100644 src/sound/RBAAllInstanceOfSoundContent.cpp create mode 100644 src/sound/RBAAllInstanceOfSoundContent.hpp create mode 100644 src/sound/RBAAllInstanceOfSoundContentMaker.cpp create mode 100644 src/sound/RBAAllInstanceOfSoundContentMaker.hpp create mode 100644 src/sound/RBAAllInstanceOfZone.cpp create mode 100644 src/sound/RBAAllInstanceOfZone.hpp create mode 100644 src/sound/RBAAllInstanceOfZoneMaker.cpp create mode 100644 src/sound/RBAAllInstanceOfZoneMaker.hpp create mode 100644 src/sound/RBAIsAttenuated.cpp create mode 100644 src/sound/RBAIsAttenuated.hpp create mode 100644 src/sound/RBAIsAttenuatedMaker.cpp create mode 100644 src/sound/RBAIsAttenuatedMaker.hpp create mode 100644 src/sound/RBAIsMuted.cpp create mode 100644 src/sound/RBAIsMuted.hpp create mode 100644 src/sound/RBAIsMutedMaker.cpp create mode 100644 src/sound/RBAIsMutedMaker.hpp create mode 100644 src/sound/RBAIsOutputted.cpp create mode 100644 src/sound/RBAIsOutputted.hpp create mode 100644 src/sound/RBAIsOutputtedMaker.cpp create mode 100644 src/sound/RBAIsOutputtedMaker.hpp create mode 100644 src/sound/RBAIsSounding.cpp create mode 100644 src/sound/RBAIsSounding.hpp create mode 100644 src/sound/RBAIsSoundingMaker.cpp create mode 100644 src/sound/RBAIsSoundingMaker.hpp create mode 100644 src/sound/RBAOutputtingSound.cpp create mode 100644 src/sound/RBAOutputtingSound.hpp create mode 100644 src/sound/RBAOutputtingSoundMaker.cpp create mode 100644 src/sound/RBAOutputtingSoundMaker.hpp create mode 100644 src/sound/RBASoundContent.cpp create mode 100644 src/sound/RBASoundContentImpl.cpp create mode 100644 src/sound/RBASoundContentImpl.hpp create mode 100644 src/sound/RBASoundContentMaker.cpp create mode 100644 src/sound/RBASoundContentMaker.hpp create mode 100644 src/sound/RBASoundContentOperator.cpp create mode 100644 src/sound/RBASoundContentOperator.hpp create mode 100644 src/sound/RBASoundContentSet.cpp create mode 100644 src/sound/RBASoundContentSet.hpp create mode 100644 src/sound/RBASoundContentSetMaker.cpp create mode 100644 src/sound/RBASoundContentSetMaker.hpp create mode 100644 src/sound/RBASoundContentState.cpp create mode 100644 src/sound/RBASoundContentStateImpl.cpp create mode 100644 src/sound/RBASoundContentStateImpl.hpp create mode 100644 src/sound/RBASoundContentStateMaker.cpp create mode 100644 src/sound/RBASoundContentStateMaker.hpp create mode 100644 src/sound/RBASoundMakerTable.cpp create mode 100644 src/sound/RBASoundMakerTable.hpp create mode 100644 src/sound/RBAZoneImpl.cpp create mode 100644 src/sound/RBAZoneImpl.hpp create mode 100644 src/sound/RBAZoneMaker.cpp create mode 100644 src/sound/RBAZoneMaker.hpp create mode 100644 src/sound/RBAZoneOperator.cpp create mode 100644 src/sound/RBAZoneOperator.hpp create mode 100644 src/sound/RBAZoneSet.cpp create mode 100644 src/sound/RBAZoneSet.hpp create mode 100644 src/sound/RBAZoneSetMaker.cpp create mode 100644 src/sound/RBAZoneSetMaker.hpp create mode 100644 src/view/RBAAllInstanceOfArea.cpp create mode 100644 src/view/RBAAllInstanceOfArea.hpp create mode 100644 src/view/RBAAllInstanceOfAreaMaker.cpp create mode 100644 src/view/RBAAllInstanceOfAreaMaker.hpp create mode 100644 src/view/RBAAllInstanceOfViewContent.cpp create mode 100644 src/view/RBAAllInstanceOfViewContent.hpp create mode 100644 src/view/RBAAllInstanceOfViewContentMaker.cpp create mode 100644 src/view/RBAAllInstanceOfViewContentMaker.hpp create mode 100644 src/view/RBAAreaImpl.cpp create mode 100644 src/view/RBAAreaImpl.hpp create mode 100644 src/view/RBAAreaMaker.cpp create mode 100644 src/view/RBAAreaMaker.hpp create mode 100644 src/view/RBAAreaOperator.cpp create mode 100644 src/view/RBAAreaOperator.hpp create mode 100644 src/view/RBAAreaSet.cpp create mode 100644 src/view/RBAAreaSet.hpp create mode 100644 src/view/RBAAreaSetMaker.cpp create mode 100644 src/view/RBAAreaSetMaker.hpp create mode 100644 src/view/RBADisplayImpl.cpp create mode 100644 src/view/RBADisplayImpl.hpp create mode 100644 src/view/RBADisplayMaker.cpp create mode 100644 src/view/RBADisplayMaker.hpp create mode 100644 src/view/RBADisplayingContent.cpp create mode 100644 src/view/RBADisplayingContent.hpp create mode 100644 src/view/RBADisplayingContentMaker.cpp create mode 100644 src/view/RBADisplayingContentMaker.hpp create mode 100644 src/view/RBAIsDisplayed.cpp create mode 100644 src/view/RBAIsDisplayed.hpp create mode 100644 src/view/RBAIsDisplayedMaker.cpp create mode 100644 src/view/RBAIsDisplayedMaker.hpp create mode 100644 src/view/RBAIsHidden.cpp create mode 100644 src/view/RBAIsHidden.hpp create mode 100644 src/view/RBAIsHiddenMaker.cpp create mode 100644 src/view/RBAIsHiddenMaker.hpp create mode 100644 src/view/RBAIsVisible.cpp create mode 100644 src/view/RBAIsVisible.hpp create mode 100644 src/view/RBAIsVisibleMaker.cpp create mode 100644 src/view/RBAIsVisibleMaker.hpp create mode 100644 src/view/RBAPositionContainerImpl.cpp create mode 100644 src/view/RBAPositionContainerImpl.hpp create mode 100644 src/view/RBAPositionContainerMaker.cpp create mode 100644 src/view/RBAPositionContainerMaker.hpp create mode 100644 src/view/RBASizeImpl.cpp create mode 100644 src/view/RBASizeImpl.hpp create mode 100644 src/view/RBASizeMaker.cpp create mode 100644 src/view/RBASizeMaker.hpp create mode 100644 src/view/RBAViewContent.cpp create mode 100644 src/view/RBAViewContentImpl.cpp create mode 100644 src/view/RBAViewContentImpl.hpp create mode 100644 src/view/RBAViewContentMaker.cpp create mode 100644 src/view/RBAViewContentMaker.hpp create mode 100644 src/view/RBAViewContentOperator.cpp create mode 100644 src/view/RBAViewContentOperator.hpp create mode 100644 src/view/RBAViewContentSet.cpp create mode 100644 src/view/RBAViewContentSet.hpp create mode 100644 src/view/RBAViewContentSetMaker.cpp create mode 100644 src/view/RBAViewContentSetMaker.hpp create mode 100644 src/view/RBAViewContentState.cpp create mode 100644 src/view/RBAViewContentStateImpl.cpp create mode 100644 src/view/RBAViewContentStateImpl.hpp create mode 100644 src/view/RBAViewContentStateMaker.cpp create mode 100644 src/view/RBAViewContentStateMaker.hpp create mode 100644 src/view/RBAViewMakerTable.cpp create mode 100644 src/view/RBAViewMakerTable.hpp (limited to 'src') diff --git a/src/BUILD.md b/src/BUILD.md new file mode 100644 index 0000000..b47b9ac --- /dev/null +++ b/src/BUILD.md @@ -0,0 +1,75 @@ +# Biuld of aribrator + +## 1. Overview + +This document describes build of Rule Based Arbitrator + +## 2. Directory structure and library + +|Path|Contents| +|:---|:---| +| rba/include/ | header files | +| rba/src/ | source code files | +| rba/lib/ | libraries | +| rba/lib/librba.a | Arbitrator staticl lib
(on Linux) | +| rba/lib/librba.so | Arbitrator shared lib
(on Linux) | +| rba/lib/rba.dll | Arbitrator DLL
(on Windows) | +| rba/unittest/ | for unit test | +| rba/doc/ | Documents | +| rba/script/ | include script file | +| rba/script/make_dll_x64.bat | for creation of DLL | + + +## 3. Build step + +### 3-1. Linux + +#### 3-1-1. Environment + +* OS + - Ubuntu 16.04 + - Ubuntu 18.04 + - Windows Subsystem for Linux (Ubuntu 16.04.5 LTS) +* Development env. + - g++ 5.4.0 + - make 4.1 + - CMake 3.5.1 + +#### 3-1-2. Build + +``` +$ cd rba +$ mkdir build +$ cd build +$ cmake .. +$ make +$ ls -F ../lib +librba.a librba.so +``` +If build will be succeed,you can get **librba.a** and **librba.so**. + +### 3-2. Windows + +#### 3-2-1. Environment + +* OS + - Microsoft Windows 7 Professional 64bit + - Microsoft Windows 10 Pro 64bit +* Development Env + - Visual Studio Professional 2017 + - Desktop for C++ + - include Visual C++ tool of CMake + +#### 3-2-2. Build + +Execute command prompt for VS 2017, then executer bat file like below. + +``` +> cd rba +> script¥make_dll_x64.bat +> dir lib /w +[.] [..] rba.dll rba.exp rba.lib +``` + +If build will be succeed,you can get ```rba.dll```. + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..4ccfe4b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,109 @@ +cmake_minimum_required(VERSION 3.1) +enable_language(CXX) +set(CMAKE_CXX_STANDARD 14) # C++14 +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(PROJECT_NAME "rba") +project(${PROJECT_NAME}) + +if(USE_GCOV) + set(LIB_NAME ${PROJECT_NAME}_gcov) +else() + set(LIB_NAME ${PROJECT_NAME}) +endif(USE_GCOV) + +set(SRC_DIR src) +set(INCLUDE_DIR include) +file(GLOB_RECURSE SRC ${SRC_DIR}/*.cpp) +include_directories( + ${INCLUDE_DIR}/rba + ${SRC_DIR}/core/logic + ${SRC_DIR}/core/model + ${SRC_DIR}/core/expression + ${SRC_DIR}/factory + ${SRC_DIR}/log + ${SRC_DIR}/optimize + ${SRC_DIR}/public + ${SRC_DIR}/sound + ${SRC_DIR}/view + ${SRC_DIR}/animation + ) + +if(NOLOG) + # compile without log +else() + add_definitions(-DRBA_USE_LOG) +endif(NOLOG) + +if(WIN32) + # for Windows + add_definitions(-D_WINDLL) + add_definitions(-D_USRDLL) + add_definitions(-DNDEBUG) + add_definitions(-DRBA_EXPORTS) + add_definitions(/source-charset:utf-8) + add_definitions(/MP9) + set(CMAKE_SHARED_LINKER_FLAGS "/SUBSYSTEM:WINDOWS") + set(rba_BINARY_DIR ${PROJECT_SOURCE_DIR}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/lib) + +else() + # for Linux + add_definitions("-Wall") + + if(RELEASE) + add_definitions("-O2") + else() + if(USE_GPROF) + add_definitions("-pg") + else() + add_definitions("-g") + endif(USE_GPROF) + endif(RELEASE) + + if(USE_GCOV) + add_definitions(-fprofile-arcs -ftest-coverage -fno-exceptions) + set(CMAKE_SHARED_LINKER_FLAGS "--coverage") + else() + if(USE_GPROF) + set(CMAKE_SHARED_LINKER_FLAGS "-pg") + endif(USE_GPROF) + endif(USE_GCOV) + + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) + +endif(WIN32) + +add_library(rba_shared SHARED ${SRC}) +set_target_properties(rba_shared PROPERTIES OUTPUT_NAME ${LIB_NAME}) + +if(WIN32) +else() + add_library(rba_static STATIC ${SRC}) + set_target_properties(rba_static PROPERTIES OUTPUT_NAME ${LIB_NAME}) +endif(WIN32) + +if(WIN32) + target_link_libraries(rba_shared + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib + shell32.lib ole32.lib oleaut32.lib uuid.lib + ) +endif(WIN32) + +if(DEBUG_CMAKE) +message(STATUS "*** dump start cmake variables ***") +get_cmake_property(_variableNames VARIABLES) +foreach(_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") +endforeach() +message(STATUS "*** dump end ***") +endif(DEBUG_CMAKE) + +# end of file diff --git a/src/CMakeSettings.json b/src/CMakeSettings.json new file mode 100644 index 0000000..ed9cc6c --- /dev/null +++ b/src/CMakeSettings.json @@ -0,0 +1,56 @@ +{ + "configurations": [ + { + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "configurationType": "Release", + "generator": "Visual Studio 15 2017 Win64", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", + "name": "x64-Release" + }, + { + "name": "x64-Debug", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}" + }, + { + "name": "x64-Debug-NOLOG", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "variables": [ + { + "name": "NOLOG", + "value": "1" + } + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}" + }, + { + "name": "x64-Release-NOLOG", + "generator": "Visual Studio 15 2017 Win64", + "configurationType": "Release", + "inheritEnvironments": [ + "msvc_x64_x64" + ], + "variables": [ + { + "name": "NOLOG", + "value": "1" + } + ], + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}" + } + ] +} \ No newline at end of file diff --git a/src/LICENSE b/src/LICENSE new file mode 100644 index 0000000..eb21216 --- /dev/null +++ b/src/LICENSE @@ -0,0 +1,180 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized + by the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, + documentation source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. + For the purposes of this License, Derivative Works shall not include + works that remain separable from, or merely link (or bind by name) + to the interfaces of, the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, + "submitted" means any form of electronic, verbal, + or written communication sent to the Licensor or its representatives, + including but not limited to communication on electronic mailing lists, + source code control systems, and issue tracking systems + that are managed by, or on behalf of, the Licensor for the + purpose of discussing and improving the Work, but excluding communication + that is conspicuously marked or otherwise designated in + writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor + and subsequently incorporated within the Work. + +2. Grant of Copyright License. + Subject to the terms and conditions of this License, + each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable copyright license + to reproduce, prepare Derivative Works of, publicly display, + publicly perform, sublicense, and distribute the Work + and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + Subject to the terms and conditions of this License, + each Contributor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, + irrevocable (except as stated in this section) patent license to make, + have made, use, offer to sell, sell, import, + and otherwise transfer the Work, where such license applies only to + those patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of + their Contribution(s) with the Work to which such Contribution(s) + was submitted. If You institute patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that + the Work or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses granted to + You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. +You may reproduce and distribute copies of the Work or +Derivative Works thereof in any medium, with or without modifications, +and in Source or Object form, provided that You meet the following conditions: + + a. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + b. You must cause any modified files to carry prominent notices + stating that You changed the files; and + c. You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, + and attribution notices from the Source form of the Work, + excluding those notices that do not pertain + to any part of the Derivative Works; and + d. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include + a readable copy of the attribution notices contained within + such NOTICE file, excluding those notices that do not pertain t + o any part of the Derivative Works, in at least one of + the following places: within a NOTICE text file distributed as part of + the Derivative Works; within the Source form or documentation, + if provided along with the Derivative Works; or, within a display + generated by the Derivative Works, if and wherever such third-party + notices normally appear. The contents of the NOTICE file are for + informational purposes only and do not modify the License. + You may add Your own attribution notices within Derivative Works that + You distribute, alongside or as an addendum to the NOTICE text + from the Work, provided that such additional attribution notices + cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and + conditions for use, reproduction, or distribution of Your modifications, + or for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies + with the conditions stated in this License. + +5. Submission of Contributions. + Unless You explicitly state otherwise, any Contribution intentionally + submitted for inclusion in the Work by You to the Licensor shall be under + the terms and conditions of this License, without any additional terms or + conditions. Notwithstanding the above, nothing herein shall supersede or + modify the terms of any separate license agreement + you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + This License does not grant permission to use the trade names, + trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing + the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + Unless required by applicable law or agreed to in writing, + Licensor provides the Work (and each Contributor provides its Contributions) + on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied, including, without limitation, any warranties or + conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or + FITNESS FOR A PARTICULAR PURPOSE. + You are solely responsible for determining the appropriateness of using or + redistributing the Work and assume any risks associated with + Your exercise of permissions under this License. + +8. Limitation of Liability. + In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and + grossly negligent acts) or agreed to in writing, + shall any Contributor be liable to You for damages, including any direct, + indirect, special, incidental, or consequential damages of + any character arising as a result of this License or out of the use or + inability to use the Work (including but not limited to damages for + loss of goodwill, work stoppage, computer failure or malfunction, + or any and all other commercial damages or losses), + even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + While redistributing the Work or Derivative Works thereof, + You may choose to offer, and charge a fee for, acceptance of support, + warranty, indemnity, or other liability obligations and/or + rights consistent with this License. + However, in accepting such obligations, + You may act only on Your own behalf and on Your sole responsibility, + not on behalf of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability incurred by, + or claims asserted against, such Contributor by reason of your accepting + any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..d61540e --- /dev/null +++ b/src/README.md @@ -0,0 +1,4 @@ +# rba +Rule Based Arbitrator. + +Rule Based Arbitrator decides which of the content to display when a large number of contents to be displayed on the cockpit display device (CID, meter, HUD, etc.) occur simultaneously under a certain rule (arbitration. ). diff --git a/src/core/expression/RBAActionOperator.cpp b/src/core/expression/RBAActionOperator.cpp new file mode 100644 index 0000000..7cd38ec --- /dev/null +++ b/src/core/expression/RBAActionOperator.cpp @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Action operator class definition + */ + +#include "RBAActionOperator.hpp" +#include "RBAExpressionType.hpp" + +namespace rba +{ + +#ifdef RBA_USE_LOG +RBAExpressionType +RBAActionOperator::getUnderlyingType() const +{ + return RBAExpressionType::ACTION; +} +#endif + +} diff --git a/src/core/expression/RBAActionOperator.hpp b/src/core/expression/RBAActionOperator.hpp new file mode 100644 index 0000000..677f699 --- /dev/null +++ b/src/core/expression/RBAActionOperator.hpp @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Action operator class + */ + +#ifndef RBAACTIONOPERATOR_HPP +#define RBAACTIONOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAActionOperator : public RBAOperator +{ +protected: + RBAActionOperator()=default; + RBAActionOperator(const RBAActionOperator&)=delete; + RBAActionOperator(const RBAActionOperator&&)=delete; + RBAActionOperator& operator=(const RBAActionOperator&)=delete; + RBAActionOperator& operator=(const RBAActionOperator&&)=delete; + +public: + // Log +#ifdef RBA_USE_LOG + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAActiveContents.cpp b/src/core/expression/RBAActiveContents.cpp new file mode 100644 index 0000000..b5d88a7 --- /dev/null +++ b/src/core/expression/RBAActiveContents.cpp @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Select operator class definition + */ + +#include +#include "RBAActiveContents.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAArbitrator.hpp" +#include "RBAAllocatable.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +RBAActiveContents::RBAActiveContents() +: RBAAllocatableOperator(), + contentSet_{std::make_unique()} +{ +} + +void +RBAActiveContents::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAActiveContents::getModelElementType() const +{ + return RBAModelElementType::ActiveContents; +} + +const RBARuleObject* +RBAActiveContents::getReferenceObjectCore(RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + const RBARuleObject* returnObj {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const lhsObj {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } + else if (lhsObj != nullptr) { + contentSet_->clear(); + const RBAAllocatable* const alloc {dynamic_cast(lhsObj->getRawObject())}; +#ifdef RBA_USE_LOG + if (arb == nullptr) { + // Follow this path when called from createHierarchy() + returnObj = alloc->getContentSet(); + } else { +#endif + for (auto& content : alloc->getInternalContents()) { + if (alloc->isPrevious()) { + if (arb->getResult()->isPreActive(content)) { + contentSet_->addTarget(content); + } + } else { + if (arb->getResult()->isActive(content)) { + contentSet_->addTarget(content); + } + } + } + returnObj = contentSet_.get(); +#ifdef RBA_USE_LOG + } +#endif + } else { + ; + } +#ifdef RBA_USE_LOG + std::string objName = "NULL"; + if (returnObj != nullptr) { + objName = returnObj->getElementName(); + } + LOG_arbitrateConstraintLogicLogLine( + " " + LOG_getExpressionText() + " is " + objName); +#endif + LOG_removeHierarchy(); + return returnObj; +} +#ifdef RBA_USE_LOG +const std::string +RBAActiveContents::getSymbol() const +{ + return ".activeContents()"; +} +#endif + +} diff --git a/src/core/expression/RBAActiveContents.hpp b/src/core/expression/RBAActiveContents.hpp new file mode 100644 index 0000000..3ee9f7d --- /dev/null +++ b/src/core/expression/RBAActiveContents.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ActiveContents operator + */ + +#ifndef RBAACTIVECONTENTS_HPP +#define RBAACTIVECONTENTS_HPP + +#include "RBAAllocatableOperator.hpp" +#include "RBAContentSet.hpp" + +namespace rba +{ + +class RBAActiveContents : public RBAAllocatableOperator +{ + public: + RBAActiveContents(); + RBAActiveContents(const RBAActiveContents&)=delete; + RBAActiveContents(const RBAActiveContents&&)=delete; + RBAActiveContents& operator=(const RBAActiveContents&)=delete; + RBAActiveContents& operator=(const RBAActiveContents&&)=delete; + virtual ~RBAActiveContents()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif + private: + std::unique_ptr contentSet_; +}; + +} + +#endif diff --git a/src/core/expression/RBAActiveContentsMaker.cpp b/src/core/expression/RBAActiveContentsMaker.cpp new file mode 100644 index 0000000..f883fee --- /dev/null +++ b/src/core/expression/RBAActiveContentsMaker.cpp @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAActiveContentsMaker.cpp +/// @brief ActiveContents object creation class defintion +/// + +#include "RBAActiveContentsMaker.hpp" +#include "RBAActiveContents.hpp" + +namespace rba +{ + +RBAActiveContentsMaker::RBAActiveContentsMaker() + : RBAOperatorMaker{"ActiveContents"} +{ +} + +std::unique_ptr +RBAActiveContentsMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAActiveContentsMaker.hpp b/src/core/expression/RBAActiveContentsMaker.hpp new file mode 100644 index 0000000..493e569 --- /dev/null +++ b/src/core/expression/RBAActiveContentsMaker.hpp @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAActiveContentsMaker.hpp +/// @brief ActiveContents object creation class header +/// + +#ifndef RBAACTIVECONTENTSMAKER_HPP +#define RBAACTIVECONTENTSMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief ActiveContents object creation class +class RBAActiveContentsMaker : public RBAOperatorMaker +{ +public: + RBAActiveContentsMaker(); + RBAActiveContentsMaker(const RBAActiveContentsMaker&)=delete; + RBAActiveContentsMaker(const RBAActiveContentsMaker&&)=delete; + RBAActiveContentsMaker& operator=(const RBAActiveContentsMaker&)=delete; + RBAActiveContentsMaker& operator=(const RBAActiveContentsMaker&&)=delete; + virtual ~RBAActiveContentsMaker()=default; + +public: + /// @brief Empty instanciation + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAActiveState.cpp b/src/core/expression/RBAActiveState.cpp new file mode 100644 index 0000000..1e0f6b3 --- /dev/null +++ b/src/core/expression/RBAActiveState.cpp @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * activeState definition + */ + +#include "RBAActiveState.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBAContent.hpp" +#include "RBAContentState.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAArbitrator.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +void RBAActiveState::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} +RBAModelElementType RBAActiveState::getModelElementType() const +{ + return RBAModelElementType::ActiveState; +} +const RBARuleObject* RBAActiveState::getReferenceObjectCore( + RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + const RBARuleObject* returnObj {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const ruleObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else if (ruleObj != nullptr) { + const RBAContent* const c { + dynamic_cast(ruleObj->getRawObject())}; + if (ruleObj->isPrevious()) { + returnObj = arb->getResult()->getPreActiveState(c); + } else { + returnObj = arb->getResult()->getActiveState(c); + } + } else { + ; + } +#ifdef RBA_USE_LOG + std::string str; + if (info->isExceptionBeforeArbitrate()) { + str = " is before arbitrate skip"; + } else if (ruleObj == nullptr) { + str = " no Content"; + } else if (returnObj == nullptr) { + str = " has no Active State"; + } else { + str = " is " + returnObj->getElementName(); + } + LOG_arbitrateConstraintLogicLogLine(" " + getExpressionText() + str); +#endif + LOG_removeHierarchy(); + return returnObj; +} +#ifdef RBA_USE_LOG +const std::string RBAActiveState::getSymbol() const +{ + return ".activeState()"; +} +#endif +} /* namespace rba */ diff --git a/src/core/expression/RBAActiveState.hpp b/src/core/expression/RBAActiveState.hpp new file mode 100644 index 0000000..3876c78 --- /dev/null +++ b/src/core/expression/RBAActiveState.hpp @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// activeState header +// + +#ifndef RBAACTIVESTATE_HPP +#define RBAACTIVESTATE_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class RBAActiveState : public RBAContentOperator +{ + public: + RBAActiveState()=default; + RBAActiveState(const RBAActiveState&)=delete; + RBAActiveState(const RBAActiveState&&)=delete; + RBAActiveState& operator=(const RBAActiveState&)=delete; + RBAActiveState& operator=(const RBAActiveState&&)=delete; + virtual ~RBAActiveState()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif +}; + +} /* namespace rba */ + +#endif /* RBAACTIVESTATE_HPP */ diff --git a/src/core/expression/RBAActiveStateMaker.cpp b/src/core/expression/RBAActiveStateMaker.cpp new file mode 100644 index 0000000..16d8f4c --- /dev/null +++ b/src/core/expression/RBAActiveStateMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAActiveStateMaker.cpp +/// @brief ActiveState objeckt maker class definition + +#include "RBAActiveStateMaker.hpp" +#include "RBAActiveState.hpp" + +namespace rba +{ + +RBAActiveStateMaker::RBAActiveStateMaker() + : RBAOperatorMaker{"ActiveState"} +{ +} + +std::unique_ptr +RBAActiveStateMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAActiveStateMaker.hpp b/src/core/expression/RBAActiveStateMaker.hpp new file mode 100644 index 0000000..7d42cbe --- /dev/null +++ b/src/core/expression/RBAActiveStateMaker.hpp @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAActiveStateMaker.hpp +/// @brief ActiveState object maker class header +/// + +#ifndef RBAACTIVESTATEMAKER_HPP +#define RBAACTIVESTATEMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief ActiveState object maker class +class RBAActiveStateMaker : public RBAOperatorMaker +{ +public: + RBAActiveStateMaker(); + RBAActiveStateMaker(const RBAActiveStateMaker&)=delete; + RBAActiveStateMaker(const RBAActiveStateMaker&&)=delete; + RBAActiveStateMaker& operator=(const RBAActiveStateMaker&)=delete; + RBAActiveStateMaker& operator=(const RBAActiveStateMaker&&)=delete; + virtual ~RBAActiveStateMaker()=default; + +protected: + /// @brief Empty instanciation + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAAllocatableOperator.cpp b/src/core/expression/RBAAllocatableOperator.cpp new file mode 100644 index 0000000..15a9104 --- /dev/null +++ b/src/core/expression/RBAAllocatableOperator.cpp @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Allcatable operator class definitio + */ + +#include "RBAAllocatableOperator.hpp" + +namespace rba +{ + +#ifdef RBA_USE_LOG +const std::string +RBAAllocatableOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +const std::string +RBAAllocatableOperator::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + getSymbol(); +} +#endif + +} diff --git a/src/core/expression/RBAAllocatableOperator.hpp b/src/core/expression/RBAAllocatableOperator.hpp new file mode 100644 index 0000000..7a4f40a --- /dev/null +++ b/src/core/expression/RBAAllocatableOperator.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Allocatable operator class header + */ + +#ifndef RBAALLOCATABLEOPERATOR_HPP +#define RBAALLOCATABLEOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAAllocatableOperator : public RBAOperator +{ +protected: + RBAAllocatableOperator()=default; + RBAAllocatableOperator(const RBAAllocatableOperator&)=delete; + RBAAllocatableOperator(const RBAAllocatableOperator&&)=delete; + RBAAllocatableOperator& operator=(const RBAAllocatableOperator&)=delete; + RBAAllocatableOperator& operator=(const RBAAllocatableOperator&&)=delete; + +public: + virtual ~RBAAllocatableOperator()=default; + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAAllocatedContent.cpp b/src/core/expression/RBAAllocatedContent.cpp new file mode 100644 index 0000000..923717d --- /dev/null +++ b/src/core/expression/RBAAllocatedContent.cpp @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Allocated Content class + */ + +#include "RBAAllocatedContent.hpp" + +#include "RBAAllocatable.hpp" +#include "RBAArbitrator.hpp" +#include "RBAContentState.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBAAllocatedContent::accept(RBAExpressionVisitor& visitor) +{ + // RBASceneAllocatableCollector which is the only visitor at the moment + // does not accept this content, so it will not pass this path. + // + // However, in the future, another visitor may accept it, so leave this. + visitor.visit(*this); +} + +RBAModelElementType +RBAAllocatedContent::getModelElementType() const +{ + return RBAModelElementType::AllocatedContent; +} + +const RBARuleObject* +RBAAllocatedContent::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + const RBARuleObject* object {nullptr}; // return value + const auto leftInfo = info->getChild(0U); + const auto ruleObj = getLhsOperand()->getReferenceObject(leftInfo, arb); + if (ruleObj != nullptr) { + if (!leftInfo->isExceptionBeforeArbitrate()) { + const RBAAllocatable* const alloc {dynamic_cast(ruleObj->getRawObject())}; + if (ruleObj->isPrevious() == true) { + const auto contentState = arb->getResult()->getDirectPreContentState(alloc); + if(contentState != nullptr) { + object = contentState->getOwner(); + } + } else if (alloc->isChecked()) { + const auto contentState = alloc->getState(); + if (contentState != nullptr) { + object = contentState->getOwner(); + } + // At this point, it is unsure whether the constraint expression will be False or True, + // so put it in both. + info->addTrueAllocatable(alloc); + info->addFalseAllocatable(alloc); + } else { + info->setExceptionBeforeArbitrate(true); + } + } else { + info->setExceptionBeforeArbitrate(true); + } + } +#ifdef RBA_USE_LOG + bool pre = false; + std::string str; + if (ruleObj == nullptr) { + // Currently there is no constraint expression that returns an area. + // Therefore, ruleObj never becomes NULL. + // In the future, a constraint expression that returns an area + // may be created, so leave this processing. + str = "Allocatable[NULL] has no Content skip"; + } else { + pre = ruleObj->isPrevious(); + if (info->isExceptionBeforeArbitrate()) { + str = "Allocatable[" + ruleObj->getElementName() + "] is before arbitrate skip"; + } else if (object == nullptr) { + str = "Allocatable[" + ruleObj->getElementName() + "] has no Allocated Content"; + } else { + str = "Allocatable[" + ruleObj->getElementName() + "] has Allocated Content[" + + object->getElementName() + "]"; + } + } + LOG_arbitrateConstraintLogicLogLine(" " + getPreMsg(pre) + str); +#endif + return object; +} + +#ifdef RBA_USE_LOG +const std::string +RBAAllocatedContent::getSymbol() const +{ + return ".allocatedContent()"; +} + +void +RBAAllocatedContent::createHierarchy() +{ + getLhsOperand()->createHierarchy(); +} +#endif + +} diff --git a/src/core/expression/RBAAllocatedContent.hpp b/src/core/expression/RBAAllocatedContent.hpp new file mode 100644 index 0000000..6fb44e2 --- /dev/null +++ b/src/core/expression/RBAAllocatedContent.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Allocated Content class + */ + +#ifndef RBAALLOCATEDCONTENT_HPP +#define RBAALLOCATEDCONTENT_HPP + +#include "RBAAllocatableOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAAllocatedContent : public RBAAllocatableOperator +{ + public: + RBAAllocatedContent()=default; + RBAAllocatedContent(const RBAAllocatedContent&)=delete; + RBAAllocatedContent(const RBAAllocatedContent&&)=delete; + RBAAllocatedContent& operator=(const RBAAllocatedContent&)=delete; + RBAAllocatedContent& operator=(const RBAAllocatedContent&&)=delete; + virtual ~RBAAllocatedContent()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + void createHierarchy() override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAAllocatedContentMaker.cpp b/src/core/expression/RBAAllocatedContentMaker.cpp new file mode 100644 index 0000000..36d3ad7 --- /dev/null +++ b/src/core/expression/RBAAllocatedContentMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatedContentMaker.cpp +/// @brief AllocatedContent object maker class + +#include "RBAAllocatedContentMaker.hpp" +#include "RBAAllocatedContent.hpp" + +namespace rba +{ + +RBAAllocatedContentMaker::RBAAllocatedContentMaker() + : RBAOperatorMaker{"AllocatedContent"} +{ +} + +std::unique_ptr +RBAAllocatedContentMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAAllocatedContentMaker.hpp b/src/core/expression/RBAAllocatedContentMaker.hpp new file mode 100644 index 0000000..10f83b9 --- /dev/null +++ b/src/core/expression/RBAAllocatedContentMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatedContentMaker.hpp +/// @brief AllocatedContent object maker class header file + +#ifndef RBAALLOCATEDCONTENTMAKER_HPP +#define RBAALLOCATEDCONTENTMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief AllocatedContent object maker class +class RBAAllocatedContentMaker : public RBAOperatorMaker +{ +public: + RBAAllocatedContentMaker(); + RBAAllocatedContentMaker(const RBAAllocatedContentMaker&)=delete; + RBAAllocatedContentMaker(const RBAAllocatedContentMaker&&)=delete; + RBAAllocatedContentMaker& operator=(const RBAAllocatedContentMaker&)=delete; + RBAAllocatedContentMaker& operator=(const RBAAllocatedContentMaker&&)=delete; + virtual ~RBAAllocatedContentMaker()=default; + +protected: + /// @brief Empty instanciation + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAAndOperator.cpp b/src/core/expression/RBAAndOperator.cpp new file mode 100644 index 0000000..0f3a30d --- /dev/null +++ b/src/core/expression/RBAAndOperator.cpp @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AND operator class definition + */ + +#include "RBAAndOperator.hpp" + +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void +RBAAndOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAAndOperator::getModelElementType() const +{ + return RBAModelElementType::AndOperator; +} + +bool +RBAAndOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator * arb) const +{ + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + std::uint32_t falseCount {0U}; + std::uint32_t exceptionCount {0U}; + std::uint32_t index {0U}; + for(const auto& ope : getOperand()) { + // Add count to constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(index)); + + RBAConstraintInfo* const childInfo {info->getChild(index)}; + const bool res {ope->execute(childInfo, arb)}; + if(childInfo->isExceptionBeforeArbitrate()) { + exceptionCount++; + } else if(!res) { + falseCount++; + } else { + ; + } + + // Remove count to constraint hierarchy for coverage + LOG_removeHierarchy(); + index++; + } + + // with fail + if (falseCount > 0U) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + // Rmove count to constraint hierarchy for coverage + LOG_removeHierarchy(); + return false; + } + + // exception + if (exceptionCount > 0U) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + // Rmove count to constraint hierarchy for coverage + LOG_removeHierarchy(); + info->setExceptionBeforeArbitrate(true); + return false; + } + + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + // Rmove count to constraint hierarchy for coverage + LOG_removeHierarchy(); + + return true; +} + +#ifdef RBA_USE_LOG +const std::string +RBAAndOperator::getSymbol() const +{ + return "AND"; +} +#endif + +} diff --git a/src/core/expression/RBAAndOperator.hpp b/src/core/expression/RBAAndOperator.hpp new file mode 100644 index 0000000..229c69f --- /dev/null +++ b/src/core/expression/RBAAndOperator.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AND operator class header fiel + */ + +#ifndef RBAANDOPERATOR_HPP +#define RBAANDOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAAndOperator : public RBALogicalOperator +{ + public: + RBAAndOperator()=default; + RBAAndOperator(const RBAAndOperator&)=delete; + RBAAndOperator(const RBAAndOperator&&)=delete; + RBAAndOperator& operator=(const RBAAndOperator&)=delete; + RBAAndOperator& operator=(const RBAAndOperator&&)=delete; + virtual ~RBAAndOperator()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAAndOperatorMaker.cpp b/src/core/expression/RBAAndOperatorMaker.cpp new file mode 100644 index 0000000..1606e6b --- /dev/null +++ b/src/core/expression/RBAAndOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAndOperatorMaker.cpp +/// @brief AndOperator object maker class defintion file + +#include "RBAAndOperatorMaker.hpp" +#include "RBAAndOperator.hpp" + +namespace rba +{ + +RBAAndOperatorMaker::RBAAndOperatorMaker() + : RBAOperatorMaker{"AndOperator"} +{ +} + +std::unique_ptr +RBAAndOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAAndOperatorMaker.hpp b/src/core/expression/RBAAndOperatorMaker.hpp new file mode 100644 index 0000000..6198440 --- /dev/null +++ b/src/core/expression/RBAAndOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAndOperatorMaker.hpp +/// @brief AndOperator object maker classs header file + +#ifndef RBAANDOPERATORMAKER_HPP +#define RBAANDOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief AndOperator object maker classs +class RBAAndOperatorMaker : public RBAOperatorMaker +{ +public: + RBAAndOperatorMaker(); + RBAAndOperatorMaker(const RBAAndOperatorMaker&)=delete; + RBAAndOperatorMaker(const RBAAndOperatorMaker&&)=delete; + RBAAndOperatorMaker& operator=(const RBAAndOperatorMaker&)=delete; + RBAAndOperatorMaker& operator=(const RBAAndOperatorMaker&&)=delete; + virtual ~RBAAndOperatorMaker()=default; + +protected: + /// @brief Empty instanciation + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAArithmeticOperator.cpp b/src/core/expression/RBAArithmeticOperator.cpp new file mode 100644 index 0000000..2bf25de --- /dev/null +++ b/src/core/expression/RBAArithmeticOperator.cpp @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ArithmeticOperator class definition + */ + +#include "RBAArithmeticOperator.hpp" + +namespace rba +{ + +} diff --git a/src/core/expression/RBAArithmeticOperator.hpp b/src/core/expression/RBAArithmeticOperator.hpp new file mode 100644 index 0000000..5113a84 --- /dev/null +++ b/src/core/expression/RBAArithmeticOperator.hpp @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ArithmeticOperator class header file + */ + +#ifndef RBAARITHMETICOPERATOR_HPP +#define RBAARITHMETICOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAArithmeticOperator : public RBAOperator +{ +protected: + RBAArithmeticOperator()=default; + RBAArithmeticOperator(const RBAArithmeticOperator&)=delete; + RBAArithmeticOperator(const RBAArithmeticOperator&&)=delete; + RBAArithmeticOperator& operator=(const RBAArithmeticOperator&)=delete; + RBAArithmeticOperator& operator=(const RBAArithmeticOperator&&)=delete; + +}; + +} + +#endif diff --git a/src/core/expression/RBAContentOperator.cpp b/src/core/expression/RBAContentOperator.cpp new file mode 100644 index 0000000..6f7083b --- /dev/null +++ b/src/core/expression/RBAContentOperator.cpp @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ContentOperator class definition + */ + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +#ifdef RBA_USE_LOG +const std::string +RBAContentOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +const std::string +RBAContentOperator::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + getSymbol(); +} +#endif + +} diff --git a/src/core/expression/RBAContentOperator.hpp b/src/core/expression/RBAContentOperator.hpp new file mode 100644 index 0000000..fef5ec3 --- /dev/null +++ b/src/core/expression/RBAContentOperator.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ContentOperator class + */ + +#ifndef RBACONTENTOPERATOR_HPP +#define RBACONTENTOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAContentOperator : public RBAOperator +{ +protected: + RBAContentOperator()=default; + RBAContentOperator(const RBAContentOperator&)=delete; + RBAContentOperator(const RBAContentOperator&&)=delete; + RBAContentOperator& operator=(const RBAContentOperator&)=delete; + RBAContentOperator& operator=(const RBAContentOperator&&)=delete; + +public: + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAContentValue.cpp b/src/core/expression/RBAContentValue.cpp new file mode 100644 index 0000000..23b1b20 --- /dev/null +++ b/src/core/expression/RBAContentValue.cpp @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * ContentValue class definition + */ + +#include +#include "RBAContentValue.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContentState.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBAContentValue::accept(RBAExpressionVisitor& visitor) +{ + // RBA SceneAllocatableCollector which is only existing vistor at this time + // does not accept the value of the content state. + // So this code doesn't work. + // + // But, leave this because another visitor may accept it in the future. + visitor.visit(*this); +} + +RBAModelElementType +RBAContentValue::getModelElementType() const +{ + return RBAModelElementType::ContentValue; +} + +std::int32_t +RBAContentValue::getValueCore(RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + std::int32_t result { -99 }; + const auto leftInfo = info->getChild(0U); + const auto r = getLhsOperand()->getReferenceObject(leftInfo, arb); + const RBAContentState* cs { nullptr }; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + if (r != nullptr) { + const auto a = dynamic_cast(r->getRawObject()); + if (a != nullptr) { + if (r->isPrevious()) { + cs = arb->getResult()->getDirectPreContentState(a); + if (cs != nullptr) { + result = cs->getContentStatePriority(); + } + } else { + info->addOperandAllocatable(a); + if (a->isChecked()) { + cs = a->getState(); + if (cs != nullptr) { + result = cs->getContentStatePriority(); + } + } else { + // Throw an Exception if arbitration is not over + info->setExceptionBeforeArbitrate(true); + } + } + } + } + } +#ifdef RBA_USE_LOG + std::string pre; + std::string aName = "NULL"; + std::string resultText = "no Content skip"; + if (r != nullptr) { + aName = r->getElementName(); + pre = getPreMsg(r->isPrevious()); + } + if (info->isExceptionBeforeArbitrate()) { + resultText = "before arbitrate skip"; + } else { + if (cs != nullptr) { + resultText = cs->getOwner()->getElementName() + "::" + cs->getElementName() + " : " + cs->getPriorityString(); + } + } + LOG_arbitrateConstraintLogicLogLine( + " " + + pre + + "Allocatable[" + + aName + + "] has Content Priority [" + + resultText + + "]"); + #endif + return result; +} +#ifdef RBA_USE_LOG +const std::string +RBAContentValue::getSymbol() const +{ + return ".contentValue()"; +} +#endif +} diff --git a/src/core/expression/RBAContentValue.hpp b/src/core/expression/RBAContentValue.hpp new file mode 100644 index 0000000..52bd841 --- /dev/null +++ b/src/core/expression/RBAContentValue.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * ContentValue class header file + */ + +#ifndef RBACONTENTVALUE_HPP +#define RBACONTENTVALUE_HPP + +#include +#include "RBAAllocatableOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAContentValue : public RBAAllocatableOperator +{ +public: + RBAContentValue()=default; + RBAContentValue(const RBAContentValue&)=delete; + RBAContentValue(RBAContentValue&&)=delete; + RBAContentValue& operator=(const RBAContentValue&)=delete; + RBAContentValue& operator=(RBAContentValue&&)=delete; + virtual ~RBAContentValue()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAContentValueMaker.cpp b/src/core/expression/RBAContentValueMaker.cpp new file mode 100644 index 0000000..48aaaeb --- /dev/null +++ b/src/core/expression/RBAContentValueMaker.cpp @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAContentValueMaker.cpp +/// @brief ContentValue object maker classs definition + +#include "RBAContentValueMaker.hpp" +#include "RBAContentValue.hpp" + +namespace rba +{ + +RBAContentValueMaker::RBAContentValueMaker() + : RBAOperatorMaker{"ContentValue"} +{ +} + +std::unique_ptr +RBAContentValueMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + + +} diff --git a/src/core/expression/RBAContentValueMaker.hpp b/src/core/expression/RBAContentValueMaker.hpp new file mode 100644 index 0000000..8f14c95 --- /dev/null +++ b/src/core/expression/RBAContentValueMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAContentValueMaker.hpp +/// @brief ContentValue object maker calss header file + +#ifndef RBACONTENTVALUEMAKER_HPP +#define RBACONTENTVALUEMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief ContentValue object generation class +class RBAContentValueMaker : public RBAOperatorMaker +{ +public: + RBAContentValueMaker(); + RBAContentValueMaker(const RBAContentValueMaker&)=delete; + RBAContentValueMaker(const RBAContentValueMaker&&)=delete; + RBAContentValueMaker& operator=(const RBAContentValueMaker&)=delete; + RBAContentValueMaker& operator=(const RBAContentValueMaker&&)=delete; + virtual ~RBAContentValueMaker()=default; + +protected: + /// @brief Create empty instance + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAExecuteResult.hpp b/src/core/expression/RBAExecuteResult.hpp new file mode 100644 index 0000000..1eaf2a5 --- /dev/null +++ b/src/core/expression/RBAExecuteResult.hpp @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A type that withdraws requests when arbitration loses + */ + +#ifndef RBAEXECUTERESULT_HPP +#define RBAEXECUTERESULT_HPP + +namespace rba +{ + +enum class RBAExecuteResult : std::uint8_t +{ + TRUE, + FALSE, + EXE, // In case of action is performed by doAction() + // (Excludes SetOfAction and IfAction) + NOTEXE, // In case of action is NOT performed by doAction() + // (Excludes SetOfAction and IfAction) + SKIP // In case of getValue() or getReferenceObject() +}; + +} + +#endif diff --git a/src/core/expression/RBAExistsOperator.cpp b/src/core/expression/RBAExistsOperator.cpp new file mode 100644 index 0000000..8bb8f05 --- /dev/null +++ b/src/core/expression/RBAExistsOperator.cpp @@ -0,0 +1,175 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Exists operator Class definition + */ + +#include "RBAExistsOperator.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContentSet.hpp" +#include "RBAContent.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALambdaExpression.hpp" +#include "RBALogManager.hpp" +#include "RBAExpressionType.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAExistsOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAExistsOperator::getModelElementType() const +{ + return RBAModelElementType::ExistsOperator; +} + +bool +RBAExistsOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator * arb) const +{ + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + const RBAExpression* const setObj {getLhsOperand()}; + RBALambdaExpression* const lambda {getLambda()}; + + // Get rule object and loop + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + + std::vector objs; + + const RBARuleObject* const ruleObj {setObj->getReferenceObject(leftInfo, arb)}; + const RBARuleObject* objset {nullptr}; + if (ruleObj != nullptr) { + objset = ruleObj->getRawObject(); + } + + if (leftInfo->isExceptionBeforeArbitrate() || (objset == nullptr)) { + // Remove itself form the constraint hierarchy for coverage + LOG_removeHierarchy(); + + info->setExceptionBeforeArbitrate(true); + return false; + } + + if (dynamic_cast(objset) != nullptr) { + objs.clear(); + for(const RBAAllocatable* alloc + : dynamic_cast(objset)->getLeafAllocatable() ) { + objs.push_back(alloc); + } + } + else { + objs.clear(); + for(const auto& cont : dynamic_cast(objset)->getLeafContent() ){ + objs.push_back(cont); + } + } + + bool isTrue {false}; + std::uint32_t i {0U}; + for(const RBARuleObject* const obj : objs) { + // Add count to the constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(i)); + + RBAConstraintInfo* const childInfo {info->getChild(i)}; + lambda->setRuleObj(obj); + + const bool res {lambda->execute(childInfo, arb)}; + + // Remove count from the constraint hierarchy for coverage + LOG_removeHierarchy(); + + if(childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + isTrue = (isTrue || res); + } + i++; + } + + if (isTrue == true) { + // Succeed + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + info->setExceptionBeforeArbitrate(false); + return true; + } else if (info->isExceptionBeforeArbitrate()) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return false; + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return false; + } +} + +#ifdef RBA_USE_LOG +const std::string +RBAExistsOperator::getSymbol() const +{ + return "Exists"; +} + +const std::string +RBAExistsOperator::getExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + return getSymbol() + " " + + exprLhs->getExpressionText() + " " + + getLambda()->getExpressionText(); +} + +const std::string +RBAExistsOperator::getCoverageExpressionText() const +{ + getLambda()->clearRuleObj(); + RBAExpression* exprLhs = getLhsOperand(); + return getSymbol() + " " + + exprLhs->getCoverageExpressionText() + " " + + getLambda()->getCoverageExpressionText(); +} + +RBAExpressionType +RBAExistsOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAExistsOperator.hpp b/src/core/expression/RBAExistsOperator.hpp new file mode 100644 index 0000000..e75af32 --- /dev/null +++ b/src/core/expression/RBAExistsOperator.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Exists operator Class header file + */ + +#ifndef RBAEXISTSOPERATOR_HPP +#define RBAEXISTSOPERATOR_HPP + +#include "RBALambdaContext.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAExistsOperator : public RBALambdaContext +{ +public: + RBAExistsOperator()=default; + RBAExistsOperator(const RBAExistsOperator&)=delete; + RBAExistsOperator(const RBAExistsOperator&&)=delete; + RBAExistsOperator& operator=(const RBAExistsOperator&)=delete; + RBAExistsOperator& operator=(const RBAExistsOperator&&)=delete; + virtual ~RBAExistsOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAExistsOperatorMaker.cpp b/src/core/expression/RBAExistsOperatorMaker.cpp new file mode 100644 index 0000000..eb8250a --- /dev/null +++ b/src/core/expression/RBAExistsOperatorMaker.cpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAExistsOperatorMaker.cpp +/// @brief Exists Operator object maker Class definition + +#include "RBAExistsOperatorMaker.hpp" +#include "RBAExistsOperator.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelFactory.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBAExistsOperatorMaker::RBAExistsOperatorMaker() + : RBALambdaContextMaker{"ExistsOperator"} +{ +} + +std::unique_ptr +RBAExistsOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAExistsOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast( + RBALambdaContextMaker::setProperty(element, jsonElem, model, owner)); + + return element; +} + +std::unique_ptr +RBAExistsOperatorMaker::createLambdaContext() +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAExistsOperatorMaker.hpp b/src/core/expression/RBAExistsOperatorMaker.hpp new file mode 100644 index 0000000..c88f610 --- /dev/null +++ b/src/core/expression/RBAExistsOperatorMaker.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAExistsOperatorMaker.hpp +/// @brief ExistsOperator object maker Class header + +#ifndef RBAEXISTSOPERATORMAKER_HPP +#define RBAEXISTSOPERATORMAKER_HPP + +#include "RBALambdaContextMaker.hpp" + +namespace rba +{ + +/// @brief ExistsOperator object maker Class +class RBAExistsOperatorMaker : public RBALambdaContextMaker +{ +public: + RBAExistsOperatorMaker(); + RBAExistsOperatorMaker(const RBAExistsOperatorMaker&)=delete; + RBAExistsOperatorMaker(const RBAExistsOperatorMaker&&)=delete; + RBAExistsOperatorMaker& operator=(const RBAExistsOperatorMaker&)=delete; + RBAExistsOperatorMaker& operator=(const RBAExistsOperatorMaker&&)=delete; + virtual ~RBAExistsOperatorMaker()=default; + +protected: + /// @brief Create empty instance + /// @details Create an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set attributes of model element for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model Model for storing created object + /// @param[in,out] owner parent object(Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + + /// @brief Crate empty object of LambdaContext + /// @details Create empty object of unique_ptr + /// @return unique_ptr for LambdaContext object + std::unique_ptr createLambdaContext() override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAExpression.cpp b/src/core/expression/RBAExpression.cpp new file mode 100644 index 0000000..2b9b6fc --- /dev/null +++ b/src/core/expression/RBAExpression.cpp @@ -0,0 +1,156 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Expression class definition + */ + +#include "RBAExpression.hpp" + +#include "RBALetStatement.hpp" +#include "RBAConstraintInfo.hpp" +#ifdef RBA_USE_LOG +#include "RBAExpressionType.hpp" +#endif + +namespace rba +{ + +void RBAExpression::addLetStatement(RBALetStatement* const letStatement) +{ + letStatements_.push_back(letStatement); +} + +void +RBAExpression::accept(RBAExpressionVisitor& visitor) +{ + // Not be called because the function of the derived class is called +} + +bool +RBAExpression::execute(RBAConstraintInfo* const info, RBAArbitrator * const arb) const +{ + info->setExpression(this); + for (RBALetStatement* const& letStatement : letStatements_) { + letStatement->setVariable(arb); + } + const bool result {executeCore(info, arb)}; + if (result) { + info->setResult(RBAExecuteResult::TRUE); + } else { + info->setResult(RBAExecuteResult::FALSE); + } + return result; +} + +bool +RBAExpression::executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const +{ + // This function is called when an Expression that does not define + // getReferenceObject() in evaluate() is specified. + info->setExceptionBeforeArbitrate(true); + return false; +} + +const RBARuleObject* +RBAExpression::getReferenceObject(RBAConstraintInfo* const info, + RBAArbitrator* const arb) const +{ + info->setExpression(this); + for (RBALetStatement* const& letStatement : letStatements_) { + letStatement->setVariable(arb); + } + return getReferenceObjectCore(info, arb); +} + +const RBARuleObject* +RBAExpression::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + // This function is called when an Expression that does not define + // getReferenceObject() in evaluateObject() is specified. + return nullptr; +} + +std::int32_t +RBAExpression::getValue(RBAConstraintInfo* const info, RBAArbitrator * const arb) const +{ + info->setExpression(this); + for (RBALetStatement* const& letStatement : letStatements_) { + letStatement->setVariable(arb); + } + return getValueCore(info, arb); +} + +const std::vector& +RBAExpression::getLetStatements() const +{ + return letStatements_; +} +std::int32_t +RBAExpression::getValueCore(RBAConstraintInfo* info, RBAArbitrator * arb) const +{ + // This function is called when an Expression that does not define + // getValue() in evaluateValue() is specified. + return -99; +} + +void +RBAExpression::doAction(RBAConstraintInfo* const info, RBAArbitrator* const arb) +{ + info->setExpression(this); + doActionCore(info, arb); + return; +} + +void +RBAExpression::doActionCore(RBAConstraintInfo* info, RBAArbitrator* arb) +{ + // This function is called when an Expression that does not define + // doAction() in evaluateDoAction() is specified. + return; +} + +#ifdef RBA_USE_LOG +const std::string +RBAExpression::getExpressionText() const +{ + // Not called because the function of the derived class is called + return "Unsupported operation exception"; +} + +const std::string +RBAExpression::getCoverageExpressionText() const +{ + // Not called because the function of the derived class is called + return "Unsupported operation exception"; +} + +void +RBAExpression::createHierarchy() +{ + // Not called because the function of the derived class is called +} + +RBAExpressionType +RBAExpression::getUnderlyingType() const +{ + // Not called because the function of the derived class is called + return RBAExpressionType::EXCEPTION; +} +#endif + +} diff --git a/src/core/expression/RBAExpression.hpp b/src/core/expression/RBAExpression.hpp new file mode 100644 index 0000000..9cd14e5 --- /dev/null +++ b/src/core/expression/RBAExpression.hpp @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Expression class header file + */ + +#ifndef RBAEXPRESSION_HPP +#define RBAEXPRESSION_HPP + +#include +#include +#include +#include "RBAModelElement.hpp" + +namespace rba +{ + +class RBAExpressionVisitor; +class RBALetStatement; +class RBAArbitrator; +class RBARuleObject; +class RBAConstraintInfo; +#ifdef RBA_USE_LOG +enum class RBAExpressionType : std::uint8_t; +#endif + +class DLL_EXPORT RBAExpression : public RBAModelElement +{ +protected: + RBAExpression()=default; + RBAExpression(const RBAExpression&)=delete; + RBAExpression(const RBAExpression&&)=delete; + RBAExpression& operator=(const RBAExpression&)=delete; + RBAExpression& operator=(const RBAExpression&&)=delete; + +public: + virtual ~RBAExpression()=default; + void addLetStatement(RBALetStatement* const letStatement); + virtual void accept(RBAExpressionVisitor& visitor); + bool execute(RBAConstraintInfo* const info, RBAArbitrator* const arb) const; + const RBARuleObject* getReferenceObject(RBAConstraintInfo* const info, + RBAArbitrator* const arb) const; + std::int32_t getValue(RBAConstraintInfo* const info, RBAArbitrator* const arb) const; + void doAction(RBAConstraintInfo* const info, RBAArbitrator* const arb); + const std::vector& getLetStatements() const; + + // Log +#ifdef RBA_USE_LOG + virtual const std::string getExpressionText() const; + virtual const std::string getCoverageExpressionText() const; + virtual void createHierarchy(); + virtual RBAExpressionType getUnderlyingType() const; +#endif + +protected: + virtual bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const; + virtual const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const; + virtual std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const; + virtual void doActionCore(RBAConstraintInfo* info, RBAArbitrator* arb); + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::vector letStatements_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAExpressionMaker.cpp b/src/core/expression/RBAExpressionMaker.cpp new file mode 100644 index 0000000..250ace0 --- /dev/null +++ b/src/core/expression/RBAExpressionMaker.cpp @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAExpreessionMaker.cpp +/// @brief Abstract class definition file for expression object generation + +#include "RBAExpressionMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBALetStatementMaker.hpp" +#include "RBALetStatement.hpp" + +namespace rba +{ + +RBAExpressionMaker::RBAExpressionMaker(const std::string& label) + : RBAModelElementMaker{label} +{ +} + +std::int32_t +RBAExpressionMaker::setLetStatement(RBAModelImpl* const model, + RBAExpression* const expr, + const RBAJsonElement* const jsonElem) +{ + std::int32_t var_num {0}; + const RBAJsonElement* const letElem {jsonElem->findChildren("letStatements")}; + if(letElem != nullptr) { + RBALetStatementMaker letMaker; + letMaker.setFactory(getFactory()); + for(const auto& param : letElem->getChildren()) { + // execute pushVariable() in letMaker::create() + RBALetStatement* const letExpr + {dynamic_cast(letMaker.create(param.get(), model))}; + expr->addLetStatement(letExpr); + var_num += 1; + } + } + + return var_num; +} + +} diff --git a/src/core/expression/RBAExpressionMaker.hpp b/src/core/expression/RBAExpressionMaker.hpp new file mode 100644 index 0000000..282a093 --- /dev/null +++ b/src/core/expression/RBAExpressionMaker.hpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAExpreessionMaker.hpp +/// @brief Abstract class definition header file for expression object generation + +#ifndef RBAEXPRESSIONMAKER_HPP +#define RBAEXPRESSIONMAKER_HPP + +#include +#include "RBAModelElementMaker.hpp" + +namespace rba +{ + +class RBAExpression; + +/// @brief Abstract class for expression object gcreation +class DLL_EXPORT RBAExpressionMaker : public RBAModelElementMaker +{ +public: + explicit RBAExpressionMaker(const std::string& label=""); + RBAExpressionMaker(const RBAExpressionMaker&)=delete; + RBAExpressionMaker(const RBAExpressionMaker&&)=delete; + RBAExpressionMaker& operator=(const RBAExpressionMaker&)=delete; + RBAExpressionMaker& operator=(const RBAExpressionMaker&&)=delete; + virtual ~RBAExpressionMaker()=default; + +protected: + /// @brief To set ”Let" expression + /// @details Generate Let expression from jsonElem and register it in expr. + /// Return the number of variables that have been registered + /// (pushed) to ModelFactory, and pop them when the reference of + /// variables is completed in function that called this function. + /// @return the number of pushed variables + std::int32_t setLetStatement(RBAModelImpl* model, + RBAExpression* expr, + const RBAJsonElement* jsonElem); + +}; + +} + +#endif diff --git a/src/core/expression/RBAExpressionType.hpp b/src/core/expression/RBAExpressionType.hpp new file mode 100644 index 0000000..6b6fcd8 --- /dev/null +++ b/src/core/expression/RBAExpressionType.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Expression type enumeration class header file + */ + +#ifndef RBAEXPRESSIONTYPE_HPP +#define RBAEXPRESSIONTYPE_HPP + +#ifdef RBA_USE_LOG + +#include + +namespace rba +{ + +enum class RBAExpressionType : std::uint8_t +{ + VALUE = 0, + BOOLEAN, + AREA, + CONTENT, + SET_OF_AREA, + SET_OF_CONTENT, + LAMBDA, + SCENE, + ZONE, + SET_OF_ZONE, + SOUND, + SET_OF_SOUND, + ACTION, + SET_OF_ACTION, + PROPERTY, + EXTENSION, + CONTENT_STATE, + EXCEPTION +}; + +} + +#endif +#endif diff --git a/src/core/expression/RBAExpressionVisitor.hpp b/src/core/expression/RBAExpressionVisitor.hpp new file mode 100644 index 0000000..e678b42 --- /dev/null +++ b/src/core/expression/RBAExpressionVisitor.hpp @@ -0,0 +1,168 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Expression visitor class header file + */ + +#ifndef RBAEXPRESSIONVISITOR_HPP +#define RBAEXPRESSIONVISITOR_HPP + +namespace rba { +class RBAIsDisplayed; +class RBADisplayingContent; +class RBAAllocatedContent; +class RBAIsHidden; +class RBAContentValue; +class RBAGetContentsList; +class RBAIsActive; +class RBAIsVisible; +class RBAStateValue; +class RBAHasBeenDisplayed; +class RBAHasComeEarlierThan; +class RBAHasComeLaterThan; +class RBAGetAllocatables; +class RBAIsOutputted; +class RBAOutputtingSound; +class RBAIsMuted; +class RBAIsAttenuated; +class RBAIsSounding; +class RBAIsOn; +class RBAGetProperty; +class RBAAndOperator; +class RBAOrOperator; +class RBANotOperator; +class RBAImpliesOperator; +class RBAIsEqualToOperator; +class RBAObjectCompare; +class RBAIsGreaterThanOperator; +class RBAIsGreaterThanEqualOperator; +class RBAIsLowerThanOperator; +class RBAIsLowerThanEqualOperator; +class RBAForAllOperator; +class RBAExistsOperator; +class RBAAllInstanceOfArea; +class RBAAllInstanceOfViewContent; +class RBAAllInstanceOfZone; +class RBAAllInstanceOfSoundContent; +class RBAIfStatement; +class RBALetStatement; +class RBAPreviousModifier; +class RBAActiveState; +class RBAActiveContents; +class RBAMaxOperator; +class RBAMinOperator; +class RBASelectOperator; +class RBASizeOperator; +class RBAObjectReference; +class RBASetOfOperator; +class RBAIsTypeOfOperator; + +class RBAExpressionVisitor { + public: + RBAExpressionVisitor()=default; + RBAExpressionVisitor(const RBAExpressionVisitor&)=delete; + RBAExpressionVisitor(const RBAExpressionVisitor&&)=delete; + RBAExpressionVisitor& operator=(const RBAExpressionVisitor&)=delete; + RBAExpressionVisitor& operator=(const RBAExpressionVisitor&&)=delete; + virtual ~RBAExpressionVisitor() = default; + + // Refer to Area status + virtual void visit(RBAIsDisplayed& exp) = 0; + virtual void visit(RBADisplayingContent& exp) = 0; + virtual void visit(RBAAllocatedContent& exp) = 0; + virtual void visit(RBAIsHidden& exp) = 0; + virtual void visit(RBAContentValue& exp) = 0; + virtual void visit(RBAGetContentsList& exp) = 0; + virtual void visit(RBAActiveContents& exp) = 0; + + // Refer to display content status + virtual void visit(RBAIsActive& exp) = 0; + virtual void visit(RBAIsVisible& exp) = 0; + virtual void visit(RBAStateValue& exp) = 0; + virtual void visit(RBAHasBeenDisplayed& exp) = 0; + virtual void visit(RBAHasComeEarlierThan& exp) = 0; + virtual void visit(RBAHasComeLaterThan& exp) = 0; + virtual void visit(RBAGetAllocatables& exp) = 0; + virtual void visit(RBAActiveState& exp) = 0; + + // Refer to Zone status + virtual void visit(RBAIsOutputted& exp) = 0; + virtual void visit(RBAOutputtingSound& exp) = 0; + // allocatedContent is common with Area + virtual void visit(RBAIsMuted& exp) = 0; + virtual void visit(RBAIsAttenuated& exp) = 0; + // contentValue is common with Area + // contentsList is common with Area + + // Refer to sound content status + // isActive is common with display content + virtual void visit(RBAIsSounding& exp) = 0; + // stateValue is common with display content + // hasComeEarlierThan is common with display content + // hasComeLaterThan is common with display content + // allocatables is common with display content + // activeState is common with display content + + // Refer to Scene + virtual void visit(RBAIsOn& exp) = 0; + virtual void visit(RBAGetProperty& exp) = 0; + + virtual void visit(RBAIsTypeOfOperator& exp) = 0; + + // Operators + virtual void visit(RBAAndOperator& exp) = 0; + virtual void visit(RBAOrOperator& exp) = 0; + virtual void visit(RBANotOperator& exp) = 0; + virtual void visit(RBAImpliesOperator& exp) = 0; + virtual void visit(RBAIsEqualToOperator& exp) = 0; + virtual void visit(RBAObjectCompare& exp) = 0; + virtual void visit(RBAIsGreaterThanOperator& exp) = 0; + virtual void visit(RBAIsGreaterThanEqualOperator& exp) = 0; + virtual void visit(RBAIsLowerThanOperator& exp) = 0; + virtual void visit(RBAIsLowerThanEqualOperator& exp) = 0; + + // Quantification symbol + virtual void visit(RBAForAllOperator& exp) = 0; + virtual void visit(RBAExistsOperator& exp) = 0; + + // Built-in definition expression + virtual void visit(RBAAllInstanceOfArea& exp) = 0; + virtual void visit(RBAAllInstanceOfViewContent& exp) = 0; + virtual void visit(RBAAllInstanceOfZone& exp) = 0; + virtual void visit(RBAAllInstanceOfSoundContent& exp) = 0; + + // Syntax + virtual void visit(RBAIfStatement& exp) = 0; + virtual void visit(RBALetStatement& exp) = 0; + + // Modifier + virtual void visit(RBAPreviousModifier& exp) = 0; + + // Set operator + virtual void visit(RBAMaxOperator& exp) = 0; + virtual void visit(RBAMinOperator& exp) = 0; + virtual void visit(RBASelectOperator& exp) = 0; + virtual void visit(RBASizeOperator& exp) = 0; + + // Object references + virtual void visit(RBAObjectReference& exp) = 0; + virtual void visit(RBASetOfOperator& exp) = 0; +}; + +} + +#endif diff --git a/src/core/expression/RBAForAllOperator.cpp b/src/core/expression/RBAForAllOperator.cpp new file mode 100644 index 0000000..93a2894 --- /dev/null +++ b/src/core/expression/RBAForAllOperator.cpp @@ -0,0 +1,173 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ForAll operator class + */ + +#include "RBAForAllOperator.hpp" + +#include "RBAAllocatable.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContent.hpp" +#include "RBAContentSet.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALambdaExpression.hpp" +#include "RBALogManager.hpp" +#include "RBAExpressionType.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAForAllOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAForAllOperator::getModelElementType() const +{ + return RBAModelElementType::ForAllOperator; +} + +bool +RBAForAllOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator * arb) const +{ + const RBAExpression* const setObj {getLhsOperand()}; + RBALambdaExpression* const lambda {getLambda()}; + + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + // get Rule object and loop + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + + std::vector objs; + const RBARuleObject* const ruleObj {setObj->getReferenceObject(leftInfo, arb)}; + const RBARuleObject* objset {nullptr}; + if (ruleObj != nullptr) { + objset = ruleObj->getRawObject(); + } + + if(leftInfo->isExceptionBeforeArbitrate() || (objset == nullptr)) { + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + + info->setExceptionBeforeArbitrate(true); + return false; + } + if (dynamic_cast(objset) != nullptr) { + objs.clear(); + for(const RBAAllocatable* alloc + : dynamic_cast(objset)->getLeafAllocatable()) { + objs.push_back(alloc); + } + } + else { + objs.clear(); + for(const auto& cont : dynamic_cast(objset)->getLeafContent() ){ + objs.push_back(cont); + } + } + + bool isTrue {true}; + std::uint32_t i {0U}; + for(const RBARuleObject* const obj : objs) { + // Add count to the constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(i)); + + RBAConstraintInfo* const childInfo {info->getChild(i)}; + lambda->setRuleObj(obj); + + const bool res {lambda->execute(childInfo, arb)}; + + // Remove count from the constraint hierarchy for coverage + LOG_removeHierarchy(); + + if(childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + isTrue = (isTrue && res); + } + i++; + } + + if (isTrue == false) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + // Remove count from the constraint hierarchy for coverage + LOG_removeHierarchy(); + info->setExceptionBeforeArbitrate(false); + return false; + } else if (info->isExceptionBeforeArbitrate()) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + // Remove count from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return false; + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + // Remove count from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return true; + } +} + +#ifdef RBA_USE_LOG +const std::string +RBAForAllOperator::getSymbol() const +{ + return "For All"; +} + +const std::string +RBAForAllOperator::getExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + return getSymbol() + " " + + exprLhs->getExpressionText() + " " + + getLambda()->getExpressionText(); +} + +const std::string +RBAForAllOperator::getCoverageExpressionText() const +{ + getLambda()->clearRuleObj(); + RBAExpression* exprLhs = getLhsOperand(); + return getSymbol() + " " + + exprLhs->getCoverageExpressionText() + " " + + getLambda()->getCoverageExpressionText(); +} + +RBAExpressionType +RBAForAllOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAForAllOperator.hpp b/src/core/expression/RBAForAllOperator.hpp new file mode 100644 index 0000000..7c0c7cc --- /dev/null +++ b/src/core/expression/RBAForAllOperator.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ForAll operator class header file + */ + +#ifndef RBAFORALLOPERATOR_HPP +#define RBAFORALLOPERATOR_HPP + +#include "RBALambdaContext.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAForAllOperator : public RBALambdaContext +{ +public: + RBAForAllOperator()=default; + RBAForAllOperator(const RBAForAllOperator&)=delete; + RBAForAllOperator(const RBAForAllOperator&&)=delete; + RBAForAllOperator& operator=(const RBAForAllOperator&)=delete; + RBAForAllOperator& operator=(const RBAForAllOperator&&)=delete; + virtual ~RBAForAllOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAForAllOperatorMaker.cpp b/src/core/expression/RBAForAllOperatorMaker.cpp new file mode 100644 index 0000000..eb1068d --- /dev/null +++ b/src/core/expression/RBAForAllOperatorMaker.cpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAForAllOperatorMaker.cpp +/// @brief ForAllOperator object generation class + +#include "RBAForAllOperatorMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelFactory.hpp" +#include "RBAForAllOperator.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBAForAllOperatorMaker::RBAForAllOperatorMaker() + : RBALambdaContextMaker{"ForAllOperator"} +{ +} + +std::unique_ptr +RBAForAllOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAForAllOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast( + RBALambdaContextMaker::setProperty(element, jsonElem, model, owner)); + + return element; +} + +std::unique_ptr +RBAForAllOperatorMaker::createLambdaContext() +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAForAllOperatorMaker.hpp b/src/core/expression/RBAForAllOperatorMaker.hpp new file mode 100644 index 0000000..9c5de92 --- /dev/null +++ b/src/core/expression/RBAForAllOperatorMaker.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAForAllOperatorMaker.hpp +/// @brief ForAllOperator object generation class header + +#ifndef RBAFORALLOPERATORMAKER_HPP +#define RBAFORALLOPERATORMAKER_HPP + +#include "RBALambdaContextMaker.hpp" + +namespace rba +{ + +/// @brief ForAllOperator object generation class +class RBAForAllOperatorMaker : public RBALambdaContextMaker +{ +public: + RBAForAllOperatorMaker(); + RBAForAllOperatorMaker(const RBAForAllOperatorMaker&)=delete; + RBAForAllOperatorMaker(const RBAForAllOperatorMaker&&)=delete; + RBAForAllOperatorMaker& operator=(const RBAForAllOperatorMaker&)=delete; + RBAForAllOperatorMaker& operator=(const RBAForAllOperatorMaker&&)=delete; + virtual ~RBAForAllOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in a derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model M\model to store the generated object + /// @param[in,out] owner parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + + /// @brief generate an empty object of LambdaContext + /// @details generate an empty object of unique_ptr in a derived class + /// @return unique_ptr for LambdaContext object + std::unique_ptr createLambdaContext() override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetAllocatables.cpp b/src/core/expression/RBAGetAllocatables.cpp new file mode 100644 index 0000000..8494a01 --- /dev/null +++ b/src/core/expression/RBAGetAllocatables.cpp @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * GetAllocatables class definition file + */ + +#include "RBAGetAllocatables.hpp" + +#include "RBAContent.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAGetAllocatables::accept(RBAExpressionVisitor& visitor) +{ + // This path is not used, because RBASceneAllocatableCollector, + // the only existing visitor as of now, does not accept content. + // But, keep this because another visitor may accept, in the future. + visitor.visit(*this); +} + +RBAModelElementType +RBAGetAllocatables::getModelElementType() const +{ + return RBAModelElementType::GetAllocatables; +} + +const RBARuleObject* +RBAGetAllocatables::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + + const RBARuleObject* const ruleObj + {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + const RBAContent* content {nullptr}; + if (ruleObj != nullptr) { + content = dynamic_cast(ruleObj->getRawObject()); + } + + if (content == nullptr) { + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } + return nullptr; + } + + return content->getAllocatableSet(); +} + +#ifdef RBA_USE_LOG +const std::string +RBAGetAllocatables::getSymbol() const +{ + return ".allocatables()"; +} + +const std::string +RBAGetAllocatables::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +// At the moment, the arbitration FW cannot write a constraint expression +// to call createHierarchy() of GetAllocatables, +// so it does not go through this path. +// But, defined this for maintainability (especially expandability. +void +RBAGetAllocatables::createHierarchy() +{ + // No operation because it does not affect structure. +} + +#endif + +} diff --git a/src/core/expression/RBAGetAllocatables.hpp b/src/core/expression/RBAGetAllocatables.hpp new file mode 100644 index 0000000..d1c7167 --- /dev/null +++ b/src/core/expression/RBAGetAllocatables.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * GetAllocatables class header file + */ + +#ifndef RBAGETALLOCATABLES_HPP +#define RBAGETALLOCATABLES_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAGetAllocatables : public RBAContentOperator +{ +public: + RBAGetAllocatables()=default; + RBAGetAllocatables(const RBAGetAllocatables&)=delete; + RBAGetAllocatables(const RBAGetAllocatables&&)=delete; + RBAGetAllocatables& operator=(const RBAGetAllocatables&)=delete; + RBAGetAllocatables& operator=(const RBAGetAllocatables&&)=delete; + virtual ~RBAGetAllocatables()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + void createHierarchy() override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetAllocatablesMaker.cpp b/src/core/expression/RBAGetAllocatablesMaker.cpp new file mode 100644 index 0000000..aac81a2 --- /dev/null +++ b/src/core/expression/RBAGetAllocatablesMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetAllocatablesMaker.cpp +/// @brief GetAllocatables object generation class definition + +#include "RBAGetAllocatablesMaker.hpp" +#include "RBAGetAllocatables.hpp" + +namespace rba +{ + +RBAGetAllocatablesMaker::RBAGetAllocatablesMaker() + : RBAOperatorMaker{"GetAllocatables"} +{ +} + +std::unique_ptr +RBAGetAllocatablesMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAGetAllocatablesMaker.hpp b/src/core/expression/RBAGetAllocatablesMaker.hpp new file mode 100644 index 0000000..722845f --- /dev/null +++ b/src/core/expression/RBAGetAllocatablesMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetAllocatablesMaker.hpp +/// @brief GetAllocatables object generation class header file + +#ifndef RBAGETALLOCATABLESMAKER_HPP +#define RBAGETALLOCATABLESMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief GetAllocatables object gneration class +class RBAGetAllocatablesMaker : public RBAOperatorMaker +{ +public: + RBAGetAllocatablesMaker(); + RBAGetAllocatablesMaker(const RBAGetAllocatablesMaker&)=delete; + RBAGetAllocatablesMaker(const RBAGetAllocatablesMaker&&)=delete; + RBAGetAllocatablesMaker& operator=(const RBAGetAllocatablesMaker&)=delete; + RBAGetAllocatablesMaker& operator=(const RBAGetAllocatablesMaker&&)=delete; + virtual ~RBAGetAllocatablesMaker()=default; + +protected: + /// @brief Generate an empty instance + /// @details Generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetContentsList.cpp b/src/core/expression/RBAGetContentsList.cpp new file mode 100644 index 0000000..5f14b33 --- /dev/null +++ b/src/core/expression/RBAGetContentsList.cpp @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * GetContentsList class definition file + */ + +#include "RBAGetContentsList.hpp" + +#include "RBAAllocatable.hpp" +#include "RBAContentSet.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBAGetContentsList::accept(RBAExpressionVisitor& visitor) +{ + // This path is not used, because RBASceneAllocatableCollector, + // the only existing visitor as of now, does not accept content. + // But, keep this because another visitor may accept, in the future. + visitor.visit(*this); +} + +RBAModelElementType +RBAGetContentsList::getModelElementType() const +{ + return RBAModelElementType::GetContentsList; +} + +const RBARuleObject* +RBAGetContentsList::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + + const RBARuleObject* const ruleObj + {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + const RBAAllocatable* allocatable {nullptr}; + if (ruleObj != nullptr) { + allocatable = dynamic_cast(ruleObj->getRawObject()); + } + // Indicates whether the content referenced by this constraint expression + // is the result of the previous arbitration result. + + if (leftInfo->isExceptionBeforeArbitrate() || (allocatable == nullptr)) { + // As of now, this path is not used due to the following reasons. + // - The expression below GetContentsList is before arbitration + // - Constraint expression that returns null as allocatable + // can not be described(specified) + // But, defined this for maintainability (especially expandability). + info->setExceptionBeforeArbitrate(true); + return nullptr; + } + + return allocatable->getContentSet(); +} + +#ifdef RBA_USE_LOG +// At the moment, the arbitration FW cannot write a constraint expression +// to call createHierarchy() of GetContentsList, +// so it does not go through this path. +// But, defined this for maintainability (especially expandability. +void +RBAGetContentsList::createHierarchy() +{ + // No operation because it does not affect structure. +} +#endif + +} diff --git a/src/core/expression/RBAGetContentsList.hpp b/src/core/expression/RBAGetContentsList.hpp new file mode 100644 index 0000000..240a50c --- /dev/null +++ b/src/core/expression/RBAGetContentsList.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * GetContentsList class header file + */ + +#ifndef RBAGETCONTENTSLIST_HPP +#define RBAGETCONTENTSLIST_HPP + +#include "RBAAllocatableOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAGetContentsList : public RBAAllocatableOperator +{ +public: + RBAGetContentsList()=default; + RBAGetContentsList(const RBAGetContentsList&)=delete; + RBAGetContentsList(const RBAGetContentsList&&)=delete; + RBAGetContentsList& operator=(const RBAGetContentsList&)=delete; + RBAGetContentsList& operator=(const RBAGetContentsList&&)=delete; + virtual ~RBAGetContentsList()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + void createHierarchy() override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetContentsListMaker.cpp b/src/core/expression/RBAGetContentsListMaker.cpp new file mode 100644 index 0000000..2081e2d --- /dev/null +++ b/src/core/expression/RBAGetContentsListMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetContentsListMaker.cpp +/// @brief GetContentsList object generation class definition file + +#include "RBAGetContentsListMaker.hpp" +#include "RBAGetContentsList.hpp" + +namespace rba +{ + +RBAGetContentsListMaker::RBAGetContentsListMaker() + : RBAOperatorMaker{"GetContentsList"} +{ +} + +std::unique_ptr +RBAGetContentsListMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAGetContentsListMaker.hpp b/src/core/expression/RBAGetContentsListMaker.hpp new file mode 100644 index 0000000..c703f68 --- /dev/null +++ b/src/core/expression/RBAGetContentsListMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetContentsListMaker.hpp +/// @brief GetContentsList object generation class header file + +#ifndef RBAGETCONTENTSLISTMAKER_HPP +#define RBAGETCONTENTSLISTMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief GetContentsList object generation class +class RBAGetContentsListMaker : public RBAOperatorMaker +{ +public: + RBAGetContentsListMaker(); + RBAGetContentsListMaker(const RBAGetContentsListMaker&)=delete; + RBAGetContentsListMaker(const RBAGetContentsListMaker&&)=delete; + RBAGetContentsListMaker& operator=(const RBAGetContentsListMaker&)=delete; + RBAGetContentsListMaker& operator=(const RBAGetContentsListMaker&&)=delete; + virtual ~RBAGetContentsListMaker()=default; + +protected: + /// @brief Generate an empty instance + /// @details Generate an empty class of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetProperty.cpp b/src/core/expression/RBAGetProperty.cpp new file mode 100644 index 0000000..3a774d8 --- /dev/null +++ b/src/core/expression/RBAGetProperty.cpp @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAGetProperty class defintino file + */ + +#include "RBAGetProperty.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBASceneImpl.hpp" +#include "RBAArbitrator.hpp" +#include "RBALogManager.hpp" +#include "RBAExpressionType.hpp" +#include "RBAModelElementType.hpp" +#include "RBAAbstractProperty.hpp" + +namespace rba +{ + +void +RBAGetProperty::accept(RBAExpressionVisitor& visitor) +{ + // This path is not used, because RBASceneAllocatableCollector, + // the only existing visitor as of now, does not accept content. + // But, keep this because another visitor may accept, in the future. + visitor.visit(*this); +} + +RBAModelElementType +RBAGetProperty::getModelElementType() const +{ + return RBAModelElementType::GetProperty; +} + +std::int32_t +RBAGetProperty::getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + std::int32_t value{0}; + const RBAAbstractProperty* prop{nullptr}; + const RBARuleObject* const ruleObj {getLhsOperand()->getReferenceObject(info, arb)}; + if(ruleObj->isPrevious()) { + prop = dynamic_cast(ruleObj->getRawObject()); + value = arb->getResult()->getPreSceneProperty(prop); + } + else { + prop = dynamic_cast(ruleObj); + value = arb->getResult()->getSceneProperty(prop); + } + LOG_arbitrateConstraintLogicLogLine(" " + + getPreMsg(ruleObj->isPrevious()) + + "Property[" + + prop->getScene()->getElementName() + + "::" + + prop->getElementName() + + "] get[" + + std::to_string(value) + + "]"); + return value; +} + +#ifdef RBA_USE_LOG +const std::string +RBAGetProperty::getSymbol() const +{ + return ".get()"; +} + +const std::string +RBAGetProperty::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +const std::string +RBAGetProperty::getCoverageExpressionText() const +{ + return getExpressionText(); +} + +RBAExpressionType +RBAGetProperty::getUnderlyingType() const +{ + return RBAExpressionType::VALUE; +} +#endif + +} diff --git a/src/core/expression/RBAGetProperty.hpp b/src/core/expression/RBAGetProperty.hpp new file mode 100644 index 0000000..eff3852 --- /dev/null +++ b/src/core/expression/RBAGetProperty.hpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAGetProperty Class + */ + +#ifndef RBAGETPROPERTY_HPP +#define RBAGETPROPERTY_HPP + +#include "RBAPropertyOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAGetProperty : public RBAPropertyOperator +{ +public: + RBAGetProperty()=default; + RBAGetProperty(const RBAGetProperty&)=delete; + RBAGetProperty(const RBAGetProperty&&)=delete; + RBAGetProperty& operator=(const RBAGetProperty&)=delete; + RBAGetProperty& operator=(const RBAGetProperty&&)=delete; + virtual ~RBAGetProperty()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAGetPropertyMaker.cpp b/src/core/expression/RBAGetPropertyMaker.cpp new file mode 100644 index 0000000..f2588ad --- /dev/null +++ b/src/core/expression/RBAGetPropertyMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetPropertyMaker.cpp +/// @brief GetProperty object generation class defintion file + +#include "RBAGetPropertyMaker.hpp" +#include "RBAGetProperty.hpp" + +namespace rba +{ + +RBAGetPropertyMaker::RBAGetPropertyMaker() + : RBAOperatorMaker{"GetProperty"} +{ +} + +std::unique_ptr +RBAGetPropertyMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAGetPropertyMaker.hpp b/src/core/expression/RBAGetPropertyMaker.hpp new file mode 100644 index 0000000..db20ce1 --- /dev/null +++ b/src/core/expression/RBAGetPropertyMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAGetPropertyMaker.hpp +/// @brief GetProperty object generation class heeader file + +#ifndef RBAGETPROPERTYMAKER_HPP +#define RBAGETPROPERTYMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief GetProperty object generation class +class RBAGetPropertyMaker : public RBAOperatorMaker +{ +public: + RBAGetPropertyMaker(); + RBAGetPropertyMaker(const RBAGetPropertyMaker&)=delete; + RBAGetPropertyMaker(const RBAGetPropertyMaker&&)=delete; + RBAGetPropertyMaker& operator=(const RBAGetPropertyMaker&)=delete; + RBAGetPropertyMaker& operator=(const RBAGetPropertyMaker&&)=delete; + virtual ~RBAGetPropertyMaker()=default; + +protected: + /// @brief Generate an empty instance + /// @details Generate an empty class of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAHasBeenDisplayed.cpp b/src/core/expression/RBAHasBeenDisplayed.cpp new file mode 100644 index 0000000..72c1d40 --- /dev/null +++ b/src/core/expression/RBAHasBeenDisplayed.cpp @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * .hasBeenDisplayed() definition + **/ + +#include "RBAHasBeenDisplayed.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAArbitrator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAContent.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +void RBAHasBeenDisplayed::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType RBAHasBeenDisplayed::getModelElementType() const +{ + return RBAModelElementType::HasBeenDisplayed; +} + +bool RBAHasBeenDisplayed::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const ruleObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else if (ruleObj != nullptr) { + const RBAContent* const c { + dynamic_cast(ruleObj->getRawObject())}; + if (!ruleObj->isPrevious()) { + isPassed = arb->getResult()->hasBeenDisplayed(c); + } else { + isPassed = arb->getResult()->hasBeenPreDisplayed(c); + } + } else { + ; + } +#ifdef RBA_USE_LOG + RBAExecuteResult r; + std::string cname; + std::string resultStr; + if (ruleObj != nullptr) { + cname = ruleObj->getRawObject()->getElementName(); + } else { + cname = "NULL"; + } + if (info->isExceptionBeforeArbitrate()) { + resultStr = " before arbitrate skip"; + r = RBAExecuteResult::SKIP; + } else if (isPassed) { + resultStr = " true"; + r = RBAExecuteResult::TRUE; + } else { + resultStr = " false"; + r = RBAExecuteResult::FALSE; + } + LOG_arbitrateConstraintLogicLogLine( + " Content[" + cname + "]" + getSymbol() + resultStr); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), r); +#endif + LOG_removeHierarchy(); + return isPassed; +} + +// Log +#ifdef RBA_USE_LOG +const std::string RBAHasBeenDisplayed::getSymbol() const +{ + return ".hasBeenDisplayed()"; +} +RBAExpressionType RBAHasBeenDisplayed::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif +} /* namespace rba */ diff --git a/src/core/expression/RBAHasBeenDisplayed.hpp b/src/core/expression/RBAHasBeenDisplayed.hpp new file mode 100644 index 0000000..3e3ebde --- /dev/null +++ b/src/core/expression/RBAHasBeenDisplayed.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// .hasBeenDisplayed() header file +// + +#ifndef RBAHASBEENDISPLAYED_HPP +#define RBAHASBEENDISPLAYED_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAHasBeenDisplayed : public RBAContentOperator +{ + public: + RBAHasBeenDisplayed()=default; + RBAHasBeenDisplayed(const RBAHasBeenDisplayed&)=delete; + RBAHasBeenDisplayed(const RBAHasBeenDisplayed&&)=delete; + RBAHasBeenDisplayed& operator=(const RBAHasBeenDisplayed&)=delete; + RBAHasBeenDisplayed& operator=(const RBAHasBeenDisplayed&&)=delete; + virtual ~RBAHasBeenDisplayed()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif +}; + +} /* namespace rba */ + +#endif /* RBAHASBEENDISPLAYED_HPP */ diff --git a/src/core/expression/RBAHasBeenDisplayedMaker.cpp b/src/core/expression/RBAHasBeenDisplayedMaker.cpp new file mode 100644 index 0000000..36aeecc --- /dev/null +++ b/src/core/expression/RBAHasBeenDisplayedMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasBeenDisplayedMaker.cpp +/// @brief HasBeenDisplayed object generation class defintion file + +#include "RBAHasBeenDisplayedMaker.hpp" +#include "RBAHasBeenDisplayed.hpp" + +namespace rba +{ + +RBAHasBeenDisplayedMaker::RBAHasBeenDisplayedMaker() + : RBAOperatorMaker{"HasBeenDisplayed"} +{ +} + +std::unique_ptr +RBAHasBeenDisplayedMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAHasBeenDisplayedMaker.hpp b/src/core/expression/RBAHasBeenDisplayedMaker.hpp new file mode 100644 index 0000000..5e9bc10 --- /dev/null +++ b/src/core/expression/RBAHasBeenDisplayedMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasBeenDisplayedMaker.hpp +/// @brief HasBeenDisplayed object generation class header file + +#ifndef RBAHASBEENDISPLAYEDMAKER_HPP +#define RBAHASBEENDISPLAYEDMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief HasBeenDisplayed object generation class +class RBAHasBeenDisplayedMaker : public RBAOperatorMaker +{ +public: + RBAHasBeenDisplayedMaker(); + RBAHasBeenDisplayedMaker(const RBAHasBeenDisplayedMaker&)=delete; + RBAHasBeenDisplayedMaker(const RBAHasBeenDisplayedMaker&&)=delete; + RBAHasBeenDisplayedMaker& operator=(const RBAHasBeenDisplayedMaker&)=delete; + RBAHasBeenDisplayedMaker& operator=(const RBAHasBeenDisplayedMaker&&)=delete; + virtual ~RBAHasBeenDisplayedMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instancce of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAHasComeEarlierThan.cpp b/src/core/expression/RBAHasComeEarlierThan.cpp new file mode 100644 index 0000000..4b5482a --- /dev/null +++ b/src/core/expression/RBAHasComeEarlierThan.cpp @@ -0,0 +1,151 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * HasComeEarlierThan class + */ + +#include "RBAHasComeEarlierThan.hpp" +#include "RBAContent.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +RBAModelElementType +RBAHasComeEarlierThan::getModelElementType() const +{ + return RBAModelElementType::HasComeEarlier; +} + +void RBAHasComeEarlierThan::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +bool +RBAHasComeEarlierThan::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + bool isResult {false}; + // Get content in left side of the expression + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* ruleObj {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + const RBAContent* contentLhs {nullptr}; + if(ruleObj != nullptr) { + contentLhs = dynamic_cast(ruleObj->getRawObject()); + } + + // Get content in right hand side of the expression + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + ruleObj = getRhsOperand()->getReferenceObject(rightInfo, arb); + const RBAContent* contentRhs {nullptr}; + if(ruleObj != nullptr) { + contentRhs = dynamic_cast(ruleObj->getRawObject()); + } + + if((contentLhs == nullptr) || (contentRhs == nullptr)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (!((arb->getResult()->isActive(contentLhs)) + && (arb->getResult()->isActive(contentRhs)))) { + info->setExceptionBeforeArbitrate(true); + } + else if(contentLhs == contentRhs) { + isResult = false; + } + else { + isResult = !arb->getResult()->isLater(contentLhs, contentRhs); + } + } +#ifdef RBA_USE_LOG + std::string lhsName; + std::string rhsName; + std::string resultText; + if(contentLhs == nullptr) { + lhsName = "NULL"; + } else { + lhsName = contentLhs->getElementName(); + } + if (contentRhs == nullptr) { + rhsName = "NULL"; + } else { + rhsName = contentRhs->getElementName(); + } + if (info->isExceptionBeforeArbitrate() == true ) { + resultText = "is before arbitrate skip"; + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else { + resultText = RBALogManager::boolToString(isResult); + if(isResult) { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } + else { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } + } + LOG_arbitrateConstraintLogicLogLine( + " Content[" + lhsName + "] has come earlier than Content[" + rhsName + "] " + resultText); +#endif + // Remove itself from constraint hierarchy for coverage + LOG_removeHierarchy(); + return isResult; +} + +#ifdef RBA_USE_LOG +const std::string +RBAHasComeEarlierThan::getSymbol() const +{ + return ".hasComeEarlierThan"; +} + +const std::string +RBAHasComeEarlierThan::getExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + RBAExpression* exprRhs = getRhsOperand(); + return exprLhs->getExpressionText() + getSymbol() + + "(" + exprRhs->getExpressionText() + ")"; +} + +const std::string +RBAHasComeEarlierThan::getCoverageExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + RBAExpression* exprRhs = getRhsOperand(); + return exprLhs->getCoverageExpressionText() + getSymbol() + + "(" + exprRhs->getCoverageExpressionText() + ")"; +} + +RBAExpressionType +RBAHasComeEarlierThan::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAHasComeEarlierThan.hpp b/src/core/expression/RBAHasComeEarlierThan.hpp new file mode 100644 index 0000000..fd39782 --- /dev/null +++ b/src/core/expression/RBAHasComeEarlierThan.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * HasComeEarlierThan class header file + */ + +#ifndef RBAHASCOMEEARLIERTHAN_HPP +#define RBAHASCOMEEARLIERTHAN_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAHasComeEarlierThan : public RBAContentOperator +{ +public: + RBAHasComeEarlierThan()=default; + RBAHasComeEarlierThan(const RBAHasComeEarlierThan&)=delete; + RBAHasComeEarlierThan(const RBAHasComeEarlierThan&&)=delete; + RBAHasComeEarlierThan& operator=(const RBAHasComeEarlierThan&)=delete; + RBAHasComeEarlierThan& operator=(const RBAHasComeEarlierThan&&)=delete; + virtual ~RBAHasComeEarlierThan()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAHasComeEarlierThanMaker.cpp b/src/core/expression/RBAHasComeEarlierThanMaker.cpp new file mode 100644 index 0000000..fb5eb08 --- /dev/null +++ b/src/core/expression/RBAHasComeEarlierThanMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasComeEarlierThanMaker.cpp +/// @brief HasComeEarlierThan object generation class definition file + +#include "RBAHasComeEarlierThanMaker.hpp" +#include "RBAHasComeEarlierThan.hpp" + +namespace rba +{ + +RBAHasComeEarlierThanMaker::RBAHasComeEarlierThanMaker() + : RBAOperatorMaker{"HasComeEarlierThan"} +{ +} + +std::unique_ptr +RBAHasComeEarlierThanMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAHasComeEarlierThanMaker.hpp b/src/core/expression/RBAHasComeEarlierThanMaker.hpp new file mode 100644 index 0000000..256a4ea --- /dev/null +++ b/src/core/expression/RBAHasComeEarlierThanMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasComeEarlierThanMaker.hpp +/// @brief HasComeEarlierThan object generation class header + +#ifndef RBAHASCOMEEARLIERTHANMAKER_HPP +#define RBAHASCOMEEARLIERTHANMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief HasComeEarlierThan object generation class +class RBAHasComeEarlierThanMaker : public RBAOperatorMaker +{ +public: + RBAHasComeEarlierThanMaker(); + RBAHasComeEarlierThanMaker(const RBAHasComeEarlierThanMaker&)=delete; + RBAHasComeEarlierThanMaker(const RBAHasComeEarlierThanMaker&&)=delete; + RBAHasComeEarlierThanMaker& operator=(const RBAHasComeEarlierThanMaker&)=delete; + RBAHasComeEarlierThanMaker& operator=(const RBAHasComeEarlierThanMaker&&)=delete; + virtual ~RBAHasComeEarlierThanMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAHasComeLaterThan.cpp b/src/core/expression/RBAHasComeLaterThan.cpp new file mode 100644 index 0000000..341d164 --- /dev/null +++ b/src/core/expression/RBAHasComeLaterThan.cpp @@ -0,0 +1,153 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * HasComeLaterThan class + */ + +#include "RBAHasComeLaterThan.hpp" + +#include "RBAContent.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBAHasComeLaterThan::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAHasComeLaterThan::getModelElementType() const +{ + return RBAModelElementType::HasComeLater; +} + +bool +RBAHasComeLaterThan::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + bool isResult {false}; + // pop the Content of left hand side expresion + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* ruleObj {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + const RBAContent* contentLhs {nullptr}; + if(ruleObj != nullptr) { + contentLhs = dynamic_cast(ruleObj->getRawObject()); + } + + // pop the Content of left hand side expresion + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + ruleObj = getRhsOperand()->getReferenceObject(rightInfo, arb); + const RBAContent* contentRhs {nullptr}; + if(ruleObj != nullptr) { + contentRhs = dynamic_cast(ruleObj->getRawObject()); + } + + if((contentLhs == nullptr) || (contentRhs == nullptr)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (!((arb->getResult()->isActive(contentLhs)) + && (arb->getResult()->isActive(contentRhs)))) { + info->setExceptionBeforeArbitrate(true); + } + else if(contentLhs == contentRhs) { + isResult = false; + } + else { + isResult = arb->getResult()->isLater(contentLhs, contentRhs); + } + } +#ifdef RBA_USE_LOG + std::string lhsName; + std::string rhsName; + std::string resultText; + if(contentLhs == nullptr) { + lhsName = "NULL"; + } else { + lhsName = contentLhs->getElementName(); + } + if (contentRhs == nullptr) { + rhsName = "NULL"; + } else { + rhsName = contentRhs->getElementName(); + } + if (info->isExceptionBeforeArbitrate() == true ) { + resultText = "is before arbitrate skip"; + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else { + resultText = RBALogManager::boolToString(isResult); + if(isResult) { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } + else { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } + } + LOG_arbitrateConstraintLogicLogLine( + " Content[" + lhsName + "] has come later than Content[" + rhsName + "] " + resultText); +#endif + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + + return isResult; +} + +#ifdef RBA_USE_LOG +const std::string +RBAHasComeLaterThan::getSymbol() const +{ + return ".hasComeLaterThan"; +} + +const std::string +RBAHasComeLaterThan::getExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + RBAExpression* exprRhs = getRhsOperand(); + return exprLhs->getExpressionText() + getSymbol() + + "(" + exprRhs->getExpressionText() + ")"; +} + +const std::string +RBAHasComeLaterThan::getCoverageExpressionText() const +{ + RBAExpression* exprLhs = getLhsOperand(); + RBAExpression* exprRhs = getRhsOperand(); + return exprLhs->getCoverageExpressionText() + getSymbol() + + "(" + exprRhs->getCoverageExpressionText() + ")"; +} + +RBAExpressionType +RBAHasComeLaterThan::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAHasComeLaterThan.hpp b/src/core/expression/RBAHasComeLaterThan.hpp new file mode 100644 index 0000000..659068f --- /dev/null +++ b/src/core/expression/RBAHasComeLaterThan.hpp @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * HasComeLaterThan class + */ + +#ifndef RBAHASCOMELATERTHAN_HPP +#define RBAHASCOMELATERTHAN_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAHasComeLaterThan : public RBAContentOperator +{ +public: + RBAHasComeLaterThan()=default; + RBAHasComeLaterThan(const RBAHasComeLaterThan&)=delete; + RBAHasComeLaterThan(const RBAHasComeLaterThan&&)=delete; + RBAHasComeLaterThan& operator=(const RBAHasComeLaterThan&)=delete; + RBAHasComeLaterThan& operator=(const RBAHasComeLaterThan&&)=delete; + virtual ~RBAHasComeLaterThan()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAHasComeLaterThanMaker.cpp b/src/core/expression/RBAHasComeLaterThanMaker.cpp new file mode 100644 index 0000000..2b49835 --- /dev/null +++ b/src/core/expression/RBAHasComeLaterThanMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasComeLaterThanMaker.cpp +/// @brief HasComeLaterThan object generation class definitino file + +#include "RBAHasComeLaterThanMaker.hpp" +#include "RBAHasComeLaterThan.hpp" + +namespace rba +{ + +RBAHasComeLaterThanMaker::RBAHasComeLaterThanMaker() + : RBAOperatorMaker{"HasComeLaterThan"} +{ +} + +std::unique_ptr +RBAHasComeLaterThanMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAHasComeLaterThanMaker.hpp b/src/core/expression/RBAHasComeLaterThanMaker.hpp new file mode 100644 index 0000000..16a42c3 --- /dev/null +++ b/src/core/expression/RBAHasComeLaterThanMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAHasComeLaterThanMaker.hpp +/// @brief HasComeLaterThan object generation class header file + +#ifndef RBAHASCOMELATERTHANMAKER_HPP +#define RBAHASCOMELATERTHANMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief HasComeLaterThan object generation class +class RBAHasComeLaterThanMaker : public RBAOperatorMaker +{ +public: + RBAHasComeLaterThanMaker(); + RBAHasComeLaterThanMaker(const RBAHasComeLaterThanMaker&)=delete; + RBAHasComeLaterThanMaker(const RBAHasComeLaterThanMaker&&)=delete; + RBAHasComeLaterThanMaker& operator=(const RBAHasComeLaterThanMaker&)=delete; + RBAHasComeLaterThanMaker& operator=(const RBAHasComeLaterThanMaker&&)=delete; + virtual ~RBAHasComeLaterThanMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIfStatement.cpp b/src/core/expression/RBAIfStatement.cpp new file mode 100644 index 0000000..d776bf7 --- /dev/null +++ b/src/core/expression/RBAIfStatement.cpp @@ -0,0 +1,268 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * If statement class defintion file + */ + +#include +#include "RBAIfStatement.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAIfStatement::setCondition(RBAExpression* const expr) +{ + condition_ = expr; +} + +void +RBAIfStatement::setThenExpression(RBAExpression* const expr) +{ + thenExpression_ = expr; +} + +void +RBAIfStatement::setElseExpression(RBAExpression* const expr) +{ + elseExpression_ = expr; +} + +RBAExpression* const +RBAIfStatement::getCondition() const +{ + return condition_; +} + +RBAExpression* const +RBAIfStatement::getThenExpression() const +{ + return thenExpression_; +} + +RBAExpression* const +RBAIfStatement::getElseExpression() const +{ + return elseExpression_; +} + +void +RBAIfStatement::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIfStatement::getModelElementType() const +{ + return RBAModelElementType::IfStatement; +} + +bool +RBAIfStatement::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + LOG_addHierarchy("IF"); + bool isPassed; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + LOG_addHierarchy("#condition:"); + const bool cond {getCondition()->execute(leftInfo, arb)}; + LOG_removeHierarchy(); + if (cond == true) { + LOG_addHierarchy("#then:"); + isPassed = getThenExpression()->execute(rightInfo, arb); + LOG_removeHierarchy(); + } else { + LOG_addHierarchy("#else:"); + isPassed = getElseExpression()->execute(rightInfo, arb); + LOG_removeHierarchy(); + } + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true)) { + info->setExceptionBeforeArbitrate(true); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); +#ifdef RBA_USE_LOG + } else if (isPassed == true) { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); +#endif + } + LOG_removeHierarchy(); + return isPassed; +} + +const RBARuleObject* +RBAIfStatement::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + LOG_addHierarchy("IF"); + const RBARuleObject* object {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + LOG_addHierarchy("#condition:"); + const bool cond {getCondition()->execute(leftInfo, arb)}; + LOG_removeHierarchy(); + if (cond == true) { + LOG_addHierarchy("#then:"); + object = getThenExpression()->getReferenceObject(rightInfo, arb); + LOG_removeHierarchy(); + } else { + LOG_addHierarchy("#else:"); + object = getElseExpression()->getReferenceObject(rightInfo, arb); + LOG_removeHierarchy(); + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true)) { + info->setExceptionBeforeArbitrate(true); + } + } + LOG_removeHierarchy(); + return object; +} + +std::int32_t +RBAIfStatement::getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + LOG_addHierarchy("IF"); + std::int32_t value; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + LOG_addHierarchy("#condition:"); + const bool cond {getCondition()->execute(leftInfo, arb)}; + LOG_removeHierarchy(); + if (cond == true) { + LOG_addHierarchy("#then:"); + value = getThenExpression()->getValue(rightInfo, arb); + LOG_removeHierarchy(); + } else { + LOG_addHierarchy("#else:"); + value = getElseExpression()->getValue(rightInfo, arb); + LOG_removeHierarchy(); + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true)) { + info->setExceptionBeforeArbitrate(true); + } + } + LOG_removeHierarchy(); + return value; +} + +void +RBAIfStatement::doActionCore(RBAConstraintInfo* info, + RBAArbitrator* arb) +{ + LOG_addHierarchy("IF"); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + LOG_addHierarchy("#condition:"); + const bool cond {getCondition()->execute(leftInfo, arb)}; + LOG_removeHierarchy(); + if (cond == true) { + LOG_addHierarchy("#then:"); + getThenExpression()->doAction(rightInfo, arb); + LOG_removeHierarchy(); + } else { + LOG_addHierarchy("#else:"); + getElseExpression()->doAction(rightInfo, arb); + LOG_removeHierarchy(); + } +#ifdef RBA_USE_LOG + LOG_coverageConstraintExpressionLog2(LOG_getCoverageExpressionText()); +#endif + LOG_removeHierarchy(); + return; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIfStatement::getExpressionText() const +{ + std::ostringstream oss; + oss << "IF("; + oss << condition_->getExpressionText(); + oss << ") THEN "; + oss << thenExpression_->getExpressionText(); + oss << " ELSE "; + oss << elseExpression_->getExpressionText(); + + return oss.str(); +} + +const std::string +RBAIfStatement::getCoverageExpressionText() const +{ + std::ostringstream oss; + oss << "IF("; + oss << condition_->getCoverageExpressionText(); + oss << ") THEN "; + oss << thenExpression_->getCoverageExpressionText(); + oss << " ELSE "; + oss << elseExpression_->getCoverageExpressionText(); + + return oss.str(); +} + +void +RBAIfStatement::createHierarchy() +{ + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy("IF"); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), + this); + + // Add condition to the constraint hierarchy for coverage + LOG_addHierarchy("#condition:"); + condition_->createHierarchy(); + // Remove condtion from to the constraint hierarchy for coverage + LOG_removeHierarchy(); + + if(thenExpression_) { + // Add "then" to the constraint hierarchy for coverage + LOG_addHierarchy("#then:"); + thenExpression_->createHierarchy(); + // Remove "then" from the constraint hierarchy for coverage + LOG_removeHierarchy(); + } + + if(elseExpression_) { + // Add "else" to the constraint hierarchy for coverage + LOG_addHierarchy("#else:"); + elseExpression_->createHierarchy(); + // Remove "else" from the constraint hierarchy for coverage + LOG_removeHierarchy(); + } + + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); +} + +RBAExpressionType +RBAIfStatement::getUnderlyingType() const +{ + return thenExpression_->getUnderlyingType(); +} +#endif +} diff --git a/src/core/expression/RBAIfStatement.hpp b/src/core/expression/RBAIfStatement.hpp new file mode 100644 index 0000000..7059583 --- /dev/null +++ b/src/core/expression/RBAIfStatement.hpp @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * If statement class header file + */ + +#ifndef RBAIFSTATEMENT_HPP +#define RBAIFSTATEMENT_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIfStatement : public RBAExpression +{ +public: + RBAIfStatement()=default; + RBAIfStatement(const RBAIfStatement&)=delete; + RBAIfStatement(const RBAIfStatement&&)=delete; + RBAIfStatement& operator=(const RBAIfStatement&)=delete; + RBAIfStatement& operator=(const RBAIfStatement&&)=delete; + virtual ~RBAIfStatement()=default; + +public: + void setCondition(RBAExpression* const expr); + void setThenExpression(RBAExpression* const expr); + void setElseExpression(RBAExpression* const expr); + RBAExpression* const getCondition() const; + RBAExpression* const getThenExpression() const; + RBAExpression* const getElseExpression() const; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + void doActionCore(RBAConstraintInfo* info, RBAArbitrator* arb) override; + + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + void createHierarchy() override; + RBAExpressionType getUnderlyingType() const override; +#endif + + private: + RBAExpression* condition_ {nullptr}; + RBAExpression* thenExpression_ {nullptr}; + RBAExpression* elseExpression_ {nullptr}; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIfStatementMaker.cpp b/src/core/expression/RBAIfStatementMaker.cpp new file mode 100644 index 0000000..b878ada --- /dev/null +++ b/src/core/expression/RBAIfStatementMaker.cpp @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIfStatementMaker.cpp +/// @brief IfStatement object generation class definition file + +#include "RBAIfStatementMaker.hpp" +#include "RBAIfStatement.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAIfStatementMaker::RBAIfStatementMaker() + : RBAExpressionMaker{"IfStatement"} +{ +} + +std::unique_ptr +RBAIfStatementMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAIfStatementMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAIfStatement* const ifstmt {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, ifstmt, jsonElem)}; + + // Set condition + const RBAJsonElement* const condElem {jsonElem->findChildren("condition")}; + RBAModelElement* const condExpr + {getFactory()->createElement(condElem->getClassName(), condElem)}; + ifstmt->setCondition(dynamic_cast(condExpr)); + // Set "then" + const RBAJsonElement* const thenElem {jsonElem->findChildren("thenExpression")}; + RBAModelElement* thenExpr {nullptr}; + if(thenElem != nullptr) { + thenExpr = getFactory()->createElement(thenElem->getClassName(), thenElem); + } + ifstmt->setThenExpression(dynamic_cast(thenExpr)); + // Set "else" + const RBAJsonElement* const elseElem {jsonElem->findChildren("elseExpression")}; + RBAModelElement* elseExpr {nullptr}; + if(elseElem != nullptr) { + elseExpr = getFactory()->createElement(elseElem->getClassName(), elseElem); + } + ifstmt->setElseExpression(dynamic_cast(elseExpr)); + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return ifstmt; +} + +} diff --git a/src/core/expression/RBAIfStatementMaker.hpp b/src/core/expression/RBAIfStatementMaker.hpp new file mode 100644 index 0000000..57a4133 --- /dev/null +++ b/src/core/expression/RBAIfStatementMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIfStatementMaker.hpp +/// @brief IfStatement object generation class header file + +#ifndef RBAIFSTATEMENTMAKER_HPP +#define RBAIFSTATEMENTMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief IfStatement object generation class +class RBAIfStatementMaker : public RBAExpressionMaker +{ +public: + RBAIfStatementMaker(); + RBAIfStatementMaker(const RBAIfStatementMaker&)=delete; + RBAIfStatementMaker(const RBAIfStatementMaker&&)=delete; + RBAIfStatementMaker& operator=(const RBAIfStatementMaker&)=delete; + RBAIfStatementMaker& operator=(const RBAIfStatementMaker&&)=delete; + virtual ~RBAIfStatementMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief set property of Model Element for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model Model for storing generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAImpliesOperator.cpp b/src/core/expression/RBAImpliesOperator.cpp new file mode 100644 index 0000000..ab95dc7 --- /dev/null +++ b/src/core/expression/RBAImpliesOperator.cpp @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * implication operator class defintion file + */ + +#include "RBAImpliesOperator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAImpliesOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAImpliesOperator::getModelElementType() const +{ + return RBAModelElementType::ImpliesOperator; +} + +bool +RBAImpliesOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + // Add "left-hand side formula" to the constraint hierarchy for coverage + LOG_addHierarchy("#left"); + const bool lhsRes {getLhsOperand()->execute(leftInfo, arb)}; + // Remove "left-hand side formula" from the constraint hierarchy for coverage + LOG_removeHierarchy(); + + if (leftInfo->isExceptionBeforeArbitrate() == false) { + if (lhsRes == false) { + isPassed = true; + } else { + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + // Add "right-hand side formula" to the constraint hierarchy for coverage + LOG_addHierarchy("#right"); + const bool rhsRes {getRhsOperand()->execute(rightInfo, arb)}; + // Remove "right-hand side formula" + // from the constraint hierarchy for coverage + LOG_removeHierarchy(); + if (rightInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else if (rhsRes == true) { + isPassed = true; + } else { + ; + } + } + } else { + info->setExceptionBeforeArbitrate(true); + // Evaluate the right-hand side fromula + // to get the right side allocatable of arbitration target + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + // Add "right-hand side formula" to the constraint hierarchy for coverage + LOG_addHierarchy("#right"); + static_cast(getRhsOperand()->execute(rightInfo, arb)); + // Remove "right-hand side formula" to the constraint hierarchy for coverage + LOG_removeHierarchy(); + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate()) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAImpliesOperator::getSymbol() const +{ + return "->"; +} + +void +RBAImpliesOperator::createHierarchy() +{ + RBAExpression* exprLhs = getLhsOperand(); + RBAExpression* exprRhs = getRhsOperand(); + + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(getSymbol()); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), this); + + // Add "left-hand side formula" to the constraint hierarchy for coverage + LOG_addHierarchy("#left"); + exprLhs->createHierarchy(); + // Remove "left-hand side formula" from + // the constraint hierarchy for coverage + LOG_removeHierarchy(); + + // Add "right-hand side formula" to the constraint hierarchy for coverage + LOG_addHierarchy("#right"); + exprRhs->createHierarchy(); + // Remove "right-hand side formula" from + // the constraint hierarchy for coverage + LOG_removeHierarchy(); + + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); +} +#endif + +} diff --git a/src/core/expression/RBAImpliesOperator.hpp b/src/core/expression/RBAImpliesOperator.hpp new file mode 100644 index 0000000..cc1cb33 --- /dev/null +++ b/src/core/expression/RBAImpliesOperator.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * implication operator class defintion file + */ + +#ifndef RBAIMPLIESOPERATOR_HPP +#define RBAIMPLIESOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAImpliesOperator: public RBALogicalOperator +{ +public: + RBAImpliesOperator()=default; + RBAImpliesOperator(const RBAImpliesOperator&)=delete; + RBAImpliesOperator(const RBAImpliesOperator&&)=delete; + RBAImpliesOperator& operator=(const RBAImpliesOperator&)=delete; + RBAImpliesOperator& operator=(const RBAImpliesOperator&&)=delete; + virtual ~RBAImpliesOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + void createHierarchy() override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAImpliesOperatorMaker.cpp b/src/core/expression/RBAImpliesOperatorMaker.cpp new file mode 100644 index 0000000..00b35fa --- /dev/null +++ b/src/core/expression/RBAImpliesOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAImpliesOperatorMaker.cpp +/// @brief ImpliesOperator object generation class definition file + +#include "RBAImpliesOperatorMaker.hpp" +#include "RBAImpliesOperator.hpp" + +namespace rba +{ + +RBAImpliesOperatorMaker::RBAImpliesOperatorMaker() + : RBAOperatorMaker{"ImpliesOperator"} +{ +} + +std::unique_ptr +RBAImpliesOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAImpliesOperatorMaker.hpp b/src/core/expression/RBAImpliesOperatorMaker.hpp new file mode 100644 index 0000000..466d36a --- /dev/null +++ b/src/core/expression/RBAImpliesOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAImpliesOperatorMaker.hpp +/// @brief ImpliesOperator object generation class header file + +#ifndef RBAIMPLIEDOPERATORMAKER_HPP +#define RBAIMPLIEDOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief ImpliesOperator object generation class +class RBAImpliesOperatorMaker : public RBAOperatorMaker +{ +public: + RBAImpliesOperatorMaker(); + RBAImpliesOperatorMaker(const RBAImpliesOperatorMaker&)=delete; + RBAImpliesOperatorMaker(const RBAImpliesOperatorMaker&&)=delete; + RBAImpliesOperatorMaker& operator=(const RBAImpliesOperatorMaker&)=delete; + RBAImpliesOperatorMaker& operator=(const RBAImpliesOperatorMaker&&)=delete; + virtual ~RBAImpliesOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIntegerValue.cpp b/src/core/expression/RBAIntegerValue.cpp new file mode 100644 index 0000000..aadffb0 --- /dev/null +++ b/src/core/expression/RBAIntegerValue.cpp @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Integer value class definition file + */ + +#include "RBAIntegerValue.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" + +namespace rba +{ + +void +RBAIntegerValue::setValue(const std::int32_t value) +{ + value_ = value; +} + +std::int32_t +RBAIntegerValue::getValue() const +{ + return value_; +} + +RBAModelElementType +RBAIntegerValue::getModelElementType() const +{ + return RBAModelElementType::IntegerValue; +} + +std::int32_t +RBAIntegerValue::getValueCore(RBAConstraintInfo* info, RBAArbitrator * arb) const +{ + return getValue(); +} + +#ifdef RBA_USE_LOG +const std::string +RBAIntegerValue::getExpressionText() const +{ + return std::to_string(value_); +} + +const std::string +RBAIntegerValue::getCoverageExpressionText() const +{ + return getExpressionText(); +} + +void +RBAIntegerValue::createHierarchy() +{ + // No opration + // because there is no hierarchy below this expression +} + +RBAExpressionType +RBAIntegerValue::getUnderlyingType() const +{ + return RBAExpressionType::VALUE; +} +#endif + +} diff --git a/src/core/expression/RBAIntegerValue.hpp b/src/core/expression/RBAIntegerValue.hpp new file mode 100644 index 0000000..44cf8cb --- /dev/null +++ b/src/core/expression/RBAIntegerValue.hpp @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Integer value class + */ + +#ifndef RBAINTEGERVALUE_HPP +#define RBAINTEGERVALUE_HPP + +#include "RBAValueExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIntegerValue : public RBAValueExpression +{ +public: + RBAIntegerValue()=default; + RBAIntegerValue(const RBAIntegerValue&)=delete; + RBAIntegerValue(const RBAIntegerValue&&)=delete; + RBAIntegerValue& operator=(const RBAIntegerValue&)=delete; + RBAIntegerValue& operator=(const RBAIntegerValue&&)=delete; + virtual ~RBAIntegerValue()=default; + +public: + void setValue(const std::int32_t value); + + std::int32_t getValue() const; + RBAModelElementType getModelElementType() const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + void createHierarchy() override; + RBAExpressionType getUnderlyingType() const override; +#endif + + private: + std::int32_t value_ {0}; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIntegerValueMaker.cpp b/src/core/expression/RBAIntegerValueMaker.cpp new file mode 100644 index 0000000..19a21eb --- /dev/null +++ b/src/core/expression/RBAIntegerValueMaker.cpp @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIntegerValueMaker.cpp +/// @brief IntegerValue object generation class definition file + +#include "RBAIntegerValueMaker.hpp" +#include "RBAIntegerValue.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAIntegerValueMaker::RBAIntegerValueMaker() + : RBAExpressionMaker{"IntegerValue"} +{ +} + +std::unique_ptr +RBAIntegerValueMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAIntegerValueMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAIntegerValue* const intVal {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, intVal, jsonElem)}; + + // Set value + const RBAJsonElement* const valueElem {jsonElem->findChildren("value")}; + intVal->setValue(stoi(valueElem->getString())); + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return intVal; +} + +} diff --git a/src/core/expression/RBAIntegerValueMaker.hpp b/src/core/expression/RBAIntegerValueMaker.hpp new file mode 100644 index 0000000..0f637df --- /dev/null +++ b/src/core/expression/RBAIntegerValueMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIntegerValueMaker.hpp +/// @brief IntegerValue object generation class header file + +#ifndef RBAINTEGERVALUEMAKER_HPP +#define RBAINTEGERVALUEMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief IntegerValue object generation class +class RBAIntegerValueMaker : public RBAExpressionMaker +{ +public: + RBAIntegerValueMaker(); + RBAIntegerValueMaker(const RBAIntegerValueMaker&)=delete; + RBAIntegerValueMaker(const RBAIntegerValueMaker&&)=delete; + RBAIntegerValueMaker& operator=(const RBAIntegerValueMaker&)=delete; + RBAIntegerValueMaker& operator=(const RBAIntegerValueMaker&&)=delete; + virtual ~RBAIntegerValueMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief set property of Model Element for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model Model for storing generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsActive.cpp b/src/core/expression/RBAIsActive.cpp new file mode 100644 index 0000000..a89745f --- /dev/null +++ b/src/core/expression/RBAIsActive.cpp @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * IsActive class definition + */ + +#include "RBAIsActive.hpp" +#include "RBAContent.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBAIsActive::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsActive::getModelElementType() const +{ + return RBAModelElementType::IsActive; +} + +bool +RBAIsActive::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to the constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const ruleObj + {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + if (leftInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else if (ruleObj != nullptr) { + const RBAContent* const content {dynamic_cast(ruleObj->getRawObject())}; + if (ruleObj->isPrevious()) { + isPassed = arb->getResult()->isPreActive(content); + } else { + isPassed = arb->getResult()->isActive(content); + } + } else { + ; + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " Content[NULL] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (ruleObj != nullptr) { + const RBAContent* content = dynamic_cast(ruleObj + ->getRawObject()); + if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " " + getPreMsg(ruleObj->isPrevious()) + "Content[" + + content->getElementName() + "] is Active"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " " + getPreMsg(ruleObj->isPrevious()) + "Content[" + + content->getElementName() + "] is not Active"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } + } else { + LOG_arbitrateConstraintLogicLogLine(" Content[NULL] is not Active"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from the constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsActive::getSymbol() const +{ + return ".isActive()"; +} + +RBAExpressionType +RBAIsActive::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsActive.hpp b/src/core/expression/RBAIsActive.hpp new file mode 100644 index 0000000..73ab055 --- /dev/null +++ b/src/core/expression/RBAIsActive.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * IsActive class header file + */ + +#ifndef RBAISACTIVE_HPP +#define RBAISACTIVE_HPP + +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsActive : public RBAContentOperator +{ +public: + RBAIsActive()=default; + RBAIsActive(const RBAIsActive&)=delete; + RBAIsActive(const RBAIsActive&&)=delete; + RBAIsActive& operator=(const RBAIsActive&)=delete; + RBAIsActive& operator=(const RBAIsActive&&)=delete; + virtual ~RBAIsActive()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsActiveMaker.cpp b/src/core/expression/RBAIsActiveMaker.cpp new file mode 100644 index 0000000..6b2e7ee --- /dev/null +++ b/src/core/expression/RBAIsActiveMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsActiveMaker.cpp +/// @brief IsActive object generation class defintion file + +#include "RBAIsActiveMaker.hpp" +#include "RBAIsActive.hpp" + +namespace rba +{ + +RBAIsActiveMaker::RBAIsActiveMaker() + : RBAOperatorMaker{"IsActive"} +{ +} + +std::unique_ptr +RBAIsActiveMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsActiveMaker.hpp b/src/core/expression/RBAIsActiveMaker.hpp new file mode 100644 index 0000000..15011fb --- /dev/null +++ b/src/core/expression/RBAIsActiveMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsActiveMaker.hpp +/// @brief IsActive object generation class heaer file + +#ifndef RBAISACTIVEMAKER_HPP +#define RBAISACTIVEMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsActive object generation class +class RBAIsActiveMaker : public RBAOperatorMaker +{ +public: + RBAIsActiveMaker(); + RBAIsActiveMaker(const RBAIsActiveMaker&)=delete; + RBAIsActiveMaker(const RBAIsActiveMaker&&)=delete; + RBAIsActiveMaker& operator=(const RBAIsActiveMaker&)=delete; + RBAIsActiveMaker& operator=(const RBAIsActiveMaker&&)=delete; + virtual ~RBAIsActiveMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsEqualToOperator.cpp b/src/core/expression/RBAIsEqualToOperator.cpp new file mode 100644 index 0000000..5dfa929 --- /dev/null +++ b/src/core/expression/RBAIsEqualToOperator.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsEqualToOperator class definitino file + +#include "RBAIsEqualToOperator.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAIsEqualToOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsEqualToOperator::getModelElementType() const +{ + return RBAModelElementType::IsEqualToOperator; +} + +bool +RBAIsEqualToOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const std::int32_t lhsVal {getLhsOperand()->getValue(leftInfo, arb)}; + const std::int32_t rhsVal {getRhsOperand()->getValue(rightInfo, arb)}; + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true) + || (lhsVal == -99) + || (rhsVal == -99)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsVal == rhsVal) { + isPassed = true; + info->addTrueAllocatableFromOperand(); + } else { + info->addFalseAllocatableFromOperand(); + } + } + +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (lhsVal == rhsVal) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsEqualToOperator::getSymbol() const +{ + return "="; +} + +RBAExpressionType +RBAIsEqualToOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsEqualToOperator.hpp b/src/core/expression/RBAIsEqualToOperator.hpp new file mode 100644 index 0000000..d66efed --- /dev/null +++ b/src/core/expression/RBAIsEqualToOperator.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsEqualToOperator class header file + +#ifndef RBAISEQUALTOOPERATOR_HPP +#define RBAISEQUALTOOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsEqualToOperator : public RBALogicalOperator +{ +public: + RBAIsEqualToOperator()=default; + RBAIsEqualToOperator(const RBAIsEqualToOperator&)=delete; + RBAIsEqualToOperator(RBAIsEqualToOperator&&)=delete; + RBAIsEqualToOperator& operator=(const RBAIsEqualToOperator&)=delete; + RBAIsEqualToOperator& operator=(RBAIsEqualToOperator&&)=delete; + virtual ~RBAIsEqualToOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsEqualToOperatorMaker.cpp b/src/core/expression/RBAIsEqualToOperatorMaker.cpp new file mode 100644 index 0000000..32717ce --- /dev/null +++ b/src/core/expression/RBAIsEqualToOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsEqualToOperatorMaker.cpp +/// @brief IsEqualToOperator object generation file + +#include "RBAIsEqualToOperatorMaker.hpp" +#include "RBAIsEqualToOperator.hpp" + +namespace rba +{ + +RBAIsEqualToOperatorMaker::RBAIsEqualToOperatorMaker() + : RBAOperatorMaker{"IsEqualToOperator"} +{ +} + +std::unique_ptr +RBAIsEqualToOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsEqualToOperatorMaker.hpp b/src/core/expression/RBAIsEqualToOperatorMaker.hpp new file mode 100644 index 0000000..9d0fa30 --- /dev/null +++ b/src/core/expression/RBAIsEqualToOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsEqualToOperatorMaker.hpp +/// @brief IsEqualToOperator object generation file + +#ifndef RBAISEQUALTOOPERATORMAKER_HPP +#define RBAISEQUALTOOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsEqualToOperator object generation class +class RBAIsEqualToOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsEqualToOperatorMaker(); + RBAIsEqualToOperatorMaker(const RBAIsEqualToOperatorMaker&)=delete; + RBAIsEqualToOperatorMaker(const RBAIsEqualToOperatorMaker&&)=delete; + RBAIsEqualToOperatorMaker& operator=(const RBAIsEqualToOperatorMaker&)=delete; + RBAIsEqualToOperatorMaker& operator=(const RBAIsEqualToOperatorMaker&&)=delete; + virtual ~RBAIsEqualToOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsGreaterThanEqualOperator.cpp b/src/core/expression/RBAIsGreaterThanEqualOperator.cpp new file mode 100644 index 0000000..368bb3b --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanEqualOperator.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsGreaterThanEqualOperator class definition file + +#include "RBAIsGreaterThanEqualOperator.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAIsGreaterThanEqualOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsGreaterThanEqualOperator::getModelElementType() const +{ + return RBAModelElementType::IsGreaterThanEqualOperator; +} + +bool +RBAIsGreaterThanEqualOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const std::int32_t lhsVal {getLhsOperand()->getValue(leftInfo, arb)}; + const std::int32_t rhsVal {getRhsOperand()->getValue(rightInfo, arb)}; + // If a pre-arbitration exception occurs on either the left side + // or the right side in the reference, throw it higher + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true) + || (lhsVal == -99) + || (rhsVal == -99)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsVal >= rhsVal) { + isPassed = true; + info->addTrueAllocatableFromOperand(); + } else { + info->addFalseAllocatableFromOperand(); + } + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsGreaterThanEqualOperator::getSymbol() const +{ + return ">="; +} + +RBAExpressionType +RBAIsGreaterThanEqualOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsGreaterThanEqualOperator.hpp b/src/core/expression/RBAIsGreaterThanEqualOperator.hpp new file mode 100644 index 0000000..0d5db61 --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanEqualOperator.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsGreaterThanEqualOperator class header file + +#ifndef RBAISGREATERTHANEQUALOPERATOR_HPP +#define RBAISGREATERTHANEQUALOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsGreaterThanEqualOperator : public RBALogicalOperator +{ +public: + RBAIsGreaterThanEqualOperator()=default; + RBAIsGreaterThanEqualOperator(const RBAIsGreaterThanEqualOperator&)=delete; + RBAIsGreaterThanEqualOperator(RBAIsGreaterThanEqualOperator&&)=delete; + RBAIsGreaterThanEqualOperator& operator=(const RBAIsGreaterThanEqualOperator&)=delete; + RBAIsGreaterThanEqualOperator& operator=(RBAIsGreaterThanEqualOperator&&)=delete; + virtual ~RBAIsGreaterThanEqualOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.cpp b/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.cpp new file mode 100644 index 0000000..e9e23a9 --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsGreaterThanEqualOperatorMaker.cpp +/// @brief IsGreaterThanEqualOperator object generation class + +#include "RBAIsGreaterThanEqualOperatorMaker.hpp" +#include "RBAIsGreaterThanEqualOperator.hpp" + +namespace rba +{ + +RBAIsGreaterThanEqualOperatorMaker::RBAIsGreaterThanEqualOperatorMaker() + : RBAOperatorMaker{"IsGreaterThanEqualOperator"} +{ +} + +std::unique_ptr +RBAIsGreaterThanEqualOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.hpp b/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.hpp new file mode 100644 index 0000000..e7f470f --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanEqualOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsGreaterThanEqualOperatorMaker.hpp +/// @brief IsGreaterThanEqualOperator object generation class header file + +#ifndef RBAISGREATERTHANEQUALOPERATORMAKER_HPP +#define RBAISGREATERTHANEQUALOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsGreaterThanEqualOperator object generation class +class RBAIsGreaterThanEqualOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsGreaterThanEqualOperatorMaker(); + RBAIsGreaterThanEqualOperatorMaker(const RBAIsGreaterThanEqualOperatorMaker&)=delete; + RBAIsGreaterThanEqualOperatorMaker(const RBAIsGreaterThanEqualOperatorMaker&&)=delete; + RBAIsGreaterThanEqualOperatorMaker& operator=(const RBAIsGreaterThanEqualOperatorMaker&)=delete; + RBAIsGreaterThanEqualOperatorMaker& operator=(const RBAIsGreaterThanEqualOperatorMaker&&)=delete; + virtual ~RBAIsGreaterThanEqualOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsGreaterThanOperator.cpp b/src/core/expression/RBAIsGreaterThanOperator.cpp new file mode 100644 index 0000000..d9153f1 --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanOperator.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsGreaterThanOperator class definition file + +#include "RBAIsGreaterThanOperator.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +RBAModelElementType +RBAIsGreaterThanOperator::getModelElementType() const +{ + return RBAModelElementType::IsGreaterThanOperator; +} + +void +RBAIsGreaterThanOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +bool +RBAIsGreaterThanOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const std::int32_t lhsVal {getLhsOperand()->getValue(leftInfo, arb)}; + const std::int32_t rhsVal {getRhsOperand()->getValue(rightInfo, arb)}; + // If a pre-arbitration exception occurs on either the left side + // or the right side in the reference, throw it higher + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true) + || (lhsVal == -99) + || (rhsVal == -99)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsVal > rhsVal) { + isPassed = true; + info->addTrueAllocatableFromOperand(); + } else { + info->addFalseAllocatableFromOperand(); + } + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsGreaterThanOperator::getSymbol() const +{ + return ">"; +} + +RBAExpressionType +RBAIsGreaterThanOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsGreaterThanOperator.hpp b/src/core/expression/RBAIsGreaterThanOperator.hpp new file mode 100644 index 0000000..9e0938b --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanOperator.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsGreaterThanOperator class header file + +#ifndef RBAISGREATERTHANOPERATOR_HPP +#define RBAISGREATERTHANOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsGreaterThanOperator : public RBALogicalOperator +{ +public: + RBAIsGreaterThanOperator()=default; + RBAIsGreaterThanOperator(const RBAIsGreaterThanOperator&)=delete; + RBAIsGreaterThanOperator(RBAIsGreaterThanOperator&&)=delete; + RBAIsGreaterThanOperator& operator=(const RBAIsGreaterThanOperator&)=delete; + RBAIsGreaterThanOperator& operator=(RBAIsGreaterThanOperator&&)=delete; + virtual ~RBAIsGreaterThanOperator()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsGreaterThanOperatorMaker.cpp b/src/core/expression/RBAIsGreaterThanOperatorMaker.cpp new file mode 100644 index 0000000..37a2888 --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsGreaterThanEqualOperatorMaker.cpp +/// @brief IsGreaterThanEqualOperator object generation class definition file + +#include "RBAIsGreaterThanOperatorMaker.hpp" +#include "RBAIsGreaterThanOperator.hpp" + +namespace rba +{ + +RBAIsGreaterThanOperatorMaker::RBAIsGreaterThanOperatorMaker() + : RBAOperatorMaker{"IsGreaterThanOperator"} +{ +} + +std::unique_ptr +RBAIsGreaterThanOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsGreaterThanOperatorMaker.hpp b/src/core/expression/RBAIsGreaterThanOperatorMaker.hpp new file mode 100644 index 0000000..40bfc17 --- /dev/null +++ b/src/core/expression/RBAIsGreaterThanOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsGreaterThanEqualOperatorMaker.hpp +/// @brief IsGreaterThanEqualOperator object generation class header file + +#ifndef RBAISGREATERTHANOPERATORMAKER_HPP +#define RBAISGREATERTHANOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsGreaterThanEqualOperator object generation class +class RBAIsGreaterThanOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsGreaterThanOperatorMaker(); + RBAIsGreaterThanOperatorMaker(const RBAIsGreaterThanOperatorMaker&)=delete; + RBAIsGreaterThanOperatorMaker(const RBAIsGreaterThanOperatorMaker&&)=delete; + RBAIsGreaterThanOperatorMaker& operator=(const RBAIsGreaterThanOperatorMaker&)=delete; + RBAIsGreaterThanOperatorMaker& operator=(const RBAIsGreaterThanOperatorMaker&&)=delete; + virtual ~RBAIsGreaterThanOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsLowerThanEqualOperator.cpp b/src/core/expression/RBAIsLowerThanEqualOperator.cpp new file mode 100644 index 0000000..811b34d --- /dev/null +++ b/src/core/expression/RBAIsLowerThanEqualOperator.cpp @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsLowerThanEqualOperator class definition file + +#include "RBAIsLowerThanEqualOperator.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" + +namespace rba +{ + +void +RBAIsLowerThanEqualOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsLowerThanEqualOperator::getModelElementType() const +{ + return RBAModelElementType::IsLowerThanEqualOperator; +} + +bool +RBAIsLowerThanEqualOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const std::int32_t lhsVal {getLhsOperand()->getValue(leftInfo, arb)}; + const std::int32_t rhsVal {getRhsOperand()->getValue(rightInfo, arb)}; + // If a pre-arbitration exception occurs on either the left side + // or the right side in the reference, throw it higher + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true) + || (lhsVal == -99) + || (rhsVal == -99)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsVal <= rhsVal) { + isPassed = true; + info->addTrueAllocatableFromOperand(); + } else { + info->addFalseAllocatableFromOperand(); + } + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsLowerThanEqualOperator::getSymbol() const +{ + return "<="; +} + +RBAExpressionType +RBAIsLowerThanEqualOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsLowerThanEqualOperator.hpp b/src/core/expression/RBAIsLowerThanEqualOperator.hpp new file mode 100644 index 0000000..3459110 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanEqualOperator.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsLowerThanEqualOperator class header file + +#ifndef RBAISLOWERTHANEQUALOPERATOR_HPP +#define RBAISLOWERTHANEQUALOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsLowerThanEqualOperator : public RBALogicalOperator +{ +public: + RBAIsLowerThanEqualOperator()=default; + RBAIsLowerThanEqualOperator(const RBAIsLowerThanEqualOperator&)=delete; + RBAIsLowerThanEqualOperator(RBAIsLowerThanEqualOperator&&)=delete; + RBAIsLowerThanEqualOperator& operator=(const RBAIsLowerThanEqualOperator&)=delete; + RBAIsLowerThanEqualOperator& operator=(RBAIsLowerThanEqualOperator&&)=delete; + virtual ~RBAIsLowerThanEqualOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsLowerThanEqualOperatorMaker.cpp b/src/core/expression/RBAIsLowerThanEqualOperatorMaker.cpp new file mode 100644 index 0000000..a04a52b --- /dev/null +++ b/src/core/expression/RBAIsLowerThanEqualOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsLowerThanEqualOperatorMaker.cpp +/// @brief IsLowerThanEqualOperator object geneation class defintion file + +#include "RBAIsLowerThanEqualOperatorMaker.hpp" +#include "RBAIsLowerThanEqualOperator.hpp" + +namespace rba +{ + +RBAIsLowerThanEqualOperatorMaker::RBAIsLowerThanEqualOperatorMaker() + : RBAOperatorMaker{"IsLowerThanEqualOperator"} +{ +} + +std::unique_ptr +RBAIsLowerThanEqualOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsLowerThanEqualOperatorMaker.hpp b/src/core/expression/RBAIsLowerThanEqualOperatorMaker.hpp new file mode 100644 index 0000000..10cf469 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanEqualOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsLowerThanEqualOperatorMaker.hpp +/// @brief IsLowerThanEqualOperator object geneation class header file + +#ifndef RBAISLOWERTHANEQUALOPERATORMAKER_HPP +#define RBAISLOWERTHANEQUALOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsLowerThanEqualOperator object generation class +class RBAIsLowerThanEqualOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsLowerThanEqualOperatorMaker(); + RBAIsLowerThanEqualOperatorMaker(const RBAIsLowerThanEqualOperatorMaker&)=delete; + RBAIsLowerThanEqualOperatorMaker(const RBAIsLowerThanEqualOperatorMaker&&)=delete; + RBAIsLowerThanEqualOperatorMaker& operator=(const RBAIsLowerThanEqualOperatorMaker&)=delete; + RBAIsLowerThanEqualOperatorMaker& operator=(const RBAIsLowerThanEqualOperatorMaker&&)=delete; + virtual ~RBAIsLowerThanEqualOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsLowerThanOperator.cpp b/src/core/expression/RBAIsLowerThanOperator.cpp new file mode 100644 index 0000000..99a7860 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanOperator.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsLowerThanOperator class definition file + +#include "RBAIsLowerThanOperator.hpp" +#include "RBAArbitrator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAIsLowerThanOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsLowerThanOperator::getModelElementType() const +{ + return RBAModelElementType::IsLowerThanOperator; +} + +bool +RBAIsLowerThanOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const std::int32_t lhsVal {getLhsOperand()->getValue(leftInfo, arb)}; + const std::int32_t rhsVal {getRhsOperand()->getValue(rightInfo, arb)}; + // If a pre-arbitration exception occurs on either the left side + // or the right side in the reference, throw it higher + if ((leftInfo->isExceptionBeforeArbitrate() == true) + || (rightInfo->isExceptionBeforeArbitrate() == true) + || (lhsVal == -99) + || (rhsVal == -99)) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsVal < rhsVal) { + isPassed = true; + info->addTrueAllocatableFromOperand(); + } else { + info->addFalseAllocatableFromOperand(); + } + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsLowerThanOperator::getSymbol() const +{ + return "<"; +} + +RBAExpressionType +RBAIsLowerThanOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsLowerThanOperator.hpp b/src/core/expression/RBAIsLowerThanOperator.hpp new file mode 100644 index 0000000..3a23e45 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanOperator.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// IsLowerThanOperator class header file + +#ifndef RBAISLOWERTHANOPERATOR_HPP +#define RBAISLOWERTHANOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsLowerThanOperator : public RBALogicalOperator +{ +public: + RBAIsLowerThanOperator()=default; + RBAIsLowerThanOperator(const RBAIsLowerThanOperator&)=delete; + RBAIsLowerThanOperator(RBAIsLowerThanOperator&&)=delete; + RBAIsLowerThanOperator& operator=(const RBAIsLowerThanOperator&)=delete; + RBAIsLowerThanOperator& operator=(RBAIsLowerThanOperator&&)=delete; + virtual ~RBAIsLowerThanOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsLowerThanOperatorMaker.cpp b/src/core/expression/RBAIsLowerThanOperatorMaker.cpp new file mode 100644 index 0000000..f6ddf53 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanOperatorMaker.cpp @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAIsLowerThanOperatorMaker.cpp +/// @brief IsLowerThanOperator object gerneation class + +#include "RBAIsLowerThanOperatorMaker.hpp" +#include "RBAIsLowerThanOperator.hpp" + +namespace rba +{ + +RBAIsLowerThanOperatorMaker::RBAIsLowerThanOperatorMaker() + : RBAOperatorMaker{"IsLowerThanOperator"} +{ +} + +std::unique_ptr +RBAIsLowerThanOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsLowerThanOperatorMaker.hpp b/src/core/expression/RBAIsLowerThanOperatorMaker.hpp new file mode 100644 index 0000000..d2c6870 --- /dev/null +++ b/src/core/expression/RBAIsLowerThanOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsLowerThanOperatorMaker.hpp +/// @brief IsLowerThanOperator object gerneation class header file + +#ifndef RBAISLOWERTHANOPERATORMAKER_HPP +#define RBAISLOWERTHANOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief sLowerThanOperator object gerneation class +class RBAIsLowerThanOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsLowerThanOperatorMaker(); + RBAIsLowerThanOperatorMaker(const RBAIsLowerThanOperatorMaker&)=delete; + RBAIsLowerThanOperatorMaker(const RBAIsLowerThanOperatorMaker&&)=delete; + RBAIsLowerThanOperatorMaker& operator=(const RBAIsLowerThanOperatorMaker&)=delete; + RBAIsLowerThanOperatorMaker& operator=(const RBAIsLowerThanOperatorMaker&&)=delete; + virtual ~RBAIsLowerThanOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsOn.cpp b/src/core/expression/RBAIsOn.cpp new file mode 100644 index 0000000..f8dd769 --- /dev/null +++ b/src/core/expression/RBAIsOn.cpp @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * IsOn class (to judge if a Scene is active) definition file + */ + +#include "RBAIsOn.hpp" +#include "RBAArbitrator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBASceneImpl.hpp" +#include "RBALogManager.hpp" +#include "RBAExpressionType.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void +RBAIsOn::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAIsOn::getModelElementType() const +{ + return RBAModelElementType::IsOn; +} + +bool +RBAIsOn::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const ruleObj + {getLhsOperand()->getReferenceObject(leftInfo, arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else if (ruleObj != nullptr){ + const RBASceneImpl* const scene {dynamic_cast(ruleObj->getRawObject())}; + if (ruleObj->isPrevious() == false) { + isPassed = arb->getResult()->isActive(scene); + } else { + isPassed = arb->getResult()->isPreActive(scene); + } + } else { + // Currently, there is no expression that returns null as "Scene", + // so it does not go through this path. But an expression that returns null + // may be added in the future, so it is described as it is. + ; + } +#ifdef RBA_USE_LOG + if (ruleObj != nullptr) { + const RBASceneImpl* scene = dynamic_cast(ruleObj + ->getRawObject()); + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " Scene[" + scene->getName() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " " + getPreMsg(ruleObj->isPrevious()) + "Scene[" + + scene->getName() + "] is On"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " " + getPreMsg(ruleObj->isPrevious()) + "Scene[" + + scene->getName() + "] is not On"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } + } else { + // Currently, there is no expression that returns null as "Scene", + // so it does not go through this path. But an expression that returns null + // may be added in the future, so it is described as it is. + LOG_arbitrateConstraintLogicLogLine( + " " + getPreMsg(ruleObj->isPrevious()) + "Scene[NULL] is not On"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIsOn::getSymbol() const +{ + return ".isOn()"; +} + +const std::string +RBAIsOn::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +const std::string RBAIsOn::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + getSymbol(); +} + +RBAExpressionType +RBAIsOn::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAIsOn.hpp b/src/core/expression/RBAIsOn.hpp new file mode 100644 index 0000000..9f3f778 --- /dev/null +++ b/src/core/expression/RBAIsOn.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * IsOn class (to judge if a Scene is active) header + */ + +#ifndef RBAISON_HPP +#define RBAISON_HPP + +#include "RBASceneOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsOn : public RBASceneOperator +{ +public: + RBAIsOn()=default; + RBAIsOn(const RBAIsOn&)=delete; + RBAIsOn(const RBAIsOn&&)=delete; + RBAIsOn& operator=(const RBAIsOn&)=delete; + RBAIsOn& operator=(const RBAIsOn&&)=delete; + virtual ~RBAIsOn()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsOnMaker.cpp b/src/core/expression/RBAIsOnMaker.cpp new file mode 100644 index 0000000..79a4e16 --- /dev/null +++ b/src/core/expression/RBAIsOnMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsOnMaker.cpp +/// @brief IsOn (to judge if a Scene is active) class generation definition + +#include "RBAIsOnMaker.hpp" +#include "RBAIsOn.hpp" + +namespace rba +{ + +RBAIsOnMaker::RBAIsOnMaker() + : RBAOperatorMaker{"IsOn"} +{ +} + +std::unique_ptr +RBAIsOnMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAIsOnMaker.hpp b/src/core/expression/RBAIsOnMaker.hpp new file mode 100644 index 0000000..824d091 --- /dev/null +++ b/src/core/expression/RBAIsOnMaker.hpp @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsOnMaker.hpp +/// @brief IsOn object generation class header file +/// IsOn is class to judge if a Scene is active + +#ifndef RBAISONMAKER_HPP +#define RBAISONMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsOn object generation class +class RBAIsOnMaker : public RBAOperatorMaker +{ +public: + RBAIsOnMaker(); + RBAIsOnMaker(const RBAIsOnMaker&)=delete; + RBAIsOnMaker(const RBAIsOnMaker&&)=delete; + RBAIsOnMaker& operator=(const RBAIsOnMaker&)=delete; + RBAIsOnMaker& operator=(const RBAIsOnMaker&&)=delete; + virtual ~RBAIsOnMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAIsTypeOfOperator.cpp b/src/core/expression/RBAIsTypeOfOperator.cpp new file mode 100644 index 0000000..2104f43 --- /dev/null +++ b/src/core/expression/RBAIsTypeOfOperator.cpp @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// IsTypeOf class defintion file +// + +#include "RBAIsTypeOfOperator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpressionType.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBALogManager.hpp" +#include "RBARuleObject.hpp" + +namespace rba +{ + +void RBAIsTypeOfOperator::setTag(const std::string& tag) +{ + tagId_ = tag; +} + +void RBAIsTypeOfOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} +RBAModelElementType RBAIsTypeOfOperator::getModelElementType() const +{ + return RBAModelElementType::IsTypeOfOperator; +} +bool RBAIsTypeOfOperator::executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + bool isPassed {false}; + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo * const leftInfo {info->getChild(0U)}; + const RBARuleObject* const ruleObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else if (ruleObj != nullptr) { + isPassed = ruleObj->containsTag(tagId_); + } else { + ; + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate()) { + LOG_arbitrateConstraintLogicLogLine( + " " + getExpressionText() + " before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if ((ruleObj == nullptr) || (!isPassed)) { + LOG_arbitrateConstraintLogicLogLine( + " " + getExpressionText() + " false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " " + getExpressionText() + " true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } +#endif + LOG_removeHierarchy(); + return isPassed; +} +#ifdef RBA_USE_LOG +const std::string RBAIsTypeOfOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} + +const std::string RBAIsTypeOfOperator::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + getSymbol(); +} + +const std::string RBAIsTypeOfOperator::getSymbol() const +{ + return ".isTypeOf(" + tagId_ + ")"; +} + +RBAExpressionType RBAIsTypeOfOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif +} +/* namespace rba */ diff --git a/src/core/expression/RBAIsTypeOfOperator.hpp b/src/core/expression/RBAIsTypeOfOperator.hpp new file mode 100644 index 0000000..ce4d213 --- /dev/null +++ b/src/core/expression/RBAIsTypeOfOperator.hpp @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// IsTypeOfクラスヘッダファイル +// + +#ifndef RBAISTYPEOFOPERATOR_HPP +#define RBAISTYPEOFOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAIsTypeOfOperator : public RBAOperator +{ + public: + RBAIsTypeOfOperator()=default; + RBAIsTypeOfOperator(const RBAIsTypeOfOperator&)=delete; + RBAIsTypeOfOperator(const RBAIsTypeOfOperator&&)=delete; + RBAIsTypeOfOperator& operator=(const RBAIsTypeOfOperator&)=delete; + RBAIsTypeOfOperator& operator=(const RBAIsTypeOfOperator&&)=delete; + virtual ~RBAIsTypeOfOperator()=default; + + public: + void setTag(const std::string& tag); + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + const std::string getSymbol() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::string tagId_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} /* namespace rba */ + +#endif /* RBAISTYPEOFOPERATOR_HPP */ diff --git a/src/core/expression/RBAIsTypeOfOperatorMaker.cpp b/src/core/expression/RBAIsTypeOfOperatorMaker.cpp new file mode 100644 index 0000000..cabd83c --- /dev/null +++ b/src/core/expression/RBAIsTypeOfOperatorMaker.cpp @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsTypeOfOperatorMaker.cpp +/// @brief IsTypeOf object generation class + +#include "RBAIsTypeOfOperatorMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBAIsTypeOfOperator.hpp" + +namespace rba +{ + +RBAIsTypeOfOperatorMaker::RBAIsTypeOfOperatorMaker() + : RBAOperatorMaker{"IsTypeOf"} +{ +} + +std::unique_ptr +RBAIsTypeOfOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAIsTypeOfOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAIsTypeOfOperator* const isTypeOfOpe + {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, isTypeOfOpe, jsonElem)}; + + // Set operand + const RBAJsonElement* const operand {jsonElem->findChildren("operand")}; + const RBAJsonElement* const param {operand->getChild()}; + RBAModelElement* const expr {getFactory()->createElement(param->getClassName(), param)}; + isTypeOfOpe->addOperand(dynamic_cast(expr)); + // Set Tag + const RBAJsonElement* const tagElem {jsonElem->findChildren("tagName")}; + isTypeOfOpe->setTag(tagElem->getString()); + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return isTypeOfOpe; +} + +} diff --git a/src/core/expression/RBAIsTypeOfOperatorMaker.hpp b/src/core/expression/RBAIsTypeOfOperatorMaker.hpp new file mode 100644 index 0000000..5877267 --- /dev/null +++ b/src/core/expression/RBAIsTypeOfOperatorMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAIsTypeOfOperatorMaker.hpp +/// @brief IsTypeOf object geneation class header file + +#ifndef RBAISTYPEOFOPERATORMAKER_HPP +#define RBAISTYPEOFOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief IsTypeOf object geneation class +class RBAIsTypeOfOperatorMaker : public RBAOperatorMaker +{ +public: + RBAIsTypeOfOperatorMaker(); + RBAIsTypeOfOperatorMaker(const RBAIsTypeOfOperatorMaker&)=delete; + RBAIsTypeOfOperatorMaker(const RBAIsTypeOfOperatorMaker&&)=delete; + RBAIsTypeOfOperatorMaker& operator=(const RBAIsTypeOfOperatorMaker&)=delete; + RBAIsTypeOfOperatorMaker& operator=(const RBAIsTypeOfOperatorMaker&&)=delete; + virtual ~RBAIsTypeOfOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBALambdaContext.cpp b/src/core/expression/RBALambdaContext.cpp new file mode 100644 index 0000000..7d68513 --- /dev/null +++ b/src/core/expression/RBALambdaContext.cpp @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * LambdaContext class definition file + */ + +#include "RBALambdaContext.hpp" +#include "RBALogManager.hpp" +#include "RBAVariable.hpp" +#include "RBAAllocatable.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContent.hpp" +#include "RBAContentSet.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBALambdaExpression* const +RBALambdaContext::getLambda() const +{ + return lambda_; +} + +void +RBALambdaContext::setLambda(RBALambdaExpression* const newLambda) +{ + lambda_ = newLambda; +} + +#ifdef RBA_USE_LOG +void +RBALambdaContext::createHierarchy() +{ + lambda_->getX()->clearRuleObj(); + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(getSymbol()); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), this); + + // Get rule object and loop + RBAExpression* setObj = getLhsOperand(); + RBAConstraintInfo dummyInfo; + // Since it is not referenced by "AllInstanceOf..." or "SetOfOperator" + // used for the set of "For-All" or "Exists", nullptr is no problem + RBAArbitrator* dummyArb = nullptr; + const RBARuleObject* objset = setObj->getReferenceObject(&dummyInfo, dummyArb); + std::vector objs; + if(objset) { + if(dynamic_cast(objset) != nullptr) { + const RBAAllocatableSet* aSet + = dynamic_cast(objset); + for(const auto& alloc : aSet->getLeafAllocatable()) { + objs.push_back(alloc); + } + } + else if(dynamic_cast(objset) != nullptr) { + const RBAContentSet* cSet = dynamic_cast(objset); + for(const auto& cont : cSet->getLeafContent() ){ + objs.push_back(cont); + } + } + } + + // Enable expansion of own variables in the coverage log + std::int32_t idx=0; + for(const RBARuleObject* obj : objs) { + LOG_addHierarchy("#" + std::to_string(idx++)); + lambda_->getX()->setRuleObj(obj); + lambda_->createHierarchy(); + LOG_removeHierarchy(); + } + + // Remove own to Constraint hierarchy for coverage + LOG_removeHierarchy(); +} +#endif + +} diff --git a/src/core/expression/RBALambdaContext.hpp b/src/core/expression/RBALambdaContext.hpp new file mode 100644 index 0000000..219be71 --- /dev/null +++ b/src/core/expression/RBALambdaContext.hpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * LambdaContext class header file + */ + +#ifndef RBALAMBDACONTEXT_HPP +#define RBALAMBDACONTEXT_HPP + +#include "RBASetOperator.hpp" + +namespace rba +{ + +class RBALambdaExpression; + +class DLL_EXPORT RBALambdaContext : public RBASetOperator +{ +protected: + RBALambdaContext()=default; + RBALambdaContext(const RBALambdaContext&)=delete; + RBALambdaContext(const RBALambdaContext&&)=delete; + RBALambdaContext& operator=(const RBALambdaContext&)=delete; + RBALambdaContext& operator=(const RBALambdaContext&&)=delete; +public: + virtual ~RBALambdaContext()=default; + +public: + RBALambdaExpression* const getLambda() const; + void setLambda(RBALambdaExpression* const newLambda); + +#ifdef RBA_USE_LOG + void createHierarchy() override; +#endif + +private: + RBALambdaExpression* lambda_ {nullptr}; + +}; + +} + +#endif diff --git a/src/core/expression/RBALambdaContextMaker.cpp b/src/core/expression/RBALambdaContextMaker.cpp new file mode 100644 index 0000000..f0e7e4d --- /dev/null +++ b/src/core/expression/RBALambdaContextMaker.cpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALambdaContextMaker.cpp +/// @brief LambdaContext object generation abstract class definition + +#include "RBALambdaContextMaker.hpp" +#include "RBALambdaContext.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBALambdaContextMaker::RBALambdaContextMaker(const std::string& label) + : RBAOperatorMaker{label} +{ +} + +RBAModelElement* +RBALambdaContextMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBALambdaContext* const lambdaContext + {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, lambdaContext, jsonElem)}; + // Set lambda + const RBAJsonElement* const lambdaElement {jsonElem->findChildren("lambda")}; + RBAModelElement* const lambdaExpr + {getFactory()->createElement(lambdaElement->getClassName(), lambdaElement)}; + lambdaContext->setLambda(dynamic_cast(lambdaExpr)); + // Set operand + const RBAJsonElement* const param {jsonElem->findChildren("operand")->getChild()}; + RBAModelElement* const expr + {getFactory()->createElement(param->getClassName(), param)}; + lambdaContext->addOperand(dynamic_cast(expr)); + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return lambdaContext; +} + +} diff --git a/src/core/expression/RBALambdaContextMaker.hpp b/src/core/expression/RBALambdaContextMaker.hpp new file mode 100644 index 0000000..6df7001 --- /dev/null +++ b/src/core/expression/RBALambdaContextMaker.hpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALambdaContextMaker.cpp +/// @brief LambdaContext object generation abstract class header file + +#ifndef RBASETOPERATORMAKER_HPP +#define RBASETOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +class RBALambdaContext; + +/// @brief LambdaContext object generation abstract class +class RBALambdaContextMaker : public RBAOperatorMaker +{ +public: + explicit RBALambdaContextMaker(const std::string& label=""); + RBALambdaContextMaker(const RBALambdaContextMaker&)=delete; + RBALambdaContextMaker(const RBALambdaContextMaker&&)=delete; + RBALambdaContextMaker& operator=(const RBALambdaContextMaker&)=delete; + RBALambdaContextMaker& operator=(const RBALambdaContextMaker&&)=delete; + virtual ~RBALambdaContextMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + + /// @brief generate an empty object of LambdaContext + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for LambdaContext object + virtual std::unique_ptr createLambdaContext()=0; + +}; + +} + +#endif diff --git a/src/core/expression/RBALambdaExpression.cpp b/src/core/expression/RBALambdaExpression.cpp new file mode 100644 index 0000000..7638faa --- /dev/null +++ b/src/core/expression/RBALambdaExpression.cpp @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBALambdaExpression class defnition + */ + +#include "RBALambdaExpression.hpp" +#include "RBAVariable.hpp" +#include "RBAArbitrator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void +RBALambdaExpression::setX(RBAVariable* const x) +{ + variable_ = x; +} + +void +RBALambdaExpression::setBodyText(RBAExpression* const expr) +{ + bodyText_ = expr; +} + +RBAVariable* const +RBALambdaExpression::getX() const +{ + return variable_; +} + +RBAExpression* const +RBALambdaExpression::getBodyText() const +{ + return bodyText_; +} + +RBAModelElementType +RBALambdaExpression::getModelElementType() const +{ + return RBAModelElementType::LambdaExpression; +} + +bool +RBALambdaExpression::executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const +{ + getX()->setRuleObj(ruleObj_); + + RBAConstraintInfo* const childInfo {info->getChild(0U)}; + bool res {getBodyText()->execute(childInfo,arb)}; + if(childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + res = false; + } + + return res; +} + +const RBARuleObject* +RBALambdaExpression::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + getX()->setRuleObj(ruleObj_); + + RBAConstraintInfo* const childInfo {info->getChild(0U)}; + const RBARuleObject* const res {getBodyText()->getReferenceObject(childInfo, arb)}; + if (childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } + + return res; +} +std::int32_t +RBALambdaExpression::getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + getX()->setRuleObj(ruleObj_); + + RBAConstraintInfo* const childInfo {info->getChild(0U)}; + const std::int32_t res {getBodyText()->getValue(childInfo, arb)}; + if (childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } + + return res; +} +#ifdef RBA_USE_LOG +void +RBALambdaExpression::createHierarchy() +{ + bodyText_->createHierarchy(); +} + +const std::string +RBALambdaExpression::getExpressionText() const +{ + return "{ " + getX()->getElementName() + " |" + + bodyText_->getExpressionText() + "}"; +} + +const std::string +RBALambdaExpression::getCoverageExpressionText() const +{ + return "{ " + getX()->getElementName() + " |" + + bodyText_->getCoverageExpressionText() + "}"; +} +#endif + +void +RBALambdaExpression::setRuleObj(const RBARuleObject* const ruleObj) +{ + ruleObj_ = ruleObj; + getX()->setRuleObj(ruleObj); +} + +void +RBALambdaExpression::clearRuleObj() +{ + ruleObj_ = nullptr; + getX()->clearRuleObj(); +} + +} diff --git a/src/core/expression/RBALambdaExpression.hpp b/src/core/expression/RBALambdaExpression.hpp new file mode 100644 index 0000000..76958e7 --- /dev/null +++ b/src/core/expression/RBALambdaExpression.hpp @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBALambdaExpression class header + */ + +#ifndef RBALAMBDAEXPRESSION_HPP +#define RBALAMBDAEXPRESSION_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class RBAArbitrator; +class RBAConstraintInfo; +class RBAVariable; +class RBARuleObject; + +class DLL_EXPORT RBALambdaExpression : public RBAExpression +{ +public: + RBALambdaExpression()=default; + RBALambdaExpression(const RBALambdaExpression&)=delete; + RBALambdaExpression(const RBALambdaExpression&&)=delete; + RBALambdaExpression& operator=(const RBALambdaExpression&)=delete; + RBALambdaExpression& operator=(const RBALambdaExpression&&)=delete; + virtual ~RBALambdaExpression()=default; + +public: + void setX(RBAVariable* const x); + void setBodyText(RBAExpression* const expr); + RBAVariable* const getX() const; + RBAExpression* const getBodyText() const; + + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + void setRuleObj(const RBARuleObject* const ruleObj); + void clearRuleObj(); + + // Log +#ifdef RBA_USE_LOG + void createHierarchy(); + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif + +private: + // "variable" is not const because it calls setExpression() + // in the arbitration process. + RBAVariable* variable_; + RBAExpression* bodyText_ {nullptr}; + const RBARuleObject* ruleObj_ {nullptr}; +}; + +} + +#endif diff --git a/src/core/expression/RBALambdaExpressionMaker.cpp b/src/core/expression/RBALambdaExpressionMaker.cpp new file mode 100644 index 0000000..674067f --- /dev/null +++ b/src/core/expression/RBALambdaExpressionMaker.cpp @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALambdaExpressionMaker.cpp +/// @brief LambdaExpression object generation class definition + +#include "RBALambdaExpressionMaker.hpp" +#include "RBALambdaExpression.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBALambdaExpressionMaker::RBALambdaExpressionMaker() + : RBAExpressionMaker{"LambdaExpression"} +{ +} + +std::unique_ptr +RBALambdaExpressionMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBALambdaExpressionMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBALambdaExpression* const lambdaExpr + {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, lambdaExpr, jsonElem)}; + + // Set variable + const RBAJsonElement* const varElement {jsonElem->findChildren("x")}; + RBAVariable* const var + {dynamic_cast(getFactory()->createElement("Variable", + varElement))}; + lambdaExpr->setX(var); + // Set bodyText + getFactory()->pushVariable(var); + const RBAJsonElement* const body {jsonElem->findChildren("bodyText")}; + RBAExpression* const expr + {dynamic_cast(getFactory()->createElement(body->getClassName(), + body))}; + lambdaExpr->setBodyText(expr); + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return lambdaExpr; +} + +} diff --git a/src/core/expression/RBALambdaExpressionMaker.hpp b/src/core/expression/RBALambdaExpressionMaker.hpp new file mode 100644 index 0000000..04e5f05 --- /dev/null +++ b/src/core/expression/RBALambdaExpressionMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALambdaExpressionMaker.hpp +/// @brief LambdaExpression object generation class header + +#ifndef RBALAMBDAEXPRESSIONMAKER_HPP +#define RBALAMBDAEXPRESSIONMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief LambdaExpression object generation class +class RBALambdaExpressionMaker : public RBAExpressionMaker +{ +public: + RBALambdaExpressionMaker(); + RBALambdaExpressionMaker(const RBALambdaExpressionMaker&)=delete; + RBALambdaExpressionMaker(const RBALambdaExpressionMaker&&)=delete; + RBALambdaExpressionMaker& operator=(const RBALambdaExpressionMaker&)=delete; + RBALambdaExpressionMaker& operator=(const RBALambdaExpressionMaker&&)=delete; + virtual ~RBALambdaExpressionMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBALetStatement.cpp b/src/core/expression/RBALetStatement.cpp new file mode 100644 index 0000000..f64cc18 --- /dev/null +++ b/src/core/expression/RBALetStatement.cpp @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * LetStatement class definition + */ + +#include "RBALetStatement.hpp" +#include "RBALogManager.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAModelElementType.hpp" +#include "RBAVariable.hpp" +#include "RBAExpressionVisitor.hpp" + +namespace rba +{ + +RBAModelElementType RBALetStatement::getModelElementType() const +{ + return RBAModelElementType::LetStatement; +} + +void RBALetStatement::setVariable(RBAVariable* const var) +{ + variable_ = var; +} + +void +RBALetStatement::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +void RBALetStatement::setVariable(RBAArbitrator* const arb) +{ + RBAConstraintInfo* const info {variable_->createConstraintInfo()}; + variable_->setRuleObj(getLhsOperand()->getReferenceObject(info, arb)); +#ifdef RBA_USE_LOG + std::string valueName; + if (info->isExceptionBeforeArbitrate() == true) { + valueName = "before arbitrate skip"; + } else if (variable_->getRuleObj() == nullptr) { + valueName = "NULL"; + } else { + valueName = variable_->getRuleObj()->getElementName(); + if (valueName == "") { + valueName = variable_->getRuleObj()->getDynamicName(); + } + } + LOG_arbitrateConstraintLogicLogLine( + " let " + variable_->getElementName() + " = " + + getLhsOperand()->getExpressionText() + " = " + valueName); +#endif +} +} /* namespace rba */ diff --git a/src/core/expression/RBALetStatement.hpp b/src/core/expression/RBALetStatement.hpp new file mode 100644 index 0000000..636b07d --- /dev/null +++ b/src/core/expression/RBALetStatement.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * LetStatement class header file + */ + +#ifndef RBALETOPERATOR_HPP_ +#define RBALETOPERATOR_HPP_ + +#include "RBAOperator.hpp" + +namespace rba { + +class RBAVariable; + +class DLL_EXPORT RBALetStatement : public RBAOperator +{ +public: + RBALetStatement()=default; + RBALetStatement(const RBALetStatement&)=delete; + RBALetStatement(const RBALetStatement&&)=delete; + RBALetStatement& operator=(const RBALetStatement&)=delete; + RBALetStatement& operator=(const RBALetStatement&&)=delete; + virtual ~RBALetStatement()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + void setVariable(RBAVariable* const var); + void setVariable(RBAArbitrator* const arb); + +private: + RBAVariable* variable_; + +}; + +} + +#endif diff --git a/src/core/expression/RBALetStatementMaker.cpp b/src/core/expression/RBALetStatementMaker.cpp new file mode 100644 index 0000000..93fcdee --- /dev/null +++ b/src/core/expression/RBALetStatementMaker.cpp @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALetStatementMaker.cpp +/// @brief LetStatement object generation class defintino. + +#include "RBALetStatementMaker.hpp" +#include "RBALetStatement.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBALetStatementMaker::RBALetStatementMaker() + : RBAExpressionMaker{"LetStatement"} +{ +} + +std::unique_ptr +RBALetStatementMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBALetStatementMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBALetStatement* const letStmt {dynamic_cast(element)}; + + // Set variable + const RBAJsonElement* const varElement {jsonElem->findChildren("variable")}; + RBAVariable* const var + {dynamic_cast(getFactory()->createElement("Variable", + varElement))}; + letStmt->setVariable(var); // Set Body + + // popVariable() is executed by the caller of this function + getFactory()->pushVariable(var); + const RBAJsonElement* const body {jsonElem->findChildren("body")}; + RBAExpression* const expr + {dynamic_cast(getFactory()->createElement(body->getClassName(), + body))}; + letStmt->addOperand(expr); + + return letStmt; +} + +} diff --git a/src/core/expression/RBALetStatementMaker.hpp b/src/core/expression/RBALetStatementMaker.hpp new file mode 100644 index 0000000..348ca71 --- /dev/null +++ b/src/core/expression/RBALetStatementMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBALetStatementMaker.hpp +/// @brief LetStatement object generation class header + +#ifndef RBAISACTIVEMAKER_HPP +#define RBAISACTIVEMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief LetStatement object generation class +class RBALetStatementMaker : public RBAExpressionMaker +{ +public: + RBALetStatementMaker(); + RBALetStatementMaker(const RBALetStatementMaker&)=delete; + RBALetStatementMaker(const RBALetStatementMaker&&)=delete; + RBALetStatementMaker& operator=(const RBALetStatementMaker&)=delete; + RBALetStatementMaker& operator=(const RBALetStatementMaker&&)=delete; + virtual ~RBALetStatementMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBALogicalOperator.cpp b/src/core/expression/RBALogicalOperator.cpp new file mode 100644 index 0000000..e931b7a --- /dev/null +++ b/src/core/expression/RBALogicalOperator.cpp @@ -0,0 +1,73 @@ + +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 論理オペレータクラス定義ファイル + */ + +#include +#include "RBALogicalOperator.hpp" +#include "RBAExpressionType.hpp" + +namespace rba +{ + +#ifdef RBA_USE_LOG +const std::string +RBALogicalOperator::getExpressionText() const +{ + std::ostringstream oss; + oss << "("; + const auto& exprList = getOperand(); + const auto& lastExpr = exprList.back(); + for (const auto& expr : exprList) { + oss << expr->getExpressionText(); + if (expr != lastExpr) { + oss << " " << getSymbol() << " "; + } + } + oss << ")"; + + return oss.str(); +} + +const std::string +RBALogicalOperator::getCoverageExpressionText() const +{ + std::ostringstream oss; + oss << "("; + auto exprList = getOperand(); + auto lastExpr = exprList.back(); + for (const auto& expr : exprList) { + oss << expr->getCoverageExpressionText(); + if (expr != lastExpr) { + oss << " " << getSymbol() << " "; + } + } + oss << ")"; + + return oss.str(); +} + +RBAExpressionType +RBALogicalOperator::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBALogicalOperator.hpp b/src/core/expression/RBALogicalOperator.hpp new file mode 100644 index 0000000..b713f5a --- /dev/null +++ b/src/core/expression/RBALogicalOperator.hpp @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * LogicalOperator class header + */ + +#ifndef RBALOGICOPERATOR_HPP +#define RBALOGICOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBALogicalOperator : public RBAOperator +{ + protected: + RBALogicalOperator()=default; + RBALogicalOperator(const RBALogicalOperator&)=delete; + RBALogicalOperator(const RBALogicalOperator&&)=delete; + RBALogicalOperator& operator=(const RBALogicalOperator&)=delete; + RBALogicalOperator& operator=(const RBALogicalOperator&&)=delete; + + public: + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAMaxOperator.cpp b/src/core/expression/RBAMaxOperator.cpp new file mode 100644 index 0000000..46d5ed1 --- /dev/null +++ b/src/core/expression/RBAMaxOperator.cpp @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * MaxOperator class definition + */ + +#include "RBAMaxOperator.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContent.hpp" +#include "RBAArbitrator.hpp" +#include "RBALogManager.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALambdaExpression.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void +RBAMaxOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAMaxOperator::getModelElementType() const +{ + return RBAModelElementType::MaxOperator; +} + +const RBARuleObject* RBAMaxOperator::getReferenceObjectCore( + RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + const RBARuleObject* returnObj {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const lhsObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsObj != nullptr) { + const RBAAllocatableSet* alloSet = dynamic_cast(lhsObj); + if (alloSet != nullptr) { + std::uint32_t i { 0U }; + std::int32_t maxVal { -99 }; + RBALambdaExpression* const lambda { getLambda() }; + for (auto& obj : alloSet->getLeafAllocatable()) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo { info->getChild(i) }; + lambda->setRuleObj(obj); + const std::int32_t val { lambda->getValue(childInfo, arb) }; + LOG_removeHierarchy(); + if ((maxVal < val) && (!childInfo->isExceptionBeforeArbitrate())) { + maxVal = val; + returnObj = obj; + } + } + } else { + const RBAContentSet* contentSet = dynamic_cast(lhsObj); + if (contentSet != nullptr) { + std::uint32_t i { 0U }; + std::int32_t maxVal { -99 }; + RBALambdaExpression* const lambda { getLambda() }; + for (auto& obj : contentSet->getLeafContent()) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo { info->getChild(i) }; + lambda->setRuleObj(obj); + const std::int32_t val { lambda->getValue(childInfo, arb) }; + LOG_removeHierarchy(); + if ((maxVal < val) && (!childInfo->isExceptionBeforeArbitrate())) { + maxVal = val; + returnObj = obj; + } + } + } + } + } + } +#ifdef RBA_USE_LOG + std::string objName = "NULL"; + if (info->isExceptionBeforeArbitrate()) { + objName = "before arbitrate skip"; + } else { + if (returnObj != nullptr){ + objName = returnObj->getElementName(); + if (objName == "") { + objName = returnObj->getDynamicName(); + } + } + } + LOG_arbitrateConstraintLogicLogLine( + " " + LOG_getExpressionText() + " is " + objName); +#endif + LOG_removeHierarchy(); + return returnObj; +} +#ifdef RBA_USE_LOG +const std::string RBAMaxOperator::getSymbol() const +{ + return ".max"; +} + +const std::string RBAMaxOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol() + + getLambda()->getExpressionText(); +} + +const std::string RBAMaxOperator::getCoverageExpressionText() const +{ + getLambda()->clearRuleObj(); + return getLhsOperand()->getCoverageExpressionText() + getSymbol() + + getLambda()->getCoverageExpressionText(); +} +#endif + +} // namespace rba diff --git a/src/core/expression/RBAMaxOperator.hpp b/src/core/expression/RBAMaxOperator.hpp new file mode 100644 index 0000000..046cec9 --- /dev/null +++ b/src/core/expression/RBAMaxOperator.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * MaxOperator class header + */ + +#ifndef RBAMAXOPERATOR_HPP +#define RBAMAXOPERATOR_HPP + +#include "RBALambdaContext.hpp" + +namespace rba +{ + +class RBAMaxOperator : public RBALambdaContext +{ + public: + RBAMaxOperator()=default; + RBAMaxOperator(const RBAMaxOperator&)=delete; + RBAMaxOperator(const RBAMaxOperator&&)=delete; + RBAMaxOperator& operator=(const RBAMaxOperator&)=delete; + RBAMaxOperator& operator=(const RBAMaxOperator&&)=delete; + virtual ~RBAMaxOperator()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif +}; + +} /* namespace rba */ + +#endif /* RBAMAXOPERATOR_HPP */ diff --git a/src/core/expression/RBAMaxOperatorMaker.cpp b/src/core/expression/RBAMaxOperatorMaker.cpp new file mode 100644 index 0000000..298bbbf --- /dev/null +++ b/src/core/expression/RBAMaxOperatorMaker.cpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMaxOperatorMaker.cpp +/// @brief MaxOperator object generation class definition + +#include "RBAMaxOperatorMaker.hpp" +#include "RBAMaxOperator.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBAMaxOperatorMaker::RBAMaxOperatorMaker() + : RBALambdaContextMaker{"MaxOperator"} +{ +} + +std::unique_ptr +RBAMaxOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAMaxOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast( + RBALambdaContextMaker::setProperty(element, jsonElem, model, owner)); + + return element; +} + +std::unique_ptr +RBAMaxOperatorMaker::createLambdaContext() +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAMaxOperatorMaker.hpp b/src/core/expression/RBAMaxOperatorMaker.hpp new file mode 100644 index 0000000..1216674 --- /dev/null +++ b/src/core/expression/RBAMaxOperatorMaker.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMaxOperatorMaker.hpp +/// @brief MaxOperator object generation class header + +#ifndef RBAMAXOPERATORMAKER_HPP +#define RBAMAXOPERATORMAKER_HPP + +#include "RBALambdaContextMaker.hpp" + +namespace rba +{ + +/// @brief MaxOperator object generation class +class RBAMaxOperatorMaker : public RBALambdaContextMaker +{ +public: + RBAMaxOperatorMaker(); + RBAMaxOperatorMaker(const RBAMaxOperatorMaker&)=delete; + RBAMaxOperatorMaker(const RBAMaxOperatorMaker&&)=delete; + RBAMaxOperatorMaker& operator=(const RBAMaxOperatorMaker&)=delete; + RBAMaxOperatorMaker& operator=(const RBAMaxOperatorMaker&&)=delete; + virtual ~RBAMaxOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + + /// @brief generate an empty object of LambdaContext + /// @details generate an empty object of unique_ptr + /// @return unique_ptr for object of LambdaContext + std::unique_ptr createLambdaContext() override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAMemberFeatureReferenceMaker.cpp b/src/core/expression/RBAMemberFeatureReferenceMaker.cpp new file mode 100644 index 0000000..699bca0 --- /dev/null +++ b/src/core/expression/RBAMemberFeatureReferenceMaker.cpp @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMemberFeatureReferenceMaker.cpp +/// @brief ObjectReference of property object generator class definition + +#include "RBAMemberFeatureReferenceMaker.hpp" +#include "RBAObjectReference.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBAAbstractProperty.hpp" + +namespace rba +{ + +RBAMemberFeatureReferenceMaker::RBAMemberFeatureReferenceMaker() + : RBAObjectReferenceMaker{"MemberFeatureReference"} +{ +} + +std::unique_ptr +RBAMemberFeatureReferenceMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAMemberFeatureReferenceMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAObjectReference* const objRef {dynamic_cast(element)}; + + // Set reference object + objRef->setRefObject(getRuleObject(jsonElem,model)); + + return objRef; +} + +const RBARuleObject* +RBAMemberFeatureReferenceMaker::getRuleObject(const RBAJsonElement* + const jsonElem, + RBAModelImpl* const model) +{ + const RBARuleObject* refObj {nullptr}; + const auto typeStr = jsonElem->findChildren("type")->getString(); + const auto refObjStr = jsonElem->findChildren("refObject")->getString(); + + if (jsonElem->findChildren("class")->getString() == "ObjectReference") { + refObj = dynamic_cast(getMaker(typeStr)->getInstance(model, + refObjStr)); + } else { // jsonElem->findChildren("class")->getString() == "MemberFeatureReference" + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // calling getRuleObject() recursively + // [Explain that it is okay to deviate from the rules] + // When "Content name.State machine name.State name" is used + // in the constraint expression, it becomes the STATEMACHINE_STATE of + // Member of "STATEMACHINE" of "CONTENT", so recursive call is used. + // Since the number of elements in the rule model is finite and + // there is no cyclic relationship, stack overflow does not occur and + // there is no problem. + const auto owner = const_cast(getRuleObject(jsonElem->findChildren("operand")->getChild(), model)); + refObj = owner->getMember(refObjStr); + if (refObj == nullptr) { + if (getMaker(typeStr) != nullptr) { + refObj = dynamic_cast(getMaker(typeStr)->getInstance(model, + refObjStr, owner)); + } + if ((refObj == nullptr) + && (jsonElem->findChildren("type")->getString() == "PROPERTY")) { + refObj = dynamic_cast(owner)->addProperty(refObjStr, -99); + } + } + } + return refObj; +} +} diff --git a/src/core/expression/RBAMemberFeatureReferenceMaker.hpp b/src/core/expression/RBAMemberFeatureReferenceMaker.hpp new file mode 100644 index 0000000..61880a7 --- /dev/null +++ b/src/core/expression/RBAMemberFeatureReferenceMaker.hpp @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMemberFeatureReferenceMaker.cpp +/// @brief ObjectReference of property object generator class header + +#ifndef RBAMEMBERFEATUREREFERENCEMAKER_HPP +#define RBAMEMBERFEATUREREFERENCEMAKER_HPP + +#include "RBAObjectReferenceMaker.hpp" + +namespace rba +{ + +class RBARuleObject; + +/// @brief ObjectReference of property object generator class +class RBAMemberFeatureReferenceMaker : public RBAObjectReferenceMaker +{ +public: + RBAMemberFeatureReferenceMaker(); + RBAMemberFeatureReferenceMaker(const RBAMemberFeatureReferenceMaker&)=delete; + RBAMemberFeatureReferenceMaker(const RBAMemberFeatureReferenceMaker&&)=delete; + RBAMemberFeatureReferenceMaker& operator=(const RBAMemberFeatureReferenceMaker&)=delete; + RBAMemberFeatureReferenceMaker& operator=(const RBAMemberFeatureReferenceMaker&&)=delete; + virtual ~RBAMemberFeatureReferenceMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; +private: + const RBARuleObject* getRuleObject(const RBAJsonElement* const jsonElem, + RBAModelImpl* const model); +}; + +} + +#endif diff --git a/src/core/expression/RBAMinOperator.cpp b/src/core/expression/RBAMinOperator.cpp new file mode 100644 index 0000000..923088b --- /dev/null +++ b/src/core/expression/RBAMinOperator.cpp @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// MinOperator class definition + +#include "RBAMinOperator.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContent.hpp" +#include "RBAArbitrator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALambdaExpression.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void +RBAMinOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAMinOperator::getModelElementType() const +{ + return RBAModelElementType::MinOperator; +} + +const RBARuleObject* RBAMinOperator::getReferenceObjectCore( + RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + const RBARuleObject* returnObj {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const lhsObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + if (lhsObj != nullptr) { + const RBAAllocatableSet* alloSet = dynamic_cast(lhsObj); + if (alloSet != nullptr) { + std::uint32_t i { 0U }; + std::int32_t minVal { INT32_MAX }; + RBALambdaExpression* const lambda { getLambda() }; + for (auto& obj : alloSet->getLeafAllocatable()) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo { info->getChild(i) }; + lambda->setRuleObj(obj); + const std::int32_t val { lambda->getValue(childInfo, arb) }; + LOG_removeHierarchy(); + if ((val != -99) && (minVal > val) + && (!childInfo->isExceptionBeforeArbitrate())) { + minVal = val; + returnObj = obj; + } + } + } else { + const RBAContentSet* contentSet = dynamic_cast(lhsObj); + if (contentSet != nullptr) { + std::uint32_t i { 0U }; + std::int32_t minVal { INT32_MAX }; + RBALambdaExpression* const lambda { getLambda() }; + for (auto& obj : contentSet->getLeafContent()) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo { info->getChild(i) }; + lambda->setRuleObj(obj); + const std::int32_t val { lambda->getValue(childInfo, arb) }; + LOG_removeHierarchy(); + if ((val != -99) && (minVal > val) + && (!childInfo->isExceptionBeforeArbitrate())) { + minVal = val; + returnObj = obj; + } + } + } + } + } + } +#ifdef RBA_USE_LOG + std::string objName = "NULL"; + if (info->isExceptionBeforeArbitrate()) { + objName = "before arbitrate skip"; + } else { + if (returnObj != nullptr){ + objName = returnObj->getElementName(); + if (objName == "") { + objName = returnObj->getDynamicName(); + } + } + } + LOG_arbitrateConstraintLogicLogLine( + " " + LOG_getExpressionText() + " is " + objName); +#endif + LOG_removeHierarchy(); + return returnObj; +} +#ifdef RBA_USE_LOG +const std::string RBAMinOperator::getSymbol() const +{ + return ".mix"; +} + +const std::string RBAMinOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol() + + getLambda()->getExpressionText(); +} + +const std::string RBAMinOperator::getCoverageExpressionText() const +{ + getLambda()->clearRuleObj(); + return getLhsOperand()->getCoverageExpressionText() + getSymbol() + + getLambda()->getCoverageExpressionText(); +} +#endif + +} // namespace rba diff --git a/src/core/expression/RBAMinOperator.hpp b/src/core/expression/RBAMinOperator.hpp new file mode 100644 index 0000000..b128877 --- /dev/null +++ b/src/core/expression/RBAMinOperator.hpp @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// MinOperator class header + +#ifndef RBAMINOPERATOR_HPP +#define RBAMINOPERATOR_HPP + +#include "RBALambdaContext.hpp" + +namespace rba +{ + +class RBAMinOperator : public RBALambdaContext +{ + public: + RBAMinOperator()=default; + RBAMinOperator(const RBAMinOperator&)=delete; + RBAMinOperator(RBAMinOperator&&)=delete; + RBAMinOperator& operator=(const RBAMinOperator&)=delete; + RBAMinOperator& operator=(RBAMinOperator&&)=delete; + virtual ~RBAMinOperator()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif +}; + +} // namespace rba + +#endif // RBAMINOPERATOR_HPP diff --git a/src/core/expression/RBAMinOperatorMaker.cpp b/src/core/expression/RBAMinOperatorMaker.cpp new file mode 100644 index 0000000..060e552 --- /dev/null +++ b/src/core/expression/RBAMinOperatorMaker.cpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMinOperatorMaker.cpp +/// @brief MinOperator object generator class definition + +#include "RBAMinOperatorMaker.hpp" +#include "RBAMinOperator.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBAMinOperatorMaker::RBAMinOperatorMaker() + : RBALambdaContextMaker{"MinOperator"} +{ +} + +std::unique_ptr +RBAMinOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAMinOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast( + RBALambdaContextMaker::setProperty(element, jsonElem, model, owner)); + + return element; +} + +std::unique_ptr +RBAMinOperatorMaker::createLambdaContext() +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAMinOperatorMaker.hpp b/src/core/expression/RBAMinOperatorMaker.hpp new file mode 100644 index 0000000..6eb90e1 --- /dev/null +++ b/src/core/expression/RBAMinOperatorMaker.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAMinOperatorMaker.hpp +/// @brief MinOperator object generator class header + +#ifndef RBAMINOPERATORMAKER_HPP +#define RBAMINOPERATORMAKER_HPP + +#include "RBALambdaContextMaker.hpp" + +namespace rba +{ + +/// @brief MinOperator object generator class +class RBAMinOperatorMaker : public RBALambdaContextMaker +{ +public: + RBAMinOperatorMaker(); + RBAMinOperatorMaker(const RBAMinOperatorMaker&)=delete; + RBAMinOperatorMaker(const RBAMinOperatorMaker&&)=delete; + RBAMinOperatorMaker& operator=(const RBAMinOperatorMaker&)=delete; + RBAMinOperatorMaker& operator=(const RBAMinOperatorMaker&&)=delete; + virtual ~RBAMinOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + + /// @brief generate an empty object of LambdaContext + /// @details generate an empty object of unique_ptr + /// @return unique_ptr for object of LambdaContext + std::unique_ptr createLambdaContext() override; + +}; + +} + +#endif diff --git a/src/core/expression/RBANotOperator.cpp b/src/core/expression/RBANotOperator.cpp new file mode 100644 index 0000000..afcf3c8 --- /dev/null +++ b/src/core/expression/RBANotOperator.cpp @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBANotOperator class definition + */ + +#include "RBANotOperator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBANotOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBANotOperator::getModelElementType() const +{ + return RBAModelElementType::NotOperator; +} + +bool +RBANotOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const childInfo {info->getChild(0U)}; + const bool isChildPassed {getLhsOperand()->execute(childInfo, arb)}; + if (childInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else { + isPassed = !isChildPassed; + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBANotOperator::getSymbol() const +{ + return "!"; +} + +const std::string +RBANotOperator::getExpressionText() const +{ + return getSymbol() + getLhsOperand()->getExpressionText(); +} + +const std::string +RBANotOperator::getCoverageExpressionText() const +{ + return getSymbol() + getLhsOperand()->getCoverageExpressionText(); +} +#endif + +} diff --git a/src/core/expression/RBANotOperator.hpp b/src/core/expression/RBANotOperator.hpp new file mode 100644 index 0000000..4af1461 --- /dev/null +++ b/src/core/expression/RBANotOperator.hpp @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBANotOperator class header + */ + +#ifndef RBANOTOPERATOR_HPP +#define RBANOTOPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBANotOperator : public RBALogicalOperator +{ +public: + RBANotOperator()=default; + RBANotOperator(const RBANotOperator&)=delete; + RBANotOperator(const RBANotOperator&&)=delete; + RBANotOperator& operator=(const RBANotOperator&)=delete; + RBANotOperator& operator=(const RBANotOperator&&)=delete; + virtual ~RBANotOperator()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBANotOperatorMaker.cpp b/src/core/expression/RBANotOperatorMaker.cpp new file mode 100644 index 0000000..e4e823c --- /dev/null +++ b/src/core/expression/RBANotOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBANotOperatorMaker.cpp +/// @brief NotOperator object generator class definition + +#include "RBANotOperatorMaker.hpp" +#include "RBANotOperator.hpp" + +namespace rba +{ + +RBANotOperatorMaker::RBANotOperatorMaker() + : RBAOperatorMaker{"NotOperator"} +{ +} + +std::unique_ptr +RBANotOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBANotOperatorMaker.hpp b/src/core/expression/RBANotOperatorMaker.hpp new file mode 100644 index 0000000..91f39b9 --- /dev/null +++ b/src/core/expression/RBANotOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBANotOperatorMaker.hpp +/// @brief NotOperator object generator class header + +#ifndef RBANOTOPERATORMAKER_HPP +#define RBANOTOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief NotOperator object generator class header +class RBANotOperatorMaker : public RBAOperatorMaker +{ +public: + RBANotOperatorMaker(); + RBANotOperatorMaker(const RBANotOperatorMaker&)=delete; + RBANotOperatorMaker(const RBANotOperatorMaker&&)=delete; + RBANotOperatorMaker& operator=(const RBANotOperatorMaker&)=delete; + RBANotOperatorMaker& operator=(const RBANotOperatorMaker&&)=delete; + virtual ~RBANotOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAObjectCompare.cpp b/src/core/expression/RBAObjectCompare.cpp new file mode 100644 index 0000000..65bee04 --- /dev/null +++ b/src/core/expression/RBAObjectCompare.cpp @@ -0,0 +1,165 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ObjectCompare calss defintion + */ + +#include "RBAObjectCompare.hpp" +#include "RBAAllocatable.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpressionType.hpp" +#include "RBAModelElementType.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +void +RBAObjectCompare::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAObjectCompare::getModelElementType() const +{ + return RBAModelElementType::ObjectCompare; +} + +bool +RBAObjectCompare::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBAExpression* const lhs {getLhsOperand()}; + // Add left hand side expression to Constraint hierarchy for coverage + LOG_addHierarchy("#left"); + const RBARuleObject* const lhobj {lhs->getReferenceObject(leftInfo, arb)}; + // Remove left hand side expression from Constraint hierarchy for coverage + LOG_removeHierarchy(); + // Throw if one of the pre-arbitration exceptions appears in the reference + if (leftInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else { + RBAConstraintInfo* const rightInfo {info->getChild(1U)}; + const RBAExpression* const rhs {getRhsOperand()}; + // Add right hand side expression to Constraint hierarchy for coverage + LOG_addHierarchy("#right"); + const RBARuleObject* const rhobj {rhs->getReferenceObject(rightInfo, arb)}; + // Remove right hand side expression to Constraint hierarchy for coverage + LOG_removeHierarchy(); + // Throw if one of the pre-arbitration exceptions appears in the reference + if (rightInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + // False if both objects cannot be got + if ((lhobj != nullptr) && (rhobj != nullptr)) { + if (lhobj->getRawObject() == rhobj->getRawObject()) { + isPassed = true; +          // Even if re-arbitration is performed for "ObjectCompare" that uses + // "ObjectRefrence" as an operand, the evaluation result does not + // change from false to True, so it is not necessary to add + // "FalseAllocatable" or "TrueAllocatabe" for re-arbitration. + // When "Expression" such as "AllocatedContent" is used as an operand, + // "FalseAllocatable" and "TrueAllocatabe" are added in the operand, + // so it is not necessary to add in ObjectCompare. + } + } + } + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAObjectCompare::getSymbol() const +{ + return "=="; +} + +const std::string +RBAObjectCompare::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + + " " + getSymbol() + " " + getRhsOperand()->getExpressionText(); +} + +const std::string +RBAObjectCompare::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + + " " + getSymbol() + " " + getRhsOperand()->getCoverageExpressionText(); +} + +void +RBAObjectCompare::createHierarchy() +{ + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(getSymbol()); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), this); + + RBAExpression* expr0 = getLhsOperand(); + RBAExpression* expr1 = getRhsOperand(); + + // Add left hand side expression to Constraint hierarchy for coverage + LOG_addHierarchy("#left"); + expr0->createHierarchy(); + // Remove left hand side expression from Constraint hierarchy for coverage + LOG_removeHierarchy(); + + // Add right hand side expression to Constraint hierarchy for coverage + LOG_addHierarchy("#right"); + expr1->createHierarchy(); + // Remove right hand side expression from Constraint hierarchy for coverage + LOG_removeHierarchy(); + + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); +} + +RBAExpressionType +RBAObjectCompare::getUnderlyingType() const +{ + return RBAExpressionType::BOOLEAN; +} +#endif + +} diff --git a/src/core/expression/RBAObjectCompare.hpp b/src/core/expression/RBAObjectCompare.hpp new file mode 100644 index 0000000..c7c345d --- /dev/null +++ b/src/core/expression/RBAObjectCompare.hpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ObjectCompare calss header + */ + +#ifndef RBAOBJECTCOMPARE_HPP +#define RBAOBJECTCOMPARE_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAObjectCompare : public RBAOperator +{ +public: + RBAObjectCompare()=default; + RBAObjectCompare(const RBAObjectCompare&)=delete; + RBAObjectCompare(const RBAObjectCompare&&)=delete; + RBAObjectCompare& operator=(const RBAObjectCompare&)=delete; + RBAObjectCompare& operator=(const RBAObjectCompare&&)=delete; + virtual ~RBAObjectCompare()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + void createHierarchy() override; + RBAExpressionType getUnderlyingType() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAObjectCompareMaker.cpp b/src/core/expression/RBAObjectCompareMaker.cpp new file mode 100644 index 0000000..ab696cf --- /dev/null +++ b/src/core/expression/RBAObjectCompareMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAObjectCompareMaker.cpp +/// @brief ObjectCompare object generator class + +#include "RBAObjectCompareMaker.hpp" +#include "RBAObjectCompare.hpp" + +namespace rba +{ + +RBAObjectCompareMaker::RBAObjectCompareMaker() + : RBAOperatorMaker{"ObjectCompare"} +{ +} + +std::unique_ptr +RBAObjectCompareMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAObjectCompareMaker.hpp b/src/core/expression/RBAObjectCompareMaker.hpp new file mode 100644 index 0000000..3d44a4e --- /dev/null +++ b/src/core/expression/RBAObjectCompareMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAObjectCompareMaker.hpp +/// @brief ObjectCompare object generator class header + +#ifndef RBAOBJECTCOMPAREMAKER_HPP +#define RBAOBJECTCOMPAREMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief ObjectCompare object generator class +class RBAObjectCompareMaker : public RBAOperatorMaker +{ +public: + RBAObjectCompareMaker(); + RBAObjectCompareMaker(const RBAObjectCompareMaker&)=delete; + RBAObjectCompareMaker(const RBAObjectCompareMaker&&)=delete; + RBAObjectCompareMaker& operator=(const RBAObjectCompareMaker&)=delete; + RBAObjectCompareMaker& operator=(const RBAObjectCompareMaker&&)=delete; + virtual ~RBAObjectCompareMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAObjectReference.cpp b/src/core/expression/RBAObjectReference.cpp new file mode 100644 index 0000000..aefe83c --- /dev/null +++ b/src/core/expression/RBAObjectReference.cpp @@ -0,0 +1,133 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// ObjectReference class definition + +#include "RBAObjectReference.hpp" + +#include "RBAExpressionVisitor.hpp" +#include "RBAVariable.hpp" +#include "RBAModelElementType.hpp" +#ifdef RBA_USE_LOG +#include "RBAAbstractProperty.hpp" +#include "RBASceneImpl.hpp" +#endif + +namespace rba +{ + +void +RBAObjectReference::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAObjectReference::getModelElementType() const +{ + return RBAModelElementType::ObjectReference; +} + +const RBARuleObject* +RBAObjectReference::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + const RBARuleObject* obj {refObject_}; + if (obj->isModelElementType(RBAModelElementType::Variable)) { + // in case of varible, its reference + const RBAVariable* const val {dynamic_cast(obj)}; + obj = val->getRuleObj(); + std::shared_ptr valInfo {val->getConstraintInfo()}; + if (valInfo != nullptr) { + info->setChild(valInfo); + if (valInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } + } + } + return obj; +} + +void +RBAObjectReference::setRefObject(const RBARuleObject* const newRefObject) +{ + refObject_ = newRefObject; +} + +#ifdef RBA_USE_LOG + +void +RBAObjectReference::setExpressionType(RBAExpressionType const newExprType) +{ + expressionType_ = newExprType; +} + +void +RBAObjectReference::createHierarchy() +{ + // No operation, because this does not affect the structure +} + +const std::string +RBAObjectReference::getExpressionText() const +{ + if (refObject_->isModelElementType(RBAModelElementType::Property)) { + return dynamic_cast(refObject_)->getScene()->getElementName(); + } + else if ((refObject_->isModelElementType(RBAModelElementType::ViewContentState)) || + (refObject_->isModelElementType(RBAModelElementType::SoundContentState))) { + return (refObject_->getOwner()->getElementName() + "." + refObject_->getElementName()); + } + if(refObject_->getElementName() != ""){ + return refObject_->getElementName(); + } else { + return refObject_->getDynamicName(); + } +} + +const std::string +RBAObjectReference::getCoverageExpressionText() const +{ + if (refObject_->isModelElementType(RBAModelElementType::Variable)) { + const RBAVariable* var = + dynamic_cast(refObject_); + if (var->getRuleObj()) { + if (var->getRuleObj()->getElementName() != "") { + return var->getRuleObj()->getElementName(); + } else { + return var->getRuleObj()->getDynamicName(); + } + } + } + if ((refObject_->isModelElementType(RBAModelElementType::ViewContentState)) || + (refObject_->isModelElementType(RBAModelElementType::SoundContentState))) { + return (refObject_->getOwner()->getElementName() + "." + refObject_->getElementName()); + } + if(refObject_->getElementName() != ""){ + return refObject_->getElementName(); + } else { + return refObject_->getDynamicName(); + } +} + +RBAExpressionType +RBAObjectReference::getUnderlyingType() const +{ + return expressionType_; +} +#endif + +} diff --git a/src/core/expression/RBAObjectReference.hpp b/src/core/expression/RBAObjectReference.hpp new file mode 100644 index 0000000..2eb38df --- /dev/null +++ b/src/core/expression/RBAObjectReference.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// ObjectReference class header + +#ifndef RBAOBJECTREFERENCE_HPP +#define RBAOBJECTREFERENCE_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAObjectReference : public RBAExpression +{ +public: + RBAObjectReference()=default; + RBAObjectReference(const RBAObjectReference&)=delete; + RBAObjectReference(const RBAObjectReference&&)=delete; + RBAObjectReference& operator=(const RBAObjectReference&)=delete; + RBAObjectReference& operator=(const RBAObjectReference&&)=delete; + virtual ~RBAObjectReference()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + void setRefObject(const RBARuleObject* const newRefObject); + + // Log +#ifdef RBA_USE_LOG + void setExpressionType(RBAExpressionType const newExprType); + void createHierarchy() override; + const std::string getExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; + const std::string getCoverageExpressionText() const override; +#endif + +private: + const RBARuleObject* refObject_; +#ifdef RBA_USE_LOG + RBAExpressionType expressionType_; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAObjectReferenceMaker.cpp b/src/core/expression/RBAObjectReferenceMaker.cpp new file mode 100644 index 0000000..8c216ba --- /dev/null +++ b/src/core/expression/RBAObjectReferenceMaker.cpp @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAObjectReferenceMaker.cpp +/// @brief ObjectReference object generator class definition + +#include "RBAObjectReferenceMaker.hpp" +#include "RBAObjectReference.hpp" + +#include "RBAJsonElement.hpp" +#include "RBAModelFactory.hpp" +#include "RBAModelImpl.hpp" + +namespace rba +{ + +RBAObjectReferenceMaker::RBAObjectReferenceMaker(const std::string& label) + : RBAExpressionMaker{label} +{ +} + +std::unique_ptr +RBAObjectReferenceMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAObjectReferenceMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAObjectReference* const objRef {dynamic_cast(element)}; + + // Set reference object + //// Getting reference object string + const auto& refObjectStr = jsonElem->findChildren("refObject")->getString(); + + //// Find object + auto ruleObj = model->findModelElement(refObjectStr); + + if(ruleObj == nullptr) { + ruleObj = getFactory()->getVariable(refObjectStr); + if(ruleObj == nullptr) { + const auto& typeStr = jsonElem->findChildren("type")->getString(); + auto maker = getMaker(typeStr); + if (maker != nullptr) { + ruleObj = maker->getInstance(model, refObjectStr, owner); + } + } + } + objRef->setRefObject(dynamic_cast(ruleObj)); + +#ifdef RBA_USE_LOG + // Set expression type + const RBAExpressionType exprType {jsonElem->getExpressionType()}; + objRef->setExpressionType(exprType); +#endif + + return objRef; +} + +} diff --git a/src/core/expression/RBAObjectReferenceMaker.hpp b/src/core/expression/RBAObjectReferenceMaker.hpp new file mode 100644 index 0000000..ee58b92 --- /dev/null +++ b/src/core/expression/RBAObjectReferenceMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAObjectReferenceMaker.hpp +/// @brief ObjectReference object generator class header + +#ifndef RBAOBJECTREFERENCEMAKER_HPP +#define RBAOBJECTREFERENCEMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief ObjectReference object generator class header +class DLL_EXPORT RBAObjectReferenceMaker : public RBAExpressionMaker +{ +public: + explicit RBAObjectReferenceMaker(const std::string& label="ObjectReference"); + RBAObjectReferenceMaker(const RBAObjectReferenceMaker&)=delete; + RBAObjectReferenceMaker(const RBAObjectReferenceMaker&&)=delete; + RBAObjectReferenceMaker& operator=(const RBAObjectReferenceMaker&)=delete; + RBAObjectReferenceMaker& operator=(const RBAObjectReferenceMaker&&)=delete; + virtual ~RBAObjectReferenceMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAOperator.cpp b/src/core/expression/RBAOperator.cpp new file mode 100644 index 0000000..7d73f66 --- /dev/null +++ b/src/core/expression/RBAOperator.cpp @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Operator class definition + */ + +#include "RBAOperator.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +const std::vector& +RBAOperator::getOperand() const +{ + return operand_; +} + +void +RBAOperator::addOperand(RBAExpression* const newExpr) +{ + if(newExpr != nullptr) { + operand_.push_back(newExpr); + } +} + +RBAExpression* +RBAOperator::getLhsOperand() const +{ + return operand_.front(); +} + +RBAExpression* +RBAOperator::getRhsOperand() const +{ + return operand_.back(); +} + +const std::string +RBAOperator::getPreMsg(const bool isPrevious) const +{ + if(isPrevious) { + return "(pre)"; + } + else { + return ""; + } +} + +#ifdef RBA_USE_LOG +const std::string +RBAOperator::getSymbol() const +{ + return ""; +} + +void +RBAOperator::createHierarchy() +{ + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(getSymbol()); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), this); + + std::uint32_t oprSize{ static_cast(getOperand().size()) }; + if(oprSize == 1U) { + RBAExpression* expr = getLhsOperand(); + expr->createHierarchy(); + } + else { + std::uint32_t num{ 0U }; + for(RBAExpression* expr : getOperand()) { + // Add count to Constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(num++)); + expr->createHierarchy(); + // Remove count from Constraint hierarchy for coverage + LOG_removeHierarchy(); + } + } + + // Remove count from Constraint hierarchy for coverage + LOG_removeHierarchy(); +} +#endif + +} diff --git a/src/core/expression/RBAOperator.hpp b/src/core/expression/RBAOperator.hpp new file mode 100644 index 0000000..5d645f2 --- /dev/null +++ b/src/core/expression/RBAOperator.hpp @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Operator class header + */ + +#ifndef RBAOPERATOR_HPP +#define RBAOPERATOR_HPP + +#include +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAOperator : public RBAExpression +{ +protected: + RBAOperator()=default; + RBAOperator(const RBAOperator&)=delete; + RBAOperator(const RBAOperator&&)=delete; + RBAOperator& operator=(const RBAOperator&)=delete; + RBAOperator& operator=(const RBAOperator&&)=delete; + +public: + const std::vector& getOperand() const; + void addOperand(RBAExpression* const newExpr); + RBAExpression* getLhsOperand() const; + RBAExpression* getRhsOperand() const; + + // Log +#ifdef RBA_USE_LOG + virtual const std::string getSymbol() const; + void createHierarchy() override; +#endif + +protected: + std::string const getPreMsg(const bool isPrevious) const; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::vector operand_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif +}; + +} + +#endif diff --git a/src/core/expression/RBAOperatorMaker.cpp b/src/core/expression/RBAOperatorMaker.cpp new file mode 100644 index 0000000..7da2885 --- /dev/null +++ b/src/core/expression/RBAOperatorMaker.cpp @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAOperatorMaker.cpp +/// @brief Operator object generator abstract class + +#include "RBAOperatorMaker.hpp" +#include "RBAOperator.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAOperatorMaker::RBAOperatorMaker(const std::string& label) + : RBAExpressionMaker{label} +{ +} + +RBAModelElement* +RBAOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + // Create expression + RBAOperator* const exprOpr {dynamic_cast(element)}; + + // Set LetStatement + const auto pop_num = setLetStatement(model, exprOpr, jsonElem); + + // Set operand + for(auto& param : jsonElem->findChildren("operand")->getChildren()) { + const auto expr = getFactory()->createElement(param->getClassName(), param.get()); + exprOpr->addOperand(dynamic_cast(expr)); + } + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return exprOpr; +} + +} diff --git a/src/core/expression/RBAOperatorMaker.hpp b/src/core/expression/RBAOperatorMaker.hpp new file mode 100644 index 0000000..681ff65 --- /dev/null +++ b/src/core/expression/RBAOperatorMaker.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAOperatorMaker.hpp +/// @brief Operator object generator abstract class header + +#ifndef RBAOPERATORMAKER_HPP +#define RBAOPERATORMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief Operator object generator abstract class +class DLL_EXPORT RBAOperatorMaker : public RBAExpressionMaker +{ +public: + explicit RBAOperatorMaker(const std::string& label=""); + RBAOperatorMaker(const RBAOperatorMaker&)=delete; + RBAOperatorMaker(const RBAOperatorMaker&&)=delete; + RBAOperatorMaker& operator=(const RBAOperatorMaker&)=delete; + RBAOperatorMaker& operator=(const RBAOperatorMaker&&)=delete; + virtual ~RBAOperatorMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAOrOperator.cpp b/src/core/expression/RBAOrOperator.cpp new file mode 100644 index 0000000..d55e4a0 --- /dev/null +++ b/src/core/expression/RBAOrOperator.cpp @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * OrOperator class definition + */ + +#include "RBAOrOperator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void +RBAOrOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBAOrOperator::getModelElementType() const +{ + return RBAModelElementType::OrOperator; +} + +bool +RBAOrOperator::executeCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + bool isPassed {false}; + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy(LOG_getSymbol()); + std::uint32_t index {0U}; + for (const RBAExpression* const ope : getOperand()) { + RBAConstraintInfo* const childInfo {info->getChild(index)}; + // Add count to Constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(index)); + const bool res {ope->execute(childInfo, arb)}; + // Remove count from Constraint hierarchy for coverage + LOG_removeHierarchy(); + if (childInfo->isExceptionBeforeArbitrate() == true) { + info->setExceptionBeforeArbitrate(true); + } else if (res == true) { + isPassed = true; + } else { + ; + } + ++index; + } + if (isPassed == true) { + info->setExceptionBeforeArbitrate(false); + } +#ifdef RBA_USE_LOG + if (info->isExceptionBeforeArbitrate() == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] before arbitrate skip"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::SKIP); + } else if (isPassed == true) { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] true"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::TRUE); + } else { + LOG_arbitrateConstraintLogicLogLine( + " [" + LOG_getExpressionText() + "] false"); + LOG_coverageConstraintExpressionLog(LOG_getCoverageExpressionText(), + RBAExecuteResult::FALSE); + } +#endif + // Remove count from Constraint hierarchy for coverage + LOG_removeHierarchy(); + return isPassed; +} + +#ifdef RBA_USE_LOG +const std::string +RBAOrOperator::getSymbol() const +{ + return "OR"; +} +#endif + +} diff --git a/src/core/expression/RBAOrOperator.hpp b/src/core/expression/RBAOrOperator.hpp new file mode 100644 index 0000000..a52aca4 --- /dev/null +++ b/src/core/expression/RBAOrOperator.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * OrOperator class header + */ + +#ifndef RBAOROPERATOR_HPP +#define RBAOROPERATOR_HPP + +#include "RBALogicalOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAOrOperator : public RBALogicalOperator +{ + public: + RBAOrOperator()=default; + RBAOrOperator(const RBAOrOperator&)=delete; + RBAOrOperator(const RBAOrOperator&&)=delete; + RBAOrOperator& operator=(const RBAOrOperator&)=delete; + RBAOrOperator& operator=(const RBAOrOperator&&)=delete; + virtual ~RBAOrOperator()=default; + + public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + bool executeCore(RBAConstraintInfo* info, RBAArbitrator * arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAOrOperatorMaker.cpp b/src/core/expression/RBAOrOperatorMaker.cpp new file mode 100644 index 0000000..934c7e1 --- /dev/null +++ b/src/core/expression/RBAOrOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAOrOperatorMaker.cpp +/// @brief OrOperator object generator + +#include "RBAOrOperatorMaker.hpp" +#include "RBAOrOperator.hpp" + +namespace rba +{ + +RBAOrOperatorMaker::RBAOrOperatorMaker() + : RBAOperatorMaker{"OrOperator"} +{ +} + +std::unique_ptr +RBAOrOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAOrOperatorMaker.hpp b/src/core/expression/RBAOrOperatorMaker.hpp new file mode 100644 index 0000000..def4d8f --- /dev/null +++ b/src/core/expression/RBAOrOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAOrOperatorMaker.hpp +/// @brief OrOperator object generator class header + +#ifndef RBAOROPERATORMAKER_HPP +#define RBAOROPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief OrOperator object generator class +class RBAOrOperatorMaker : public RBAOperatorMaker +{ +public: + RBAOrOperatorMaker(); + RBAOrOperatorMaker(const RBAOrOperatorMaker&)=delete; + RBAOrOperatorMaker(const RBAOrOperatorMaker&&)=delete; + RBAOrOperatorMaker& operator=(const RBAOrOperatorMaker&)=delete; + RBAOrOperatorMaker& operator=(const RBAOrOperatorMaker&&)=delete; + virtual ~RBAOrOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAPlusOperator.cpp b/src/core/expression/RBAPlusOperator.cpp new file mode 100644 index 0000000..8a6dbbb --- /dev/null +++ b/src/core/expression/RBAPlusOperator.cpp @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PlusOperator class definition + */ + +#include "RBAPlusOperator.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +RBAModelElementType +RBAPlusOperator::getModelElementType() const +{ + return RBAModelElementType::PlusOperator; +} + +} diff --git a/src/core/expression/RBAPlusOperator.hpp b/src/core/expression/RBAPlusOperator.hpp new file mode 100644 index 0000000..ab04ebb --- /dev/null +++ b/src/core/expression/RBAPlusOperator.hpp @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PlusOperator class header + */ + +#ifndef RBAPLUSOPERATOR_HPP +#define RBAPLUSOPERATOR_HPP + +#include "RBAArithmeticOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAPlusOperator : public RBAArithmeticOperator +{ +public: + RBAPlusOperator()=default; + RBAPlusOperator(const RBAPlusOperator&)=delete; + RBAPlusOperator(const RBAPlusOperator&&)=delete; + RBAPlusOperator& operator=(const RBAPlusOperator&)=delete; + RBAPlusOperator& operator=(const RBAPlusOperator&&)=delete; + virtual ~RBAPlusOperator()=default; + +public: + RBAModelElementType getModelElementType() const override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAPlusOperatorMaker.cpp b/src/core/expression/RBAPlusOperatorMaker.cpp new file mode 100644 index 0000000..677d456 --- /dev/null +++ b/src/core/expression/RBAPlusOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAPlusOperatorsMaker.cpp +/// @brief PlusOperator object generator class definition + +#include "RBAPlusOperatorMaker.hpp" +#include "RBAPlusOperator.hpp" + +namespace rba +{ + +RBAPlusOperatorMaker::RBAPlusOperatorMaker() + : RBAOperatorMaker{"PlusOperator"} +{ +} + +std::unique_ptr +RBAPlusOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAPlusOperatorMaker.hpp b/src/core/expression/RBAPlusOperatorMaker.hpp new file mode 100644 index 0000000..aea1df7 --- /dev/null +++ b/src/core/expression/RBAPlusOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAPlusOperatorsMaker.hpp +/// @brief PlusOperator object generator class header + +#ifndef RBAPLUSOPERATORMAKER_HPP +#define RBAPLUSOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief PlusOperator object generator class +class RBAPlusOperatorMaker : public RBAOperatorMaker +{ +public: + RBAPlusOperatorMaker(); + RBAPlusOperatorMaker(const RBAPlusOperatorMaker&)=delete; + RBAPlusOperatorMaker(const RBAPlusOperatorMaker&&)=delete; + RBAPlusOperatorMaker& operator=(const RBAPlusOperatorMaker&)=delete; + RBAPlusOperatorMaker& operator=(const RBAPlusOperatorMaker&&)=delete; + virtual ~RBAPlusOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAPreviousModifier.cpp b/src/core/expression/RBAPreviousModifier.cpp new file mode 100644 index 0000000..53a7112 --- /dev/null +++ b/src/core/expression/RBAPreviousModifier.cpp @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PreviousModifier class definition + */ + +#include "RBAPreviousModifier.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAPreviousObjectWrapper.hpp" + +namespace rba +{ + +RBAPreviousModifier::RBAPreviousModifier() + : RBAExpression(), + previousObj_{std::make_unique()} +{ +} + +void +RBAPreviousModifier::accept(RBAExpressionVisitor& visitor) +{ + // RBASceneAllocatableCollector, + // which is the only vistor that exists at the moment, + // does not pass this path because it does not accept the rule object. + // In the future, another visitor may accept, so implement this. + visitor.visit(*this); +} + +void +RBAPreviousModifier::setObjReference(RBAExpression* const newObjRef) +{ + objReference_ = newObjRef; +} + +RBAExpression* const +RBAPreviousModifier::getObjReference() const +{ + return objReference_; +} + +const RBARuleObject* +RBAPreviousModifier::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + previousObj_->setRefObject(objReference_->getReferenceObject(info, arb)); + return previousObj_.get(); +} + +#ifdef RBA_USE_LOG +const std::string +RBAPreviousModifier::getSymbol() const +{ + return "(pre)"; +} + +void +RBAPreviousModifier::createHierarchy() +{ + objReference_->createHierarchy(); +} + +const std::string +RBAPreviousModifier::getExpressionText() const +{ + return getSymbol() + objReference_->getExpressionText(); +} + +const std::string +RBAPreviousModifier::getCoverageExpressionText() const +{ + return getSymbol() + objReference_->getCoverageExpressionText(); +} + +RBAExpressionType +RBAPreviousModifier::getUnderlyingType() const +{ + return objReference_->getUnderlyingType(); +} + +#endif + +} diff --git a/src/core/expression/RBAPreviousModifier.hpp b/src/core/expression/RBAPreviousModifier.hpp new file mode 100644 index 0000000..ff34deb --- /dev/null +++ b/src/core/expression/RBAPreviousModifier.hpp @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PreviousModifier class header + */ + + +#ifndef RBAPREVIOUSMODIFIER_HPP +#define RBAPREVIOUSMODIFIER_HPP + +#include +#include "RBAExpression.hpp" + +namespace rba +{ + +class RBAPreviousObjectWrapper; + +class DLL_EXPORT RBAPreviousModifier : public RBAExpression +{ +public: + RBAPreviousModifier(); + RBAPreviousModifier(const RBAPreviousModifier&)=delete; + RBAPreviousModifier(const RBAPreviousModifier&&)=delete; + RBAPreviousModifier& operator=(const RBAPreviousModifier&)=delete; + RBAPreviousModifier& operator=(const RBAPreviousModifier&&)=delete; + virtual ~RBAPreviousModifier()=default; + + void accept(RBAExpressionVisitor& visitor) override; + void setObjReference(RBAExpression* const newObjRef); + RBAExpression* const getObjReference() const; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + virtual const std::string getSymbol() const; + void createHierarchy() override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + RBAExpressionType getUnderlyingType() const override; +#endif + +private: + // This pointer is not "const" in order to call + // objReference_->getReferenceObject() + RBAExpression* objReference_; +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr previousObj_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAPreviousModifierMaker.cpp b/src/core/expression/RBAPreviousModifierMaker.cpp new file mode 100644 index 0000000..764ef34 --- /dev/null +++ b/src/core/expression/RBAPreviousModifierMaker.cpp @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAPreviousModifierMaker.cpp +/// @brief PreviousModifier object generator class definition + +#include "RBAPreviousModifierMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBAPreviousModifier.hpp" +#include "RBAPreviousObjectWrapper.hpp" + +namespace rba +{ + +RBAPreviousModifierMaker::RBAPreviousModifierMaker() + : RBAExpressionMaker{"PreviousModifier"} +{ +} + +std::unique_ptr +RBAPreviousModifierMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBAPreviousModifierMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + RBAPreviousModifier* const prevMod {dynamic_cast(element)}; + + // Set LetStatement + const std::int32_t pop_num {setLetStatement(model, prevMod, jsonElem)}; + + // Set object reference + const RBAJsonElement* const objRefElem {jsonElem->findChildren("objReference")}; + RBAModelElement* const expr {getFactory()->createElement(objRefElem->getClassName(), + objRefElem)}; + prevMod->setObjReference(dynamic_cast(expr)); + + // Pop variable + for(std::int32_t i{0}; ipopVariable(); + } + + return prevMod; +} + +} diff --git a/src/core/expression/RBAPreviousModifierMaker.hpp b/src/core/expression/RBAPreviousModifierMaker.hpp new file mode 100644 index 0000000..0f58892 --- /dev/null +++ b/src/core/expression/RBAPreviousModifierMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAPreviousModifierMaker.cpp +/// @brief PreviousModifier object generator class header + +#ifndef RBAPREVIOUSMODIFIERMAKER_HPP +#define RBAPREVIOUSMODIFIERMAKER_HPP + +#include "RBAExpressionMaker.hpp" + +namespace rba +{ + +/// @brief PreviousModifier object generator class +class RBAPreviousModifierMaker : public RBAExpressionMaker +{ +public: + RBAPreviousModifierMaker(); + RBAPreviousModifierMaker(const RBAPreviousModifierMaker&)=delete; + RBAPreviousModifierMaker(const RBAPreviousModifierMaker&&)=delete; + RBAPreviousModifierMaker& operator=(const RBAPreviousModifierMaker&)=delete; + RBAPreviousModifierMaker& operator=(const RBAPreviousModifierMaker&&)=delete; + virtual ~RBAPreviousModifierMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAPreviousObjectWrapper.cpp b/src/core/expression/RBAPreviousObjectWrapper.cpp new file mode 100644 index 0000000..348b05f --- /dev/null +++ b/src/core/expression/RBAPreviousObjectWrapper.cpp @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PreviousObjectWrapper (Previous Wrapper of RuleObject) + * generator class definition + */ + +#include "RBAPreviousObjectWrapper.hpp" + +namespace rba +{ + +bool +RBAPreviousObjectWrapper::isPrevious() const +{ + return true; +} + +const RBARuleObject* +RBAPreviousObjectWrapper::getRawObject() const +{ + return refObject_->getRawObject(); +} + +void +RBAPreviousObjectWrapper::setRefObject(const RBARuleObject* const obj) +{ + refObject_ = obj; +} + +} diff --git a/src/core/expression/RBAPreviousObjectWrapper.hpp b/src/core/expression/RBAPreviousObjectWrapper.hpp new file mode 100644 index 0000000..571c450 --- /dev/null +++ b/src/core/expression/RBAPreviousObjectWrapper.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PreviousObjectWrapper (Previous Wrapper of RuleObject) + * generator class header + */ + +#ifndef RBAPREVIOUSOBJECTWRAPPER_HPP +#define RBAPREVIOUSOBJECTWRAPPER_HPP + +#include "RBARuleObject.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAPreviousObjectWrapper : public RBARuleObject +{ +public: + RBAPreviousObjectWrapper()=default; + RBAPreviousObjectWrapper(const RBAPreviousObjectWrapper&)=delete; + RBAPreviousObjectWrapper(const RBAPreviousObjectWrapper&&)=delete; + RBAPreviousObjectWrapper& operator=(const RBAPreviousObjectWrapper&)=delete; + RBAPreviousObjectWrapper& operator=(const RBAPreviousObjectWrapper&&)=delete; + virtual ~RBAPreviousObjectWrapper()=default; + +public: + bool isPrevious() const override; + const RBARuleObject* getRawObject() const override; + void setRefObject(const RBARuleObject* const obj); + +private: + const RBARuleObject* refObject_ {nullptr}; + +}; + +} + +#endif diff --git a/src/core/expression/RBAPropertyOperator.hpp b/src/core/expression/RBAPropertyOperator.hpp new file mode 100644 index 0000000..250e6a2 --- /dev/null +++ b/src/core/expression/RBAPropertyOperator.hpp @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PropertyOperator class definition + */ + +#ifndef RBAPROPERTYOPERATOR_HPP +#define RBAPROPERTYOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAPropertyOperator : public RBAOperator +{ +protected: + RBAPropertyOperator()=default; + RBAPropertyOperator(const RBAPropertyOperator&)=delete; + RBAPropertyOperator(const RBAPropertyOperator&&)=delete; + RBAPropertyOperator& operator=(const RBAPropertyOperator&)=delete; + RBAPropertyOperator& operator=(const RBAPropertyOperator&&)=delete; + +public: + virtual ~RBAPropertyOperator()=default; + +}; + +} + +#endif + \ No newline at end of file diff --git a/src/core/expression/RBASceneCondition.hpp b/src/core/expression/RBASceneCondition.hpp new file mode 100644 index 0000000..44f543c --- /dev/null +++ b/src/core/expression/RBASceneCondition.hpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SceneCondition class header + */ + +#ifndef RBASCENECONDITION_HPP +#define RBASCENECONDITION_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBASceneCondition : public RBAExpression +{ +protected: + RBASceneCondition()=default; + RBASceneCondition(const RBASceneCondition&)=delete; + RBASceneCondition(const RBASceneCondition&&)=delete; + RBASceneCondition& operator=(const RBASceneCondition&)=delete; + RBASceneCondition& operator=(const RBASceneCondition&&)=delete; +public: + virtual ~RBASceneCondition()=default; + +}; + +} + +#endif diff --git a/src/core/expression/RBASceneOperator.hpp b/src/core/expression/RBASceneOperator.hpp new file mode 100644 index 0000000..630c655 --- /dev/null +++ b/src/core/expression/RBASceneOperator.hpp @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SceneOperator class header + */ + +#ifndef RBASCENEOPERATOR_HPP +#define RBASCENEOPERATOR_HPP + +#include "RBADllExport.hpp" +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBASceneOperator : public RBAOperator +{ +protected: + RBASceneOperator()=default; + RBASceneOperator(const RBASceneOperator&)=delete; + RBASceneOperator(const RBASceneOperator&&)=delete; + RBASceneOperator& operator=(const RBASceneOperator&)=delete; + RBASceneOperator& operator=(const RBASceneOperator&&)=delete; +public: + ~RBASceneOperator()=default; + +}; + +} + +#endif diff --git a/src/core/expression/RBASelectOperator.cpp b/src/core/expression/RBASelectOperator.cpp new file mode 100644 index 0000000..be74fa5 --- /dev/null +++ b/src/core/expression/RBASelectOperator.cpp @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SelectOperator class definition + */ + +#include +#include "RBASelectOperator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAContent.hpp" +#include "RBAContentSet.hpp" +#include "RBAAllocatable.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALambdaExpression.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +RBASelectOperator::RBASelectOperator() +: RBALambdaContext(), + allocatableSet_{std::make_unique()}, + contentSet_{std::make_unique()} +{ +} + +void +RBASelectOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBASelectOperator::getModelElementType() const +{ + return RBAModelElementType::SelectOperator; +} + +const RBARuleObject* RBASelectOperator::getReferenceObjectCore( + RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + const RBARuleObject* returnObj {nullptr}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const lhsObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else if (lhsObj != nullptr) { + if (dynamic_cast(lhsObj) != nullptr) { + std::list objs { + dynamic_cast(lhsObj)->getLeafAllocatable()}; + allocatableSet_->clear(); + std::uint32_t i {0U}; + RBALambdaExpression* const lambda {getLambda()}; + for (auto& obj : objs) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo {info->getChild(i)}; + lambda->setRuleObj(obj); + const bool isPassed {lambda->execute(childInfo, arb)}; + LOG_removeHierarchy(); + if (isPassed && (!childInfo->isExceptionBeforeArbitrate())) { + allocatableSet_->addTarget(obj); + } + } + returnObj = allocatableSet_.get(); + } else { + std::list objs { + dynamic_cast(lhsObj)->getLeafContent()}; + contentSet_->clear(); + std::uint32_t i {0U}; + RBALambdaExpression* const lambda {getLambda()}; + for (auto& obj : objs) { + LOG_addHierarchy("#" + std::to_string(i)); + ++i; + RBAConstraintInfo* const childInfo {info->getChild(i)}; + lambda->setRuleObj(obj); + const bool isPassed {lambda->execute(childInfo, arb)}; + LOG_removeHierarchy(); + if (isPassed && (!childInfo->isExceptionBeforeArbitrate())) { + contentSet_->addTarget(obj); + } + } + returnObj = contentSet_.get(); + } + } else { + ; + } +#ifdef RBA_USE_LOG + std::string objName = "NULL"; + if (returnObj != nullptr) { + objName = returnObj->getElementName(); + if (objName == "") { + objName = returnObj->getDynamicName(); + } + } + LOG_arbitrateConstraintLogicLogLine( + " " + LOG_getExpressionText() + " is " + objName); +#endif + LOG_removeHierarchy(); + return returnObj; +} +#ifdef RBA_USE_LOG +const std::string RBASelectOperator::getSymbol() const +{ + return ".select"; +} + +const std::string RBASelectOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol() + + getLambda()->getExpressionText(); +} + +const std::string RBASelectOperator::getCoverageExpressionText() const +{ + getLambda()->clearRuleObj(); + return getLhsOperand()->getCoverageExpressionText() + getSymbol() + + getLambda()->getCoverageExpressionText(); +} +#endif + +} // namespace rba diff --git a/src/core/expression/RBASelectOperator.hpp b/src/core/expression/RBASelectOperator.hpp new file mode 100644 index 0000000..9c85fb0 --- /dev/null +++ b/src/core/expression/RBASelectOperator.hpp @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SelectOperator class header + */ + +#ifndef RBASELECTOPERATOR_HPP +#define RBASELECTOPERATOR_HPP + +#include "RBALambdaContext.hpp" + +namespace rba +{ + +class RBAAllocatableSet; +class RBAContentSet; + +class RBASelectOperator : public RBALambdaContext +{ + public: + RBASelectOperator(); + RBASelectOperator(const RBASelectOperator&)=delete; + RBASelectOperator(const RBASelectOperator&&)=delete; + RBASelectOperator& operator=(const RBASelectOperator&)=delete; + RBASelectOperator& operator=(const RBASelectOperator&&)=delete; + virtual ~RBASelectOperator()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif + private: + std::unique_ptr allocatableSet_; + std::unique_ptr contentSet_; +}; + +} /* namespace rba */ + +#endif /* RBASELECTOPERATOR_HPP */ diff --git a/src/core/expression/RBASelectOperatorMaker.cpp b/src/core/expression/RBASelectOperatorMaker.cpp new file mode 100644 index 0000000..d7c1a35 --- /dev/null +++ b/src/core/expression/RBASelectOperatorMaker.cpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASelectOperatorMaker.cpp +/// @brief SelectOperator object generator class definition + +#include "RBASelectOperatorMaker.hpp" +#include "RBASelectOperator.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBALambdaExpression.hpp" + +namespace rba +{ + +RBASelectOperatorMaker::RBASelectOperatorMaker() + : RBALambdaContextMaker{"SelectOperator"} +{ +} + +std::unique_ptr +RBASelectOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +RBAModelElement* +RBASelectOperatorMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast( + RBALambdaContextMaker::setProperty(element, jsonElem, model, owner)); + + return element; +} + +std::unique_ptr +RBASelectOperatorMaker::createLambdaContext() +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBASelectOperatorMaker.hpp b/src/core/expression/RBASelectOperatorMaker.hpp new file mode 100644 index 0000000..0415331 --- /dev/null +++ b/src/core/expression/RBASelectOperatorMaker.hpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASelectOperatorMaker.cpp +/// @brief SelectOperator object generator class header + +#ifndef RBASELECTOPERATORMAKER_HPP +#define RBASELECTOPERATORMAKER_HPP + +#include "RBALambdaContextMaker.hpp" + +namespace rba +{ + +/// @brief SelectOperator object generator class +class RBASelectOperatorMaker : public RBALambdaContextMaker +{ +public: + RBASelectOperatorMaker(); + RBASelectOperatorMaker(const RBASelectOperatorMaker&)=delete; + RBASelectOperatorMaker(const RBASelectOperatorMaker&&)=delete; + RBASelectOperatorMaker& operator=(const RBASelectOperatorMaker&)=delete; + RBASelectOperatorMaker& operator=(const RBASelectOperatorMaker&&)=delete; + virtual ~RBASelectOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated object + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) override; + + /// @brief generate an empty object of LambdaContext + /// @details generate an empty object of unique_ptr + /// @return unique_ptr for object of LambdaContext + std::unique_ptr createLambdaContext() override; + +}; + +} + +#endif diff --git a/src/core/expression/RBASetExpression.hpp b/src/core/expression/RBASetExpression.hpp new file mode 100644 index 0000000..5ad1de4 --- /dev/null +++ b/src/core/expression/RBASetExpression.hpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SetExpression class header + */ + +#ifndef RBASETEXPRESSION_HPP +#define RBASETEXPRESSION_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBASetExpression : public RBAExpression +{ +protected: + RBASetExpression()=default; + RBASetExpression(const RBASetExpression&)=delete; + RBASetExpression(const RBASetExpression&&)=delete; + RBASetExpression& operator=(const RBASetExpression&)=delete; + RBASetExpression& operator=(const RBASetExpression&&)=delete; +public: + virtual ~RBASetExpression()=default; + +}; + +} + +#endif diff --git a/src/core/expression/RBASetOfOperator.cpp b/src/core/expression/RBASetOfOperator.cpp new file mode 100644 index 0000000..03e82eb --- /dev/null +++ b/src/core/expression/RBASetOfOperator.cpp @@ -0,0 +1,194 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBASetOfOperator class definition + */ + +#include +#include "RBASetOfOperator.hpp" +#include "RBARuleObject.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContentSet.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContent.hpp" +#include "RBALogManager.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +RBASetOfOperator::RBASetOfOperator() + : RBAOperator(), + allocatableSet_{std::make_unique()}, + contentSet_{std::make_unique()} +{ +} + +void +RBASetOfOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} + +RBAModelElementType +RBASetOfOperator::getModelElementType() const +{ + return RBAModelElementType::SetOfOperator; +} + +const RBARuleObject* +RBASetOfOperator::getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + allocatableSet_->clear(); + contentSet_->clear(); + + bool isAllocatableSet {false}; + bool isContentSet {false}; + + std::uint32_t i {0U}; + for(const RBAExpression* const expr : getOperand()) { + RBAConstraintInfo* const childInfo {info->getChild(i)}; + const RBARuleObject* const obj {expr->getReferenceObject(childInfo,arb)}; + if(childInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + return nullptr; + } + if(obj != nullptr) { + if (obj->isModelElementType(RBAModelElementType::Area) || + obj->isModelElementType(RBAModelElementType::Zone)) { + allocatableSet_->addTarget(dynamic_cast(obj)); + isAllocatableSet = true; + } + else if (obj->isModelElementType(RBAModelElementType::ViewContent) || + obj->isModelElementType(RBAModelElementType::SoundContent)) { + contentSet_->addTarget(dynamic_cast(obj)); + isContentSet = true; + } + else if (dynamic_cast(obj) != nullptr) { + for (const RBAAllocatable* const a : dynamic_cast(obj)->getLeafAllocatable()) { + allocatableSet_->addTarget(a); + } + isAllocatableSet = true; + } else { + for (const RBAContent* const c : dynamic_cast(obj)->getLeafContent()) { + contentSet_->addTarget(c); + } + isContentSet = true; + } + } + i++; + } + if (isAllocatableSet) { + return allocatableSet_.get(); + } else if (isContentSet){ + return contentSet_.get(); + } else { + return nullptr; + } +} + +void +RBASetOfOperator::doActionCore(RBAConstraintInfo* info, RBAArbitrator* arb) +{ + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy("SetOf"); + + std::uint32_t i {0U}; + for(RBAExpression* const expr : getOperand()) { + // Add number of element to Constraint hierarchy for coverage + LOG_addHierarchy("#" + std::to_string(i) + ":"); + + // Since it should only execute Action, info is as it is + expr->doAction(info, arb); + i++; + + // Remove number of element from Constraint hierarchy for coverage + LOG_removeHierarchy(); + } + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); + + return; +} + +#ifdef RBA_USE_LOG +const std::string +RBASetOfOperator::getExpressionText() const +{ + std::ostringstream oss; + oss << "{"; + const auto& exprList = getOperand(); + const auto& lastExpr = exprList.back(); + for (const auto& expr : exprList) { + oss << expr->getExpressionText(); + if (expr != lastExpr) { + oss << ", "; + } + } + oss << "}"; + + return oss.str(); +} + +const std::string +RBASetOfOperator::getCoverageExpressionText() const +{ + std::ostringstream oss; + oss << "{"; + const auto& exprList = getOperand(); + const auto& lastExpr = exprList.back(); + for (const auto& expr : exprList) { + oss << expr->getCoverageExpressionText(); + if (expr != lastExpr) { + oss << ", "; + } + } + oss << "}"; + + return oss.str(); +} + +void +RBASetOfOperator::createHierarchy() +{ + // Add itself to Constraint hierarchy for coverage + LOG_addHierarchy("SetOf"); + RBALogManager::coverageHierarchyOfConstraintExpressionLog(getCoverageExpressionText(), this); + uint32_t idx=0; + for(RBAExpression* expr : getOperand()) { + // Add number of element to Constraint hierarchy for coverage + LOG_addHierarchy("#"+std::to_string(idx)+":"); + expr->createHierarchy(); + // Remove number of element from Constraint hierarchy for coverage + LOG_removeHierarchy(); + idx++; + } + // Remove itself from Constraint hierarchy for coverage + LOG_removeHierarchy(); +} + +RBAExpressionType +RBASetOfOperator::getUnderlyingType() const +{ + return getLhsOperand()->getUnderlyingType(); +} +#endif + +} diff --git a/src/core/expression/RBASetOfOperator.hpp b/src/core/expression/RBASetOfOperator.hpp new file mode 100644 index 0000000..d73e1f7 --- /dev/null +++ b/src/core/expression/RBASetOfOperator.hpp @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBASetOfOperator class header + */ + +#ifndef RBASETOFOPERATOR_HPP +#define RBASETOFOPERATOR_HPP + +#include +#include "RBAOperator.hpp" + +namespace rba +{ + +class RBAAllocatableSet; +class RBAContentSet; + +class DLL_EXPORT RBASetOfOperator : public RBAOperator +{ +public: + RBASetOfOperator(); + RBASetOfOperator(const RBASetOfOperator&)=delete; + RBASetOfOperator(const RBASetOfOperator&&)=delete; + RBASetOfOperator& operator=(const RBASetOfOperator&)=delete; + RBASetOfOperator& operator=(const RBASetOfOperator&&)=delete; + virtual ~RBASetOfOperator()=default; + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; + void createHierarchy() override; + RBAExpressionType getUnderlyingType() const override; +#endif + +protected: + const RBARuleObject* getReferenceObjectCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + void doActionCore(RBAConstraintInfo* info, RBAArbitrator* arb) override; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr allocatableSet_; + std::unique_ptr contentSet_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBASetOfOperatorMaker.cpp b/src/core/expression/RBASetOfOperatorMaker.cpp new file mode 100644 index 0000000..f17f17d --- /dev/null +++ b/src/core/expression/RBASetOfOperatorMaker.cpp @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASetOfOperatorMaker.cpp +/// @brief SetOfOperator object generator class + +#include "RBASetOfOperatorMaker.hpp" +#include "RBASetOfOperator.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContentSet.hpp" + +namespace rba +{ + +RBASetOfOperatorMaker::RBASetOfOperatorMaker() + : RBAOperatorMaker{"SetOfOperator"} +{ +} + +std::unique_ptr +RBASetOfOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBASetOfOperatorMaker.hpp b/src/core/expression/RBASetOfOperatorMaker.hpp new file mode 100644 index 0000000..87905fa --- /dev/null +++ b/src/core/expression/RBASetOfOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASetOfOperatorMaker.cpp +/// @brief SetOfOperator object generator class header + +#ifndef RBASETOFOPERATORMAKER_HPP +#define RBASETOFOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief SetOfOperator object generator class +class RBASetOfOperatorMaker : public RBAOperatorMaker +{ +public: + RBASetOfOperatorMaker(); + RBASetOfOperatorMaker(const RBASetOfOperatorMaker&)=delete; + RBASetOfOperatorMaker(const RBASetOfOperatorMaker&&)=delete; + RBASetOfOperatorMaker& operator=(const RBASetOfOperatorMaker&)=delete; + RBASetOfOperatorMaker& operator=(const RBASetOfOperatorMaker&&)=delete; + virtual ~RBASetOfOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBASetOperator.hpp b/src/core/expression/RBASetOperator.hpp new file mode 100644 index 0000000..ded7a16 --- /dev/null +++ b/src/core/expression/RBASetOperator.hpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SetOperator class header + */ + +#ifndef RBASETOPERATOR_HPP +#define RBASETOPERATOR_HPP + +#include "RBAOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBASetOperator : public RBAOperator +{ +protected: + RBASetOperator()=default; + RBASetOperator(const RBASetOperator&)=delete; + RBASetOperator(const RBASetOperator&&)=delete; + RBASetOperator& operator=(const RBASetOperator&)=delete; + RBASetOperator& operator=(const RBASetOperator&&)=delete; +public: + virtual ~RBASetOperator()=default; + +}; + +} + +#endif diff --git a/src/core/expression/RBASizeOperator.cpp b/src/core/expression/RBASizeOperator.cpp new file mode 100644 index 0000000..c928bcf --- /dev/null +++ b/src/core/expression/RBASizeOperator.cpp @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// SizeOperator class definition +// + +#include "RBASizeOperator.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBAModelElementType.hpp" +#include "RBALogManager.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContentSet.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +void RBASizeOperator::accept(RBAExpressionVisitor& visitor) +{ + visitor.visit(*this); +} +RBAModelElementType RBASizeOperator::getModelElementType() const +{ + return RBAModelElementType::SizeOperator; +} +std::int32_t RBASizeOperator::getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const +{ + LOG_addHierarchy(LOG_getSymbol()); + std::int32_t returnValue {-99}; + RBAConstraintInfo* const leftInfo {info->getChild(0U)}; + const RBARuleObject* const lhsObj {getLhsOperand()->getReferenceObject(leftInfo, + arb)}; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else if (lhsObj != nullptr) { + if (dynamic_cast(lhsObj) != nullptr) { + returnValue = static_cast(dynamic_cast(lhsObj) + ->getLeafAllocatable().size()); + } else { + returnValue = static_cast(dynamic_cast(lhsObj)->getLeafContent() + .size()); + } + } else { + ; + } +#ifdef RBA_USE_LOG + LOG_arbitrateConstraintLogicLogLine( + " " + LOG_getExpressionText() + " is " + std::to_string(returnValue)); +#endif + LOG_removeHierarchy(); + return returnValue; +} + +#ifdef RBA_USE_LOG +const std::string RBASizeOperator::getSymbol() const +{ + return ".size()"; +} +const std::string RBASizeOperator::getExpressionText() const +{ + return getLhsOperand()->getExpressionText() + getSymbol(); +} +const std::string RBASizeOperator::getCoverageExpressionText() const +{ + return getLhsOperand()->getCoverageExpressionText() + getSymbol(); +} +#endif + +} /* namespace rba */ diff --git a/src/core/expression/RBASizeOperator.hpp b/src/core/expression/RBASizeOperator.hpp new file mode 100644 index 0000000..26f22fa --- /dev/null +++ b/src/core/expression/RBASizeOperator.hpp @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// SizeOperator class header +// + +#ifndef RBASIZEOPERATOR_HPP +#define RBASIZEOPERATOR_HPP + +#include "RBASetOperator.hpp" + +namespace rba +{ + +class RBASizeOperator : public RBASetOperator +{ + public: + RBASizeOperator()=default; + RBASizeOperator(const RBASizeOperator&)=delete; + RBASizeOperator(const RBASizeOperator&&)=delete; + RBASizeOperator& operator=(const RBASizeOperator&)=delete; + RBASizeOperator& operator=(const RBASizeOperator&&)=delete; + virtual ~RBASizeOperator()=default; + + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + std::int32_t getValueCore(RBAConstraintInfo* info, RBAArbitrator* arb) const override; +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; + const std::string getExpressionText() const override; + const std::string getCoverageExpressionText() const override; +#endif +}; + +} /* namespace rba */ + +#endif /* SRC_CORE_EXPRESSION_RBASIZEOPERATOR_HPP_ */ diff --git a/src/core/expression/RBASizeOperatorMaker.cpp b/src/core/expression/RBASizeOperatorMaker.cpp new file mode 100644 index 0000000..2a905c7 --- /dev/null +++ b/src/core/expression/RBASizeOperatorMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASizeOperatorMaker.cpp +/// @brief SizeOperator object generator class definition + +#include "RBASizeOperatorMaker.hpp" +#include "RBASizeOperator.hpp" + +namespace rba +{ + +RBASizeOperatorMaker::RBASizeOperatorMaker() + : RBAOperatorMaker{"SizeOperator"} +{ +} + +std::unique_ptr +RBASizeOperatorMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBASizeOperatorMaker.hpp b/src/core/expression/RBASizeOperatorMaker.hpp new file mode 100644 index 0000000..b5dd0f6 --- /dev/null +++ b/src/core/expression/RBASizeOperatorMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBASizeOperatorMaker.hpp +/// @brief SizeOperator object generator abstract class header + +#ifndef RBASIZEOPERATORMAKER_HPP +#define RBASIZEOPERATORMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief SizeOperator object generator class +class RBASizeOperatorMaker : public RBAOperatorMaker +{ +public: + RBASizeOperatorMaker(); + RBASizeOperatorMaker(const RBASizeOperatorMaker&)=delete; + RBASizeOperatorMaker(const RBASizeOperatorMaker&&)=delete; + RBASizeOperatorMaker& operator=(const RBASizeOperatorMaker&)=delete; + RBASizeOperatorMaker& operator=(const RBASizeOperatorMaker&&)=delete; + virtual ~RBASizeOperatorMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAStateValue.cpp b/src/core/expression/RBAStateValue.cpp new file mode 100644 index 0000000..f2fe5cb --- /dev/null +++ b/src/core/expression/RBAStateValue.cpp @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /// StateValue class denition + +#include +#include "RBAStateValue.hpp" +#include "RBAArbitrator.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAContent.hpp" +#include "RBAContentState.hpp" +#include "RBAExpressionVisitor.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void RBAStateValue::accept(RBAExpressionVisitor& visitor) +{ + // RBASceneAllocatableCollector which is the only existing vistor + // does not pass this path because it does not accept + // the expression that returns Value. But, in the future, + // another visitor may accept, so implement this. + visitor.visit(*this); +} + +RBAModelElementType +RBAStateValue::getModelElementType() const +{ + return RBAModelElementType::StateValue; +} + +std::int32_t +RBAStateValue::getValueCore(RBAConstraintInfo* info, RBAArbitrator* arb) const +{ + std::int32_t result { -99 }; + const auto leftInfo = info->getChild(0U); + const auto r = getLhsOperand()->getReferenceObject(leftInfo, arb); + const RBAContent* c { nullptr }; + const RBAContentState* cs { nullptr }; + if (leftInfo->isExceptionBeforeArbitrate()) { + info->setExceptionBeforeArbitrate(true); + } else { + if (r != nullptr) { + c = dynamic_cast(r->getRawObject()); + if (c != nullptr) { + if (r->isPrevious()) { + cs = arb->getResult()->getPreActiveState(c); + } else { + cs = arb->getResult()->getActiveState(c); + } + if (cs != nullptr) { + result = cs->getContentStatePriority(); + } + } + } + } +#ifdef RBA_USE_LOG + std::string pre; + std::string cName { "NULL" }; + std::string resultText{ "no Content skip" }; + if (r != nullptr) { + cName = r->getElementName(); + pre = getPreMsg(r->isPrevious()); + } + if (info->isExceptionBeforeArbitrate()) { + resultText = "before arbitrate skip"; + } else { + if (cs != nullptr) { + resultText = cs->getElementName() + " : " + std::to_string(result); + } + } + LOG_arbitrateConstraintLogicLogLine( + " " + + pre + + "Content[" + + cName + + "] state value [" + + resultText + + "]"); +#endif + return result; +} + +#ifdef RBA_USE_LOG +const std::string +RBAStateValue::getSymbol() const +{ + return ".stateValue()"; +} +#endif + +} diff --git a/src/core/expression/RBAStateValue.hpp b/src/core/expression/RBAStateValue.hpp new file mode 100644 index 0000000..52cf8fc --- /dev/null +++ b/src/core/expression/RBAStateValue.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /// StateValue class header + +#ifndef RBASTATEVALUE_HPP +#define RBASTATEVALUE_HPP + +#include +#include "RBAContentOperator.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAStateValue : public RBAContentOperator +{ +public: + RBAStateValue()=default; + RBAStateValue(const RBAStateValue&)=delete; + RBAStateValue(RBAStateValue&&)=delete; + RBAStateValue& operator=(const RBAStateValue&)=delete; + RBAStateValue& operator=(RBAStateValue&&)=delete; + virtual ~RBAStateValue()=default; + +public: + void accept(RBAExpressionVisitor& visitor) override; + RBAModelElementType getModelElementType() const override; + std::int32_t getValueCore(RBAConstraintInfo* info, + RBAArbitrator* arb) const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getSymbol() const override; +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAStateValueMaker.cpp b/src/core/expression/RBAStateValueMaker.cpp new file mode 100644 index 0000000..22a0c81 --- /dev/null +++ b/src/core/expression/RBAStateValueMaker.cpp @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAStateValueMaker.cpp +/// @brief StateValue object generator class + +#include "RBAStateValueMaker.hpp" +#include "RBAStateValue.hpp" + +namespace rba +{ + +RBAStateValueMaker::RBAStateValueMaker() + : RBAOperatorMaker{"StateValue"} +{ +} + +std::unique_ptr +RBAStateValueMaker::createInstance(const std::string& name) +{ + return std::make_unique(); +} + +} diff --git a/src/core/expression/RBAStateValueMaker.hpp b/src/core/expression/RBAStateValueMaker.hpp new file mode 100644 index 0000000..8b01e09 --- /dev/null +++ b/src/core/expression/RBAStateValueMaker.hpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAStateValueMaker.cpp +/// @brief StateValue object generator class header + +#ifndef RBASTATEVALUEMAKER_HPP +#define RBASTATEVALUEMAKER_HPP + +#include "RBAOperatorMaker.hpp" + +namespace rba +{ + +/// @brief StateValue object generator class +class RBAStateValueMaker : public RBAOperatorMaker +{ +public: + RBAStateValueMaker(); + RBAStateValueMaker(const RBAStateValueMaker&)=delete; + RBAStateValueMaker(const RBAStateValueMaker&&)=delete; + RBAStateValueMaker& operator=(const RBAStateValueMaker&)=delete; + RBAStateValueMaker& operator=(const RBAStateValueMaker&&)=delete; + virtual ~RBAStateValueMaker()=default; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + +}; + +} + +#endif diff --git a/src/core/expression/RBAValueExpression.hpp b/src/core/expression/RBAValueExpression.hpp new file mode 100644 index 0000000..111ad02 --- /dev/null +++ b/src/core/expression/RBAValueExpression.hpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ValueExpression class header + */ + +#ifndef RBAVALUEEXPRESSION_HPP +#define RBAVALUEEXPRESSION_HPP + +#include "RBAExpression.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAValueExpression : public RBAExpression +{ +protected: + RBAValueExpression()=default; + RBAValueExpression(const RBAValueExpression&)=delete; + RBAValueExpression(const RBAValueExpression&&)=delete; + RBAValueExpression& operator=(const RBAValueExpression&)=delete; + RBAValueExpression& operator=(const RBAValueExpression&&)=delete; +public: + virtual ~RBAValueExpression()=default; + +}; + +} + +#endif diff --git a/src/core/expression/RBAVariable.cpp b/src/core/expression/RBAVariable.cpp new file mode 100644 index 0000000..9220c0a --- /dev/null +++ b/src/core/expression/RBAVariable.cpp @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Variable class defintion + */ + +#include "RBAVariable.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +RBAVariable::RBAVariable(const std::string& name) + : RBARuleObject{name} +{ +} + +RBAModelElementType +RBAVariable::getModelElementType() const +{ + return RBAModelElementType::Variable; +} + +const RBARuleObject* +RBAVariable::getRuleObj() const +{ + return ruleObj_; +} + +void +RBAVariable::setRuleObj(const RBARuleObject* const ruleObj) +{ + ruleObj_ = ruleObj; +} + +void +RBAVariable::clearRuleObj() +{ + ruleObj_ = nullptr; +} + +RBAConstraintInfo* +RBAVariable::createConstraintInfo() +{ + // When the "Let" expression is written in a lambda expression such as + // "For-All", the expansion result of the "Let" expression also changes + // each time the variable of "For-All" changes. Even if the Let expression + // is written in "For-All", there is only one valiable object. + // Therefore, "constraintInfo" cannot be cleared and reused, and it is + // necessary to do "make_shared" each time the "Let" expression is evaluated. + // The ownership of the "ConstraintInfo" of the "Let" expression is + // transferred to the "ConstraintInfo" of the "RBAObjectReference" + // when the RBAObjectReference that refers to the definition of the Let + // expression is evaluated. + constraintInfo_ = std::make_shared(); + return constraintInfo_.get(); +} + +std::shared_ptr +RBAVariable::getConstraintInfo() const +{ + return constraintInfo_; +} + +} diff --git a/src/core/expression/RBAVariable.hpp b/src/core/expression/RBAVariable.hpp new file mode 100644 index 0000000..88f071e --- /dev/null +++ b/src/core/expression/RBAVariable.hpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Variable class header + */ + +#ifndef RBAVARIABLE_HPP +#define RBAVARIABLE_HPP + +#include +#include "RBARuleObject.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAVariable : public RBARuleObject +{ +public: + explicit RBAVariable(const std::string& name=""); + RBAVariable(const RBAVariable&)=delete; + RBAVariable(const RBAVariable&&)=delete; + RBAVariable& operator=(const RBAVariable&)=delete; + RBAVariable& operator=(const RBAVariable&&)=delete; + virtual ~RBAVariable()=default; + +public: + RBAModelElementType getModelElementType() const override; + + const RBARuleObject* getRuleObj() const; + void setRuleObj(const RBARuleObject* const ruleObj); + void clearRuleObj(); + RBAConstraintInfo* createConstraintInfo(); + std::shared_ptr getConstraintInfo() const; + +private: + const RBARuleObject* ruleObj_ {nullptr}; +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::shared_ptr constraintInfo_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/expression/RBAVariableMaker.cpp b/src/core/expression/RBAVariableMaker.cpp new file mode 100644 index 0000000..aa7d5e8 --- /dev/null +++ b/src/core/expression/RBAVariableMaker.cpp @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAVariableMaker.cpp +/// @brief Variable object generator class definition + +#include "RBAVariableMaker.hpp" +#include "RBAVariable.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAVariableMaker::RBAVariableMaker() + : RBAModelElementMaker::RBAModelElementMaker{"Variable"} +{ +} + +RBAModelElement* +RBAVariableMaker::create(const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + // Register the instance without a name, because Variable has the same name + std::unique_ptr inst + {createInstance(jsonElem->findChildren("name")->getString())}; + const auto element = inst.get(); + static_cast(model->addModelElement(std::move(inst))); + + return setProperty(element, jsonElem, model, owner); +} + +std::unique_ptr +RBAVariableMaker::createInstance(const std::string& name) +{ + return std::make_unique(name); +} + +RBAModelElement* +RBAVariableMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + return element; +} + +} diff --git a/src/core/expression/RBAVariableMaker.hpp b/src/core/expression/RBAVariableMaker.hpp new file mode 100644 index 0000000..e3d52e6 --- /dev/null +++ b/src/core/expression/RBAVariableMaker.hpp @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAVariableMaker.cpp +/// @brief Variable object generator class header + +#ifndef RBAVARIABLEMAKER_HPP +#define RBAVARIABLEMAKER_HPP + +#include "RBAModelElementMaker.hpp" + +namespace rba +{ + +/// @brief Variable object generator class +class RBAVariableMaker : public RBAModelElementMaker +{ +public: + RBAVariableMaker(); + RBAVariableMaker(const RBAVariableMaker&)=delete; + RBAVariableMaker(const RBAVariableMaker&&)=delete; + RBAVariableMaker& operator=(const RBAVariableMaker&)=delete; + RBAVariableMaker& operator=(const RBAVariableMaker&&)=delete; + virtual ~RBAVariableMaker()=default; + +public: + /// @brief Create ModelElement object + /// @details Create ModelElement object and register unique_ptr to model. + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store created object + /// @param[in,out] owner Parent object (Not in use) + /// @return ModelElement object + RBAModelElement* create(const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +protected: + /// @brief generate an empty instance + /// @details generate an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set attributes of model element for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store created object + /// @param[in,out] owner Parent object (Not in use) + /// @return ModelElement object + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/logic/RBAAffectInfo.cpp b/src/core/logic/RBAAffectInfo.cpp new file mode 100644 index 0000000..6cf4e98 --- /dev/null +++ b/src/core/logic/RBAAffectInfo.cpp @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AffectInfo class definition + */ + +#include "RBAAffectInfo.hpp" + +namespace rba +{ + +/** + * @brief Returns whether the allocable already affects the target allocable + * @param allocatable Influential Allocatable + * @param affectAllocatable Affected Allocatable + * @return bool + */ +bool +RBAAffectInfo::alreadyKnowsThatFormerHasAffectedToLatter(const RBAAllocatable* const allocatable, + const RBAAllocatable* const affectAllocatable) const +{ + for(const auto& alloc : reaffected_[allocatable]) { + if(alloc == affectAllocatable) { + return true; + } + } + return false; +} + +/** + * @brief Register Affect information + * @param allocatable Influential Allocatable + * @param affectAllocatable Affected Allocatable + */ +void +RBAAffectInfo::addInfoThatFormerAffectedToLatter(const RBAAllocatable* const allocatable, + const RBAAllocatable* const affectAllocatable) +{ + static_cast(reaffected_[allocatable].insert(affectAllocatable)); +} + +/** + * @brief Deletes the Affect information of "allocatable" registered by + *        other allocatables registered by arbitration of the specified + *        recursion hierarchy of the specified "allocatable". + * @param affectAllocatable + */ +void RBAAffectInfo::removeAffectInfo(const RBAAllocatable* const affectAllocatable) +{ + static_cast(reaffected_.erase(affectAllocatable)); +} + +} diff --git a/src/core/logic/RBAAffectInfo.hpp b/src/core/logic/RBAAffectInfo.hpp new file mode 100644 index 0000000..c9c73be --- /dev/null +++ b/src/core/logic/RBAAffectInfo.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AffectInfo class header + */ + +#ifndef RBAAFFECTINFO_HPP +#define RBAAFFECTINFO_HPP + +#include +#include + +namespace rba +{ + +class RBAAllocatable; + +class RBAAffectInfo +{ +public: + RBAAffectInfo()=default; + RBAAffectInfo(const RBAAffectInfo&)=delete; + RBAAffectInfo(const RBAAffectInfo&&)=delete; + RBAAffectInfo& operator=(const RBAAffectInfo&)=delete; + RBAAffectInfo& operator=(const RBAAffectInfo&&)=delete; + virtual ~RBAAffectInfo()=default; + +public: + bool alreadyKnowsThatFormerHasAffectedToLatter(const RBAAllocatable* const allocatable, + const RBAAllocatable* const affectAllocatable) const; + void addInfoThatFormerAffectedToLatter(const RBAAllocatable* const allocatable, + const RBAAllocatable* const affectAllocatable); + void removeAffectInfo(const RBAAllocatable* const affectAllocatable); + +private: + // Information of other "allocatable" affected by "allocatable" + mutable std::unordered_map>reaffected_; + +}; + +} + +#endif diff --git a/src/core/logic/RBAArbitrator.cpp b/src/core/logic/RBAArbitrator.cpp new file mode 100644 index 0000000..9fdd7d3 --- /dev/null +++ b/src/core/logic/RBAArbitrator.cpp @@ -0,0 +1,1987 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * Arbitrator class definition + */ + +#include +#include +#include "RBAArbitrator.hpp" +#include "RBAModelImpl.hpp" +#include "RBAResult.hpp" +#include "RBAResultSet.hpp" +#include "RBAAffectInfo.hpp" +#include "RBAConstraintImpl.hpp" +#include "RBAViewAction.hpp" +#include "RBAViewTransition.hpp" +#include "RBAViewMove.hpp" +#include "RBARollbacker.hpp" +#include "RBALogManager.hpp" +#include "RBAModelElementType.hpp" + +namespace rba { + +RBAArbitrator::RBAArbitrator(RBAModel* newModel) +{ + setModel(newModel); +} + +#ifdef RBA_USE_LOG +RBAArbitrator::RBAArbitrator(RBAModel* newModel, RBALogManager* logManager) +{ + setModel(newModel); + RBALogManager::setLogManager(logManager); + // Even if the argument logManager is null, it may be setLogManager() + // from outside the rba, so it is determined by getLogManager() instead of + // the argument determination. + if (RBALogManager::getLogManager() != nullptr) { + setSimulationMode(true); + } +} +#endif + +RBAArbitrator::~RBAArbitrator() noexcept +{ +} + +void +RBAArbitrator::setModel(RBAModel* newModel) +{ + setModel(dynamic_cast(newModel)); +} + +const RBAModel* +RBAArbitrator::getModel() const +{ + return dynamic_cast(model_); +} + +void +RBAArbitrator::initialize(std::list& contexts) +{ + const std::lock_guard lock{getMutex()}; + setRequestData(contexts, true); +} + +std::unique_ptr +RBAArbitrator::execute(const std::string& contextName, bool require) +{ + const std::lock_guard lock {getMutex()}; + if (isValidContext(contextName) == false) { + // In case of error, creates a copy of "Result", + // sets the error flag in it and returns + std::unique_ptr result {std::make_unique( + this, std::make_unique(*getBackupResultSet()))}; + result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE); + return std::move(result); + } else { + static_cast(setRequestData(contextName, require, nullptr, + static_cast(getRequestQue().size()))); + return arbitrateMain(); + } +} + +std::unique_ptr +RBAArbitrator::execute(std::list& contexts, + bool require) +{ + const std::lock_guard lock {getMutex()}; + if (isValidContext(contexts) == false) { + // In case of error, creates a copy of "Result", + // sets the error flag in it and returns + std::unique_ptr result {std::make_unique( + this, std::make_unique(*getBackupResultSet()))}; + result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE); + return std::move(result); + } else { + setRequestData(contexts, require); + return arbitrateMain(); + } +} + +std::unique_ptr +RBAArbitrator::execute(const std::string& sceneName, + std::list>& properties) +{ + const std::lock_guard lock {getMutex()}; + // Check argument + if (isValidContext(sceneName) == false) { + // In case of error, creates a copy of "Result", + // sets the error flag in it and returns + std::unique_ptr result {std::make_unique( + this, std::make_unique(*getBackupResultSet()))}; + result->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE); + return std::move(result); + } else { + static_cast(setRequestData(sceneName, true, &properties, + static_cast(getRequestQue().size()))); + return arbitrateMain(); + } +} + +std::unique_ptr +RBAArbitrator::setResultContentState(const std::string& allocatableName, + const std::string& contextName) +{ + const std::lock_guard lock{getMutex()}; + RBAResultSet* const backupResultSetTmp {getBackupResultSet().get()}; + if (getReservedResultSet() == nullptr) { + setResult(std::make_unique(this, + std::make_unique(), + std::move(getBackupResultSet()))); + } else { + RBAResultSet* const reservedResultSetTmp {getReservedResultSet().get()}; + setResult(std::make_unique(this, + std::move(getReservedResultSet()), + std::move(getBackupResultSet()))); + setReservedResultSet(std::make_unique(*reservedResultSetTmp)); + } + setBackupResultSet(std::make_unique(*backupResultSetTmp)); + + // find allocatable + const RBAAllocatable* alloc {nullptr}; + const RBAAreaImpl* const area {model_->findAreaImpl(allocatableName)}; + if(area != nullptr) { + alloc = area; + } + else { + const RBAZoneImpl* const zone {model_->findZoneImpl(allocatableName)}; + if(zone != nullptr) { + alloc = zone; + } + } + // find content state + const RBAContentState* state {nullptr}; + const RBAViewContentStateImpl* const viewState + {model_->findViewContentStateImpl(contextName)}; + if(viewState != nullptr) { + state = viewState; + } + else { + const RBASoundContentStateImpl* const soundState + {model_->findSoundContentStateImpl(contextName)}; + if(soundState != nullptr) { + state = soundState; + } + } + if( (alloc == nullptr) || (state == nullptr) ) { + // Unknown context or allocatable + getResult()->setStatusType(RBAResultStatusType::UNKNOWN_CONTENT_STATE); + return std::move(getResultRef()); + } + // Set alloc and state to result + const RBAContentState* const beforeContentState {alloc->getState()}; + const_cast(alloc)->setState(state); + const_cast(alloc)->setChecked(true); + getResult()->setActive(state, true); + getResult()->setContentState(alloc, state); + + // ---------------------------------------------------------- + // Post processing of Arbitration + // ---------------------------------------------------------- + postArbitrate(); + + // Excecute offline constraint +#ifdef RBA_USE_LOG + checkAllConstraints(); +#endif + + // ---------------------------------------------------------- + // Update the state of Content + // ---------------------------------------------------------- + if (beforeContentState != nullptr) { + // Update the state of the Content originally assigned to + // the requested Allocatable + dynamic_cast(beforeContentState->getOwner())->updateStatus(getResultRef().get()); + } + // Update the state of requested Content + dynamic_cast(state->getOwner())->updateStatus(getResultRef().get()); + + // Cancel processing of Content + checkCancelContent(); + + // Update display and non-display Area + updateResult(); + + // Generate Result + createResultData(); + + // Store backup of current arbitration result set + setBackupResultSet(getResult()->createBackupCurrentResultSet()); + // Create next arbitration result set + setNextResultSet(getResult()->createNextCurrentResultSet()); + + return std::move(getResultRef()); +} + +std::unique_ptr +RBAArbitrator::cancelArbitration() +{ + const std::lock_guard lock{getMutex()}; + if(getReservedResultSet() == nullptr) { + std::unique_ptr res + {std::make_unique(this, + std::make_unique())}; + res->setStatusType(RBAResultStatusType::CANCEL_ERROR); + return std::move(res); + } + + setResult( + std::make_unique(this, + std::make_unique(), + std::move(getReservedResultSet()))); + setBackupResultSet(getResult()->createBackupCurrentResultSet()); + setNextResultSet(getResult()->createNextCurrentResultSet()); + + return std::move(getResultRef()); +} + +void +RBAArbitrator::clearArbitration() +{ + std::lock_guard lock {getMutex()}; + getCancelChecked().clear(); + setReservedResultSet(nullptr); + setBackupResultSet(std::make_unique()); + for(const auto& scene : model_->getSceneImpls()) { + for(const std::string propertyName : scene->getPropertyNames()) { + const std::int32_t value {scene->getPropertyValue(propertyName)}; + getBackupResultSet()->setSceneProperty(scene, propertyName, value); + } + } + setNextResultSet( + std::make_unique(*getBackupResultSet().get())); + setResult(std::make_unique( + this, + std::make_unique(*getBackupResultSet().get()))); + + model_->clearElementsStatus(); +} + +bool +RBAArbitrator::setScene(const std::string& sceneName, bool require, + std::list>& properties) +{ + const std::lock_guard lock{getMutex()}; + return setRequestData(sceneName, require, &properties); +} + +bool +RBAArbitrator::setContentState(const std::string& contextName, bool require) +{ + const std::lock_guard lock{getMutex()}; + const std::deque>& requestQue{getRequestQue()}; + std::uint32_t syncIndex{static_cast(requestQue.size())}; + if (syncIndex > 0U ) { + const std::unique_ptr& prevReq{requestQue.back()}; + if (prevReq->isOn() == require) { + syncIndex = prevReq->getSyncIndex(); + } + } + return setRequestData(contextName, require, nullptr, syncIndex); +} + +bool +RBAArbitrator::setAllocatableResult(const std::string& allocatableName, + const std::string& contextName) +{ + std::lock_guard lock {getMutex()}; + // Get allocatable + const auto alloc = model_->findAllocatable(allocatableName); + if(alloc == nullptr) { + return false; + } + + // Get context + const auto state = model_->findContentState(contextName); + if(state == nullptr) { + return false; + } + + // Set state to allocatable + const auto beforeContentState = alloc->getState(); + const_cast(alloc)->setState(state); + RBAResultSet* const nextResultSet {getNextResultSet().get()}; + RBAResultSet* const prevResultSet {getBackupResultSet().get()}; + nextResultSet->setContentState(alloc, state); + prevResultSet->setContentState(alloc, state); + nextResultSet->setActive(state, true); + prevResultSet->setActive(state, true); + + // ---------------------------------------------------------- + // Update the state of Content + // ---------------------------------------------------------- + // Create "result" and update state, because updating the content state + // determines the transition destination this time + // based on previous state. + setResult(std::make_unique( + this, + std::make_unique(*getBackupResultSet()), + std::make_unique(*getNextResultSet()))); + RBAContent* const content {dynamic_cast(state->getOwner())}; + content->updateRequestStatus(getResult()->getCurResultSet().get(), true); + if (beforeContentState != nullptr) { + // Update the state of the content originally assigned to + // the requested Allocatable + dynamic_cast(beforeContentState->getOwner())->updateStatus(getResultRef().get()); + } + // Update the state of requested Content + content->updateStatus(getResultRef().get()); + + setBackupResultSet(std::make_unique(*getResult()->getPreResultSet())); + setNextResultSet(getResult()->createNextCurrentResultSet()); + + return true; +} + +bool +RBAArbitrator::RBAArbitrator::evaluate(RBAExpression* expression) +{ + if(expression == nullptr) { + return false; + } + const std::lock_guard lock{getMutex()}; + RBAConstraintInfo info; + // Constraint expression evaluation + return expression->execute(&info, this); +} + +const RBARuleObject* +RBAArbitrator::evaluateObject(RBAExpression* expression) +{ + if(expression == nullptr) { + return nullptr; + } + const std::lock_guard lock{getMutex()}; + RBAConstraintInfo info; + // Constraint expression evaluation + const RBARuleObject* const ruleObj + {expression->getReferenceObject(&info, this)}; + if (ruleObj != nullptr) { + return ruleObj->getRawObject(); + } else { + return nullptr; + } +} + +int32_t +RBAArbitrator::evaluateValue(RBAExpression* expression) +{ + if(expression == nullptr) { + return -99; + } + const std::lock_guard lock{getMutex()}; + RBAConstraintInfo info; + // Constraint expression evaluation + return expression->getValue(&info, this); +} + + +void +RBAArbitrator::setModel(RBAModelImpl* const newModel) +{ + std::lock_guard lock {getMutex()}; + model_ = newModel; + model_->createSortedAllocatables(); + clearArbitration(); +} + +bool +RBAArbitrator:: +satisfiesConstraints() const +{ + const std::lock_guard lock{mutex_}; + // Temporarily store the actual result_ + // because result_ is used for evaluation + std::unique_ptr tmpResult {std::move(result_)}; + result_ = std::make_unique( + this, + std::make_unique(*(reservedResultSet_.get())), + std::make_unique(*(resultSetForSatisfiesConstraints_.get()))); + bool result {true}; + for(const RBAConstraintImpl*& constraint : model_->getConstraintImpls()) { + if (constraint->isRuntime() == true) { + result = const_cast(constraint)->execute(const_cast(this)); + if (result == false) { + break; + } + } + } + result_ = std::move(tmpResult); + return result; +} + +/** + * Execute arbitration + */ +std::unique_ptr +RBAArbitrator::arbitrateMain() +{ + // Store request state before arbitration, + // in case cancelArbitration() is executed + reservedResultSet_ = std::make_unique(*backupResultSet_); + + // Differential arbitration for each request + if (requestQue_.empty()) { + // Prepare Result here because it will be used in differenceArbitrate. + result_ = std::make_unique(this, + std::move(backupResultSet_), + std::move(nextResultSet_)); + // Arbitration request without arguments. + // there is a possibility of being queued in "requestQue_" + // due to "onDisplayed" in this, + differenceArbitrate(); + } + if (!requestQue_.empty()) { + result_ = std::make_unique(this, + std::move(backupResultSet_), + std::move(nextResultSet_)); + do { + const std::unique_ptr request {std::move(requestQue_.front())}; + requestQue_.pop_front(); + result_->setActive(request->getContentState(), request->isOn()); + // Update the state of Content + RBAContent* const content {dynamic_cast(request->getContentState()->getOwner())}; + content->updateRequestStatus(result_->getCurResultSet().get(), request->isOn()); + if (requestQue_.empty()) { + differenceArbitrate(); + if (!requestQue_.empty()) { + // Update "result_" for the next differenceArbitrate(). + result_ = std::make_unique(this, + std::move(backupResultSet_), + std::move(nextResultSet_)); + } + } else if (requestQue_.front()->getSyncIndex() != request->getSyncIndex()) { + differenceArbitrate(); + // Update "result_" for the next differenceArbitrate(). + result_ = std::make_unique(this, + std::move(backupResultSet_), + std::move(nextResultSet_)); + } else { + // No Operation + } + } while (!requestQue_.empty()); + } + + result_ = std::make_unique( + this, std::make_unique(*reservedResultSet_), + result_->createBackupCurrentResultSet()); + + // Cancel processing of Content + checkCancelContent(); + + // Update displayed and non-displayed Area + updateResult(); + +#ifdef RBA_USE_LOG + RBALogManager::setType(RBALogManager::TYPE_RESULT); + logResultArbitration(); + + setLogToResult(); + RBALogManager::setType(RBALogManager::TYPE_NOTHING); +#endif + + createResultData(); + // Store backup of current arbitration result set + backupResultSet_ = result_->createBackupCurrentResultSet(); + // Create next arbitration result set + nextResultSet_ = result_->createNextCurrentResultSet(); + + // The "result_" of the return value is changed to another name, + // because "result_" will be used for storing. + auto retResult = std::move(result_); + + // Hold the arbitration result because the arbitration result may be used + // in cases other than arbitration. + result_ = std::make_unique(retResult.get()); + + // A compile error occurs if std::move() is missing because + // std::unique_ptr is cast to std::unique_ptr + return std::move(retResult); +} + +bool +RBAArbitrator:: +isValidContext(const std::string& context) +{ + if (context != "") { + const RBAContentState* const state {model_->findContentState(context)}; + if (state == nullptr) { + const RBASceneImpl* const scene {model_->findSceneImpl(context)}; + if (scene == nullptr) { + return false; + } + } + } + + return true; +} + +bool +RBAArbitrator:: +isValidContext(std::list& contexts) +{ + for(const std::string contextName : contexts) { + if(isValidContext(contextName) == false) { + return false; + } + } + + return true; +} + +/** + * Reflect input information + */ + +bool +RBAArbitrator::setRequestData( + const std::string& context, bool require, + std::list>* const properties, + std::uint32_t syncIndex) +{ + bool isSet {false}; + if (context != "") { + // When content state is specified + // If contextName is the only content name, pop the first content state + const RBAContentState* state {model_->findContentState(context)}; + if (state != nullptr) { + requestQue_.push_back( std::make_unique(state, require, syncIndex)); + isSet = true; + } else { + // When Scene is specified + const RBASceneImpl* const scene {model_->findSceneImpl(context)}; + if (scene != nullptr) { + // for next arbitration + nextResultSet_->setActive(scene, require); + // For when "Result" is referenced before the next arbitration + result_->setActive(scene, require); + isSet = true; + if (properties != nullptr) { + for (auto& p : *properties) { + const RBAAbstractProperty* const ap {scene->getProperty(p.first)}; + if (ap != nullptr) { + // for next arbitration + nextResultSet_->setSceneProperty(ap, p.second); + // For when "Result" is referenced before the next arbitration + result_->setSceneProperty(ap, p.second); + } + } + } + } + } + } + return isSet; +} + +void +RBAArbitrator::setRequestData(const RBAContentState* state, + bool require) +{ + if (requestQue_.empty()){ + requestQue_.push_back( std::make_unique(state, require, 0U)); + } else { + requestQue_.push_back( std::make_unique(state, require, requestQue_.back()->getSyncIndex())); + } +} + +void +RBAArbitrator::setRequestData(const RBAContent* const content, + bool require) +{ + if (requestQue_.empty()){ + requestQue_.push_back( std::make_unique(content->getStates().front(), require, 0U)); + } else { + requestQue_.push_back( std::make_unique(content->getStates().front(), require, requestQue_.back()->getSyncIndex())); + } +} + +void +RBAArbitrator::setActive(const RBASceneImpl* const scene, const bool require) +{ + if (nextResultSet_ != nullptr) { + // Update nextResultSet_" when onScene is done in onRequest or onWithdrawn + nextResultSet_->setActive(scene, require); + } else { + result_->setActive(scene, require); + } +} + +void +RBAArbitrator::setSceneProperty(const RBAAbstractProperty* const prop, const std::int32_t value) +{ + if (nextResultSet_ != nullptr) { + // Update nextResultSet_" when onScene is done in onRequest or onWithdrawn + nextResultSet_->setSceneProperty(prop, value); + } else { + result_->getCurResultSet()->setSceneProperty(prop, value); + } +} + +void +RBAArbitrator::setRequestData(std::list& contexts, + const bool require) +{ + const std::uint32_t syncIndex {static_cast(requestQue_.size())}; + for (auto& c : contexts) { + static_cast(setRequestData(c, require, nullptr, syncIndex)); + } +} + +/** + * @brief Execute an extended version of arbitration that allows arbitration + when the "implication" is false + * @param areas + */ +void +RBAArbitrator:: +arbitrate(std::list& allocatables) +{ + LOG_arbitrateAreaLogLine("----Arbitrate----"); + std::set revisitedInitSet; + + std::set revisited; + for (auto& alloc : allocatables) { + revisited = revisitedInitSet; + // ------------------------------------------------------------------------- + // To prevent an infinite loop, generate information to limit registration +   // of other "allocable" that affected the target "allocatable" + // during arbitration + // ------------------------------------------------------------------------- + RBAAffectInfo affectInfo; + LOG_arbitrateAreaLogLine( + alloc->getSymbol() + "[" + alloc->getElementName() + "] check start"); + arbitrateAllocatable(alloc, revisited, 0, &affectInfo, nullptr); + } + for (auto& a : model_->getSortedAllocatables()) { + result_->setContentState(a, a->getState()); + } +} + +/** + * @brief Recursively arbitrate "allocatable" + * @param allocatable Allocatable that you want to arbitrate + * @param revisited Allocatable that re-arbitration is complete + * @param nest Re-arbitration nesting hierarchy (first arbitration is zero) + * @param affectInfo Allocatable information affected by "allocatable" + */ +void RBAArbitrator::arbitrateAllocatable( + RBAAllocatable* allocatable, + std::set& revisited, + const std::int32_t nest, + RBAAffectInfo* const affectInfo, + RBARollbacker* const parentRollbacker) +{ +#ifdef RBA_USE_LOG + RBALogManager::setIndent(nest); +#endif + // "Allocable" affected by "Allocable" which is the target of this arbitration + // during the recursive process until this variable is defined, + std::set affectAllocatables; + affectAllocatables.insert(allocatable->getAllocatablesAffectedByYou().begin(), + allocatable->getAllocatablesAffectedByYou().end()); + + const RBAContentState* const beforeState {allocatable->getState()}; + + // Mark Content allocation for target Allocable" as "checked" + allocatable->setChecked(true); + // Get content status sorted by arbitration policy + // (only active requests) + std::list contentStates; + getSortedContentStates(allocatable, contentStates); + for(const RBAContentState* const contentState : contentStates) { + // Allocate Content to Area + allocatable->setState(contentState); +#ifdef RBA_USE_LOG + { + std::string str = " Content["; + if (contentState == nullptr) { + str += "null"; + } else { + str += contentState->getOwner()->getElementName() + "::" + + contentState->getElementName(); + } + str += "] check online constraints start"; + RBALogManager::arbitrateContentLogLine(str); + } +#endif + bool isSkipped {false}; + const bool isPassed {checkConstraintAndReArbitrate( + allocatable, revisited, nest, affectInfo, parentRollbacker, + allocatable->getConstraints(), &isSkipped, false)}; + if (isPassed == true) { + + // ---------------------------------------------------------- + // Check if self-allocatable should be hidden + // by constraint expression after content allocation process. + // Check even if content is not assigned because there is contentValue() + // ---------------------------------------------------------- +#ifdef RBA_USE_LOG + std::string alloSymbol = allocatable->getSymbol(); + std::string alloName = allocatable->getElementName(); + if (allocatable->isArea() == true) { + LOG_arbitrateAreaLogLine( + " check online constraints to confirm area hidden state"); + } else { + LOG_arbitrateAreaLogLine( + " check online constraints to confirm zone muted state"); + } +#endif + // Mark "hidden" of target "Allocable" as "checked" + allocatable->setHiddenChecked(true); + // Set "hidden" of target "Allocable" to false + allocatable->setHidden(false); + bool hiddenIsPassed {checkConstraintAndReArbitrate( + allocatable, revisited, nest, affectInfo, parentRollbacker, + allocatable->getHiddenFalseCheckConstraints(), &isSkipped, + !allocatable->isZone())}; + if (hiddenIsPassed == false) { + allocatable->setHidden(true); + hiddenIsPassed = checkConstraintAndReArbitrate( + allocatable, revisited, nest, affectInfo, parentRollbacker, + allocatable->getHiddenTrueCheckConstraints(), &isSkipped, + !allocatable->isZone()); + if (hiddenIsPassed == false) { + // Clear hiding state of Allocatable + allocatable->setHiddenChecked(false); + } else { + LOG_arbitrateAreaLogLine( + alloSymbol + "[" + alloName + "] change " + + allocatable->getHiddenSymbol()); + } + } + + // ------------------------------------- + // For Zone, judge attenuation after hiding (mute) + // ------------------------------------- + bool attenuateIsPassed {true}; + if (allocatable->isZone()) { + RBAZoneImpl* const zone {dynamic_cast(allocatable)}; + // Mark "attenuattion" of target "Zone" as checked" + zone->setAttenuateChecked(true); + // Set "attenuattion" of target "Zone" to false + zone->setAttenuated(false); + LOG_arbitrateAreaLogLine( + " check online constraints to confirm zone attenuated state"); + attenuateIsPassed = checkConstraintAndReArbitrate( + allocatable, revisited, nest, affectInfo, parentRollbacker, + allocatable->getAttenuateFalseCheckConstraints(), &isSkipped, true); + if (attenuateIsPassed == false) { + zone->setAttenuated(true); + attenuateIsPassed = checkConstraintAndReArbitrate( + allocatable, revisited, nest, affectInfo, parentRollbacker, + allocatable->getAttenuateTrueCheckConstraints(), &isSkipped, true); + if (attenuateIsPassed == false) { + allocatable->setAttenuateChecked(false); + } else { + LOG_arbitrateAreaLogLine( + alloSymbol + "[" + alloName + "] change attenuated"); + } + } + } +#ifdef RBA_USE_LOG + { + std::string str = alloSymbol + "[" + alloName + "] "; + if (allocatable->isArea() == true) { + str += "displays"; + } else { + str += "outputs"; + } + str += " Content["; + const RBAContentState* state = allocatable->getState(); + if (state == nullptr) { + str += "null"; + } else { + str += state->getOwner()->getElementName() + "::" + + state->getElementName(); + } + str += "] " + allocatable->getHiddenSymbol() + "[" + + RBALogManager::boolToString(allocatable->isHidden()) + "]"; + if (allocatable->isZone() == true) { + str += " attenuated[" + + RBALogManager::boolToString(allocatable->isAttenuated()) + "]"; + } + str += "\n"; + LOG_arbitrateAreaLogLine(str); + } +#endif + if ((hiddenIsPassed == true) && (attenuateIsPassed == true)) { + break; + } + } + } + // --------------------------------------------------------------------- + // Re-arbitration of the Allocatable that influenced + // --------------------------------------------------------------------- + if ((beforeState != allocatable->getState()) + || allocatable->isHidden() + || allocatable->isAttenuated()) { + + // Re-arbitration is performed in a state other than "hidden" + // When allocating content. Therefore, if state become "hidden" or + // "attenuation", re-arbitration is required for the "allocatable" + // that was affected by re-arbitration during content allocation. + // Update the increased Area that influenced + if (allocatable->isHidden() || allocatable->isAttenuated()) { + for (const auto& a : allocatable->getAllocatablesAffectedByYou()) { + static_cast(affectAllocatables.insert(a)); + } + } + + // If the re-arbitration source of Area/Zone (including any re-arbitration + // sources, if any reconciliation nests) becomes an Area/Zone affected by + // the re-arbitration area/zone, such Area/Zone is excluded from + // the re-arbitration target and the affected Area/Zone is re-arbitrated. + // Further, even if the affected Area/Zone is unarbitrated Allocatable + // at that time, it is excluded from the re-arbitration target of + // the affected Area. This is because it is sufficient to arbitrate + // during normal arbitration. + for (const auto& a : revisited) { + if (affectAllocatables.find(a) != affectAllocatables.end() + || (!a->isChecked())) { + static_cast(affectAllocatables.erase(a)); + } + } + std::list sortedAllocatables(affectAllocatables.begin(),affectAllocatables.end()); + sortedAllocatables.sort(&RBAAllocatable::compareIndex); + if (parentRollbacker != nullptr) { + std::shared_ptr rollbacker {std::make_shared()}; + parentRollbacker->addChild(rollbacker); + rollbacker->backup(sortedAllocatables); + } + + for (auto& affect : sortedAllocatables) { + // Remove Allocatable which will be re-arbitration from Allocatable + // that influenced Allocable during arbitration. + allocatable->removeAffectAllocatable(affect); + } + static_cast(revisited.insert(allocatable)); // Add to arbitrated Area + for (auto& affectAllocatable : sortedAllocatables) { + // @Deviation (EXP55-CPP,Rule-5_2_5,A5-2-3) + // [Contents that deviate from the rules] + // This is a 'const_cast' expression that strips away a 'const' or + // 'volatile' qualifier. + // [Why there is no problem if it deviate from the rules] +   // Confirmed that there is no problem from the design point of view. + // We won't fix it now because we need to redesign the class, but + // no much effort as of now. + RBAAllocatable* allo {const_cast(affectAllocatable)}; + + // Initialize the check flag of the Allocatable that performs the + // re-arbitration of the affetcted Allocatable + // If the affected Allocables are cleared in advance, a skip occurred in + // the constraint expression evaluation during the re-arbitration of + // the affected Allocatable that was carried out earlier, after that + // re-arbitration will work during re-arbitration of affected Allocatable. + // Therefore, clear check flag individually + // before re-arbitration of affected Allocable + allo->clearChecked(); + + LOG_arbitrateAreaLogLine( " " + + affectAllocatable->getSymbol() + "[" + + affectAllocatable->getElementName() + + "] affect allocatable check start"); + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Recursively calling arbitrateAllocatable() + // [Why there is no problem if it deviate from the rules] + // - This process is necessary for re-arbitration of the affected Area, + // - stack overflow will not occur becasue the infinite loop + // prevention process is imeplemented. + arbitrateAllocatable(allo, revisited, nest + 1, affectInfo, + parentRollbacker); + } + for(const RBAAllocatable* const revisitAllocatable : sortedAllocatables) { + static_cast(revisited.erase(revisitAllocatable)); + } + } + + // -------------------------------------------------- + // Delete temporary affect information + // to prevent infinite loop during re-arbitration + // -------------------------------------------------- + affectInfo->removeAffectInfo(allocatable); +#ifdef RBA_USE_LOG + RBALogManager::setIndent(nest-1); +#endif +} + +/** + * @brief Sort content state based on arbitration policy + * @param allocatable + * @param contentStates + * @return success/failure of sort + */ +bool +RBAArbitrator:: +sortContentStates(const RBAAllocatable* const allocatable, + std::list& states) const +{ + bool isResult {true}; + switch(allocatable->getAllocatableArbitrationPolicy()) { + case RBAArbitrationPolicy::FIRST_COME_FIRST: + states.sort(&RBAContentState::compareFirstComeFirst); + break; + case RBAArbitrationPolicy::LAST_COME_FIRST: + states.sort(&RBAContentState::compareLastComeFirst); + break; + case RBAArbitrationPolicy::PRIORITY_FIRST_COME_FIRST: + states.sort(&RBAContentState::comparePriorityFirstComeFirst); + break; + case RBAArbitrationPolicy::DEFAULT: + case RBAArbitrationPolicy::PRIORITY_LAST_COME_FIRST: + states.sort(&RBAContentState::comparePriorityLastComeFirst); + break; + default: + isResult = false; + break; + } + + return isResult; +} + +/** + * @brief Get re-arbitration list from judgment NG constraint + * @param totalRevisitAllocatables + * @param allocatable + * @param falseConstraints + * @param revisited + */ +void +RBAArbitrator:: +collectRevisitAllocatable(std::list* const totalRevisitAllocatables, + RBAAllocatable*& allocatable, + std::list& falseConstraints, + std::set& revisited) +{ + std::set revisitAllocatablesSet; + +  // Determine if re-arbitration should be done based on the constraint + // that the determination was NG + for(RBAConstraintImpl*& constraint : falseConstraints) { + // Get Contraint information + const RBAConstraintInfo* const info {constraint->getInfo()}; + // Allocatable, a candidate for re-arbitration + std::set rightFalseAllocatables; + + if (info->needsRearbitrationFor(allocatable)) { + info->collectRearbitrationTargetFor(allocatable, rightFalseAllocatables, false); + } + if (rightFalseAllocatables.empty()) { + // Non-implication constraint expression + // To ensure that "currently arbitrated allocable" does not lose to lower + // priority allocable, arbitration of low priority Allocable is performed + // if low priority Allocable is included in + // "re-arbitration candidate Allocable". + info->collectFalseAllocatables(rightFalseAllocatables); + bool isContainsLowPriorityAllocatable {false}; + for(const RBAAllocatable* const rightFalseAllocatable + : rightFalseAllocatables) { + if(RBAAllocatable::compareIndex(allocatable,rightFalseAllocatable)) { + // index is smaller for higher priority allocable + isContainsLowPriorityAllocatable = true; + break; + } + } + if(!isContainsLowPriorityAllocatable) { + continue; + } + } + + // Remove Allocable during arbitration from re-arbitration target + static_cast(rightFalseAllocatables.erase(allocatable)); + + // If even one Allocable candidate for re-arbitration has been + // re-arbitrated, re-arbitration will not be performed again. + // Go to next content assignment + for(const RBAAllocatable* const rightFalseAllocatable : rightFalseAllocatables) { + if(revisited.find(rightFalseAllocatable) != revisited.end()) { + return; + } + } + + // Set re-arbitration Allocable + for(const RBAAllocatable* const alloc : rightFalseAllocatables) { + static_cast(revisitAllocatablesSet.insert(alloc)); + } + } + + // Re-arbitration Allocatable exists + if(!(revisitAllocatablesSet.empty())) { + // copy std::set to std::list + static_cast(totalRevisitAllocatables->insert(totalRevisitAllocatables->end(), + revisitAllocatablesSet.begin(), + revisitAllocatablesSet.end())); + // Sort re-arbitration Areas in ascending order based on priority + // It is necessary to sort by index comparison considering the order of models. + totalRevisitAllocatables->sort(&RBAAllocatable::compareIndex); + } +} + +/** + * Confirm cancellation of all content status + * to cancel Request which lost in arbitration + */ +void +RBAArbitrator:: +postArbitrate() +{ +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine("----Cancel Request----"); +#endif + for(const RBAContentState* const state : model_->getContentStates()) { +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine("Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] check start"); +#endif + static_cast(cancelChecked_.insert(state)); + if(!result_->isActive(state)) { +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is not Active skip"); +#endif + continue; + } + if(result_->isAlreadyOutputting(state)) { +#ifdef RBA_USE_LOG + std::string contTypeName; + if(state->isViewContentState()) { + contTypeName = "Visible"; + } + else { + contTypeName = "Sounding"; + } + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is "+contTypeName+" skip"); +#endif + continue; + } + + changeContentStateCancelWithPolicy(state); + } + +#ifdef RBA_USE_LOG + // Log output for coverage of request cancellation + for(const RBAContentState* state : model_->getContentStates()) { + std::string contentName = state->getOwner()->getElementName(); + std::string stateName = state->getElementName(); + std::string canceled = isCancel(state) ? "t" : "f"; + RBALogManager::coverageCanceledRequestLogLine( + contentName + "," + stateName + ',' +canceled); + } +#endif +} + +/** + * @brief Change the cancellation information of hidden Content status + based on arbitration results and cancellation policy + * @param state + */ +void +RBAArbitrator:: +changeContentStateCancelWithPolicy(const RBAContentState* const state) +{ + switch(dynamic_cast(state->getOwner())->getContentLoserType()) { + case RBAContentLoserType::GOOD_LOSER: +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is Canceled because GOOD_LOSER"); +#endif + setCancel(state, true); + break; + case RBAContentLoserType::NEVER_GIVEUP: +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is not Canceled because NEVER_GIVEUP"); +#endif + setCancel(state, false); + break; + case RBAContentLoserType::DO_NOT_GIVEUP_UNTIL_WIN: + if(state->isModelElementType(RBAModelElementType::ViewContentState)) { + if(result_->isPreVisible(dynamic_cast(state))) { +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is Canceled because DO_NOT_GIVEUP_UNTIL_WIN"); +#endif + setCancel(state, true); + } else { +#ifdef RBA_USE_LOG + RBALogManager::cancelRequestLogLine(" Content["+ + state->getOwner()->getElementName()+"::"+ + state->getElementName()+ + "] is not Canceled because DO_NOT_GIVEUP_UNTIL_WIN"); +#endif + setCancel(state, false); + } + } + else { + if(result_->isPreSounding(dynamic_cast(state))) { + setCancel(state, true); + } else { + setCancel(state, false); + } + } + break; + default: + break; + } +} + +#ifdef RBA_USE_LOG +void +RBAArbitrator:: +checkAllConstraints() +{ + std::string log; + LOG_arbitrateConstraintLogLine("----Check All Constraint----"); + + if(simulationMode_) { + for(const RBAConstraintImpl* constraint : model_->getConstraintImpls()) { + bool result = const_cast(constraint)->execute(this); + if(result == false) { + result_->addFailedConstraint(constraint); + } + if (constraint->isRuntime() == true) { + log += "online "; + } else { + log += "offline "; + } + log += "constraint[" + constraint->getElementName() + "] "; + log += "result[" + RBALogManager::boolToString(result) + "]\n"; + } + if (log.empty() != true ) { + log.erase(log.end() - 1, log.end()); // Remove last line break + } + } + +} +#endif + +void +RBAArbitrator:: +checkCancelContent() const +{ + for(const RBAViewContentState* const viewState + : result_->getActiveViewContentStates()) { + if(result_->isCancel(viewState)) { + result_->cancelContentState(dynamic_cast(viewState)); + } + } + for(const RBASoundContentState* const soundState + : result_->getActiveSoundContentStates()) { + if(result_->isCancel(soundState)) { + result_->cancelContentState(dynamic_cast(soundState)); + } + } +} + +/** + * @brief Update display and non-dislay Allocatable List + */ +void +RBAArbitrator:: +updateResult() +{ + // Deactivate canceled Content + result_->updateActiveContentStates(); + + // Update coordinates of Area + for(auto& area : result_->getVisibleAreas()) { + const RBAAreaImpl* const areaImpl {dynamic_cast(area)}; + const auto posCont = model_->findPositionContainerImpl(area->getName()); + const auto sizeObj = result_->getSize(area); + if((posCont != nullptr) && (sizeObj != nullptr)) { + const auto offset = posCont->getOffset(sizeObj->getName()); + const_cast(areaImpl)->setOffsetX(offset.first); + const_cast(areaImpl)->setOffsetY(offset.second); + } + } + + // Set output Content state list + std::set outputtingContentStateSet; + for(auto& alloc : result_->getOutputtingAllocatables()) { + const auto state = result_->getAllocatedContentState(alloc); + static_cast(outputtingContentStateSet.insert(state)); + } + for(auto& state : outputtingContentStateSet) { + static_cast(result_->addOutputtingContentState(state)); + } + + for(auto& state : result_->getActiveContentStates()) { + // If the Area allocated in the display request is not displayed, + // set it to "Stanby Content". + const auto allocs = result_->getAllocatable(state); + if(allocs.empty()) { + result_->addStandbyContent(dynamic_cast(state->getOwner())); + } + } +} + +/** + * ### Generate result information + * + * Generate animation information (RBAViewAction) and register it in the + * viewActions list of RBAResult. + * The animation information generation pattern is as follows. + * | Area A(pre) | Area B(pre) | Area A(cur) | Area B(cur) | type | + * |:-: |:-: |:-: |:-: |:---- | + * | (none) | - | **content** | - | TRANSITON_ADD | + * | **content** | - | (none) | - | TRANSITION_REMOVE | + * | **contentA** | - | **contentB** | - | TRANSITION_REPLACE | + * | **content** | (none) | (none) | **content** | MOVE | + */ +void +RBAArbitrator:: +createResultData() +{ + std::list> actions; + // Check the Areas that have not changed + std::set stableAreas; + for(const RBAArea* const preArea : result_->getPreVisibleAreas()) { + if(result_->isVisible(preArea)) { + const RBAViewContent* const curContent {result_->getContentState(preArea)->getOwner()}; + const RBAViewContent* const preContent {result_->getPreContentState(preArea)->getOwner()}; + if(curContent == preContent) { + static_cast(stableAreas.insert(preArea)); + } + } + } + // Check "MOVE" + std::set movedContents; + for(const RBAArea* curArea : result_->getVisibleAreas()) { + // Current display Area + const RBAViewContentState* curState {result_->getContentState(curArea)}; + const RBAViewContent* const curContent {curState->getOwner()}; + // Skip stable Area + if(stableAreas.find(curArea) != stableAreas.end()) { + continue; + } + for(const RBAArea* preArea : result_->getPreVisibleAreas()) { + // Do not consider stable areas to have changed + if (stableAreas.find(preArea) != stableAreas.end()) { + continue; + } + // Previous display Area + const RBAViewContent* const preContent {result_->getPreContentState(preArea)->getOwner()}; + if(curContent == preContent) { + // "MOVE" if there is matching content + actions.push_back(std::make_unique(preArea, curArea, + curState)); + // Check moved Content + static_cast(movedContents.insert(curState->getOwner())); + } + } + } + // Check "REMOVE" + for(const RBAArea* preArea : result_->getPreVisibleAreas()) { + // Skip stable Area + if(stableAreas.find(preArea) != stableAreas.end()) { + continue; + } + const RBAViewContentState* preState {result_->getPreContentState(preArea)}; + // Skip if Content is "MOVE" + if(movedContents.find(preState->getOwner()) + != movedContents.end()) { + continue; + } + if(!result_->isVisible(preArea)) { + // If the previously displayed Area isn't displayed, it is REMOVE. + actions.push_back(std::make_unique( + RBAViewActionType::TRANSITION_REMOVE, preArea, preState)); + } + } + // Check Examine ADD/REMOVE and REPLACE related to MOVE + for(const RBAArea* curArea : result_->getVisibleAreas()) { + // Display Area at this time + // Skip stable Area + if(stableAreas.find(curArea) != stableAreas.end()) { + continue; + } + const RBAViewContentState* curState {result_->getContentState(curArea)}; + const RBAViewContent* const curContent {curState->getOwner()}; + const RBAViewContentState* preState {result_->getPreContentState(curArea)}; + + if(movedContents.find(curContent) != movedContents.end()) { + if((preState != nullptr) && (!result_->isVisible(preState))) { + // If the previously displayed content isn't displayed, it is REMOVE. + actions.push_back(std::make_unique( + RBAViewActionType::TRANSITION_REMOVE, + curArea, preState)); + } + else { + continue; + } + } + else if(result_->isPreVisible(curArea)) { + // It was the display Area last time + // If pre is MOVE content + const RBAViewContent* const preContent {preState->getOwner()}; + if(movedContents.find(preContent) != movedContents.end()) { + // Content at this time is ADD + actions.push_back(std::make_unique( + RBAViewActionType::TRANSITION_ADD, + curArea, curState)); + } + else if(curContent != preContent) { + // REPLACE because the content is different + actions.push_back(std::make_unique( + RBAViewActionType::TRANSITION_REPLACE, + curArea, preState, curState)); + } else { + ; + } + } + else { + // ADD because it was not the display Area last time + actions.push_back(std::make_unique( + RBAViewActionType::TRANSITION_ADD, + curArea, curState)); + } + } + + // Sort and register + actions.sort(&compareViewAction); + for(auto& action : actions) { + result_->addViewAction(action); + } +} + +void +RBAArbitrator::differenceArbitrate() +{ +#ifdef RBA_USE_LOG + // Set request information in log + RBALogManager::setType(RBALogManager::TYPE_REQUEST); + logRequestArbitration(); + RBALogManager::setType(RBALogManager::TYPE_PREVIOUS_RESULT); + logPreResultArbitration(); + logRequestForCoverage(); +#endif + + for (auto& a : model_->getSortedAllocatables()) { + a->clearStatus(); + } + + // ---------------------------------------------------------- + // Arbitration + // ---------------------------------------------------------- + // Priority and post-win arbitoration + // (Value arbitration is the same as priority arbitration) +#ifdef RBA_USE_LOG +RBALogManager::setType(RBALogManager::TYPE_ARBITRATE); +#endif + arbitrate(model_->getSortedAllocatables()); + + // ---------------------------------------------------------- + // Post processing of arbitration + // ---------------------------------------------------------- +#ifdef RBA_USE_LOG +RBALogManager::setType(RBALogManager::TYPE_CANCEL_REQUEST); +#endif + // when the constraint expression is evaluated by satisfiesConstraints(), + // if the cancel state is different from the time when execute() is executed, + // the result may be false. Therefore, it is necessary to store + // the state before cancellation processing. + // When performing the constraint expression evaluation in + // satisfiedConstraints(), restore to this value and evaluate. + resultSetForSatisfiesConstraints_ = std::make_unique( + *result_->getCurResultSet()); + postArbitrate(); + + // Move offline Constraint +#ifdef RBA_USE_LOG +RBALogManager::setType(RBALogManager::TYPE_CHECK_ALL_CONSTRAINTS); + checkAllConstraints(); +#endif + + // ---------------------------------------------------------- + // Update Content state + // ---------------------------------------------------------- + for (auto& c : model_->getContents()){ + const_cast(c)->updateStatus(result_.get()); + } + + backupResultSet_ = result_->createBackupCurrentResultSet(); + nextResultSet_ = result_->createNextCurrentResultSet(); + +#ifdef RBA_USE_LOG + logResultForCoverage(); +#endif +} + +bool +RBAArbitrator:: +checkConstraints( std::list& constraints, + std::list& falseConstraints, + const RBAAllocatable* const allocatable) +{ + bool containsSkip {false}; + for (const auto& constraint : constraints) { + const bool isPassed {constraint->execute(this)}; + if (isPassed == false) { + falseConstraints.push_back(constraint); + } + if (constraint->getInfo()->isExceptionBeforeArbitrate()) { + if (constraint->getInfo()->needsReRearbitrationFor(allocatable)) { + containsSkip = true; + } + } + } + return containsSkip; +} + +bool +RBAArbitrator:: +checkConstraintAndReArbitrate(RBAAllocatable* allocatable, + std::set& revisited, + const std::int32_t nest, + RBAAffectInfo* const affectInfo, + RBARollbacker* const parentRollbacker, + std::list& constraints, + bool * const isSkipped, + const bool isFinal) +{ + bool isPassed {false}; + std::list falseConstraints; + const bool containsSkip {checkConstraints(constraints, falseConstraints, allocatable)}; + if(falseConstraints.empty()) { + *isSkipped = (*isSkipped || containsSkip); + if(!containsSkip && !*isSkipped && isFinal) { + static_cast(revisited.insert(allocatable)); + } + isPassed = true; + } else { + std::list revisitAllocatables; + collectRevisitAllocatable(&revisitAllocatables, allocatable, falseConstraints, revisited); + if(!(revisitAllocatables.empty())) { + // There is re-arbitration Allocatable. + // Generates backup information for rollback when re-arbitration fails. + // For efficiency, instantiate only once when re-arbitration is needed + // for the first time. + // Since it is backed up after content allocation, + // it is necessary to set NULL to the allocated content after rollback. + + // Rollback information when arbitration fails + std::shared_ptr rollbacker {std::make_shared()}; + if (parentRollbacker != nullptr) { + parentRollbacker->addChild(rollbacker); + } + rollbacker->backup(revisitAllocatables); + // Initialize all re-arbitration Allocatable + for (auto& a : revisitAllocatables) { + const_cast(a)->clearChecked(); + } + // -------------------------------------------------- + // Re-arbitrate "Allocatable" that has not been re-arbitrated + // in the re-arbitration candidate list + // -------------------------------------------------- + static_cast(revisited.insert(allocatable)); + for(const RBAAllocatable* const revisitAllocatable : revisitAllocatables) { + LOG_arbitrateAreaLogLine( " " + + revisitAllocatable->getSymbol() + "[" + + revisitAllocatable->getElementName() + + "] revisit allocatable check start"); + arbitrateAllocatable(const_cast(revisitAllocatable), + revisited, nest + 1, affectInfo, rollbacker.get()); + } + for(const RBAAllocatable* const revisitAllocatable : revisitAllocatables) { + static_cast(revisited.erase(revisitAllocatable)); + } + // -------------------------------------------------- + // Check if content allocation succeeded as a result of re-arbitration + // -------------------------------------------------- + falseConstraints.clear(); + static_cast(checkConstraints(constraints, falseConstraints, allocatable)); + if (falseConstraints.empty()) { + // The content of the allocatable allocation is fixed by re-arbitration, + // so exit the loop and proceed to the next allocatable. + // In some cases, "Allocatable" is re-arbitrated due to recursion and + // allocated Content is lost, but go to the next Allocable because + // all contents have been checked + isPassed = true; + } else { + // Roll back arbitration status and affected information + rollbacker->rollback(); + if (parentRollbacker != nullptr) { + parentRollbacker->removeChild(rollbacker); + } + } + } + } + if (isPassed == false) { + //Collect Areas that affected the area in arbitration status + std::set allocatablesWhichHaveAffectedToThisAllocatable; + + for (const RBAConstraintImpl* const constraint : falseConstraints) { + constraint->getInfo()->collectAffectedAllocatables( + false, allocatablesWhichHaveAffectedToThisAllocatable, false, + false); + } + static_cast(allocatablesWhichHaveAffectedToThisAllocatable.erase(allocatable)); + + // Record fact that affected the area being arbitrated on Area that + // affected Area during arbitration. + // The re-arbitration of the affected area is recorded in AffectInfo, + // so it does not record the re-arbitrated area. + for (const RBAAllocatable* const a : allocatablesWhichHaveAffectedToThisAllocatable) { + if (!(affectInfo->alreadyKnowsThatFormerHasAffectedToLatter(a, + allocatable))) { + const_cast(a)->addAllocatableWhichHasBeenAffectedByYou( + allocatable); + affectInfo->addInfoThatFormerAffectedToLatter(a, allocatable); + } + } + } + return isPassed; +} + +void +RBAArbitrator:: +setCancel(const RBAContentState* const state, const bool checked) +{ + result_->setCancel(state, checked); +} + +bool +RBAArbitrator:: +isCancel(const RBAContentState* const state) const +{ + if(state->isViewContentState()) { + return result_->isCancel(state); + } + else { + return result_->isCancel(state); + } +} + +void +RBAArbitrator:: +getSortedContentStates(const RBAAllocatable* const allocatable, + std::list& contentStates) const +{ + for (const RBAContent* const content : allocatable->getInternalContents()) { + const RBAContentState* const state {result_->getActiveState(content)}; + if (state != nullptr) { + contentStates.push_back(state); +#ifdef RBA_USE_LOG + } else { + RBALogManager::arbitrateContentLogLine( + " Content[" + content->getElementName() + "] is not Active skip"); +#endif + } + } + static_cast(sortContentStates(allocatable, contentStates)); + // Add null at the end, to evaluate constraint expression when unassigned + contentStates.push_back(nullptr); +} + +std::int32_t +RBAArbitrator:: +getViewActionPriority(const RBAViewActionType viewActionType) +{ + std::int32_t result{0}; + + switch(viewActionType) { + case RBAViewActionType::TRANSITION_REMOVE: + result = 4; + break; + case RBAViewActionType::MOVE: + result = 3; + break; + case RBAViewActionType::TRANSITION_ADD: + result = 2; + break; + case RBAViewActionType::TRANSITION_REPLACE: + result = 1; + break; + default: + break; + } + + return result; +} + +bool +RBAArbitrator:: +compareViewAction(const std::unique_ptr& lhs, + const std::unique_ptr& rhs) +{ + const std::int32_t lval {getViewActionPriority(lhs->getViewActionType())}; + const std::int32_t rval {getViewActionPriority(rhs->getViewActionType())}; + + return lval > rval; +} + +RBAResultImpl* +RBAArbitrator::getResult() const +{ + return result_.get(); +} + +void RBAArbitrator::setResult(std::unique_ptr result) +{ + result_ = std::move(result); +} + +std::set& RBAArbitrator::getCancelChecked() +{ + return cancelChecked_; +} + +std::unique_ptr& RBAArbitrator::getResultRef() const +{ + return result_; +} + +std::unique_ptr& RBAArbitrator::getNextResultSet() +{ + return nextResultSet_; +} + +void RBAArbitrator::setNextResultSet(std::unique_ptr nextResultSet) +{ + nextResultSet_ = std::move(nextResultSet); +} + +std::unique_ptr& RBAArbitrator::getBackupResultSet() +{ + return backupResultSet_; +} + +void RBAArbitrator::setBackupResultSet(std::unique_ptr backupResultSet) +{ + backupResultSet_ = std::move(backupResultSet); +} + +std::unique_ptr& RBAArbitrator::getReservedResultSet() +{ + return reservedResultSet_; +} + +void RBAArbitrator::setReservedResultSet(std::unique_ptr reservedResultSet) +{ + reservedResultSet_ = std::move(reservedResultSet); +} + +std::recursive_mutex& RBAArbitrator::getMutex() const +{ + return mutex_; +} + +#ifdef RBA_USE_LOG +void RBAArbitrator::setSimulationMode(bool simulationMode) +{ + simulationMode_ = simulationMode; +} +#endif + +std::deque>& RBAArbitrator::getRequestQue() +{ + return requestQue_; +} + +#ifdef RBA_USE_LOG +/** + * Output request information for log view + */ +void +RBAArbitrator::logRequestArbitration() +{ + const std::list allocatables = + model_->getAllocatables(); + RBALogManager::requestLogLine("----Request Information----"); + RBALogManager::requestLogLine( + "Allocatable Count:" + std::to_string(allocatables.size())); + for (const RBAAllocatable* allocatable : allocatables) { + RBALogManager::requestLogLine( + " " + allocatable->getSymbol() + "[" + allocatable->getElementName() + + "] policy[" + allocatable->getArbitrationPolicyString() + + "] visibility[" + allocatable->getVisibilityString() + "]"); + } + + const std::list contentStates = model_ + ->getContentStates(); + RBALogManager::requestLogLine( + "ContentState Count:" + std::to_string(contentStates.size())); + for (const RBAContentState* contentState : contentStates) { + std::string active; + if (contentState->getModelElementType() == RBAModelElementType::ViewContentState) { + active = RBALogManager::boolToString( + result_->isActive( + dynamic_cast(contentState))); + } else { + active = RBALogManager::boolToString( + result_->isActive( + dynamic_cast(contentState))); + } + RBALogManager::requestLogLine( + " " + dynamic_cast(contentState->getOwner())->getSymbol() + "[" + + contentState->getOwner()->getElementName() + "::" + + contentState->getElementName() + "] priority[" + + contentState->getPriorityString() + "] isActive[" + active + + "] order[" + contentState->getOrderString() + "]"); + } + + const std::list scenes = model_->getScenes(); + RBALogManager::requestLogLine("Scene Count:" + std::to_string(scenes.size())); + for (const RBAScene* scene : scenes) { + RBALogManager::requestLogLine( + " Scene[" + scene->getName() + "] isActive[" + + RBALogManager::boolToString(result_->isActive(scene)) + + "]"); + } + + std::list constraints = model_->getConstraints(); + RBALogManager::requestLogLine( + "Constraint Count:" + std::to_string(constraints.size())); + for (RBAConstraint* constraint : constraints) { + RBAConstraintImpl* impl = dynamic_cast(constraint); + RBALogManager::requestLogLine( + " Constraint[" + impl->getName() + "] Expression[" + + impl->getExpression()->getExpressionText() + "] runtime[" + + RBALogManager::boolToString(impl->isRuntime()) + "]"); + } + +} + +/** + * Output previous arbitration result for log view + */ +void +RBAArbitrator::logPreResultArbitration() +{ + RBALogManager::resultLogLine("----Previous Result Information----"); + + auto allocs = model_->getAllocatables(); + RBALogManager::resultLogLine("Allocatable TotalCount:" + + std::to_string(allocs.size())); + for (auto& alloc : allocs) { + auto contentState = result_->getPreContentState(alloc); + auto hidden = result_->isPreHidden(alloc); + std::string str = " " + alloc->getSymbol() + + "[" + alloc->getElementName() + "] Content["; + if (contentState == nullptr) { + str += "null"; + } else { + str += contentState->getOwner()->getElementName() + + "::" + contentState->getElementName(); + } + str += "] " + alloc->getHiddenSymbol() + + "[" + RBALogManager::boolToString(hidden) + "]"; + if (alloc->isZone() == true) { + str += " attenuated["; + str += RBALogManager::boolToString( + result_->isPreAttenuated(dynamic_cast(alloc))); + str += "]"; + } + RBALogManager::resultLogLine(str); + if (contentState && !hidden) { + RBALogManager::coveragePrevResultLogLine( + "A," + alloc->getElementName() + "," + + contentState->getOwner()->getElementName() + "," + + contentState->getElementName()); + } + } + + auto contents = model_->getContents(); + RBALogManager::resultLogLine("Content TotalCount:" + + std::to_string(contents.size())); + for (auto& content : contents) { + auto state = result_->getPreActiveState(content); + bool isOutputting = false; + bool isActive = false; + if (state != nullptr) { + isActive = true; + isOutputting = result_->isPreOutputting(state); + } + RBALogManager::resultLogLine( + " " + content->getSymbol() + "[" + content->getElementName() + "] " + + content->getVisibleSymbol() + "[" + + RBALogManager::boolToString(isOutputting) + "] active[" + + RBALogManager::boolToString(isActive) + "]"); + for (auto alloc : content->getAllocatables()) { + auto allocatedState = result_->getPreContentState(alloc); + if ((allocatedState != nullptr) + && (allocatedState->getOwner() == content)) { + RBALogManager::resultLogLine( + " allocated " + alloc->getSymbol() + "[" + + alloc->getElementName() + "]"); + } + } + } +} + +/** + * Output current arbitration result for log view + */ +void +RBAArbitrator::logResultArbitration() +{ + RBALogManager::resultLogLine("----Result Information----"); + + const std::list allocatables + = model_->getAllocatables(); + RBALogManager::resultLogLine("Allocatable TotalCount:" + std::to_string(allocatables.size())); + for(const RBAAllocatable* allocatable : allocatables) { + const RBAContentState* contentState = result_->getContentState(allocatable); + std::string str = " "; + str += allocatable->getSymbol(); + str += "["; + str += allocatable->getElementName(); + str += "] Content["; + if (contentState == nullptr) { + str += "null"; + } else { + str += contentState->getOwner()->getElementName() + "::" + + contentState->getElementName(); + } + str += "] "; + str += allocatable->getHiddenSymbol(); + str += "["; + str += RBALogManager::boolToString(result_->isHidden(allocatable)); + str += "]"; + if (allocatable->isZone() == true) { + str += " attenuated["; + str += RBALogManager::boolToString(result_->isAttenuated(dynamic_cast(allocatable))); + str += "]"; + } + RBALogManager::resultLogLine(str); + } + + const std::list contents = model_->getContents(); + RBALogManager::resultLogLine("Content TotalCount:" + std::to_string(contents.size())); + for(const RBAContent* content : contents) { + bool isOutputting = false; + bool isCancel = false; + const RBAContentState* state = result_->getActiveState(content); + if(state != nullptr) { + isOutputting = result_->isOutputting(state); + } else { + for(const RBAContentState* state : content->getStates()) { + isCancel |= result_->isCancel(state); + } + } + RBALogManager::resultLogLine(" " + + content->getSymbol() + + "[" + + content->getElementName() + + "] " + + content->getVisibleSymbol() + + "[" + + RBALogManager::boolToString(isOutputting) + + "] cancel[" + + RBALogManager::boolToString(isCancel) + + "]"); + for(const RBAAllocatable* allocatable : content->getAllocatables()) { + const RBAContentState* allocatedState + = result_->getContentState(allocatable); + if((allocatedState != nullptr) && (allocatedState->getOwner() == content)) { + RBALogManager::resultLogLine(" allocated " + + allocatable->getSymbol() + "[" + + allocatable->getElementName() + "]"); + } + } + } +} + +/** + * For coverage: Output request information + */ +void +RBAArbitrator::logRequestForCoverage() +{ + for(const RBAContentState* contentState : model_->getContentStates()) { + std::ostringstream oss; + oss << "C,"; + if(result_->isActive(contentState)) { + oss << "on,"; + } + else { + oss << "off,"; + } + oss << contentState->getOwner()->getElementName() << ","; + oss << contentState->getElementName() << ","; + oss << contentState->getContentStateOrder(); + RBALogManager::coverageRequestLogLine(oss.str()); + } + for(const RBAScene* scene : model_->getScenes()) { + std::ostringstream oss; + oss << "S,"; + if(result_->isActive(scene)) { + oss << "on,"; + } + else { + oss << "off,"; + } + oss << scene->getName(); + for(const auto& name : scene->getPropertyNames()) { + std::int32_t value {result_->getSceneProperty(scene, name)}; + oss << ","; + oss << name; + oss << ":"; + oss << value; + } + RBALogManager::coverageRequestLogLine(oss.str()); + } +} + +/** + * For coverage: Output result information + */ +void +RBAArbitrator::logResultForCoverage() +{ + for(const RBAAllocatable* allocatable : model_->getAllocatables()) { + std::ostringstream oss; + oss << "A,"; + oss << allocatable->getElementName() + ","; + const RBAContentState* contentState = result_->getContentState(allocatable); + if((contentState != nullptr) && (!result_->isHidden(allocatable))) { + oss << contentState->getOwner()->getElementName(); + } + RBALogManager::coverageResultLogLine(oss.str()); + } +} + +void +RBAArbitrator::setLogToResult() +{ + std::ostringstream oss; + oss << RBALogManager::getAllConstraintLog(); + oss << RBALogManager::getRequestLog(); + oss << RBALogManager::getPreviousResultLog(); + oss << RBALogManager::getArbitrateLog(); + oss << RBALogManager::getCancelRequestLog(); + oss << RBALogManager::getCheckAllConstraintLog(); + oss << RBALogManager::getResultLog(); + result_->setLog(oss.str()); +} +#endif + +} diff --git a/src/core/logic/RBABackUpAllocatable.cpp b/src/core/logic/RBABackUpAllocatable.cpp new file mode 100644 index 0000000..2843db1 --- /dev/null +++ b/src/core/logic/RBABackUpAllocatable.cpp @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * BackUpAllocatable class + */ + +#include "RBABackUpAllocatable.hpp" + +namespace rba +{ + +RBABackUpAllocatable::RBABackUpAllocatable(const std::string& name) + : RBARuleObject{name}, + RBAAllocatable{name} +{ +} + +} + diff --git a/src/core/logic/RBABackUpAllocatable.hpp b/src/core/logic/RBABackUpAllocatable.hpp new file mode 100644 index 0000000..a57aa01 --- /dev/null +++ b/src/core/logic/RBABackUpAllocatable.hpp @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * BackUpAllocatable class header + */ + +#ifndef RBABACKUPALLOCATABLE_HPP +#define RBABACKUPALLOCATABLE_HPP + +#include "RBAAllocatable.hpp" + +namespace rba +{ +class RBABackUpAllocatable : public RBAAllocatable +{ +public: + explicit RBABackUpAllocatable(const std::string& name); + RBABackUpAllocatable(const RBABackUpAllocatable&)=delete; + RBABackUpAllocatable(const RBABackUpAllocatable&&)=delete; + RBABackUpAllocatable& operator=(const RBABackUpAllocatable&)=delete; + RBABackUpAllocatable& operator=(const RBABackUpAllocatable&&)=delete; + virtual ~RBABackUpAllocatable()=default; + +}; + +} + +#endif diff --git a/src/core/logic/RBACommonMakerTable.cpp b/src/core/logic/RBACommonMakerTable.cpp new file mode 100644 index 0000000..dde13b7 --- /dev/null +++ b/src/core/logic/RBACommonMakerTable.cpp @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBACommonMakerTable.cpp +/// @brief Expression element maker table class definition file + +#include "RBACommonMakerTable.hpp" +#include "RBAActiveStateMaker.hpp" +#include "RBAAllocatedContentMaker.hpp" +#include "RBAActiveContentsMaker.hpp" +#include "RBAAndOperatorMaker.hpp" +#include "RBAContentValueMaker.hpp" +#include "RBAExistsOperatorMaker.hpp" +#include "RBAForAllOperatorMaker.hpp" +#include "RBAGetAllocatablesMaker.hpp" +#include "RBAGetContentsListMaker.hpp" +#include "RBAGetPropertyMaker.hpp" +#include "RBAHasBeenDisplayedMaker.hpp" +#include "RBAHasComeEarlierThanMaker.hpp" +#include "RBAHasComeLaterThanMaker.hpp" +#include "RBAIfStatementMaker.hpp" +#include "RBAImpliesOperatorMaker.hpp" +#include "RBAIntegerValueMaker.hpp" +#include "RBAIsActiveMaker.hpp" +#include "RBAIsEqualToOperatorMaker.hpp" +#include "RBAIsGreaterThanEqualOperatorMaker.hpp" +#include "RBAIsGreaterThanOperatorMaker.hpp" +#include "RBAIsLowerThanEqualOperatorMaker.hpp" +#include "RBAIsLowerThanOperatorMaker.hpp" +#include "RBAIsOnMaker.hpp" +#include "RBAIsTypeOfOperatorMaker.hpp" +#include "RBALambdaExpressionMaker.hpp" +#include "RBAMaxOperatorMaker.hpp" +#include "RBAMemberFeatureReferenceMaker.hpp" +#include "RBAMinOperatorMaker.hpp" +#include "RBASelectOperatorMaker.hpp" +#include "RBANotOperatorMaker.hpp" +#include "RBAObjectCompareMaker.hpp" +#include "RBAObjectReferenceMaker.hpp" +#include "RBAOrOperatorMaker.hpp" +#include "RBAPlusOperatorMaker.hpp" +#include "RBAPreviousModifierMaker.hpp" +#include "RBASetOfOperatorMaker.hpp" +#include "RBASizeOperatorMaker.hpp" +#include "RBAStateValueMaker.hpp" +#include "RBAVariableMaker.hpp" +#include "RBAConstraintMaker.hpp" +#include "RBASceneMaker.hpp" +#include "RBAModelElement.hpp" + +namespace rba +{ + +RBACommonMakerTable::RBACommonMakerTable() + : RBAAbstractMakerTable{} +{ + addTag("scenes"); + addTag("constraints"); + addTag("postconstraints"); + addTag("rules"); +} + +std::list> +RBACommonMakerTable::getMakers() const +{ + std::list> makers; + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + makers.push_back(std::make_unique()); + RBAModelElementMaker::addMaker("SCENE", std::make_unique()); + + return makers; +} + +} diff --git a/src/core/logic/RBACommonMakerTable.hpp b/src/core/logic/RBACommonMakerTable.hpp new file mode 100644 index 0000000..ae18dad --- /dev/null +++ b/src/core/logic/RBACommonMakerTable.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBACommonMakerTable.hpp +/// @brief Expression element maker table class header + +#ifndef RBACOMMONMAKERTABLE_HPP +#define RBACOMMONMAKERTABLE_HPP + +#include "RBAAbstractMakerTable.hpp" + +namespace rba +{ + +class DLL_EXPORT RBACommonMakerTable : public RBAAbstractMakerTable +{ +public: + RBACommonMakerTable(); + RBACommonMakerTable(const RBACommonMakerTable&)=delete; + RBACommonMakerTable(const RBACommonMakerTable&&)=delete; + RBACommonMakerTable& operator=(const RBACommonMakerTable&)=delete; + RBACommonMakerTable& operator=(const RBACommonMakerTable&&)=delete; + virtual ~RBACommonMakerTable()=default; + +public: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list> getMakers() const override; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/logic/RBAConstraintInfo.cpp b/src/core/logic/RBAConstraintInfo.cpp new file mode 100644 index 0000000..b208c5f --- /dev/null +++ b/src/core/logic/RBAConstraintInfo.cpp @@ -0,0 +1,695 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// ConstraintInfo class + +#include +#include "RBAAllocatable.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAExpression.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void RBAConstraintInfo::setExpression(const RBAExpression* const expression) +{ + expression_ = expression; +} + +const RBAExpression* +RBAConstraintInfo::getExpression() const +{ + return expression_; +} + +void RBAConstraintInfo::addOperandAllocatable(const RBAAllocatable* const operandAllocatable) +{ + static_cast(operandAllocatable_.insert(operandAllocatable)); +} + +void RBAConstraintInfo::setResult(const RBAExecuteResult result) +{ + result_ = result; +} + +RBAConstraintInfo* +RBAConstraintInfo::getChild(const std::uint32_t index) const +{ + const std::size_t requiredSize {static_cast(index + 1U)}; + if (children_.size() < requiredSize) { + children_.resize(requiredSize, std::make_unique()); + } + // Use "[]" instead of "at" because it doesn't access out of range + return children_[static_cast(index)].get(); +} + +void RBAConstraintInfo::setChild(const std::shared_ptr info) +{ + // This function is used in "let" expressions, which generate a new + // "ConstraintInfo" on each evaluation. + // Therefore, in the case of "add", "children" will be added for each arbitration, + // so use "set" to set "children" for each arbitration. + children_ = { info }; +} + +void RBAConstraintInfo::addTrueAllocatable(const RBAAllocatable* const allocatable) +{ + static_cast(trueAllocatables_.insert(allocatable)); +} + +void RBAConstraintInfo::addFalseAllocatable(const RBAAllocatable* const allocatable) +{ + static_cast(falseAllocatables_.insert(allocatable)); +} + +void RBAConstraintInfo::addTrueAllocatableFromOperand() +{ + for (const auto& c : children_) { + for (const auto& a : c->operandAllocatable_) { + static_cast(trueAllocatables_.insert(a)); + } + } +} + +void RBAConstraintInfo::addFalseAllocatableFromOperand() +{ + for (const auto& c : children_) { + for (const auto& a : c->operandAllocatable_) { + static_cast(falseAllocatables_.insert(a)); + } + } +} + +void RBAConstraintInfo::clearFalseAllocatable() +{ + falseAllocatables_.clear(); +} + +/// TCheck whether to invert True/False +/// @return +bool RBAConstraintInfo::isRevert() const +{ + if ((expression_ != nullptr) + && expression_->isModelElementType(RBAModelElementType::NotOperator)) { + return true; + } + return false; +} + +bool RBAConstraintInfo::isSizeOperator() const +{ + if ((expression_ != nullptr) + && (expression_->isModelElementType(RBAModelElementType::SizeOperator))) { + return true; + } + return false; +} + +const bool RBAConstraintInfo::isImplies() const +{ + if ((expression_ != nullptr) + && (expression_->isModelElementType(RBAModelElementType::ImpliesOperator) + || expression_->isModelElementType(RBAModelElementType::IfStatement))) { + return true; + } + return false; +} + +void RBAConstraintInfo::clear() +{ + for (const std::shared_ptr& child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // recursively calling clear() + //  [Reason that there is no problem if the rule is deviated] + // ConstraintInfo is created for each node in the Constraint expression + // tree. The Constraint expression tree is determined by the constraint + // expressions written in the model file, and its depth is finite. + // Therefore, stack overflow does not occur and there is no problem + child->clear(); + } + result_ = RBAExecuteResult::SKIP; + exceptionBeforeArbitrate_ = false; + trueAllocatables_.clear(); + falseAllocatables_.clear(); + operandAllocatable_.clear(); +} + +bool RBAConstraintInfo::isExceptionBeforeArbitrate() const +{ + return exceptionBeforeArbitrate_; +} + +void RBAConstraintInfo::setExceptionBeforeArbitrate( + const bool exceptionBeforeArbitrate) +{ + exceptionBeforeArbitrate_ = exceptionBeforeArbitrate; +} + +bool RBAConstraintInfo::needsReRearbitrationFor( + const RBAAllocatable* const allocatable) const +{ + bool result {false}; + if (children_.empty() == false) { + switch (expression_->getModelElementType()) { + case RBAModelElementType::ImpliesOperator: + if (children_.front()->isExceptionBeforeArbitrate()) { + result = children_.back()->needsReRearbitrationFor(allocatable); + } + break; + case RBAModelElementType::IfStatement: + if (children_.front()->isExceptionBeforeArbitrate()) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::needsReRearbitrationFor=(_, + // p={c::rba::RBAAllocatable})' is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + result = children_.back()->needsReRearbitrationFor(allocatable); + } + break; + default: + for (const auto& child : children_) { + result = (result || child->needsReRearbitrationFor(allocatable)); + } + result = + (result || (trueAllocatables_.find(allocatable) != trueAllocatables_.end()) + || (falseAllocatables_.find(allocatable) != falseAllocatables_.end())); + break; + } + } + return result; +} + +bool RBAConstraintInfo::needsRearbitrationFor(const RBAAllocatable* const allocatable, + bool isImplies) const +{ + bool result {false}; // 再調停要否 + if (children_.empty() == false) { + // When the syntax of the constraint expression is + // - ImpliesOperator + // - IfStatement + // - other than the above + switch (expression_->getModelElementType()) { + case RBAModelElementType::ImpliesOperator: + // If the left side of the implication is true and + // the left side contains an Allocatable during arbitration, + // re-arbitration is required. + // + // If the left side of the implication is true and + // the left side contains an allocatable state reference expression, + // re-arbitration is NOT required. + if (children_.front()->isTrue()) { + if (children_.front()->contains(allocatable)) { + result = true; + } else { + if (children_.front()->contains(nullptr)) { + isImplies = true; + } + result = (result || children_.back()->needsRearbitrationFor(allocatable, + isImplies)); + } + } + break; + case RBAModelElementType::IfStatement: + // If the IF condition includes Allocatble in arbitration, + // re-arbitration is required. + // If the IF condition includes an Allocatable state reference + // expression, re-arbitration is NOT required. + // If the IF condition does not include an allocatable state reference + // expression, search the child syntax. + if (children_.front()->contains(allocatable)) { + result = true; + } else { + if (children_.front()->contains(nullptr)) { + isImplies = true; + } + result = (result || children_.back()->needsRearbitrationFor(allocatable, + isImplies)); + } + break; + default: + for (const auto& child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::needsRearbitrationFor=(_, + // p={c::rba::RBAAllocatable},_o)' is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + result = (result || child->needsRearbitrationFor(allocatable, isImplies)); + } + // The Constraint expression does not include IF or implication, + // or + // the Allocatable state reference expression is not included in the + // left side of the IF condition of the parent syntax or + // the implication of the parent syntax, + // or + // "Allocable" during arbitration is included in the left side of + // the IF condition of the parent syntax or the implication of the + // parent syntax, + // + // re-arbitration is required. + if (!isImplies && contains(allocatable)) { + result = true; + } + break; + } + } + return result; +} + +/// @brief Collect "Allocatable" whose right side is false. +/// @details +/// - Do not collect if an exception has occurred +/// - When expression_ is nullptr or When expression_ is implication +/// - If the left side is satisfied and there is a condition on the left +/// side that is affected by the allocatable state, collect the +/// allocatable that caused the right side to be false. +/// - If the left side is satisfied and there is NO condition affected by +/// the allocatable state on the left side, this function is called on +/// the right side. (To correspond to implication or IF nest) +/// - When expression_ is IF +/// - If there is a condition on the left side that is affected by the +/// "Allocatable" state, collect the "Allocatable that caused the +/// right side to be false. +/// - If there is no condition affected by the allocatable state on the left +/// side, call this function for the right side. +/// (To correspond to the implication or nest of IF) +/// - When expression_ is negative +/// - Call this function with "isNot" inverted for the left side. +/// (To deal with implications or IFs present in children.) +/// - When expression_ is above +/// - Call this function for the child ConstraintInfo. +/// (To deal with implications or IFs present in children.) +/// @param[in] allocatable "Allcatable" during arbitration +/// @param[out] targets "Allocatable" for re-arbitration +/// @param[in] isNot Inversion state of right and wrong by negation operator. +void RBAConstraintInfo::collectRearbitrationTargetFor( + const RBAAllocatable* const allocatable, std::set& targets, + const bool isNot) const +{ + if (isExceptionBeforeArbitrate()) { + return; + } + if (children_.empty() == false) { + switch (expression_->getModelElementType()) { + case RBAModelElementType::ImpliesOperator: + if (children_.front()->isTrue()) { + if (isNot) { + children_.back()->collectTrueAllocatables(targets); + } else { + children_.back()->collectFalseAllocatables(targets); + } + } else if (!children_.front()->isFalse()) { + children_.back()->collectRearbitrationTargetFor(allocatable, targets, + isNot); + } else { + } + break; + case RBAModelElementType::IfStatement: + if (isNot) { + children_.back()->collectTrueAllocatables(targets); + } else { + children_.back()->collectFalseAllocatables(targets); + } + break; + case RBAModelElementType::NotOperator: + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::collectRearbitrationTargetFor=(_,p={c::rba::RBAAllocatable}, + // &{c::std::set}, + // {c::std::allocator}>},_o)' is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + children_.front()->collectRearbitrationTargetFor(allocatable, targets, + !isNot); + break; + default: + for (const auto& child : children_) { + child->collectRearbitrationTargetFor(allocatable, targets, isNot); + } + break; + } + } +} + +void RBAConstraintInfo::collectTrueAllocatables( + std::set& allocatables) const +{ + if (isExceptionBeforeArbitrate() || isFalse()) { + return; + } + if (isRevert()) { + for (const auto& child : children_) { + child->collectFalseAllocatables(allocatables); + } + allocatables.insert(falseAllocatables_.begin(), falseAllocatables_.end()); + } else if (isImplies()) { + children_.back()->collectTrueAllocatables(allocatables); + } else if (isSizeOperator()) { + // Since the size operator evaluates the number of sets, + // the Allocatable that combines FalseAllocatable and TrueAllocatable + // becomes TrueAllocatables. + children_.back()->collectTrueAllocatables(allocatables); + children_.back()->collectFalseAllocatables(allocatables); + } else { + for (const auto& child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::collectTrueAllocatables=(_, + // &{c::std::set}, + // {c::std::allocator}>})' is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + child->collectTrueAllocatables(allocatables); + } + allocatables.insert(trueAllocatables_.begin(), trueAllocatables_.end()); + } + return; +} + +void RBAConstraintInfo::collectFalseAllocatables( + std::set& allocatables) const +{ + if (isExceptionBeforeArbitrate() || isTrue()) { + return; + } + if (isRevert()) { + for (const auto& child : children_) { + child->collectTrueAllocatables(allocatables); + } + allocatables.insert(trueAllocatables_.begin(), trueAllocatables_.end()); + } else if (isImplies()) { + children_.back()->collectFalseAllocatables(allocatables); + } else if (isSizeOperator()) { + // The size operator evaluates the number of sets, so "Allocatable", + // which is a combination of "FalseAllocatable" and "TrueAllocatable", + // becomes "FalseAllocatables". + children_.back()->collectTrueAllocatables(allocatables); + children_.back()->collectFalseAllocatables(allocatables); + } else { + for (const auto& child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::collectFalseAllocatables=(_, + // &{c::std::set}, + // {c::std::allocator}>})' + // is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + child->collectFalseAllocatables(allocatables); + } + allocatables.insert(falseAllocatables_.begin(), falseAllocatables_.end()); + } + return; +} + +bool RBAConstraintInfo::contains(const RBAAllocatable* const allocatable) const +{ + if (allocatable != nullptr) { + if (trueAllocatables_.find(allocatable) != trueAllocatables_.end()) { + return true; + } + if (falseAllocatables_.find(allocatable) != falseAllocatables_.end()) { + return true; + } + } else { + if (!trueAllocatables_.empty() || !falseAllocatables_.empty()) { + return true; + } + } + for (const auto& child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::contains=(_, + // p={c::rba::RBAAllocatable})' + // is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + if (child->contains(allocatable)) { + return true; + } + } + return false; +} + +bool RBAConstraintInfo::isTrue() const +{ + return (result_ == RBAExecuteResult::TRUE); +} + +bool RBAConstraintInfo::isFalse() const +{ + return (result_ == RBAExecuteResult::FALSE); +} + +void RBAConstraintInfo::collectAffectedAllocatables( + const bool isRevert, std::set& affectAllocatables, + const bool collecting, + const bool forObject) +{ + // Collect the allocatable that caused the constraint expression to be False. + // It is implemented by recursively calling ConstraintInfo of the tree + // structure created at the time of "Constraint" expression evaluation. + // with this function. + // Collect True because the success or failure of ConstraintInfo below + // "negative" is reversed. + switch (getExpression()->getModelElementType()) { + case RBAModelElementType::NotOperator: + // ConstraintInfo below negative negates success or failure, + // so invert isRevert and call child Info. + children_[0U]->collectAffectedAllocatables(!isRevert, affectAllocatables, + collecting, forObject); + break; + case RBAModelElementType::SizeOperator: + // Since the size operator evaluates the number of sets, + // "Allocatable" which is a combination of "FalseAllocatable" and + // "TrueAllocatable" becomes "affectAllocatables". + children_[0U]->collectAffectedAllocatables(false, affectAllocatables, + true, true); + break; + case RBAModelElementType::OrOperator: + case RBAModelElementType::ExistsOperator: + // the same processing is performed, because "Exists {A,B}{x|x.isXXX}" + // is equivalent to "A.isXXX OR B.isXXX" + if (!isRevert) { + // Processing when "Info" of "OR" in which evaluation result that is not + // qualified by an odd number of negative is "Skip" or evaluation reslt + // that is not qualified by an odd number of negative is "False". + if (!isTrue()) { + // Collect the Allocatable of child Info whose + // whose evaluation result is False. + // When "A.isXXX OR B.isXXX", if the evaluation result of A is True, + // the evaluation result of OR will be True even if the evaluation + // result of B is False. Therefore, A affects B. + // Conversely, B also affects A. + // Therefore, set "collecting" to True and + // search "child Info" for allocatable. + for (auto& i : children_) { + i->collectAffectedAllocatables(isRevert, affectAllocatables, true, + forObject); // Collct when "OR" + } + } + } else { + // Processing when "Info" of "OR" in which evaluation result that is not + // qualified by an odd number of negative is "Skip" or evaluation reslt + // that is not qualified by an odd number of negative is "False". + // "!(A.isXXX OR B.isXXX)" can be decomposed into + // "!A.isXXX AND !B.isXXX", so if "NOT", perform the same processing + // as "AND". + if (!isFalse()) { + for (auto& i : children_) { + i->collectAffectedAllocatables(isRevert, affectAllocatables, + collecting, forObject); + } + } + } + break; + case RBAModelElementType::AndOperator: + case RBAModelElementType::ForAllOperator: + //"For-All {A,B}{x|x.isXXX}" is equivalent to "A.isXXX AND B.isXXX", + // so the same processing is performed + if (isRevert) { + // Processing when "Info" of "AND" in which evaluation result that + // is not qualified by an odd number of "negative" is "Skip" or + // evaluation reslt that is not qualified by an odd number of negative + // is "True". + // + // "!(A.isXXX AND B.isXXX)" can be decomposed into + // "!A.isXXX OR !B.isXXX", so if "NOT", perform the same processing + // as "OR". + if (!isFalse()) { + for (auto& i : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAConstraintInfo::collectAffectedAllocatables(_,_o,&{c::std::set},{c::std::allocator}>},_o)' is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + i->collectAffectedAllocatables(isRevert, affectAllocatables, true, + forObject); + } + } + } else { + // Processing when "Info" of "AND" in which evaluation result that + // is not qualified by an odd number of "negative" is "Skip" or + // evaluation reslt that is not qualified by an odd number of negative + // is "True". + // + // When "A.isXXX AND B.isXXX", the evaluation result of "AND" does not + // become True unless the evaluation result of B becomes True, + // regardless of the evaluation result of A. Therefore, A does not + // affect B, and B does not affect A. + // Therefore, "collecting" is as it is, and the "child Info" is + // searched for an allocable influence. + if (!isTrue()) { + for (auto& i : children_) { + i->collectAffectedAllocatables(isRevert, affectAllocatables, + collecting, forObject); + } + } + } + break; + case RBAModelElementType::MaxOperator: + case RBAModelElementType::MinOperator: + { + // When the expression is "IF(A.isDisplayed) THEN {B,C} ELSE {D,E}", + // scan the left side to extract A as the area of influence + children_[0U]->collectAffectedAllocatables(false, affectAllocatables, + collecting,forObject); + // All the operands that are "x" in the lambda expression affect + // each other, so it is necessary to extract them as the affected Area. + for (std::uint8_t i { 1U }; i < children_.size(); ++i) { + children_[i]->collectAffectedAllocatables(isRevert, affectAllocatables, + true, true); + } + break; + } + // "A -> B" is the same as "!A OR B". + case RBAModelElementType::ImpliesOperator: + if (!isRevert) { + if (!isTrue()) { + // "A.isXXX -> B.isXXX" can be decomposed into "!A.isXXX OR B.isXXX", + // so the same process as OR is performed + // For the above reason, the acquisition target on the left side + // inverts isRevert. + children_[0U]->collectAffectedAllocatables(!isRevert, + affectAllocatables, true, + forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + } + } else { + if (!isFalse()) { + // "!(A.isXXX -> B.isXXX)" can be decomposed into "A.isXXX OR !B.isXXX" + // For the above reason, the acquisition target on the left side + // inverts isRevert. + children_[0U]->collectAffectedAllocatables(!isRevert, + affectAllocatables, + collecting, forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, + collecting, forObject); + } + } + break; + case RBAModelElementType::IfStatement: + // "IF(A) THEN B ELSE C" is the same as "!A OR B" if A is True, + // and the same as "A OR C" if A is False + if (children_[0U]->isTrue()) { + if (!isRevert) { + if (!isTrue()) { + // "IF(A.isXXX) THEN B.isXXX ELSE C.isXXX" can be decomposed into + // "(!A.isXXX OR B.isXXX)" when A is True. + // For the above reason, the acquisition target on the left side + // inverts isRevert. + children_[0U]->collectAffectedAllocatables(!isRevert, + affectAllocatables, true, + forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + } + } else { + if (!isFalse()) { + // "!(IF(A.isXXX) THEN B.isXXX ELSE C.isXXX)" can be decomposed into + // "(!A.isXXX OR !B.isXXX)" when A is True. + // For the above reason, the acquisition target on the left side + // inverts isRevert. + children_[0U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + } + } + } else { + if (!isRevert) { + if (!isTrue()) { + // "IF(A.isXXX) THEN B.isXXX ELSE C.isXXX" can be decomposed into + // "(A.isXXX OR C.isXXX)" when A is False. + children_[0U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + } + } else { + if (!isFalse()) { + // "!(IF(A.isXXX) THEN B.isXXX ELSE C.isXXX)" can be decomposed into + // "(A.isXXX OR !C.isXXX)" when A is False. + children_[0U]->collectAffectedAllocatables(!isRevert, + affectAllocatables, true, + forObject); + children_[1U]->collectAffectedAllocatables(isRevert, + affectAllocatables, true, + forObject); + } + } + } + break; + default: // Collect Allocatable + if (collecting) { + if (isRevert) { + affectAllocatables.insert(trueAllocatables_.begin(), + trueAllocatables_.end()); + } else { + affectAllocatables.insert(falseAllocatables_.begin(), + falseAllocatables_.end()); + } + if (forObject) { + for (const auto& a : operandAllocatable_) { + affectAllocatables.insert(a); + } + } + } + for (auto& i : children_) { + i->collectAffectedAllocatables(isRevert, affectAllocatables, collecting, + forObject); + } + break; + } + return; +} + +} + diff --git a/src/core/logic/RBAConstraintInfo.hpp b/src/core/logic/RBAConstraintInfo.hpp new file mode 100644 index 0000000..8ab88dd --- /dev/null +++ b/src/core/logic/RBAConstraintInfo.hpp @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// ConstraintInfo (Constraint expression Information) class header + +#ifndef RBACONSTRAINTINFO_HPP +#define RBACONSTRAINTINFO_HPP + +#include +#include +#include +#include +#include "RBAExecuteResult.hpp" +#include "RBADllExport.hpp" + +namespace rba { + +class RBAAllocatable; +class RBAExpression; + +class DLL_EXPORT RBAConstraintInfo +{ +public: + RBAConstraintInfo()=default; + RBAConstraintInfo(const RBAConstraintInfo&)=delete; + RBAConstraintInfo(const RBAConstraintInfo&&)=delete; + RBAConstraintInfo& operator=(const RBAConstraintInfo&)=delete; + RBAConstraintInfo& operator=(const RBAConstraintInfo&&)=delete; + virtual ~RBAConstraintInfo()=default; + +public: + void setExpression(const RBAExpression* const expression); + const RBAExpression* getExpression() const; + void addOperandAllocatable(const RBAAllocatable* const operandAllocatable); + void setResult(const RBAExecuteResult result); + RBAConstraintInfo* getChild(const std::uint32_t index) const; + void setChild(const std::shared_ptr info); + void addTrueAllocatable(const RBAAllocatable* const allocatable); + void addFalseAllocatable(const RBAAllocatable* const allocatable); + void addTrueAllocatableFromOperand(); + void addFalseAllocatableFromOperand(); + void clearFalseAllocatable(); + const bool isImplies() const; + void clear(); + + bool isExceptionBeforeArbitrate() const; + void setExceptionBeforeArbitrate(const bool exceptionBeforeArbitrate); + + /// @brief Determine the need for re-arbitration + /// @param [in] allocatable Allcatable druing arbitration + /// @param [in] isImplies Whether the constraint expression contains + /// implication syntax. + /// @return Necessity of re-arbitration (true: need / false: No need) + bool needsRearbitrationFor(const RBAAllocatable* const allocatable, + bool isImplies = false) const; + + bool needsReRearbitrationFor(const RBAAllocatable* const allocatable) const; + void collectRearbitrationTargetFor(const RBAAllocatable* const allocatable, + std::set& targets, + const bool isNot) const; + void collectTrueAllocatables(std::set& allocatables) const; + void collectFalseAllocatables(std::set& allocatables) const; + bool contains(const RBAAllocatable* const allocatable) const; + bool isTrue() const; + bool isFalse() const; + + /// @brief Extraction of affected Area/Zone + /// @param [in] isRevert Negative context (true: inside / false: outside) + /// @param [out] affectAllocatables List of affected Allcatable + /// @param [out] collecting Collection target context + /// (true: inside / false: outside) + /// @param [out] forObject ReferenceObject context + /// (true: inside / false: outside) + /// @return Necessity of re-arbitration (true: need / false: No need) + void collectAffectedAllocatables( + const bool isRevert, std::set& affectAllocatables, + const bool collecting, + const bool forObject); + +private: + bool isRevert() const; + bool isSizeOperator() const; + +private: + bool exceptionBeforeArbitrate_ {false}; + const RBAExpression* expression_ {nullptr}; + RBAExecuteResult result_ {RBAExecuteResult::SKIP}; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::set trueAllocatables_; + std::set falseAllocatables_; + std::set operandAllocatable_; + // use to respond with an empty set + const std::set emptyAllocatables_; + mutable std::vector> children_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif +}; + +} + +#endif diff --git a/src/core/logic/RBAConstraintMap.hpp b/src/core/logic/RBAConstraintMap.hpp new file mode 100644 index 0000000..6f37694 --- /dev/null +++ b/src/core/logic/RBAConstraintMap.hpp @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAConstraintMap.hpp + */ + +#ifndef RBACONSTRAINTMAP_HPP +#define RBACONSTRAINTMAP_HPP + +namespace rba +{ + +enum class RBAConstraintMap : std::uint8_t +{ + CONTENT_ALLOCATE_CONSTRAINTS, + HIDDEN_TRUE_CHECK_CONSTRAINTS, + HIDDEN_FALSE_CHECK_CONSTRAINTS, + ATTENUATE_TRUE_CHECK_CONSTRAINTS, + ATTENUATE_FALSE_CHECK_CONSTRAINTS, +}; + +} + +#endif diff --git a/src/core/logic/RBAContentStatus.cpp b/src/core/logic/RBAContentStatus.cpp new file mode 100644 index 0000000..04ed6d9 --- /dev/null +++ b/src/core/logic/RBAContentStatus.cpp @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// ContentStatus (Content state transition management) class +// + +#include "RBAContentState.hpp" +#include "RBAContentStatus.hpp" +#include "RBAContentStatusType.hpp" + +namespace rba +{ + +void RBAContentStatus::onRequest() +{ + if ((status_ != RBAContentStatusType::Displayed) + && (status_ != RBAContentStatusType::StandBy)) { + status_ = RBAContentStatusType::Undisplayed; + } +} +void RBAContentStatus::setStatusType( + const RBAContentStatusType type) +{ + status_ = type; +} +RBAContentStatusType RBAContentStatus::getStatusType() const +{ + return status_; +} +bool RBAContentStatus::isActive() const +{ + return ((status_ != RBAContentStatusType::NoRequest) + && (status_ != RBAContentStatusType::Canceled)); +} + +bool RBAContentStatus::isUndisplayed() const +{ + return (status_ == RBAContentStatusType::Undisplayed); +} + +bool RBAContentStatus::isDisplayed() const +{ + return (status_ == RBAContentStatusType::Displayed); +} +bool RBAContentStatus::isStandby() const +{ + return (status_ == RBAContentStatusType::StandBy); +} +bool RBAContentStatus::hasBeenCanceled() const +{ + return (status_ == RBAContentStatusType::Canceled); +} +bool RBAContentStatus::hasBeenDisplayed() const +{ + return ((status_ == RBAContentStatusType::Displayed) + || (status_ == RBAContentStatusType::StandBy)); +} +} /* namespace rba */ diff --git a/src/core/logic/RBAContentStatus.hpp b/src/core/logic/RBAContentStatus.hpp new file mode 100644 index 0000000..69f7e8d --- /dev/null +++ b/src/core/logic/RBAContentStatus.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// ContentStatus (Content state transition management) class +// + +#ifndef RBACONTENTSTATUS_HPP +#define RBACONTENTSTATUS_HPP +#include + +#include "RBAContentStatusType.hpp" + +namespace rba +{ +class RBAContentState; + +class RBAContentStatus +{ + public: + RBAContentStatus()=default; + // Copy constructor is defined in default because it is used in another class + RBAContentStatus(const RBAContentStatus&)=default; + RBAContentStatus(const RBAContentStatus&&)=delete; + // Copy assignment operator is defined in default + // because it is used in other classes + RBAContentStatus& operator=(const RBAContentStatus&)=default; + RBAContentStatus& operator=(const RBAContentStatus&&)=delete; + virtual ~RBAContentStatus()=default; + void onRequest(); + void setStatusType(const RBAContentStatusType type); + RBAContentStatusType getStatusType() const; + bool isActive() const; + bool isUndisplayed() const; + bool isDisplayed() const; + bool isStandby() const; + bool hasBeenCanceled() const; + bool hasBeenDisplayed() const; + private: + RBAContentStatusType status_ {RBAContentStatusType::NoRequest}; +}; + +} /* namespace rba */ + +#endif /* RBACONTENTSTATUS_HPP */ diff --git a/src/core/logic/RBARequest.cpp b/src/core/logic/RBARequest.cpp new file mode 100644 index 0000000..c55cac1 --- /dev/null +++ b/src/core/logic/RBARequest.cpp @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBARequest (request arbitration) class implementation + */ + +#include "RBARequest.hpp" + +namespace rba +{ + +RBARequest::RBARequest(const std::string& context, const bool isOn) : + context_{context}, + isOn_{isOn} +{ +} + +std::string +RBARequest::getContext() const +{ + return context_; +} + +bool +RBARequest::isOn() const +{ + return isOn_; +} + +} diff --git a/src/core/logic/RBARequest.hpp b/src/core/logic/RBARequest.hpp new file mode 100644 index 0000000..b6da5e4 --- /dev/null +++ b/src/core/logic/RBARequest.hpp @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBARequest (request arbitration) class header + */ + +#ifndef RBAREQUEST_HPP +#define RBAREQUEST_HPP + +#include +#include "RBADllExport.hpp" + +namespace rba +{ + +class DLL_EXPORT RBARequest +{ + public: + explicit RBARequest(const std::string& context, const bool isOn = true); + RBARequest(const RBARequest&)=delete; + RBARequest(const RBARequest&&)=delete; + RBARequest& operator=(const RBARequest&)=delete; + RBARequest& operator=(const RBARequest&&)=delete; + virtual ~RBARequest()=default; + + public: + std::string getContext() const; + bool isOn() const; + + private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::string context_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + bool isOn_; + +}; + +} + +#endif diff --git a/src/core/logic/RBARequestQueMember.cpp b/src/core/logic/RBARequestQueMember.cpp new file mode 100644 index 0000000..a5a0d35 --- /dev/null +++ b/src/core/logic/RBARequestQueMember.cpp @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBARequestQueueMember class implementation + */ + +#include + +#include "RBARequestQueMember.hpp" +#include "RBAContentState.hpp" + +namespace rba { + +RBARequestQueMember::RBARequestQueMember(const RBAContentState* const contentState, const bool isOn, + const std::uint32_t syncIndex): + contentState_{contentState}, + isOn_{isOn}, + syncIndex_{syncIndex} +{ +} + +const RBAContentState* RBARequestQueMember::getContentState() const { + return contentState_; +} + +bool RBARequestQueMember::isOn() const { + return isOn_; +} + +std::uint32_t RBARequestQueMember::getSyncIndex() const { + return syncIndex_; +} + +} diff --git a/src/core/logic/RBARequestQueMember.hpp b/src/core/logic/RBARequestQueMember.hpp new file mode 100644 index 0000000..cb18987 --- /dev/null +++ b/src/core/logic/RBARequestQueMember.hpp @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBARequestQueueMember class header + */ + +#ifndef RBAREQUESTQUEMEMBER_HPP +#define RBAREQUESTQUEMEMBER_HPP + +#include + +namespace rba { + +class RBAContentState; + +class RBARequestQueMember { + public: + RBARequestQueMember(const RBAContentState* const contentState, const bool isOn, const std::uint32_t syncIndex); + RBARequestQueMember()=delete; + RBARequestQueMember(const RBARequestQueMember&)=delete; + RBARequestQueMember(const RBARequestQueMember&&)=delete; + RBARequestQueMember& operator=(const RBARequestQueMember&)=delete; + RBARequestQueMember& operator=(const RBARequestQueMember&&)=delete; + virtual ~RBARequestQueMember() = default; + + const RBAContentState* getContentState() const; + bool isOn() const; + std::uint32_t getSyncIndex() const; + + private: + // Content state for which arbitration was requested + const RBAContentState* contentState_; + // Whether display/output request or scene ON request + bool isOn_; + + /// Index of arbitration syntax + /// QueMenber with the same value will be arbitrated at the same timing, + /// and if the values are different, differential arbitration is performed. + /// When a request for execute(list,bool) is received, the content icluded + /// in the list will all have the same value. + /// When setContentState(ContentState, bool) request is received twice, + /// the first request and the second request have different values. + /// When created by onRequest or onWithdrawn, + /// it has the same value as the request that triggered it. + std::uint32_t syncIndex_; +}; + +} + +#endif /* RBAREQUESTQUEMEMBER_HPP */ diff --git a/src/core/logic/RBAResultImpl.cpp b/src/core/logic/RBAResultImpl.cpp new file mode 100644 index 0000000..41c291f --- /dev/null +++ b/src/core/logic/RBAResultImpl.cpp @@ -0,0 +1,1088 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAResultImpl (result of arbitration implementation) class + */ + +#include "RBAResultImpl.hpp" + +#include "RBAContentStatusType.hpp" +#include "RBAArbitrator.hpp" +#include "RBAViewContentImpl.hpp" +#include "RBAViewContentStateImpl.hpp" +#include "RBASoundContentImpl.hpp" +#include "RBASoundContentStateImpl.hpp" +#include "RBAResultSet.hpp" +#include "RBAAllocatable.hpp" +#include "RBAContentState.hpp" +#include "RBAContent.hpp" +#include "RBAAreaImpl.hpp" +#include "RBAZoneImpl.hpp" +#include "RBASceneImpl.hpp" +#include "RBASizeImpl.hpp" +#include "RBAConstraint.hpp" +#include "RBAModelElementType.hpp" +#include "RBAViewActionType.hpp" +#include "RBAViewTransition.hpp" +#include "RBAViewMove.hpp" + +namespace rba { + +RBAResultImpl::RBAResultImpl(const RBAArbitrator* const arb, + std::unique_ptr newPrevResultSet): + RBAResult(), + preResultSet_{std::move(newPrevResultSet)}, + arb_{arb}, + statusType_{RBAResultStatusType::SUCCESS} +{ + curResultSet_ = std::make_unique(); + curResultSet_->copyActives(preResultSet_); + curResultSet_->copyProperties(preResultSet_); +} + +RBAResultImpl::RBAResultImpl(const RBAArbitrator* const arb, + std::unique_ptr newPrevResultSet, + std::unique_ptr newCurResultSet): + RBAResult(), + curResultSet_{std::move(newCurResultSet)}, + preResultSet_{std::move(newPrevResultSet)}, + arb_{arb}, + statusType_{RBAResultStatusType::SUCCESS} +{ +} + +RBAResultImpl::RBAResultImpl(const RBAResultImpl* const replicationTarget) + : RBAResult{}, + curResultSet_{std::make_unique(*(replicationTarget->curResultSet_.get()))}, + preResultSet_{std::make_unique(*(replicationTarget->preResultSet_.get()))}, + arb_{replicationTarget->arb_}, + statusType_{RBAResultStatusType::SUCCESS}, + log_{replicationTarget->log_} +{ + for (const auto &va : replicationTarget->viewActions_) { + if (va->getViewActionType() == RBAViewActionType::MOVE) { + viewActions_.push_back( + std::make_unique(va->getFromArea(), va->getToArea(), + va->getContentState())); + } else if (va->getViewActionType() + == RBAViewActionType::TRANSITION_REPLACE) { + viewActions_.push_back( + std::make_unique(va->getViewActionType(), + va->getArea(), + va->getFromContentState(), + va->getToContentState())); + } else { + viewActions_.push_back( + std::make_unique(va->getViewActionType(), + va->getArea(), + va->getContentState())); + } + } +} + +// +// External +// + +// [get VisibleArea/SoundingZone] + +const std::list& +RBAResultImpl::getVisibleAreas() const +{ + return curResultSet_->getVisibleAreas(); +} + +const std::list& +RBAResultImpl::getPreVisibleAreas() const +{ + return preResultSet_->getVisibleAreas(); +} + +const std::list& +RBAResultImpl::getSoundingZones() const +{ + return curResultSet_->getSoundingZones(); +} + +const std::list& +RBAResultImpl::getPreSoundingZones() const +{ + return preResultSet_->getSoundingZones(); +} + +// [get Visible/Sounding ContentStates] + +const std::list& +RBAResultImpl::getVisibleContentStates() const +{ + return curResultSet_->getVisibleContentStates(); +} + +const std::list& +RBAResultImpl::getPreVisibleContentStates() const +{ + return preResultSet_->getVisibleContentStates(); +} + +const std::list& +RBAResultImpl::getSoundingContentStates() const +{ + return curResultSet_->getSoundingContentStates(); +} + +const std::list& +RBAResultImpl::getPreSoundingContentStates() const +{ + return preResultSet_->getSoundingContentStates(); +} + +// [get Active View/Sound ContentStates] + +const std::list& +RBAResultImpl::getActiveViewContentStates() const +{ + return curResultSet_->getActiveViewContentStates(); +} + +const std::list& +RBAResultImpl::getPreActiveViewContentStates() const +{ + return preResultSet_->getActiveViewContentStates(); +} + +const std::list& +RBAResultImpl::getActiveSoundContentStates() const +{ + return curResultSet_->getActiveSoundContentStates(); +} + +const std::list& +RBAResultImpl::getPreActiveSoundContentStates() const +{ + return preResultSet_->getActiveSoundContentStates(); +} + +// [get etActive Scenes] + +const std::list& +RBAResultImpl::getActiveScenes() const +{ + return curResultSet_->getActiveScenes(); +} + +const std::list& +RBAResultImpl::getPreActiveScenes() const +{ + return preResultSet_->getActiveScenes(); +} + +// [get InvisibleAreas/UnsoundingZone] + +const std::list& +RBAResultImpl::getInvisibleAreas() const +{ + return curResultSet_->getInvisibleAreas(); +} + +const std::list& +RBAResultImpl::getPreInvisibleAreas() const +{ + return preResultSet_->getInvisibleAreas(); +} + +const std::list& +RBAResultImpl::getUnsoundingZones() const +{ + return curResultSet_->getUnsoundingZones(); +} + +const std::list& +RBAResultImpl::getPreUnsoundingZones() const +{ + return preResultSet_->getUnsoundingZones(); +} + +// [get HiddenAreas/MuteZones] + +const std::list& +RBAResultImpl::getHiddenAreas() const +{ + return curResultSet_->getHiddenAreas(); +} + +const std::list& +RBAResultImpl::getPreHiddenAreas() const +{ + return preResultSet_->getHiddenAreas(); +} + +const std::list& +RBAResultImpl::getMuteZones() const +{ + return curResultSet_->getMuteZones(); +} + +const std::list& +RBAResultImpl::getPreMuteZones() const +{ + return preResultSet_->getMuteZones(); +} + +// [get Attenuated] + +const std::list& +RBAResultImpl::getAttenuatedZones() const +{ + return curResultSet_->getAttenuatedZones(); +} + +const std::list& +RBAResultImpl::getPreAttenuatedZones() const +{ + return preResultSet_->getAttenuatedZones(); +} + +// [get Canceled Contents] + +const std::list& +RBAResultImpl::getCanceledViewContents() const +{ + return curResultSet_->getCanceledViewContents(); +} + +const std::list& +RBAResultImpl::getPreCanceledViewContents() const +{ + return preResultSet_->getCanceledViewContents(); +} + +const std::list& +RBAResultImpl::getCanceledSoundContents() const +{ + return curResultSet_->getCanceledSoundContents(); +} + +const std::list& +RBAResultImpl::getPreCanceledSoundContents() const +{ + return preResultSet_->getCanceledSoundContents(); +} + +// [get Standby Contents] + +const std::list& +RBAResultImpl::getStandbyViewContents() const +{ + return curResultSet_->getStandbyViewContents(); +} + +const std::list& +RBAResultImpl::getPreStandbyViewContents() const +{ + return preResultSet_->getStandbyViewContents(); +} + +const std::list& +RBAResultImpl::getStandbySoundContents() const +{ + return curResultSet_->getStandbySoundContents(); +} + +const std::list& +RBAResultImpl::getPreStandbySoundContents() const +{ + return preResultSet_->getStandbySoundContents(); +} + +// [get ContentStates] + +const RBAViewContentState* +RBAResultImpl::getContentState(const RBAArea* area) const +{ + return dynamic_cast( + curResultSet_->getContentState(dynamic_cast(area))); +} + +const RBAViewContentState* +RBAResultImpl::getPreContentState(const RBAArea* area) const +{ + return dynamic_cast( + preResultSet_->getContentState(dynamic_cast(area))); +} + +const RBASoundContentState* +RBAResultImpl::getContentState(const RBAZone* zone) const +{ + return dynamic_cast( + curResultSet_->getContentState(dynamic_cast(zone))); +} + +const RBASoundContentState* +RBAResultImpl::getPreContentState(const RBAZone* zone) const +{ + return dynamic_cast( + preResultSet_->getContentState(dynamic_cast(zone))); +} + +// [get Areas/Zones by ConentState] + +const std::list +RBAResultImpl::getArea(const RBAViewContentState* state) const +{ + std::list areaList; + curResultSet_->getArea(state, areaList); + return areaList; +} + +const std::list +RBAResultImpl::getPreArea(const RBAViewContentState* state) const +{ + std::list areaList; + preResultSet_->getArea(state, areaList); + return areaList; +} + +const std::list +RBAResultImpl::getZone(const RBASoundContentState* state) const +{ + std::list zoneList; + curResultSet_->getZone(state, zoneList); + return zoneList; +} + +const std::list +RBAResultImpl::getPreZone(const RBASoundContentState* state) const +{ + std::list zoneList; + preResultSet_->getZone(state, zoneList); + return zoneList; +} + +// [get Areas/Zones by Content] + +const std::list +RBAResultImpl::getArea(const RBAViewContent* content) const +{ + std::list areaList; + curResultSet_->getArea(content, areaList); + return areaList; +} + +const std::list +RBAResultImpl::getPreArea(const RBAViewContent* content) const +{ + std::list areaList; + preResultSet_->getArea(content, areaList); + return areaList; +} + +const std::list +RBAResultImpl::getZone(const RBASoundContent* content) const +{ + std::list zoneList; + curResultSet_->getZone(content, zoneList); + return zoneList; +} + +const std::list +RBAResultImpl::getPreZone(const RBASoundContent* content) const +{ + std::list zoneList; + preResultSet_->getZone(content, zoneList); + return zoneList; +} + +// [get Size] + +const RBASize* +RBAResultImpl::getSize(const RBAArea* area) const +{ + return curResultSet_->getSize(area); +} + +const RBASize* +RBAResultImpl::getPreSize(const RBAArea* area) const +{ + return preResultSet_->getSize(area); +} + +// [check Active Scene] +bool +RBAResultImpl::isActive(const RBAScene* scene) const +{ + return curResultSet_->isActive(scene); +} + +bool +RBAResultImpl::isPreActive(const RBAScene* scene) const +{ + return preResultSet_->isActive(scene); +} + +// [check Active Content] +bool +RBAResultImpl::isActive(const RBAContent* const content) const +{ + return curResultSet_->isActive(content); +} +bool +RBAResultImpl::isActive(const RBAViewContent* content) const +{ + return curResultSet_->isActive(dynamic_cast(content)); +} + +bool +RBAResultImpl::isActive(const RBASoundContent* content) const +{ + return curResultSet_->isActive(dynamic_cast(content)); +} +bool +RBAResultImpl::isPreActive(const RBAContent* const content) const +{ + return preResultSet_->isActive(content); +} +bool +RBAResultImpl::isPreActive(const RBAViewContent* content) const +{ + return preResultSet_->isActive(dynamic_cast(content)); +} + +bool +RBAResultImpl::isPreActive(const RBASoundContent* content) const +{ + return preResultSet_->isActive(dynamic_cast(content)); +} + +// [check Active ContentState] +bool +RBAResultImpl::isActive(const RBAContentState* const state) const +{ + return curResultSet_->isActive(state); +} + +bool +RBAResultImpl::isActive(const RBAViewContentState* const state) const +{ + return isActive(dynamic_cast(state)); +} + +bool +RBAResultImpl::isActive(const RBASoundContentState* const state) const +{ + return isActive(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreActive(const RBAContentState* const state) const +{ + return preResultSet_->isActive(state); +} + +bool +RBAResultImpl::isPreActive(const RBAViewContentState* const state) const +{ + return isPreActive(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreActive(const RBASoundContentState* const state) const +{ + return isPreActive(dynamic_cast(state)); +} + +const RBAContentState* +RBAResultImpl::getActiveState(const RBAContent* const content) const +{ + if (curResultSet_->isActive(content)){ + return curResultSet_->getReqestState(content); + } + return nullptr; +} + +const RBAContentState* +RBAResultImpl::getPreActiveState(const RBAContent* const content) const +{ + if (preResultSet_->isActive(content)){ + return preResultSet_->getReqestState(content); + } + return nullptr; +} + +// [check Visible/Sounding Alloc ContentState] + +bool +RBAResultImpl::isOutputting(const RBAAllocatable* const alloc) const +{ + return curResultSet_->isOutputting(alloc); +} + +bool +RBAResultImpl::isPreOutputting(const RBAAllocatable* const alloc) const +{ + return preResultSet_->isOutputting(alloc); +} + +bool +RBAResultImpl::isOutputting(const RBAContentState* const state) const +{ + return curResultSet_->isOutputting(state); +} + +bool +RBAResultImpl::isPreOutputting(const RBAContentState* const state) const +{ + return preResultSet_->isOutputting(state); +} + +bool +RBAResultImpl::isVisible(const RBAViewContentState* state) const +{ + return isOutputting(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreVisible(const RBAViewContentState* state) const +{ + return isPreOutputting(dynamic_cast(state)); +} + +bool +RBAResultImpl::isSounding(const RBASoundContentState* state) const +{ + return isOutputting(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreSounding(const RBASoundContentState* state) const +{ + return isPreOutputting(dynamic_cast(state)); +} + +// [get View/Sound ContentState] + +const RBAContentState* +RBAResultImpl::getAllocatedContentState(const RBAAllocatable* const allocatable) const +{ + return curResultSet_->getContentState(allocatable); +} + +const RBAContentState* +RBAResultImpl::getPreAllocatedContentState(const RBAAllocatable* const allocatable) const +{ + return preResultSet_->getContentState(allocatable); +} + +const RBAViewContentState* +RBAResultImpl::getViewContentState(const RBAArea* area) const +{ + return dynamic_cast( + curResultSet_->getContentState(dynamic_cast(area))); +} + +const RBAViewContentState* +RBAResultImpl::getPreViewContentState(const RBAArea* area) const +{ + return dynamic_cast( + preResultSet_->getContentState(dynamic_cast(area))); +} + +const RBASoundContentState* +RBAResultImpl::getSoundContentState(const RBAZone* zone) const +{ + return dynamic_cast( + curResultSet_->getContentState(dynamic_cast(zone))); +} + +const RBASoundContentState* +RBAResultImpl::getPreSoundContentState(const RBAZone* zone) const +{ + return dynamic_cast( + preResultSet_->getContentState(dynamic_cast(zone))); +} + +// [check Hidden/Mute] + +bool +RBAResultImpl::isHidden(const RBAArea* area) const +{ + return isHidden(dynamic_cast(area)); +} + +bool +RBAResultImpl::isPreHidden(const RBAArea* area) const +{ + return isPreHidden(dynamic_cast(area)); +} + +bool +RBAResultImpl::isMute(const RBAZone* zone) const +{ + return isHidden(dynamic_cast(zone)); +} + +bool +RBAResultImpl::isPreMute(const RBAZone* zone) const +{ + return isPreHidden(dynamic_cast(zone)); +} + +// [check Attenuated] +bool +RBAResultImpl::isAttenuated(const RBAZone* zone) const +{ + return curResultSet_->isAttenuated(zone); +} + +bool +RBAResultImpl::isPreAttenuated(const RBAZone* zone) const +{ + return preResultSet_->isAttenuated(zone); +} + +// [common] + +const std::list& +RBAResultImpl::getViewActions() const +{ + viewActionsForPublicUse_.clear(); + for (auto& va :viewActions_) { + viewActionsForPublicUse_.push_back(va.get()); + } + return viewActionsForPublicUse_; +} + +RBAResultStatusType +RBAResultImpl::getStatusType() const +{ + return statusType_; +} + +bool +RBAResultImpl::isLater(const RBAContent* const target, + const RBAContent* const comparisonTarget) const +{ + return curResultSet_->isLater(target, comparisonTarget); +} + +std::string +RBAResultImpl::getLog() const +{ + return log_; +} + +void +RBAResultImpl::setLog(const std::string& log) +{ + log_ = log; +} + +bool +RBAResultImpl::hasDisplayingArea(const RBADisplay* display) const +{ + if (display == nullptr) { + return false; + } else { + return curResultSet_->hasDisplayingArea(display); + } +} + +bool +RBAResultImpl::satisfiesConstraints() const +{ + if(statusType_ != RBAResultStatusType::SUCCESS) { + return false; + } + return arb_->satisfiesConstraints(); +} + +void +RBAResultImpl::setSceneProperty(const RBASceneImpl* const scene, + const std::string& propertyName, + const std::int32_t value) +{ + curResultSet_->setSceneProperty(scene->getProperty(propertyName), value); +} + +void +RBAResultImpl::setSceneProperty(const RBAAbstractProperty* const property, + const std::int32_t value) +{ + curResultSet_->setSceneProperty(property, value); +} + +std::int32_t +RBAResultImpl::getSceneProperty(const RBAScene* scene, + const std::string& propertyName) const +{ + if(scene == nullptr) { + return -99; + } + + const RBAAbstractProperty* const prop + {dynamic_cast(scene)->getProperty(propertyName)}; + if(prop == nullptr) { + return -99; + } + + return curResultSet_->getSceneProperty(prop); +} + +std::int32_t +RBAResultImpl::getSceneProperty(const RBAAbstractProperty* const property) const +{ + return curResultSet_->getSceneProperty(property); +} + +std::int32_t +RBAResultImpl::getPreSceneProperty(const RBAAbstractProperty* const property) const +{ + return preResultSet_->getSceneProperty(property); +} + +// +// Internal +// + +// Impl [VisibleArea/SoundingZone] + +const std::set& +RBAResultImpl::getOutputtingAllocatables() const +{ + return curResultSet_->getOutputtingAllocatables(); +} + +// Impl [get Active View/Sound ContentStates] + +const std::set& +RBAResultImpl::getActiveContentStates() const +{ + return curResultSet_->getActiveContentStates(); +} + +// Impl [get ContentStates] +const RBAContentState* +RBAResultImpl::getContentState(const RBAAllocatable* const allocatable) const +{ + return curResultSet_->getContentState(allocatable); +} + +const RBAContentState* +RBAResultImpl::getDirectContentState(const RBAAllocatable* const allocatable) const +{ + return curResultSet_->getDirectContentState(allocatable); +} + +const RBAContentState* +RBAResultImpl::getPreContentState(const RBAAllocatable* const allocatable) const +{ + return preResultSet_->getContentState(allocatable); +} + +const RBAContentState* +RBAResultImpl::getDirectPreContentState(const RBAAllocatable* const allocatable) const +{ + return preResultSet_->getDirectContentState(allocatable); +} + +// Impl [get Areas/Zones by ConentState] + +std::list +RBAResultImpl::getAllocatable(const RBAContentState* const state) const +{ + std::list allocatables; + if(state->isViewContentState()) { + std::list areaList; + curResultSet_->getArea(dynamic_cast(state), + areaList); + for (const auto& area : areaList) { + allocatables.push_back(dynamic_cast(area)); + } + } + else { + std::list zoneList; + curResultSet_->getZone(dynamic_cast(state), + zoneList); + for (const auto& zone : zoneList) { + allocatables.push_back(dynamic_cast(zone)); + } + } + return allocatables; +} + +// Impl [check Aleady Visible/Sounding] +bool +RBAResultImpl::isAlreadyOutputting(const RBAContentState* const state) const +{ + return curResultSet_->isAlreadyOutputting(state); +} + +// Impl [set Active Scene] + +void +RBAResultImpl::setActive(const RBAScene* const scene, const bool newActive) +{ + curResultSet_->setActive(scene, newActive); +} + +// Impl [set Active ContentState] + +void +RBAResultImpl::setActive(const RBAContentState* const state, const bool newActive) +{ + curResultSet_->setActive(state, newActive); +} + +// Impl [add Standby Content] + +void +RBAResultImpl::addStandbyContent(const RBAContent* const content) +{ + curResultSet_->addStandbyContent(content); +} + +// Impl [check Visible/Sounding Area/Zone] + +bool +RBAResultImpl::isVisible(const RBAArea* area) const +{ + return curResultSet_->isOutputting(dynamic_cast(area)); +} + +bool +RBAResultImpl::isPreVisible(const RBAArea* area) const +{ + return preResultSet_->isOutputting(dynamic_cast(area)); +} + +bool +RBAResultImpl::isSounding(const RBAZone* zone) const +{ + return curResultSet_->isOutputting(dynamic_cast(zone)); +} + +bool +RBAResultImpl::isPreSounding(const RBAZone* zone) const +{ + return preResultSet_->isOutputting(dynamic_cast(zone)); +} + +// Impl [set View/Sound ContentState] + +void RBAResultImpl::setContentState(const RBAAllocatable* const allocatable, + const RBAContentState* const state) +{ + curResultSet_->setContentState(allocatable, state); +} + +// Impl [check Hidden/Mute Area/Zone] + +bool +RBAResultImpl::isHidden(const RBAAllocatable* const allocatable) const +{ + return curResultSet_->isHidden(allocatable); +} + +bool +RBAResultImpl::isPreHidden(const RBAAllocatable* const allocatable) const +{ + return preResultSet_->isHidden(allocatable); +} + +// Impl [set Cancel ContentState] + +void +RBAResultImpl::setCancel(const RBAContentState* const state, const bool checked) +{ + curResultSet_->setCancel(state, checked); +} + +// Impl [check Cancel ContentState] + +bool +RBAResultImpl::isCancel(const RBAContentState* const state) const +{ + return curResultSet_->isCancel(state); +} + +bool +RBAResultImpl::isPreCancel(const RBAContentState* const state) const +{ + return preResultSet_->isCancel(state); +} + +bool +RBAResultImpl::isCancel(const RBAViewContentState* state) const +{ + return isCancel(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreCancel(const RBAViewContentState* state) const +{ + return isPreCancel(dynamic_cast(state)); +} + +bool +RBAResultImpl::isCancel(const RBASoundContentState* state) const +{ + return isCancel(dynamic_cast(state)); +} + +bool +RBAResultImpl::isPreCancel(const RBASoundContentState* state) const +{ + return isPreCancel(dynamic_cast(state)); +} + +// Impl [add Visible/Sounding ContentState] + +void +RBAResultImpl::addOutputtingContentState(const RBAContentState* const state) +{ + curResultSet_->addOutputtingContentState(state); +} + +// Impl [cancel ContentState] + +void +RBAResultImpl::cancelContentState(const RBAContentState* const state) +{ + curResultSet_->cancelContentState(state); +} + +// Impl [common] + +std::unique_ptr +RBAResultImpl::createBackupCurrentResultSet() +{ + return std::make_unique(*curResultSet_); +} + +std::unique_ptr +RBAResultImpl::createNextCurrentResultSet() +{ + std::unique_ptr nextResultSet {std::make_unique()}; + nextResultSet->copyActives(curResultSet_); + nextResultSet->copyProperties(curResultSet_); + return nextResultSet; +} + +void +RBAResultImpl::addViewAction(std::unique_ptr& newViewAction) +{ + viewActions_.push_back(move(newViewAction)); +} + +void +RBAResultImpl::setStatusType(const RBAResultStatusType newStatusType) +{ + statusType_ = newStatusType; +} + +void +RBAResultImpl::updateActiveContentStates() +{ + curResultSet_->updateActiveContentStates(); +} + +void +RBAResultImpl::setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing, + const RBAContent* const viewContent) +{ + curResultSet_->setContentOfEventProcessing(eventProcessing, viewContent); +} + +std::unique_ptr& +RBAResultImpl::getCurResultSet() +{ + return curResultSet_; +} + +std::unique_ptr& +RBAResultImpl::getPreResultSet() +{ + return preResultSet_; +} + +RBAContentStatusType RBAResultImpl::getStatusType(const RBAContent* const content) const +{ + return curResultSet_->getStatusType(content); +} +bool RBAResultImpl::isStandby(const RBAContent* const content) const +{ + return curResultSet_->isStandby(content); +} + +bool RBAResultImpl::hasBeenCanceled(const RBAContent* const content) const +{ + return curResultSet_->hasBeenCanceled(content); +} + +bool RBAResultImpl::hasBeenPreCanceled(const RBAContent* const content) const +{ + return preResultSet_->hasBeenCanceled(content); +} + +bool RBAResultImpl::hasBeenDisplayed(const RBAContent* const content) const +{ + return curResultSet_->hasBeenDisplayed(content); +} +bool RBAResultImpl::hasBeenPreDisplayed(const RBAContent* const content) const +{ + return preResultSet_->hasBeenDisplayed(content); +} + +void RBAResultImpl::updateStatus(const RBAContent* const content) +{ + const RBAContentState* const s {getActiveState(content)}; + if (s != nullptr) { + if (isOutputting(s)) { + curResultSet_->setStatusType(content, RBAContentStatusType::Displayed); + } else if (isCancel(s)) { + curResultSet_->setStatusType(content, RBAContentStatusType::Canceled); + } else if (curResultSet_->getStatusType(content) != RBAContentStatusType::Undisplayed) { + curResultSet_->setStatusType(content, RBAContentStatusType::StandBy); + } else { + ; + } + } +} + +std::unordered_map* RBAResultImpl::getCurStatus() const +{ + return curResultSet_->getStatus(); +} + +std::set& RBAResultImpl::getDifferentConditionScenes() const +{ + return (curResultSet_->getDifferentConditionScenes(*preResultSet_.get())); +} +#ifdef RBA_USE_LOG +void +RBAResultImpl::addFailedConstraint(const RBAConstraint* constraint) +{ + curResultSet_->addFailedConstraint(constraint); +} + +const std::list& +RBAResultImpl::getFailedConstraints() const +{ + return curResultSet_->getFailedConstraints(); +} +#endif + +} diff --git a/src/core/logic/RBAResultImpl.hpp b/src/core/logic/RBAResultImpl.hpp new file mode 100644 index 0000000..d7a1aa1 --- /dev/null +++ b/src/core/logic/RBAResultImpl.hpp @@ -0,0 +1,343 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAResultImpl (result of arbitration implementation) class header + */ + +#ifndef RBARESULTIMPL_HPP +#define RBARESULTIMPL_HPP + +#include +#include +#include +#include "RBAResult.hpp" +#include "RBAResultStatusType.hpp" +#include "RBAContentStatusType.hpp" + +namespace rba { + +class RBAArbitrator; +class RBAArea; +class RBAViewContent; +class RBAViewContentState; +class RBASize; +class RBAScene; +class RBAAbstractProperty; +class RBAAreaImpl; +class RBAContentStateImpl; +class RBAViewContentImpl; +class RBAViewContentStateImpl; +class RBASizeImpl; +class RBASceneImpl; +class RBAResultSet; +class RBAViewAction; +class RBAZoneImpl; +class RBASoundContentImpl; +class RBASoundContentStateImpl; +class RBASoundContent; +class RBASoundContentState; +class RBAContentState; +class RBAAllocatable; +class RBAContent; +class RBAEventProcessing; +class RBAConstraint; +class RBAContentStatus; + +class DLL_EXPORT RBAResultImpl : public RBAResult +{ +public: + RBAResultImpl(const RBAArbitrator* const arb, + std::unique_ptr newPrevResultSet); + RBAResultImpl(const RBAArbitrator* const arb, + std::unique_ptr newPrevResultSet, + std::unique_ptr newCurResultSet); + RBAResultImpl(const RBAResultImpl* const replicationTarget); + RBAResultImpl(const RBAResultImpl&)=delete; + RBAResultImpl(const RBAResultImpl&&)=delete; + RBAResultImpl& operator=(const RBAResultImpl&)=delete; + RBAResultImpl& operator=(const RBAResultImpl&&)=delete; + virtual ~RBAResultImpl()=default; + +public: + + // + // External + // + + // [get VisibleArea/SoundingZone] + const std::list& getVisibleAreas() const override; + const std::list& getPreVisibleAreas() const override; + const std::list& getSoundingZones() const override; + const std::list& getPreSoundingZones() const override; + + // [get Visible/Sounding ContentStates] + const std::list& getVisibleContentStates() const override; + const std::list& getPreVisibleContentStates() const override; + const std::list& getSoundingContentStates() const override; + const std::list& getPreSoundingContentStates() const override; + + // [get Active View/Sound ContentStates] + const std::list& getActiveViewContentStates() const override; + const std::list& getPreActiveViewContentStates() const override; + const std::list& getActiveSoundContentStates() const override; + const std::list& getPreActiveSoundContentStates() const override; + + // [get Active Scenes] + const std::list& getActiveScenes() const override; + const std::list& getPreActiveScenes() const override; + + // [get InvisibleAreas/UnsoundingZone] + const std::list& getInvisibleAreas() const override; + const std::list& getPreInvisibleAreas() const override; + const std::list& getUnsoundingZones() const override; + const std::list& getPreUnsoundingZones() const override; + + // [get HiddenAreas/MuteZones] + const std::list& getHiddenAreas() const override; + const std::list& getPreHiddenAreas() const override; + const std::list& getMuteZones() const override; + const std::list& getPreMuteZones() const override; + + // [get Attenuated] + const std::list& getAttenuatedZones() const override; + const std::list& getPreAttenuatedZones() const override; + + // [get Canceled Contents] + const std::list& getCanceledViewContents() const override; + const std::list& getPreCanceledViewContents() const override; + const std::list& getCanceledSoundContents() const override; + const std::list& getPreCanceledSoundContents() const override; + + // [get Standby Contents] + const std::list& getStandbyViewContents() const override; + const std::list& getPreStandbyViewContents() const override; + const std::list& getStandbySoundContents() const override; + const std::list& getPreStandbySoundContents() const override; + + // [get ContentStates] + const RBAViewContentState* getContentState(const RBAArea* area) const override; + const RBAViewContentState* getPreContentState(const RBAArea* area) const override; + const RBASoundContentState* getContentState(const RBAZone* zone) const override; + const RBASoundContentState* getPreContentState(const RBAZone* zone) const override; + + // [get Areas/Zones by ConentState] + const std::list getArea(const RBAViewContentState* state) const override; + const std::list getPreArea(const RBAViewContentState* state) const override; + const std::list getZone(const RBASoundContentState* state) const override; + const std::list getPreZone(const RBASoundContentState* state) const override; + + // [get Areas/Zones by Content] + const std::list getArea(const RBAViewContent* content) const override; + const std::list getPreArea(const RBAViewContent* content) const override; + const std::list getZone(const RBASoundContent* content) const override; + const std::list getPreZone(const RBASoundContent* content) const override; + + // [get Size] + const RBASize* getSize(const RBAArea* area) const override; + const RBASize* getPreSize(const RBAArea* area) const override; + + // [check Active Scene] + bool isActive(const RBAScene* scene) const override; + bool isPreActive(const RBAScene* scene) const override; + + // [check Active Content] + bool isActive(const RBAContent* const content) const; + bool isPreActive(const RBAContent* const content) const; + bool isActive(const RBAViewContent* content) const override; + bool isActive(const RBASoundContent* content) const override; + bool isPreActive(const RBAViewContent* content) const override; + bool isPreActive(const RBASoundContent* content) const override; + + // [check Visible/Sounding Area/Zone] + bool isVisible(const RBAArea* area) const override; + bool isPreVisible(const RBAArea* area) const override; + bool isSounding(const RBAZone* zone) const override; + bool isPreSounding(const RBAZone* zone) const override; + + // [check Visible/Sounding ContentState] + bool isVisible(const RBAViewContentState* state) const override; + bool isPreVisible(const RBAViewContentState* state) const override; + bool isSounding(const RBASoundContentState* state) const override; + bool isPreSounding(const RBASoundContentState* state) const override; + + // [get View/Sound ContentState] + const RBAViewContentState* getViewContentState(const RBAArea* area) const override; + virtual const RBAViewContentState* getPreViewContentState(const RBAArea* area) const; + const RBASoundContentState* getSoundContentState(const RBAZone* zone) const override; + const RBASoundContentState* getPreSoundContentState(const RBAZone* zone) const override; + + // [check Hidden/Mute] + bool isHidden(const RBAArea* area) const override; + bool isPreHidden(const RBAArea* area) const override; + bool isMute(const RBAZone* zone) const override; + bool isPreMute(const RBAZone* zone) const override; + + // [check Attenuated] + bool isAttenuated(const RBAZone* zone) const override; + bool isPreAttenuated(const RBAZone* zone) const override; + + // [check Cancel] + bool isCancel(const RBAViewContentState* state) const override; + bool isPreCancel(const RBAViewContentState* state) const override; + bool isCancel(const RBASoundContentState* state) const override; + bool isPreCancel(const RBASoundContentState* state) const override; + + // [common] + const std::list& getViewActions() const override; + RBAResultStatusType getStatusType() const override; + bool isLater(const RBAContent* const target, + const RBAContent* const comparisonTarget) const; + + std::string getLog() const override; + void setLog(const std::string& log); + + bool hasDisplayingArea(const RBADisplay* display) const override; + + bool satisfiesConstraints() const override; + + std::int32_t getSceneProperty(const RBAScene* scene, + const std::string& propertyName) const override; + // + // Internal + // + + // Impl [get VisibleArea/SoundingZone] + const std::set& getOutputtingAllocatables() const; + + // Impl [get Active View/Sound ContentStates] + const std::set& getActiveContentStates() const; + + // Impl [get ContentStates] + const RBAContentState* getContentState(const RBAAllocatable* const allocatable) const; + const RBAContentState* getDirectContentState(const RBAAllocatable* const allocatable) const; + const RBAContentState* getPreContentState(const RBAAllocatable* const allocatable) const; + const RBAContentState* getDirectPreContentState(const RBAAllocatable* const allocatable) const; + + // Impl [get Areas/Zones by ConentState] + std::list getAllocatable(const RBAContentState* const state) const; + + // Impl [check Aleady Outputting] + bool isAlreadyOutputting(const RBAContentState* const state) const; + + // Impl [set Active Scene] + void setActive(const RBAScene* const scene, const bool newActive); + + // Impl [check Active ContentState] + bool isActive(const RBAContentState* const state) const; + bool isActive(const RBAViewContentState* const state) const; + bool isActive(const RBASoundContentState* const state) const; + bool isPreActive(const RBAContentState* const state) const; + bool isPreActive(const RBAViewContentState* const state) const; + bool isPreActive(const RBASoundContentState* const state) const; + const RBAContentState* getActiveState(const RBAContent* const content) const; + const RBAContentState* getPreActiveState(const RBAContent* const content) const; + + // Impl [set Active ContentState] + void setActive(const RBAContentState* const state, const bool newActive); + + // Impl [add Standby Content] + void addStandbyContent(const RBAContent* const content); + + // Impl [check Visible/Sounding Alloc ContentState] + bool isOutputting(const RBAAllocatable* const alloc) const; + bool isPreOutputting(const RBAAllocatable* const alloc) const; + bool isOutputting(const RBAContentState* const state) const; + bool isPreOutputting(const RBAContentState* const state) const; + + // Impl [get View/Sound ContentState by Allocatable] + const RBAContentState* getAllocatedContentState(const RBAAllocatable* const allocatable) const; + const RBAContentState* getPreAllocatedContentState(const RBAAllocatable* const allocatable) const; + + // Impl [set View/Sound ContentState] + void setContentState(const RBAAllocatable* const allocatable, const RBAContentState* const state); + + // Impl [check Hidden/Mute Area/Zone] + bool isHidden(const RBAAllocatable* const allocatable) const; + bool isPreHidden(const RBAAllocatable* const allocatable) const; + + // Impl [set Cancel ContentState] + void setCancel(const RBAContentState* const state, const bool checked); + + // Impl [check Cancel ContentState] + bool isCancel(const RBAContentState* const state) const; + bool isPreCancel(const RBAContentState* const state) const; + + // Impl [add Visible/Sounding ContentState] + void addOutputtingContentState(const RBAContentState* const state); + + // Impl [cancel ContentState] + void cancelContentState(const RBAContentState* const state); + + // Impl [common] + std::unique_ptr createBackupCurrentResultSet(); + std::unique_ptr createNextCurrentResultSet(); + void addViewAction(std::unique_ptr& newViewAction); + void setStatusType(const RBAResultStatusType newStatusType); + void updateActiveContentStates(); + void setSceneProperty(const RBASceneImpl* const scene, + const std::string& propertyName, + const std::int32_t value); + void setSceneProperty(const RBAAbstractProperty* const property, + const std::int32_t value); + std::int32_t getSceneProperty(const RBAAbstractProperty* const property) const; + std::int32_t getPreSceneProperty(const RBAAbstractProperty* const property) const; + void setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing, + const RBAContent* const viewContent); + std::unique_ptr& getCurResultSet(); + std::unique_ptr& getPreResultSet(); + RBAContentStatusType getStatusType(const RBAContent* const content) const; + bool isStandby(const RBAContent* const content) const; + bool hasBeenCanceled(const RBAContent* const content) const; + bool hasBeenPreCanceled(const RBAContent* const content) const; + bool hasBeenDisplayed(const RBAContent* const content) const; + bool hasBeenPreDisplayed(const RBAContent* const content) const; + + /// @brief Update status of Content + /// @details Update the status based on the request status, + /// output status, and status at the time of request of the content + /// @param[in] content Content to be updated + void updateStatus(const RBAContent* const content); + + std::unordered_map* getCurStatus() const; + std::set& getDifferentConditionScenes() const; +#ifdef RBA_USE_LOG + void addFailedConstraint(const RBAConstraint* constraint); + const std::list& getFailedConstraints() const; +#endif + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr curResultSet_; + std::unique_ptr preResultSet_; + mutable std::list> viewActions_; + mutable std::list viewActionsForPublicUse_; +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + const RBAArbitrator* arb_; + RBAResultStatusType statusType_; + std::string log_; + +}; + +} + +#endif diff --git a/src/core/logic/RBAResultSet.cpp b/src/core/logic/RBAResultSet.cpp new file mode 100644 index 0000000..bcc9892 --- /dev/null +++ b/src/core/logic/RBAResultSet.cpp @@ -0,0 +1,996 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ResultSet (set arbitration result) class + */ + +#include +#include +#include "RBAResultSet.hpp" + +#include "RBAContentStatusType.hpp" +#include "RBAAreaImpl.hpp" +#include "RBAViewContentImpl.hpp" +#include "RBAViewContentState.hpp" +#include "RBASizeImpl.hpp" +#include "RBAZone.hpp" +#include "RBAZoneImpl.hpp" +#include "RBASoundContent.hpp" +#include "RBASoundContentState.hpp" +#include "RBASceneImpl.hpp" +#include "RBAContentState.hpp" +#include "RBAContent.hpp" +#include "RBAAbstractAllocatable.hpp" +#include "RBAAllocatable.hpp" +#include "RBAConstraint.hpp" +#include "RBADisplay.hpp" +#include "RBAAbstractProperty.hpp" + +namespace rba { + +RBAResultSet::RBAResultSet(const RBAResultSet& resultSet) + : outputtingAllocs_{resultSet.outputtingAllocs_} + , hiddenAllocs_{resultSet.hiddenAllocs_} + , activeContentStates_{resultSet.activeContentStates_} + , canceledContentStates_{resultSet.canceledContentStates_} + , allocToContentState_{resultSet.allocToContentState_} + , visibleAreas_{resultSet.visibleAreas_} + , soundingZones_{resultSet.soundingZones_} + , invisibleAreas_{resultSet.invisibleAreas_} + , unsoundingZones_{resultSet.unsoundingZones_} + , hiddenAreas_{resultSet.hiddenAreas_} + , muteZones_{resultSet.muteZones_} + , attenuatedZones_{resultSet.attenuatedZones_} + , canceledViewContents_{resultSet.canceledViewContents_} + , canceledSoundContents_{resultSet.canceledSoundContents_} + , standbyViewContents_{resultSet.standbyViewContents_} + , standbySoundContents_{resultSet.standbySoundContents_} + , visibleContentStates_{resultSet.visibleContentStates_} + , soundingContentStates_{resultSet.soundingContentStates_} + , activeViewContentStates_{resultSet.activeViewContentStates_} + , activeSoundContentStates_{resultSet.activeSoundContentStates_} + , requestOrderView_{resultSet.requestOrderView_} + , requestOrderSound_{resultSet.requestOrderSound_} + , activeScenes_{resultSet.activeScenes_} + , propertyMap_{resultSet.propertyMap_} + , event_content_{resultSet.event_content_} + , contentToStatus_{resultSet.contentToStatus_} + , requestContentStateMap_{resultSet.requestContentStateMap_} +#ifdef RBA_USE_LOG + , failedConstraints_{resultSet.failedConstraints_} +#endif +{ +} + +// Impl [get VisibleArea/SoundingZone] + +const std::set& +RBAResultSet::getOutputtingAllocatables() const +{ + return outputtingAllocs_; +} + +const std::list& +RBAResultSet::getVisibleAreas() const +{ + return visibleAreas_; +} + +const std::list& +RBAResultSet::getSoundingZones() const +{ + return soundingZones_; +} + +// Impl [get Visible/Sounding ContentStates] + +const std::list& +RBAResultSet::getVisibleContentStates() const +{ + return visibleContentStates_; +} + +const std::list& +RBAResultSet::getSoundingContentStates() const +{ + return soundingContentStates_; +} + +// Impl [get Active View/Sound ContentStates] + +const std::set& +RBAResultSet::getActiveContentStates() const +{ + return activeContentStates_; +} + +const std::list& +RBAResultSet::getActiveViewContentStates() const +{ + return activeViewContentStates_; +} + +const std::list& +RBAResultSet::getActiveSoundContentStates() const +{ + return activeSoundContentStates_; +} + +// Impl [get Active Scenes] + +const std::list& +RBAResultSet::getActiveScenes() const +{ + return activeScenes_; +} + +// Impl [get InvisibleAreas/UnsoundingZone] + +const std::list& +RBAResultSet::getInvisibleAreas() const +{ + return invisibleAreas_; +} + +const std::list& +RBAResultSet::getUnsoundingZones() const +{ + return unsoundingZones_; +} + +// Impl [get HiddenAreas/MuteZones] + +const std::list& +RBAResultSet::getHiddenAreas() const +{ + return hiddenAreas_; +} + +const std::list& +RBAResultSet::getMuteZones() const +{ + return muteZones_; +} + +// Impl [get Attenuated] +const std::list& +RBAResultSet::getAttenuatedZones() const +{ + return attenuatedZones_; +} + +// Impl [get Canceled Contents] + +const std::list& +RBAResultSet::getCanceledViewContents() const +{ + return canceledViewContents_; +} + +const std::list& +RBAResultSet::getCanceledSoundContents() const +{ + return canceledSoundContents_; +} + +// Impl [get Standby Contents] + +const std::list& +RBAResultSet::getStandbyViewContents() const +{ + return standbyViewContents_; +} + +const std::list& +RBAResultSet::getStandbySoundContents() const +{ + return standbySoundContents_; +} + +// Impl [get ContentStates] + +const RBAContentState* +RBAResultSet::getContentState(const RBAAllocatable* const alloc) const +{ + if(alloc != nullptr) { + auto it = allocToContentState_.find(alloc); + if(it != allocToContentState_.end()) { + auto state = it->second; + // If the content(state) assigned to the "alloc" has the + // allocatable function (such as cyclic), the contentState assigned to it + // is the contentState assigned to the "alloc". + // Search this until it is not allocatable content. + while ((state != nullptr) + && (dynamic_cast(state->getOwner()) != nullptr)) { + it = allocToContentState_.find(dynamic_cast(state->getOwner())); + state = it->second; + } + return state; + } + } + return nullptr; +} + +const RBAContentState* +RBAResultSet::getDirectContentState(const RBAAllocatable* const alloc) const +{ + if(alloc != nullptr) { + auto it = allocToContentState_.find(alloc); + if(it != allocToContentState_.end()) { + return it->second; + } + } + return nullptr; +} + +// Impl [get Areas/Zones by ConentState] + +void +RBAResultSet::getAlloc(const RBAContentState* const state, + std::list& allocList) const +{ + if(state != nullptr) { + for(const auto& it : allocToContentState_) { + if(it.second == state) { + allocList.push_back(it.first); + } + } + } +} + +void +RBAResultSet::getArea(const RBAViewContentState* const state, + std::list& areaList) const +{ + if(state != nullptr) { + for(const auto& it : allocToContentState_) { + if(dynamic_cast(it.second) == state) { + const RBAContent* const content {dynamic_cast(it.first)}; + if (content != nullptr) { // In case of CyclicContent + // Get ViewContentState assigned to CyclicContent + const RBAViewContentState* const ownerState + {dynamic_cast(getReqestState(content))}; + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // calling getArea() recursively + //  [Reason that there is no problem if the rule is deviated] + // When getArea() is performed on CyclicContent, at that time, + // respond Area where ViewContent assigned to CyclicContent + // is assigned. When CyclicContent is assigned to CyclicContent, + // multiple recursive calls may be made, but the rule model + // definition is finite. + // Therefore, stack overflow will not be occured, no problem. + getArea(ownerState, areaList); + } else { + areaList.push_back(dynamic_cast(it.first)); + } + } + } + } +} + +void +RBAResultSet::getZone(const RBASoundContentState* const state, + std::list& zoneList) const +{ + if(state != nullptr) { + for(const auto& it : allocToContentState_) { + if (dynamic_cast(it.second) == state) { + const RBAContent* const content {dynamic_cast(it.first)}; + if (content != nullptr) { + const RBASoundContentState* const ownerState + {dynamic_cast(getReqestState(content))}; + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Function '::rba::RBAResultSet::getZone=(_, + // p={c::rba::RBASoundContentState}, + // &{c::std::__cxx11::list}>})' + // is recursive. + //  [Reason that there is no problem if the rule is deviated] + // Recursive call is required as a feature + getZone(ownerState, zoneList); + } else { + zoneList.push_back(dynamic_cast(it.first)); + } + } + } + } +} + +// Impl [get Areas/Zones by Content] + +void +RBAResultSet::getArea(const RBAViewContent* const content, + std::list& areaList) const +{ + if(content != nullptr) { + for(auto& state : content->getContentStates()) { + getArea(state, areaList); + if(!areaList.empty()) { + break; + } + } + } +} + +void +RBAResultSet::getZone(const RBASoundContent* const content, + std::list& zoneList) const +{ + if(content != nullptr) { + for(auto& state : content->getContentStates()) { + getZone(state, zoneList); + if(!zoneList.empty()) { + break; + } + } + } +} + +// Impl [get Size] + +const RBASize* +RBAResultSet::getSize(const RBAArea* const area) const +{ + if(area == nullptr) { + return nullptr; + } + const RBAAreaImpl* const areaImpl {dynamic_cast(area)}; + auto it = allocToContentState_.find(areaImpl); + if(it == allocToContentState_.end() || (it->second == nullptr)) { + return nullptr; + } + const RBAContent* const content {dynamic_cast(it->second->getOwner())}; + const RBASize* backupAreaSize {nullptr}; + std::int32_t backupDiffVal {-1}; + for(auto& areaSize : areaImpl->getSizes()) { + const RBASizeImpl* const areaSizeImpl {dynamic_cast(areaSize)}; + for(auto& contentSize : content->getSizes()) { + const RBASizeImpl* const contentSizeImpl {dynamic_cast(contentSize)}; + const auto diffVal = areaSizeImpl->diff(contentSizeImpl); + if(diffVal == 0) { + return areaSizeImpl; + } + else if((backupDiffVal < 0) || (backupDiffVal > diffVal)) { + backupAreaSize = areaSizeImpl; + backupDiffVal = diffVal; + } else { + ; + } + } + } + + return backupAreaSize; +} + +// Impl [check Active Scene] + +bool +RBAResultSet::isActive(const RBAScene* const scene) const +{ + return (std::find(activeScenes_.begin(), activeScenes_.end(), scene) + != activeScenes_.end()); +} + +// Impl [check Active ContentState] +bool +RBAResultSet::isActive(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) != contentToStatus_.end()) { + return contentToStatus_[content].isActive(); + } + return false; +} + +bool +RBAResultSet::isActive(const RBAContentState* const state) const +{ + const RBAContent* const content {dynamic_cast(state->getOwner())}; + return (isActive(content) && (getReqestState(content) == state)); +} + +const RBAContentState* +RBAResultSet::getReqestState(const RBAContent* const content) const +{ + if (requestContentStateMap_.find(content) != requestContentStateMap_.end()) { + return requestContentStateMap_[content]; + } + return nullptr; +} + +// Impl [check Outputting Allocatable] + +bool +RBAResultSet::isOutputting(const RBAAllocatable* const alloc) const +{ + return outputtingAllocs_.find(alloc) != outputtingAllocs_.end(); +} + +// Impl [check Outputting ContentState] + +bool +RBAResultSet::isOutputting(const RBAContentState* const state) const +{ + std::list allocList; + getAlloc(state, allocList); + for(auto& alloc : allocList) { + if(isOutputting(alloc)) { + return true; + } + } + return false; +} + +// Impl [check Hidden/Mute Area/Zone] + +bool +RBAResultSet::isHidden(const RBAAllocatable* const alloc) const +{ + return hiddenAllocs_.find(alloc) != hiddenAllocs_.end(); +} + +// Impl [check Attenuated Zone] + +bool +RBAResultSet::isAttenuated(const RBAZone* const zone) const +{ + return std::find(attenuatedZones_.begin(), attenuatedZones_.end(), zone) != attenuatedZones_.end(); +} + +// Impl [check Cancel ContentState] + +bool +RBAResultSet::isCancel(const RBAContentState* const state) const +{ + return canceledContentStates_.find(state) != canceledContentStates_.end(); +} + +// Impl [check Aleady OutPutting] + +bool +RBAResultSet::isAlreadyOutputting(const RBAContentState* const state) const +{ + const auto content = dynamic_cast(state->getOwner()); + for(auto& alloc : content->getAllocatables()) { + if((getContentState(alloc) == state) && !alloc->isHidden()) { + return true; + } + } + return false; +} + +// Impl [set Active Scene] + +/** + * @brief Set display request or display withdrawal request, for Scene + * @param scene Scene + * @param newActive true: display request, false: display withdrawal request + */ +void +RBAResultSet::setActive(const RBAScene* const scene, const bool newActive) +{ + const auto it = std::find(activeScenes_.begin(), activeScenes_.end(), scene); + if(it == activeScenes_.end()) { + if(newActive) { + activeScenes_.push_back(scene); + } + } + else { + if(!newActive) { + static_cast(activeScenes_.erase(it)); + } + } +} + +// Impl [set Active ContentState] + +/** + * @brief Set display request or display withdrawal request, for Content state + * @details If the content has already been registered, + delete the registered content. + * @param contentState Content state + * @param newActive true: display request, false: display withdrawal request + */ +void +RBAResultSet::setActive(const RBAContentState* const state, const bool newActive) +{ + updateRequestStatus(dynamic_cast(state->getOwner()), newActive); + + // Check if Content is already active + const RBAContentState* temp {nullptr}; + for(auto& cs : activeContentStates_) { + if(cs->getOwner() == state->getOwner()) { + temp = cs; + break; + } + } + // Delete if Content is active + if (temp != nullptr) { + setOrder(temp, 0); + static_cast(activeContentStates_.erase(temp)); + if (temp->isViewContentState()) { + activeViewContentStates_.remove(dynamic_cast(temp)); + } else { + activeSoundContentStates_.remove(dynamic_cast(temp)); + } + } + + // Rgistre active + if(newActive) { + requestContentStateMap_[dynamic_cast(state->getOwner())] = state; + static_cast(activeContentStates_.insert(state)); + if (state->isViewContentState()) { + setOrder(state, requestOrderView_); + requestOrderView_++; + activeViewContentStates_.push_back(dynamic_cast(state)); + } else { + setOrder(state, requestOrderSound_); + requestOrderSound_++; + activeSoundContentStates_.push_back(dynamic_cast(state)); + } + } + else { + setOrder(state, 0); + static_cast(requestContentStateMap_.erase(dynamic_cast(state->getOwner()))); + } +} + +// [cancel ContentState] + +void +RBAResultSet::cancelContentState(const RBAContentState* const state) +{ + setOrder(state, 0); + if (state->isViewContentState()) { + canceledViewContents_.push_back(dynamic_cast(state->getOwner())); + } else { + canceledSoundContents_.push_back(dynamic_cast(state->getOwner())); + } +} + +// Impl [set Cancel ContentState] + +void +RBAResultSet::setCancel(const RBAContentState* const state, const bool checked) +{ + if(checked) { + static_cast(canceledContentStates_.insert(state)); + } + else { + static_cast(canceledContentStates_.erase(state)); + } +} + +// Impl [set ContentState] + +void +RBAResultSet::setContentState(const RBAAllocatable* const alloc, const RBAContentState* const state) +{ + //alloc + allocToContentState_[alloc] = state; + const bool isHiddenRes {alloc->isHidden()}; + const bool existsState {(state != nullptr)}; + const RBAAreaImpl* area {dynamic_cast(alloc)}; + const RBAZoneImpl* zone {dynamic_cast(alloc)}; + + if (isHiddenRes) { + static_cast(hiddenAllocs_.insert(alloc)); + } else { + // Currently, there is no case to delete the Allocable stored in + // hiddenAllocs_. In the future, since hiding may be forcibly released, + // implement it. + static_cast(hiddenAllocs_.erase(alloc)); + } + + if (!isHiddenRes && existsState) { + if (alloc->isArea() || alloc->isZone()) { + static_cast(outputtingAllocs_.insert(alloc)); + } + if (isOutputting(alloc)) { + const RBAContentState* s {state}; + while ((s != nullptr) && (dynamic_cast(s->getOwner()) != nullptr)) { + RBAAllocatable* extAlloc {dynamic_cast(s->getOwner())}; + static_cast(outputtingAllocs_.insert(extAlloc)); + s = extAlloc->getState(); + } + } + + if (alloc->isArea()) { + if (std::find(visibleAreas_.begin(), visibleAreas_.end(), area) == visibleAreas_.end()) { + visibleAreas_.push_back(area); + } + invisibleAreas_.remove(area); + } else if (alloc->isZone()) { + if (std::find(soundingZones_.begin(), soundingZones_.end(), zone) == soundingZones_.end()) { + soundingZones_.push_back(zone); + } + unsoundingZones_.remove(zone); + } else { + ; + } + } else { + static_cast(outputtingAllocs_.erase(alloc)); + if (alloc->isArea()) { + // Currently, there is no case to delete the Area stored in visibleAreas_. + // In the future, it may happen that content allocation is + // forcibly released, so implement thes. + visibleAreas_.remove(area); + if (std::find(invisibleAreas_.begin(), invisibleAreas_.end(), area) == invisibleAreas_.end()) { + invisibleAreas_.push_back(area); + } + } else if (alloc->isZone()) { + // Currently, there is no case to delete the Area stored in soundingZones_. + // In the future, it may happen that content allocation is + // forcibly released, so implement thes. + soundingZones_.remove(zone); + if (std::find(unsoundingZones_.begin(), unsoundingZones_.end(), zone) == unsoundingZones_.end()) { + unsoundingZones_.push_back(zone); + } + } else { + ; + } + } + + if (isHiddenRes && existsState) { + if (alloc->isArea()) { + if (std::find(hiddenAreas_.begin(), hiddenAreas_.end(), area) == hiddenAreas_.end()) { + hiddenAreas_.push_back(area); + } + } else if (alloc->isZone()) { + if (std::find(muteZones_.begin(), muteZones_.end(), zone) == muteZones_.end()) { + muteZones_.push_back(zone); + } + } else { + ; + } + } else { + if (alloc->isArea()) { + hiddenAreas_.remove(area); + } else if (alloc->isZone()) { + muteZones_.remove(zone); + } else { + ; + } + } + + if (alloc->isZone()) { + if (existsState && !isHiddenRes && zone->isAttenuated()) { + if (std::find(attenuatedZones_.begin(), attenuatedZones_.end(), zone) == attenuatedZones_.end()) { + attenuatedZones_.push_back(zone); + } + } else { + // Currently, there is no case to delete the Allocatable stored in + // attenuatedZones_. In the future, there may be cases in which + // "attenuation" is forcibly canceled, so implement this. + attenuatedZones_.remove(zone); + } + } +} + +// Impl [add Visible/Sounding ContentState] + +void +RBAResultSet::addOutputtingContentState(const RBAContentState* const state) +{ + if (state->isViewContentState()) { + visibleContentStates_.push_back(dynamic_cast(state)); + } + else if (state->isSoundContentState()) { + soundingContentStates_.push_back(dynamic_cast(state)); + } + else { + ; + } +} + +// Impl [add Standby Content] + +void +RBAResultSet::addStandbyContent(const RBAContent* const content) +{ + if (content->isViewContent()) { + standbyViewContents_.push_back(dynamic_cast(content)); + } + else if (content->isSoundContent()) { + standbySoundContents_.push_back(dynamic_cast(content)); + } + else { + ; + } +} + +// [activeView] + +void +RBAResultSet::copyActives(const std::unique_ptr& resultSet) +{ + activeContentStates_ = resultSet->activeContentStates_; + activeViewContentStates_ = resultSet->activeViewContentStates_; + activeSoundContentStates_ = resultSet->activeSoundContentStates_; + activeScenes_ = resultSet->activeScenes_; + contentToStatus_ = resultSet->contentToStatus_; + requestContentStateMap_ = resultSet->requestContentStateMap_; + + // Reset order + requestOrderView_ = 1; + requestOrderSound_ = 1; + for(const RBAViewContentState* const viewState : activeViewContentStates_) { + setOrder(dynamic_cast(viewState), requestOrderView_); + requestOrderView_++; + } + for(const RBASoundContentState* const soundState : activeSoundContentStates_) { + setOrder(dynamic_cast(soundState), requestOrderSound_); + requestOrderSound_++; + } +} + +void +RBAResultSet::updateActiveContentStates() +{ + for (auto& state : canceledContentStates_) { + static_cast(activeContentStates_.erase(state)); + if (state->isViewContentState()) { + activeViewContentStates_.remove(dynamic_cast(state)); + } else { + activeSoundContentStates_.remove(dynamic_cast(state)); + } + } +} + +void +RBAResultSet::copyProperties(const std::unique_ptr& resultSet) +{ + propertyMap_ = resultSet->propertyMap_; +} + +void +RBAResultSet::setSceneProperty(const RBAScene* const scene, + const std::string& propertyName, + const std::int32_t value) +{ + propertyMap_[dynamic_cast(scene)->getProperty(propertyName)] = value; +} + +void +RBAResultSet::setSceneProperty(const RBAAbstractProperty* const property, + const std::int32_t value) +{ + propertyMap_[property] = value; +} + +std::int32_t +RBAResultSet::getSceneProperty(const RBAAbstractProperty* const property) const +{ + auto it = propertyMap_.find(property); + if(it == propertyMap_.end()) { + // Property not registered + return -99; + } + + return it->second; +} + +void +RBAResultSet::setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing, + const RBAContent* const content) +{ + event_content_[eventProcessing] = content; +} + +const RBAContent* +RBAResultSet::getContentOfEventProcessing(const RBAEventProcessing* const eventProcessing) const +{ + if (event_content_.find(eventProcessing) != event_content_.end()) { + return event_content_.at(eventProcessing); + } + return nullptr; +} + +bool +RBAResultSet::hasDisplayingArea(const RBADisplay* const display) const +{ + bool displayed {false}; + const std::list areas {display->getAreas()}; + const auto areasBegin = areas.begin(); + const auto areasEnd = areas.end(); + for(const RBAArea* const area : visibleAreas_) { + if (std::find(areasBegin, areasEnd, area) != areasEnd) { + displayed = true; + break; + } + } + return displayed; +} + +bool +RBAResultSet::isLater(const RBAContent* const target, + const RBAContent* const comparisonTarget) const +{ + bool isLaterRes {false}; + bool isBreak {false}; + + if (target->isViewContent()) { + const RBAViewContent* const targetContent { + dynamic_cast(target)}; + const RBAViewContent* const comparisonTargetContent { + dynamic_cast(comparisonTarget)}; + for (auto it = activeViewContentStates_.rbegin(); + (it != activeViewContentStates_.rend()) && (!isBreak) ; it++) { + if ((*it)->getOwner() == targetContent) { + isLaterRes = true; + isBreak = true; + } else if ((*it)->getOwner() == comparisonTargetContent) { + isBreak = true; + } else { + ; + } + } + } else { + const RBASoundContent* const targetContent { + dynamic_cast(target)}; + const RBASoundContent* const comparisonTargetContent { + dynamic_cast(comparisonTarget)}; + for (auto it = activeSoundContentStates_.rbegin(); + (it != activeSoundContentStates_.rend()) && (!isBreak); it++) { + if ((*it)->getOwner() == targetContent) { + isLaterRes = true; + isBreak = true; + } else if ((*it)->getOwner() == comparisonTargetContent) { + isBreak = true; + } else { + ; + } + } + } + return isLaterRes; +} + +std::set& +RBAResultSet::getDifferentConditionScenes(const RBAResultSet& target) +{ + // Detect the difference from the target scene On state + const std::list targetScenes {target.getActiveScenes()}; + for (auto& s : activeScenes_) { + if (std::find(targetScenes.begin(), targetScenes.end(), s) + == targetScenes.end()) { + static_cast(differentConditionScenes_.insert(dynamic_cast(s))); + } + } + for (auto& s : targetScenes) { + if (std::find(activeScenes_.begin(), activeScenes_.end(), s) + == activeScenes_.end()) { + static_cast(differentConditionScenes_.insert(dynamic_cast(s))); + } + } + + // Detect the difference from the target scene property state + for (auto& p : propertyMap_) { + if (target.getSceneProperty(p.first) != p.second) { + static_cast(differentConditionScenes_.insert(p.first->getScene())); + } + } + for (auto& p : target.getScenePropertyMap()) { + if (getSceneProperty(p.first) != p.second) { + static_cast(differentConditionScenes_.insert(p.first->getScene())); + } + } + return differentConditionScenes_; +} + +void +RBAResultSet::updateRequestStatus(const RBAContent* const content, const bool isOnRequest) +{ + if (isOnRequest) { + contentToStatus_[content].onRequest(); + } else { + // When a content "off request" comes in, turn off the content request + // even if the requested state is different from Active state at that time. + static_cast(contentToStatus_.erase(content)); + } +} + +void +RBAResultSet::setStatusType(const RBAContent* const content, const RBAContentStatusType type) +{ + contentToStatus_[content].setStatusType(type); +} + +RBAContentStatusType +RBAResultSet::getStatusType(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) != contentToStatus_.end()) { + return contentToStatus_[content].getStatusType(); + }else { + return RBAContentStatusType::NoRequest; + } +} + +bool +RBAResultSet::isOutput(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) != contentToStatus_.end()) { + return contentToStatus_[content].isDisplayed(); + } else { + return false; + } +} + +bool +RBAResultSet::isStandby(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) + != contentToStatus_.end()) { + return contentToStatus_[content].isStandby(); + } else { + return false; + } +} + +bool +RBAResultSet::hasBeenCanceled(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) != contentToStatus_.end()) { + return contentToStatus_[content].hasBeenCanceled(); + } else { + return false; + } +} + +bool +RBAResultSet::hasBeenDisplayed(const RBAContent* const content) const +{ + if (contentToStatus_.find(content) != contentToStatus_.end()) { + return contentToStatus_[content].hasBeenDisplayed(); + } else { + return false; + } +} + +std::unordered_map* +RBAResultSet::getStatus() const +{ + return &contentToStatus_; +} + +#ifdef RBA_USE_LOG +void +RBAResultSet::addFailedConstraint(const RBAConstraint* constraint) +{ + failedConstraints_.push_back(constraint); +} + +const std::list& +RBAResultSet::getFailedConstraints() +{ + return failedConstraints_; +} +#endif + +const std::unordered_map& +RBAResultSet::getScenePropertyMap() const +{ + return propertyMap_; +} + +void +RBAResultSet::setOrder(const RBAContentState* const state, const std::int32_t newOrder) const +{ + const_cast(state)->setOrder(newOrder); +} + +} diff --git a/src/core/logic/RBAResultSet.hpp b/src/core/logic/RBAResultSet.hpp new file mode 100644 index 0000000..3aca4e9 --- /dev/null +++ b/src/core/logic/RBAResultSet.hpp @@ -0,0 +1,246 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ResultSet (set arbitration result) class header + */ + +#ifndef RBARESULTSET_HPP +#define RBARESULTSET_HPP + +#include +#include +#include +#include +#include +#include + +#include "RBAContentStatusType.hpp" +#include "RBAContentStatus.hpp" + +namespace rba +{ + +class RBADisplay; +class RBASize; +class RBAAllocatable; +class RBAArea; +class RBAZone; +class RBAContent; +class RBAViewContent; +class RBASoundContent; +class RBAContentState; +class RBAViewContentState; +class RBASoundContentState; +class RBAScene; +class RBASceneImpl; +class RBAAbstractProperty; +class RBAEventProcessing; +class RBAConstraint; + +class RBAResultSet +{ +public: + RBAResultSet()=default; + RBAResultSet(const RBAResultSet& resultSet); + RBAResultSet(const RBAResultSet&&)=delete; + RBAResultSet& operator=(const RBAResultSet&)=delete; + RBAResultSet& operator=(const RBAResultSet&&)=delete; + virtual ~RBAResultSet()=default; + +public: + // Impl [get VisibleArea/SoundingZone] + const std::set& getOutputtingAllocatables() const; + const std::list& getVisibleAreas() const; + const std::list& getSoundingZones() const; + + // Impl [get Visible/Sounding ContentStates] + const std::list& getVisibleContentStates() const; + const std::list& getSoundingContentStates() const; + + // Impl [get Active View/Sound ContentStates] + const std::set& getActiveContentStates() const; + const std::list& getActiveViewContentStates() const; + const std::list& getActiveSoundContentStates() const; + + // Impl [get Active Scenes] + const std::list& getActiveScenes() const; + + // Impl [get InvisibleAreas/UnsoundingZone] + const std::list& getInvisibleAreas() const; + const std::list& getUnsoundingZones() const; + + // Impl [get HiddenAreas/MuteZones] + const std::list& getHiddenAreas() const; + const std::list& getMuteZones() const; + + // Impl [get Attenuated] + const std::list& getAttenuatedZones() const; + + // Impl [get Canceled Contents] + const std::list& getCanceledViewContents() const; + const std::list& getCanceledSoundContents() const; + + // Impl [get Standby Contents] + const std::list& getStandbyViewContents() const; + const std::list& getStandbySoundContents() const; + + // Impl [get ContentStates] + const RBAContentState* getContentState(const RBAAllocatable* const alloc) const; + const RBAContentState* getDirectContentState(const RBAAllocatable* const alloc) const; + + // Impl [get Areas/Zones by ConentState] + void getAlloc(const RBAContentState* const state, + std::list& allocList) const; + void getArea(const RBAViewContentState* const state, + std::list& areaList) const; + void getZone(const RBASoundContentState* const state, + std::list& zoneList) const; + + // Impl [get Areas/Zones by Content] + void getArea(const RBAViewContent* const content, + std::list& areaList) const; + void getZone(const RBASoundContent* const content, + std::list& zoneList) const; + + // Impl [get Size] + const RBASize* getSize(const RBAArea* const area) const; + + // Impl [check Active Scene/Content/ContentState] + bool isActive(const RBAScene* const scene) const; + bool isActive(const RBAContent* const content) const; + bool isActive(const RBAContentState* const state) const; + const RBAContentState* getReqestState(const RBAContent* const content) const; + + // Impl [check Outputting Allocatable/ContentState] + bool isOutputting(const RBAAllocatable* const alloc) const; + bool isOutputting(const RBAContentState* const state) const; + + // Impl [check Hidden] + bool isHidden(const RBAAllocatable* const alloc) const; + + // Impl [check Attenuated Zone] + bool isAttenuated(const RBAZone* const zone) const; + + // Impl [check Cancel ContentState] + bool isCancel(const RBAContentState* const state) const; + + // Impl [check Aleady OutPutting] + bool isAlreadyOutputting(const RBAContentState* const state) const; + + // Impl [set Active Scene/ContentState] + void setActive(const RBAScene* const scene, const bool newActive); + void setActive(const RBAContentState* const state, const bool newActive); + + // [cancel ContentState] + void cancelContentState(const RBAContentState* const state); + + // Impl [set Cancel ContentState] + void setCancel(const RBAContentState* const state, const bool checked); + + // Impl [set ContentState] + void setContentState(const RBAAllocatable* const alloc, const RBAContentState* const state); + + // Impl [add Outputting ContentState] + void addOutputtingContentState(const RBAContentState* const state); + + // Impl [add Standby Content] + void addStandbyContent(const RBAContent* const content); + + // [activeView] + void copyActives(const std::unique_ptr& resultSet); + void updateActiveContentStates(); + + // [Property] + void copyProperties(const std::unique_ptr& resultSet); + void setSceneProperty(const RBAScene* const scene, + const std::string& propertyName, + const std::int32_t value); + void setSceneProperty(const RBAAbstractProperty* const property, + const std::int32_t value); + std::int32_t getSceneProperty(const RBAAbstractProperty* const property) const; + + // [EventProcessing] + void setContentOfEventProcessing(const RBAEventProcessing* const eventProcessing, + const RBAContent* const content); + const RBAContent* getContentOfEventProcessing(const RBAEventProcessing* const eventProcessing) const; + + // [DisplayContents] + bool hasDisplayingArea(const RBADisplay* const display) const; + + // common + bool isLater(const RBAContent* const target, const RBAContent* const comparisonTarget) const; + std::set& getDifferentConditionScenes(const RBAResultSet& target); + void updateRequestStatus(const RBAContent* const content, const bool isOnRequest); + void setStatusType(const RBAContent* const content, const RBAContentStatusType type); + RBAContentStatusType getStatusType(const RBAContent* const content) const; + bool isOutput(const RBAContent* const content) const; + bool isStandby(const RBAContent* const content) const; + bool hasBeenCanceled(const RBAContent* const content) const; + bool hasBeenDisplayed(const RBAContent* const content) const; + std::unordered_map* getStatus() const; +#ifdef RBA_USE_LOG + void addFailedConstraint(const RBAConstraint* constraint); + const std::list& getFailedConstraints(); +#endif + +private: + const std::unordered_map& getScenePropertyMap() const; + void setOrder(const RBAContentState* const state, const std::int32_t newOrder) const; + + std::set outputtingAllocs_; + std::set hiddenAllocs_; + std::set activeContentStates_; + std::set canceledContentStates_; + std::unordered_map allocToContentState_; + + // The lists for getList type acquisition function + std::list visibleAreas_; + std::list soundingZones_; + std::list invisibleAreas_; + std::list unsoundingZones_; + std::list hiddenAreas_; + std::list muteZones_; + std::list attenuatedZones_; + std::list canceledViewContents_; + std::list canceledSoundContents_; + std::list standbyViewContents_; + std::list standbySoundContents_; + std::list visibleContentStates_; + std::list soundingContentStates_; + std::list activeViewContentStates_; + std::list activeSoundContentStates_; + + // common + std::int32_t requestOrderView_ {1}; + std::int32_t requestOrderSound_ {1}; + std::list activeScenes_; + std::unordered_map propertyMap_; + std::unordered_map event_content_; + mutable std::unordered_map contentToStatus_; + std::set differentConditionScenes_; + + mutable std::unordered_map requestContentStateMap_; + + mutable std::mutex mutex_; +#ifdef RBA_USE_LOG + std::list failedConstraints_; +#endif + +}; + +} +#endif diff --git a/src/core/logic/RBARollbacker.cpp b/src/core/logic/RBARollbacker.cpp new file mode 100644 index 0000000..9870fa9 --- /dev/null +++ b/src/core/logic/RBARollbacker.cpp @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Rollbacker (rollback of arbitration results) class implementation + */ + +#include "RBARollbacker.hpp" +#include "RBAModelImpl.hpp" +#include "RBABackUpAllocatable.hpp" +#include "RBAArbitrator.hpp" + +namespace rba +{ + +RBARollbacker::~RBARollbacker() noexcept +{ + children_.clear(); +} + +void +RBARollbacker::addChild(const std::shared_ptr child) +{ + children_.push_back(child); +} + +void +RBARollbacker::removeChild(const std::shared_ptr child) +{ + children_.remove(child); +} + +void +RBARollbacker::backup(std::list& backuplist) +{ + backupMap_.clear(); + for(const RBAAllocatable* const original : backuplist) { + std::unique_ptr backupObj + {std::make_unique("backup_" + + original->getElementName())}; + copyAllocatable(original, backupObj.get()); + backupMap_[original] = std::move(backupObj); + } +} + +void +RBARollbacker::rollback() +{ + for (auto& Child : children_) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // rollback() is called recursively + // [Explanation that there is no problem if you deviate from the rules] + // RBARollbacker is created each time the re-arbitration nest becomes + // deeper, but since the infinite loop prevention process is implemented + // in re-arbitration, stack overflow does not occur. + Child->rollback(); + } + for(auto itr = backupMap_.begin(); itr != backupMap_.end(); ++itr) { + const RBAAllocatable* const original {itr->first}; + const RBAAllocatable* const backupVal {itr->second.get()}; + copyAllocatable(backupVal, const_cast(original)); + } +} + +void +RBARollbacker::copyAllocatable(const RBAAllocatable* const from, + RBAAllocatable* const to) +{ + to->setHiddenChecked(from->isHiddenChecked()); + to->setHidden(from->isHidden()); + to->setChecked(from->isChecked()); + to->setState(from->getState()); + to->clearAllocatablesAffectedByYou(); + for(const RBAAllocatable* const allocatable : from->getAllocatablesAffectedByYou()) { + to->addAllocatableWhichHasBeenAffectedByYou(allocatable); + } + to->setAttenuateChecked(from->isAttenuateChecked()); + to->setAttenuated(from->isAttenuated()); +} + +} diff --git a/src/core/logic/RBARollbacker.hpp b/src/core/logic/RBARollbacker.hpp new file mode 100644 index 0000000..08ee4e9 --- /dev/null +++ b/src/core/logic/RBARollbacker.hpp @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Rollbacker (rollback of arbitration results) class header + */ + +#ifndef RBARROLLBACKER_HPP +#define RBARROLLBACKER_HPP + +#include +#include +#include + +namespace rba +{ +class RBAModel; +class RBAAllocatable; +class RBAArbitrator; + +class RBARollbacker +{ + public: + RBARollbacker()=default; + RBARollbacker(const RBARollbacker&)=delete; + RBARollbacker(const RBARollbacker&&)=delete; + RBARollbacker& operator=(const RBARollbacker&)=delete; + RBARollbacker& operator=(const RBARollbacker&&)=delete; + virtual ~RBARollbacker() noexcept; + + /** + * Register a backup for child re-arbitration when execute re-arbitration + * during re-arbitration. + * Restore child backup when rolling back + */ + void addChild(const std::shared_ptr child); + + void removeChild(const std::shared_ptr child); + + /** + * Back up arbitration status and impact information. + * (Only "Allocatable" that directly arbitration is backed up) + * Child will back up re-arbitraion during execution of re-aribitration. + * + * Backing up all "Allocatable" on a model is inefficient, + * so back up only those that execute re-arbitration + */ + void backup(std::list& backuplist); + + /** + * Roll back the arbitration state and impact information to + * the state when the instance was created + */ + void rollback(); + + private: + /** + * @brief Copy Allocable arbitration state + * @param from source of copy + * @param to destination of copy + */ + void copyAllocatable(const RBAAllocatable* const from, RBAAllocatable* const to); + + std::list> children_; + // Rollback information when arbitration fails + std::unordered_map> backupMap_; +}; + +} + +#endif diff --git a/src/core/logic/RBAViewAction.cpp b/src/core/logic/RBAViewAction.cpp new file mode 100644 index 0000000..54553dc --- /dev/null +++ b/src/core/logic/RBAViewAction.cpp @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ViewAction Class implementation + */ + +#include "RBAArea.hpp" +#include "RBAViewContent.hpp" +#include "RBAViewContentState.hpp" +#include "RBAViewAction.hpp" +#include "RBAViewMove.hpp" +#include "RBAViewTransition.hpp" + +namespace rba { + +const RBAArea* +RBAViewAction::getArea() const +{ + return nullptr; +} + +const RBAViewContent* +RBAViewAction::getFromContent() const +{ + return nullptr; +} + +const RBAViewContent* +RBAViewAction::getToContent() const +{ + return nullptr; +} + +const RBAViewContentState* +RBAViewAction::getFromContentState() const +{ + return nullptr; +} + +const RBAViewContentState* +RBAViewAction::getToContentState() const +{ + return nullptr; +} + +const RBAArea* +RBAViewAction::getFromArea() const +{ + return nullptr; +} + +const RBAArea* +RBAViewAction::getToArea() const +{ + return nullptr; +} + +const RBAViewContent* +RBAViewAction::getContent() const +{ + // This function is never called because the function of the derived class + // is always called + return nullptr; +} + +const RBAViewContentState* +RBAViewAction::getContentState() const +{ + // This function is never called because the function of the derived class + // is always called + return nullptr; +} + +} diff --git a/src/core/logic/RBAViewMove.cpp b/src/core/logic/RBAViewMove.cpp new file mode 100644 index 0000000..7e40043 --- /dev/null +++ b/src/core/logic/RBAViewMove.cpp @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBAViewMove.cpp + */ + +#include "RBAArea.hpp" +#include "RBAViewContent.hpp" +#include "RBAViewContentState.hpp" +#include "RBAViewMove.hpp" + +namespace rba { + +RBAViewMove::RBAViewMove(const RBAArea* const newFromArea, const RBAArea* const newToArea, + const RBAViewContentState* const newContentState) + : RBAViewAction{} +{ + fromArea_ = newFromArea; + toArea_ = newToArea; + contentState_ = newContentState; +} + +RBAViewMove::RBAViewMove(const RBAViewMove& viewMove) + : RBAViewAction{viewMove} +{ + fromArea_ = viewMove.fromArea_; + toArea_ = viewMove.toArea_; + contentState_ = viewMove.contentState_; +} + +bool +RBAViewMove::operator==(const RBAViewAction& viewAction) +{ + if(getViewActionType() != viewAction.getViewActionType()) { + // False if the view action types do not match + return false; + } + + const RBAViewMove* const viewMove {dynamic_cast(&viewAction)}; + return ((fromArea_ == viewMove->fromArea_) && + (toArea_ == viewMove->toArea_) && + (contentState_ == viewMove->contentState_)); +} + +const RBAArea* +RBAViewMove::getFromArea() const +{ + return fromArea_; +} + +const RBAArea* +RBAViewMove::getToArea() const +{ + return toArea_; +} + +const RBAViewContent* +RBAViewMove::getContent() const +{ + return contentState_->getOwner(); +} + +const RBAViewContentState* +RBAViewMove::getContentState() const +{ + return contentState_; +} + +RBAViewActionType +RBAViewMove::getViewActionType() const +{ + return RBAViewActionType::MOVE; +} + +} diff --git a/src/core/logic/RBAViewMove.hpp b/src/core/logic/RBAViewMove.hpp new file mode 100644 index 0000000..2b8db08 --- /dev/null +++ b/src/core/logic/RBAViewMove.hpp @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAViewMove.hpp + */ + +#ifndef RBAVIEWMOVE_HPP +#define RBAVIEWMOVE_HPP + +#include "RBAViewActionType.hpp" +#include "RBAViewAction.hpp" + +namespace rba { + +class RBAArea; +class RBAViewContent; +class RBAViewContentState; + +class DLL_EXPORT RBAViewMove : public RBAViewAction +{ +public: + RBAViewMove(const RBAArea* const newFromArea, const RBAArea* const newToArea, + const RBAViewContentState* const newContentState); + RBAViewMove(const RBAViewMove& viewMove); + RBAViewMove(const RBAViewMove&&)=delete; + RBAViewMove& operator=(const RBAViewMove&)=delete; + RBAViewMove& operator=(const RBAViewMove&&)=delete; + virtual ~RBAViewMove()=default; + + bool operator==(const RBAViewAction& viewAction) override; + +public: + const RBAArea* getFromArea() const override; + const RBAArea* getToArea() const override; + const RBAViewContent* getContent() const override; + const RBAViewContentState* getContentState() const override; + RBAViewActionType getViewActionType() const override; + +private: + const RBAArea* fromArea_ {nullptr}; + const RBAArea* toArea_ {nullptr}; + const RBAViewContentState* contentState_ {nullptr}; + +}; + +} + +#endif diff --git a/src/core/logic/RBAViewTransition.cpp b/src/core/logic/RBAViewTransition.cpp new file mode 100644 index 0000000..93b86a7 --- /dev/null +++ b/src/core/logic/RBAViewTransition.cpp @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * RBAViewTransition.cpp + */ + +#include "RBAArea.hpp" +#include "RBAViewContent.hpp" +#include "RBAViewContentState.hpp" +#include "RBAViewTransition.hpp" + +namespace rba { + +RBAViewTransition::RBAViewTransition( + const RBAViewActionType newViewActionType, const RBAArea* const newArea, + const RBAViewContentState* const newContentState1, + const RBAViewContentState* const newContentState2) + : RBAViewAction(), + viewActionType_{newViewActionType}, + area_{newArea}, + contentState1_{newContentState1}, + contentState2_{newContentState2} +{ +} + +RBAViewTransition::RBAViewTransition(const RBAViewTransition& viewTrans) + : RBAViewAction{viewTrans} +{ + viewActionType_ = viewTrans.viewActionType_; + area_ = viewTrans.area_; + contentState1_ = viewTrans.contentState1_; + contentState2_ = viewTrans.contentState2_; +} + +bool +RBAViewTransition::operator==(const RBAViewAction& viewAction) +{ + if(getViewActionType() != viewAction.getViewActionType()) { + // False if the view action types do not match + return false; + } + + const RBAViewTransition* const viewTran + {dynamic_cast(&viewAction)}; + return ((area_ == viewTran->area_) && + (contentState1_ == viewTran->contentState1_) && + (contentState2_ == viewTran->contentState2_)); +} + +const RBAArea* +RBAViewTransition::getArea() const +{ + return area_; +} + +const RBAViewContent* +RBAViewTransition::getFromContent() const +{ + if((contentState1_ == nullptr) || + (viewActionType_ == RBAViewActionType::TRANSITION_ADD) || + (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) { + return nullptr; + } + return contentState1_->getOwner(); +} + +const RBAViewContent* +RBAViewTransition::getToContent() const +{ + if((contentState2_ == nullptr) || + (viewActionType_ == RBAViewActionType::TRANSITION_ADD) || + (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) { + return nullptr; + } + return contentState2_->getOwner(); +} + +const RBAViewContentState* +RBAViewTransition::getFromContentState() const +{ + if((viewActionType_ == RBAViewActionType::TRANSITION_ADD) || + (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) { + return nullptr; + } + return contentState1_; +} + +const RBAViewContentState* +RBAViewTransition::getToContentState() const +{ + if((viewActionType_ == RBAViewActionType::TRANSITION_ADD) || + (viewActionType_ == RBAViewActionType::TRANSITION_REMOVE)) { + return nullptr; + } + return contentState2_; +} + +const RBAViewContent* +RBAViewTransition::getContent() const +{ + if((contentState1_ == nullptr) || + (viewActionType_ == RBAViewActionType::TRANSITION_REPLACE)) { + return nullptr; + } + return contentState1_->getOwner(); +} + +const RBAViewContentState* +RBAViewTransition::getContentState() const +{ + if(viewActionType_ == RBAViewActionType::TRANSITION_REPLACE) { + return nullptr; + } + return contentState1_; +} + +RBAViewActionType +RBAViewTransition::getViewActionType() const +{ + return viewActionType_; +} + +} diff --git a/src/core/logic/RBAViewTransition.hpp b/src/core/logic/RBAViewTransition.hpp new file mode 100644 index 0000000..1b9338f --- /dev/null +++ b/src/core/logic/RBAViewTransition.hpp @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * RBAViewTransition.hpp + */ + +#ifndef RBAVIEWTRANSITION_HPP +#define RBAVIEWTRANSITION_HPP + +#include "RBAViewAction.hpp" + +namespace rba { + +class RBAArea; + +class DLL_EXPORT RBAViewTransition : public RBAViewAction +{ +public: + RBAViewTransition(const RBAViewActionType newViewActionType, const RBAArea* const newArea, + const RBAViewContentState* const newContentState1, + const RBAViewContentState* const newContentState2 = nullptr); + RBAViewTransition(const RBAViewTransition& viewTrans); + RBAViewTransition(const RBAViewTransition&&)=delete; + RBAViewTransition& operator=(const RBAViewTransition&)=delete; + RBAViewTransition& operator=(const RBAViewTransition&&)=delete; + virtual ~RBAViewTransition()=default; + + bool operator==(const RBAViewAction& viewAction) override; + +public: + const RBAArea* getArea() const override; + + const RBAViewContent* getFromContent() const override; + const RBAViewContent* getToContent() const override; + const RBAViewContentState* getFromContentState() const override; + const RBAViewContentState* getToContentState() const override; + const RBAViewContent* getContent() const override; + const RBAViewContentState* getContentState() const override; + RBAViewActionType getViewActionType() const override; + +private: + RBAViewActionType viewActionType_; + const RBAArea* area_; + const RBAViewContentState* contentState1_; + const RBAViewContentState* contentState2_; +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractAllocatable.cpp b/src/core/model/RBAAbstractAllocatable.cpp new file mode 100644 index 0000000..c0dfb4f --- /dev/null +++ b/src/core/model/RBAAbstractAllocatable.cpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AbstractAllocatable class implementation + */ + +#include "RBAAbstractAllocatable.hpp" + +#include "RBAModelElementType.hpp" +#include "RBAContent.hpp" +#include "RBAContentSet.hpp" +#include "RBAViewContentSet.hpp" +#include "RBASoundContentSet.hpp" + +namespace rba +{ + +RBAAbstractAllocatable::RBAAbstractAllocatable(const std::string& name) + : RBARuleObject{name}, + contentSet_{std::make_unique()} +{ +} + +const std::list& +RBAAbstractAllocatable::getInternalContents() const +{ + return contentSet_->getLeafContent(); +} + +void +RBAAbstractAllocatable::addContent(const RBAContent* const content) +{ + contentSet_->addTarget(content); +} + +const RBAContentSet* +RBAAbstractAllocatable::getContentSet() const +{ + return contentSet_.get(); +} + +} diff --git a/src/core/model/RBAAbstractAllocatable.hpp b/src/core/model/RBAAbstractAllocatable.hpp new file mode 100644 index 0000000..b8b7acb --- /dev/null +++ b/src/core/model/RBAAbstractAllocatable.hpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AbstractAllocatable class header + */ + +#ifndef RBAABSTRACTALLOCATABLE_HPP +#define RBAABSTRACTALLOCATABLE_HPP + +#include +#include +#include "RBARuleObject.hpp" +#include "RBAContentSet.hpp" + +namespace rba +{ + +class RBAContent; + +class DLL_EXPORT RBAAbstractAllocatable : virtual public RBARuleObject +{ +protected: + explicit RBAAbstractAllocatable(const std::string& name=""); + RBAAbstractAllocatable(const RBAAbstractAllocatable&)=delete; + RBAAbstractAllocatable(const RBAAbstractAllocatable&&)=delete; + RBAAbstractAllocatable& operator=(const RBAAbstractAllocatable&)=delete; + RBAAbstractAllocatable& operator=(const RBAAbstractAllocatable&&)=delete; + +public: + virtual ~RBAAbstractAllocatable()=default; + +public: + const std::list& getInternalContents() const; + void addContent(const RBAContent* const content); + const RBAContentSet* getContentSet() const; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr contentSet_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractAllocatableMaker.cpp b/src/core/model/RBAAbstractAllocatableMaker.cpp new file mode 100644 index 0000000..793336a --- /dev/null +++ b/src/core/model/RBAAbstractAllocatableMaker.cpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractAllocatableMaker.cpp +/// @brief AbstractAllocatable generator class implementation + +#include "RBAAbstractAllocatableMaker.hpp" +#include "RBAAbstractAllocatable.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAAbstractAllocatableMaker::RBAAbstractAllocatableMaker(const std::string& label) + : RBARuleObjectMaker{label} +{ +} + +RBAModelElement* +RBAAbstractAllocatableMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBARuleObjectMaker::setProperty(element, jsonElem, model, owner)); + + const auto abstAllo = dynamic_cast(element); + + // Currently, there is no member set by RBAAbstractAllocatableMaker + // as model information, but this process is implemented + // because it may be added in the future. + + return abstAllo; +} + +} diff --git a/src/core/model/RBAAbstractAllocatableMaker.hpp b/src/core/model/RBAAbstractAllocatableMaker.hpp new file mode 100644 index 0000000..845acd2 --- /dev/null +++ b/src/core/model/RBAAbstractAllocatableMaker.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractAllocatableMaker.hpp +/// @brief AbstractAllocatable generator class header + +#ifndef RBAABSTRACTALLOCATABLEMAKER_HPP +#define RBAABSTRACTALLOCATABLEMAKER_HPP + +#include "RBARuleObjectMaker.hpp" + +namespace rba +{ + +/// @brief AbstractAllocatable generator class +class DLL_EXPORT RBAAbstractAllocatableMaker : virtual public RBARuleObjectMaker +{ +public: + explicit RBAAbstractAllocatableMaker(const std::string& label=""); + RBAAbstractAllocatableMaker(const RBAAbstractAllocatableMaker&)=delete; + RBAAbstractAllocatableMaker(const RBAAbstractAllocatableMaker&&)=delete; + RBAAbstractAllocatableMaker& operator=(const RBAAbstractAllocatableMaker&)=delete; + RBAAbstractAllocatableMaker& operator=(const RBAAbstractAllocatableMaker&&)=delete; + virtual ~RBAAbstractAllocatableMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractConstraint.cpp b/src/core/model/RBAAbstractConstraint.cpp new file mode 100644 index 0000000..3c8ba73 --- /dev/null +++ b/src/core/model/RBAAbstractConstraint.cpp @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AbstractConstraint class implementation + */ + +#include "RBAAbstractConstraint.hpp" + +#include "RBAExpression.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +RBAAbstractConstraint::RBAAbstractConstraint(const std::string& name) + : RBANamedElement{name} +{ +} + +bool +RBAAbstractConstraint::isConstraint() const +{ + return false; +} + +bool +RBAAbstractConstraint::isRule() const +{ + return false; +} + +void +RBAAbstractConstraint::clearInfo() +{ + info_->clear(); +} + +void +RBAAbstractConstraint::setExpression(RBAExpression* newExpr) +{ + expression_ = newExpr; +} + +RBAExpression* const +RBAAbstractConstraint::getExpression() const +{ + return expression_; +} + +RBAConstraintInfo* +RBAAbstractConstraint::getInfo() const +{ + return info_.get(); +} + +#ifdef RBA_USE_LOG +void +RBAAbstractConstraint::createHierarchy() +{ + LOG_initConstraintHierarchy(); + LOG_coverageHierarchyOfConstraintStartLog(this); + getExpression()->createHierarchy(); + LOG_coverageHierarchyOfConstraintEndLog(this); +} +#endif + +} diff --git a/src/core/model/RBAAbstractConstraint.hpp b/src/core/model/RBAAbstractConstraint.hpp new file mode 100644 index 0000000..d19bba5 --- /dev/null +++ b/src/core/model/RBAAbstractConstraint.hpp @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AbstractConstraint class header + */ + +#ifndef RBAABSTRACTCONSTRAINT_HPP +#define RBAABSTRACTCONSTRAINT_HPP + +#include +#include "RBANamedElement.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +class RBAExpression; + +class DLL_EXPORT RBAAbstractConstraint : public RBANamedElement +{ +protected: + explicit RBAAbstractConstraint(const std::string& name); + RBAAbstractConstraint(const RBAAbstractConstraint&)=delete; + RBAAbstractConstraint(const RBAAbstractConstraint&&)=delete; + RBAAbstractConstraint& operator=(const RBAAbstractConstraint&)=delete; + RBAAbstractConstraint& operator=(const RBAAbstractConstraint&&)=delete; + void clearInfo(); + +public: + virtual ~RBAAbstractConstraint()=default; + virtual bool isConstraint() const; + virtual bool isRule() const; + virtual void setExpression(RBAExpression*); + virtual RBAExpression* const getExpression() const; + RBAConstraintInfo* getInfo() const; + + // Log +#ifdef RBA_USE_LOG + virtual void createHierarchy(); +#endif + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unique_ptr info_ {std::make_unique()}; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + RBAExpression* expression_ {nullptr}; + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractConstraintMaker.cpp b/src/core/model/RBAAbstractConstraintMaker.cpp new file mode 100644 index 0000000..5de0ae3 --- /dev/null +++ b/src/core/model/RBAAbstractConstraintMaker.cpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractConstraintMaker.cpp +/// @brief Abstract Constraint expresion generator class + +#include "RBAAbstractConstraintMaker.hpp" +#include "RBAAbstractConstraint.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAAbstractConstraintMaker::RBAAbstractConstraintMaker(const std::string& label) + : RBAModelElementMaker{label} +{ +} + +RBAModelElement* +RBAAbstractConstraintMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + const auto abstConstraint = dynamic_cast(element); + + // Set expression + const RBAJsonElement* const childElem {jsonElem->findChildren("expression")}; + RBAModelElement* const expr {getFactory()->createElement(childElem->getClassName(), + childElem)}; + abstConstraint->setExpression(dynamic_cast(expr)); + + return abstConstraint; +} + +} diff --git a/src/core/model/RBAAbstractConstraintMaker.hpp b/src/core/model/RBAAbstractConstraintMaker.hpp new file mode 100644 index 0000000..916408e --- /dev/null +++ b/src/core/model/RBAAbstractConstraintMaker.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractConstraintMaker.hpp +/// @brief Abstract Constraint expresion generator class header + +#ifndef RBAABSTRACTCONSTRAINTMAKER_HPP +#define RBAABSTRACTCONSTRAINTMAKER_HPP + +#include "RBAModelElementMaker.hpp" + +namespace rba +{ + +/// @brief Abstract Constraint expresion generator class +class DLL_EXPORT RBAAbstractConstraintMaker + : public RBAModelElementMaker +{ +public: + explicit RBAAbstractConstraintMaker(const std::string& label); + RBAAbstractConstraintMaker(const RBAAbstractConstraintMaker&)=delete; + RBAAbstractConstraintMaker(const RBAAbstractConstraintMaker&&)=delete; + RBAAbstractConstraintMaker& operator=(const RBAAbstractConstraintMaker&)=delete; + RBAAbstractConstraintMaker& operator=(const RBAAbstractConstraintMaker&&)=delete; + virtual ~RBAAbstractConstraintMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractContent.cpp b/src/core/model/RBAAbstractContent.cpp new file mode 100644 index 0000000..d8f025f --- /dev/null +++ b/src/core/model/RBAAbstractContent.cpp @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstract Content class implementation + */ + +#include "RBAAbstractContent.hpp" + +namespace rba +{ + +RBAAbstractContent::RBAAbstractContent(const std::string& name) + : RBARuleObject{name} +{ +} + +} diff --git a/src/core/model/RBAAbstractContent.hpp b/src/core/model/RBAAbstractContent.hpp new file mode 100644 index 0000000..c2d72b1 --- /dev/null +++ b/src/core/model/RBAAbstractContent.hpp @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstract Content class header + */ + +#ifndef RBAABSTRACTCONTENT_HPP +#define RBAABSTRACTCONTENT_HPP + +#include "RBARuleObject.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAAbstractContent : virtual public RBARuleObject +{ +protected: + explicit RBAAbstractContent(const std::string& name=""); + RBAAbstractContent(const RBAAbstractContent&)=delete; + RBAAbstractContent(const RBAAbstractContent&&)=delete; + RBAAbstractContent& operator=(const RBAAbstractContent&)=delete; + RBAAbstractContent& operator=(const RBAAbstractContent&&)=delete; + +public: + virtual ~RBAAbstractContent()=default; + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractContentMaker.cpp b/src/core/model/RBAAbstractContentMaker.cpp new file mode 100644 index 0000000..b0ff0be --- /dev/null +++ b/src/core/model/RBAAbstractContentMaker.cpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractContentMaker.cpp +/// @brief Abstract Content generator class implementation + +#include "RBAAbstractContentMaker.hpp" +#include "RBAAbstractContent.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAAbstractContentMaker::RBAAbstractContentMaker(const std::string& label) + : RBARuleObjectMaker{label} +{ +} + +RBAModelElement* +RBAAbstractContentMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBARuleObjectMaker::setProperty( element, jsonElem, + model, owner)); + + const auto abstContent = dynamic_cast(element); + + // Currently, there is no member set by RBAAbstractContentMaker + // as model information, but this process is implemented + // because it may be added in the future. + + return abstContent; +} + +} diff --git a/src/core/model/RBAAbstractContentMaker.hpp b/src/core/model/RBAAbstractContentMaker.hpp new file mode 100644 index 0000000..df311a8 --- /dev/null +++ b/src/core/model/RBAAbstractContentMaker.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAbstractContentMaker.cpp +/// @brief Abstract Content generator class header + +#ifndef RBAABSTRACTCONTENTMAKER_HPP +#define RBAABSTRACTCONTENTMAKER_HPP + +#include "RBARuleObjectMaker.hpp" + +namespace rba +{ + +/// @brief Abstract Content generator class +class DLL_EXPORT RBAAbstractContentMaker : virtual public RBARuleObjectMaker +{ +public: + explicit RBAAbstractContentMaker(const std::string& label=""); + RBAAbstractContentMaker(const RBAAbstractContentMaker&)=delete; + RBAAbstractContentMaker(const RBAAbstractContentMaker&&)=delete; + RBAAbstractContentMaker& operator=(const RBAAbstractContentMaker&)=delete; + RBAAbstractContentMaker& operator=(const RBAAbstractContentMaker&&)=delete; + virtual ~RBAAbstractContentMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAAbstractProperty.cpp b/src/core/model/RBAAbstractProperty.cpp new file mode 100644 index 0000000..a90fa4d --- /dev/null +++ b/src/core/model/RBAAbstractProperty.cpp @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstract property class implementation + */ + +#include "RBAAbstractProperty.hpp" +#include "RBASceneImpl.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +RBAAbstractProperty::RBAAbstractProperty(const RBASceneImpl* const scene, const std::string& name) + : RBARuleObject{name}, + scene_{scene} +{ +} + +RBAModelElementType +RBAAbstractProperty::getModelElementType() const +{ + return RBAModelElementType::Property; +} + +const RBASceneImpl* +RBAAbstractProperty::getScene() const +{ + return scene_; +} + +} diff --git a/src/core/model/RBAAbstractProperty.hpp b/src/core/model/RBAAbstractProperty.hpp new file mode 100644 index 0000000..15ecc2d --- /dev/null +++ b/src/core/model/RBAAbstractProperty.hpp @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstract property class header + */ + +#ifndef RBAABSTRACTPROPERTY_HPP +#define RBAABSTRACTPROPERTY_HPP + +#include +#include "RBARuleObject.hpp" + +namespace rba +{ + +class RBASceneImpl; + +class RBAAbstractProperty : public RBARuleObject +{ +protected: + RBAAbstractProperty(const RBASceneImpl* const scene, const std::string& name); + RBAAbstractProperty(const RBAAbstractProperty&)=delete; + RBAAbstractProperty(const RBAAbstractProperty&&)=delete; + RBAAbstractProperty& operator=(const RBAAbstractProperty&)=delete; + RBAAbstractProperty& operator=(const RBAAbstractProperty&&)=delete; + +public: + virtual ~RBAAbstractProperty()=default; + +public: + RBAModelElementType getModelElementType() const override; + virtual std::int32_t getValue() const=0; + virtual const RBASceneImpl* getScene() const; + + // Log +#ifdef RBA_USE_LOG + virtual const std::string getExpressionText() const=0; +#endif + +private: + const RBASceneImpl* scene_; + +}; + +} + +#endif diff --git a/src/core/model/RBAAllocatable.cpp b/src/core/model/RBAAllocatable.cpp new file mode 100644 index 0000000..aac639b --- /dev/null +++ b/src/core/model/RBAAllocatable.cpp @@ -0,0 +1,387 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Allocatable class implementation + */ + +#include + +#include "RBAAllocatable.hpp" +#include "RBAModelElementType.hpp" +#include "RBAViewContent.hpp" +#include "RBAAreaImpl.hpp" +#include "RBAConstraintImpl.hpp" +#include "RBAConstraintInfo.hpp" +#include "RBAConstraintMap.hpp" + +namespace rba +{ + +RBAAllocatable::RBAAllocatable(const std::string& name) + : RBARuleObject{name}, + RBAAbstractAllocatable{name} +{ +} + +void RBAAllocatable::clearStatus() +{ + allocatablesAffectedByThisAllocatable_.clear(); + state_ = nullptr; + hiddenChecked_ = false; + checked_ = false; + attenuateChecked_ = false; + hidden_ = false; + attenuated_ = false; +} + +bool +RBAAllocatable::isArea() const +{ + return isModelElementType(RBAModelElementType::Area); +} + +bool +RBAAllocatable::isZone() const +{ + return isModelElementType(RBAModelElementType::Zone); +} + +RBAArbitrationPolicy +RBAAllocatable::getAllocatableArbitrationPolicy() const +{ + return arbitrationPolicy_; +} + +void +RBAAllocatable::setArbitrationPolicy(const RBAArbitrationPolicy newPolicy) +{ + arbitrationPolicy_ = newPolicy; +} + +std::int32_t +RBAAllocatable::getVisibility() const +{ + return visibility_; +} + +void +RBAAllocatable::setVisibility(const std::int32_t newVisibility) +{ + visibility_ = newVisibility; +} + +const std::list& +RBAAllocatable::getAllocatablesAffectedByYou() const +{ + return allocatablesAffectedByThisAllocatable_; +} + +void +RBAAllocatable::clearAllocatablesAffectedByYou() +{ + return allocatablesAffectedByThisAllocatable_.clear(); +} + +void +RBAAllocatable::addAllocatableWhichHasBeenAffectedByYou(const RBAAllocatable* const allocatable) +{ + allocatablesAffectedByThisAllocatable_.push_back(allocatable); +} + +void +RBAAllocatable::removeAffectAllocatable(const RBAAllocatable* const allocatable) +{ + const auto it = std::find(allocatablesAffectedByThisAllocatable_.begin(), + allocatablesAffectedByThisAllocatable_.end(), allocatable); + if(it != allocatablesAffectedByThisAllocatable_.end()) { + static_cast(allocatablesAffectedByThisAllocatable_.erase(it)); + } +} + +void +RBAAllocatable::clearAffectAllocatable() +{ + allocatablesAffectedByThisAllocatable_.clear(); +} + +void +RBAAllocatable::clearChecked() +{ + hiddenChecked_ = false; + checked_ = false; + attenuateChecked_ =false; + hidden_ = false; + attenuated_ = false; +} + +std::int32_t +RBAAllocatable::getIndex() const +{ + return index_; +} + +void +RBAAllocatable::setIndex(const std::int32_t newIndex) +{ + index_ = newIndex; +} + +bool +RBAAllocatable::compare(const RBAAllocatable* const arg0, + const RBAAllocatable* const arg1) +{ + const std::int32_t visibility0 {arg0->getVisibility()}; + const std::int32_t visibility1 {arg1->getVisibility()}; + // Do not swap because the front element is more visible than the rear element + if(visibility0 > visibility1) { + return true; + } + // Compare the Z orders because the front element and the rear element + // have the same visibility. + else if(visibility0 == visibility1) { + std::int32_t zorder0{0}; + std::int32_t zorder1{0}; + if(arg0->isModelElementType(RBAModelElementType::Area)) { + zorder0 = (dynamic_cast(arg0))->getZorder(); + zorder1 = (dynamic_cast(arg1))->getZorder(); + } + else { + zorder0 = ZONE_ZORDER; + zorder1 = ZONE_ZORDER; + } + // Do not swap because the front element has a larger Z order than + // the rear element. + if(zorder0 > zorder1) { + return true; + } + // Do not swap because the Z order of the front element and the rear element + // is the same + else if(zorder0 == zorder1) { + return false; + } + // Swap because the front element has a smaller Z order than + // the rear element. + else { + return false; + } + } + // Replace because the front element is less visible than + // the rear element. + else { + return false; + } +} + +bool +RBAAllocatable::compareIndex(const RBAAllocatable* const arg0, + const RBAAllocatable* const arg1) +{ + return arg0->getIndex() < arg1->getIndex(); +} + +void +RBAAllocatable::addConstraint(RBAConstraintImpl* const constraint, + const RBAConstraintMap& kind) +{ + if (kind == RBAConstraintMap::CONTENT_ALLOCATE_CONSTRAINTS) { + addConstraintImpl(constraint, constraints_); + } else if (kind == RBAConstraintMap::HIDDEN_TRUE_CHECK_CONSTRAINTS) { + addConstraintImpl(constraint, hiddenTrueCheckConstraints_); + } else if (kind == RBAConstraintMap::HIDDEN_FALSE_CHECK_CONSTRAINTS) { + addConstraintImpl(constraint, hiddenFalseCheckConstraints_); + } else if (kind == RBAConstraintMap::ATTENUATE_TRUE_CHECK_CONSTRAINTS) { + addConstraintImpl(constraint, attenuateTrueCheckConstraints_); + } else { + addConstraintImpl(constraint, attenuateFalseCheckConstraints_); + } +} + +std::list& +RBAAllocatable::getConstraints() +{ + return constraints_; +} +std::list& RBAAllocatable::getHiddenTrueCheckConstraints() +{ + return hiddenTrueCheckConstraints_; +} +std::list& RBAAllocatable::getHiddenFalseCheckConstraints() +{ + return hiddenFalseCheckConstraints_; +} +std::list& RBAAllocatable::getAttenuateTrueCheckConstraints() +{ + return attenuateTrueCheckConstraints_; +} +std::list& RBAAllocatable::getAttenuateFalseCheckConstraints() +{ + return attenuateFalseCheckConstraints_; +} + +bool RBAAllocatable::hasConstraint(const RBAConstraintImpl* const constraint) const +{ + if ((std::find(constraints_.begin(), constraints_.end(), constraint) + != constraints_.end()) + || (std::find(hiddenTrueCheckConstraints_.begin(), + hiddenTrueCheckConstraints_.end(), constraint) + != hiddenTrueCheckConstraints_.end()) + || (std::find(hiddenFalseCheckConstraints_.begin(), + hiddenFalseCheckConstraints_.end(), constraint) + != hiddenFalseCheckConstraints_.end()) + || (std::find(attenuateTrueCheckConstraints_.begin(), + attenuateTrueCheckConstraints_.end(), constraint) + != attenuateTrueCheckConstraints_.end()) + || (std::find(attenuateFalseCheckConstraints_.begin(), + attenuateFalseCheckConstraints_.end(), constraint) + != attenuateFalseCheckConstraints_.end())) { + return true; + } + return false; +} + +bool +RBAAllocatable::isChecked() const +{ + return checked_; +} + +void +RBAAllocatable::setChecked(const bool checked) +{ + checked_ = checked; +} + +bool +RBAAllocatable::isHiddenChecked() const +{ + return hiddenChecked_; +} + +void +RBAAllocatable::setHiddenChecked(const bool hiddenChecked) +{ + hiddenChecked_ = hiddenChecked; +} + +bool +RBAAllocatable::isAttenuateChecked() const +{ + return attenuateChecked_; +} + +void +RBAAllocatable::setAttenuateChecked(const bool attenuateChecked) +{ + this->attenuateChecked_ = attenuateChecked; +} + +bool +RBAAllocatable::isAttenuated() const +{ + return attenuated_; +} + +void +RBAAllocatable::setAttenuated(const bool attenuated) +{ + this->attenuated_ = attenuated; +} + +bool +RBAAllocatable::isHidden() const +{ + return hidden_; +} + +void +RBAAllocatable::setHidden(const bool hidden) +{ + hidden_ = hidden; +} + +const RBAContentState* +RBAAllocatable::getState() const +{ + return state_; +} + +void +RBAAllocatable::setState(const RBAContentState* const state) +{ + state_ = state; +} + +#ifdef RBA_USE_LOG +std::string +RBAAllocatable::getSymbol() const +{ + // This function is never called because the function of the derived class + // is called. + return "Allocatable"; +} + +std::string +RBAAllocatable::getHiddenSymbol() const +{ + // This function is never called because the function of the derived class + // is called. + return "Allocatable: Unsuppored operation exception"; +} + +std::string +RBAAllocatable::getArbitrationPolicyString() const +{ + std::string res; + switch(arbitrationPolicy_) { + case RBAArbitrationPolicy::FIRST_COME_FIRST: + res = "FIRST_COME_FIRST"; + break; + case RBAArbitrationPolicy::LAST_COME_FIRST: + res = "LAST_COME_FIRST"; + break; + case RBAArbitrationPolicy::PRIORITY_FIRST_COME_FIRST: + res = "PRIORITY_FIRST_COME_FIRST"; + break; + case RBAArbitrationPolicy::PRIORITY_LAST_COME_FIRST: + res = "PRIORITY_LAST_COME_FIRST"; + break; + default: + res = "DEFAULT"; + break; + } + + return res; +} + +std::string +RBAAllocatable::getVisibilityString() const +{ + return std::to_string(visibility_); +} +#endif + +void +RBAAllocatable::addConstraintImpl(RBAConstraintImpl* const constraint, + std::list& constraints) +{ + if (std::find(constraints.begin(), constraints.end(), constraint) + == constraints.end()) { + constraints.push_back(constraint); + } +} + +} diff --git a/src/core/model/RBAAllocatable.hpp b/src/core/model/RBAAllocatable.hpp new file mode 100644 index 0000000..c44d643 --- /dev/null +++ b/src/core/model/RBAAllocatable.hpp @@ -0,0 +1,131 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Allocatable class header + */ + +#ifndef RBAALLOCATABLE_HPP +#define RBAALLOCATABLE_HPP + +#include "RBAAbstractAllocatable.hpp" +#include "RBAArbitrationPolicy.hpp" + +namespace rba +{ + +class RBAViewContent; +class RBANotificationChain; +class RBAContentState; +class RBAConstraintImpl; +enum class RBAConstraintMap : std::uint8_t; + +class DLL_EXPORT RBAAllocatable : public RBAAbstractAllocatable +{ +public: + explicit RBAAllocatable(const std::string& name=""); + RBAAllocatable(const RBAAllocatable&)=delete; + RBAAllocatable(const RBAAllocatable&&)=delete; + RBAAllocatable& operator=(const RBAAllocatable&)=delete; + RBAAllocatable& operator=(const RBAAllocatable&&)=delete; + virtual ~RBAAllocatable()=default; + +public: + void clearStatus() override; + virtual bool isArea() const; + virtual bool isZone() const; + RBAArbitrationPolicy getAllocatableArbitrationPolicy() const; + void setArbitrationPolicy(const RBAArbitrationPolicy newPolicy); + std::int32_t getVisibility() const; + void setVisibility(const std::int32_t newVisibility); + const std::list& getAllocatablesAffectedByYou() const; + void clearAllocatablesAffectedByYou(); + void addAllocatableWhichHasBeenAffectedByYou(const RBAAllocatable* const allocatable); + void removeAffectAllocatable(const RBAAllocatable* const allocatable); + void clearAffectAllocatable(); + virtual void clearChecked(); + std::int32_t getIndex() const; + void setIndex(const std::int32_t newIndex); + + static bool compare(const RBAAllocatable* const arg0, const RBAAllocatable* const arg1); + static bool compareIndex(const RBAAllocatable* const arg0, const RBAAllocatable* const arg1); + const static RBAArbitrationPolicy ARBITRATION_POLICY_EDEFAULT = + RBAArbitrationPolicy::DEFAULT; + void addConstraint(RBAConstraintImpl* const constraint, const RBAConstraintMap& kind); + std::list& getConstraints(); + std::list& getHiddenTrueCheckConstraints(); + std::list& getHiddenFalseCheckConstraints(); + std::list& getAttenuateTrueCheckConstraints(); + std::list& getAttenuateFalseCheckConstraints(); + bool hasConstraint(const RBAConstraintImpl* const constraint) const; + + bool isChecked() const; + void setChecked(const bool checked); + bool isHiddenChecked() const; + void setHiddenChecked(const bool hiddenChecked); + bool isAttenuateChecked() const; + void setAttenuateChecked(const bool attenuateChecked=false); + bool isAttenuated() const; + void setAttenuated(const bool attenuated=false); + bool isHidden() const; + void setHidden(const bool hidden=false); + const RBAContentState* getState() const; + void setState(const RBAContentState* const state); + + // Log +#ifdef RBA_USE_LOG + virtual std::string getSymbol() const; + virtual std::string getHiddenSymbol() const; + std::string getArbitrationPolicyString() const; + std::string getVisibilityString() const; +#endif + + private: + void addConstraintImpl(RBAConstraintImpl* const constraint, + std::list& constraints); + +protected: + // Zone should be a Z-order below the minimum Area + const static std::int32_t ZONE_ZORDER = -2; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list allocatablesAffectedByThisAllocatable_; + std::list constraints_; + std::list hiddenTrueCheckConstraints_; + std::list hiddenFalseCheckConstraints_; + std::list attenuateTrueCheckConstraints_; + std::list attenuateFalseCheckConstraints_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + RBAArbitrationPolicy arbitrationPolicy_{ARBITRATION_POLICY_EDEFAULT}; + std::int32_t visibility_ {0}; + std::int32_t index_ {0}; + const RBAContentState * state_ {nullptr}; + bool hiddenChecked_ {false}; + bool checked_ {false}; + bool attenuateChecked_ {false}; + bool hidden_ {false}; + bool attenuated_ {false}; +}; + +} + +#endif diff --git a/src/core/model/RBAAllocatableMaker.cpp b/src/core/model/RBAAllocatableMaker.cpp new file mode 100644 index 0000000..f59813b --- /dev/null +++ b/src/core/model/RBAAllocatableMaker.cpp @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatableMaker.cpp +/// @brief Allocatable object generator abstract class implementation + +#include +#include "RBAAllocatableMaker.hpp" +#include "RBAAllocatable.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAAllocatableMaker::RBAAllocatableMaker(const std::string& label) + : RBARuleObjectMaker{label}, + RBAAbstractAllocatableMaker{label} +{ +} + +RBAModelElement* +RBAAllocatableMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBAAbstractAllocatableMaker::setProperty(element, jsonElem, model, owner)); + + const auto alloc = dynamic_cast(element); + + // Set policy + const RBAJsonElement* const policy {jsonElem->findChildren("arbitrationPolicy")}; + if(policy == nullptr) { + std::cerr << alloc->getElementName() + << ": arbitrationPolicy not found" << &std::endl; + return nullptr; + } + alloc->setArbitrationPolicy(policy->getArbitrationPolicy()); + + // Set visibility or priority + if (alloc->isArea()) { + const RBAJsonElement* const visibility {jsonElem->findChildren("visibility")}; + if(visibility == nullptr) { + std::cerr << alloc->getElementName() + << ": visibility not found" << &std::endl; + return nullptr; + } + alloc->setVisibility(visibility->getInt()); + } else if (alloc->isZone()) { + const RBAJsonElement* const priority {jsonElem->findChildren("priority")}; + if(priority == nullptr) { + std::cerr << alloc->getElementName() + << ": priority not found" << &std::endl; + return nullptr; + } + alloc->setVisibility(priority->getInt()); + } else { + ; + } + + model->addAllocatable(alloc); + + return alloc; +} + +} diff --git a/src/core/model/RBAAllocatableMaker.hpp b/src/core/model/RBAAllocatableMaker.hpp new file mode 100644 index 0000000..f4393cb --- /dev/null +++ b/src/core/model/RBAAllocatableMaker.hpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatableMaker.cpp +/// @brief Allocatable object generator abstract class header + +#ifndef RBAALLOCATABLEMAKER_HPP +#define RBAALLOCATABLEMAKER_HPP + +#include "RBAAbstractAllocatableMaker.hpp" + +namespace rba +{ + +/// @brief Allocatable object generator abstract class +class DLL_EXPORT RBAAllocatableMaker + : public RBAAbstractAllocatableMaker +{ +public: + explicit RBAAllocatableMaker(const std::string& label=""); + RBAAllocatableMaker(const RBAAllocatableMaker&)=delete; + RBAAllocatableMaker(const RBAAllocatableMaker&&)=delete; + RBAAllocatableMaker& operator=(const RBAAllocatableMaker&)=delete; + RBAAllocatableMaker& operator=(const RBAAllocatableMaker&&)=delete; + virtual ~RBAAllocatableMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAAllocatableSet.cpp b/src/core/model/RBAAllocatableSet.cpp new file mode 100644 index 0000000..c545417 --- /dev/null +++ b/src/core/model/RBAAllocatableSet.cpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AllocatableSet class implementation + */ + +#include "RBAAllocatableSet.hpp" +#include "RBAAllocatable.hpp" + +namespace rba +{ + +RBAAllocatableSet::RBAAllocatableSet(const std::string& name) + : RBARuleObject{name}, + RBAAbstractAllocatable{name} +{ +} + +void +RBAAllocatableSet::addTarget(const RBAAllocatable* alloc) +{ + leafAllocatable_.push_back(alloc); +#ifdef RBA_USE_LOG + std::string newName = "["; + for (auto& a : leafAllocatable_) { + newName += a->getElementName() + ","; + } + if (newName.size() != 1U) { + newName.erase(newName.end() - 1); // Remove the trailing ",". + } + newName += "]"; + setDynamicName(newName); +#endif +} + +void +RBAAllocatableSet::clear() +{ + leafAllocatable_.clear(); +#ifdef RBA_USE_LOG + setDynamicName("[]"); +#endif +} + +const std::list& +RBAAllocatableSet::getLeafAllocatable() const +{ + return leafAllocatable_; +} + +} diff --git a/src/core/model/RBAAllocatableSet.hpp b/src/core/model/RBAAllocatableSet.hpp new file mode 100644 index 0000000..1c02155 --- /dev/null +++ b/src/core/model/RBAAllocatableSet.hpp @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AllocatableSet class header + */ + +#ifndef RBAALLOCATABLESET_HPP +#define RBAALLOCATABLESET_HPP + +#include "RBAAbstractAllocatable.hpp" + +namespace rba +{ + +class RBAAllocatable; + +class DLL_EXPORT RBAAllocatableSet : public RBAAbstractAllocatable +{ +public: + explicit RBAAllocatableSet(const std::string& name=""); + RBAAllocatableSet(const RBAAllocatableSet&)=delete; + RBAAllocatableSet(const RBAAllocatableSet&&)=delete; + RBAAllocatableSet& operator=(const RBAAllocatableSet&)=delete; + RBAAllocatableSet& operator=(const RBAAllocatableSet&&)=delete; + virtual ~RBAAllocatableSet()=default; + +public: + virtual void addTarget(const RBAAllocatable* alloc); + virtual void clear(); + const std::list& getLeafAllocatable() const; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list leafAllocatable_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} +#endif diff --git a/src/core/model/RBAAllocatableSetMaker.cpp b/src/core/model/RBAAllocatableSetMaker.cpp new file mode 100644 index 0000000..9b9922a --- /dev/null +++ b/src/core/model/RBAAllocatableSetMaker.cpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatableSetMaker.cpp +/// @brief AllocatableSet object genartor abstract class implementation + +#include +#include "RBAAllocatableSetMaker.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAAllocatableSetMaker::RBAAllocatableSetMaker(const std::string& label) + : RBARuleObjectMaker{label}, + RBAAbstractAllocatableMaker{label} +{ +} + +RBAModelElement* +RBAAllocatableSetMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBAAbstractAllocatableMaker::setProperty(element, jsonElem, model, owner)); + + const auto allocSet = dynamic_cast(element); + + // Set target + const RBAJsonElement* const target {jsonElem->findChildren("target")}; + for(const auto& targetElem : target->getChildren()) { + const auto alloc = model->findAllocatable(targetElem->getName()); + allocSet->addTarget(alloc); + } + + return allocSet; +} + +} diff --git a/src/core/model/RBAAllocatableSetMaker.hpp b/src/core/model/RBAAllocatableSetMaker.hpp new file mode 100644 index 0000000..619d220 --- /dev/null +++ b/src/core/model/RBAAllocatableSetMaker.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAAllocatableSetMaker.cpp +/// @brief AllocatableSet object genartor abstract class header + +#ifndef RBAALLOCATABLESETMAKER_HPP +#define RBAALLOCATABLESETMAKER_HPP + +#include "RBAAbstractAllocatableMaker.hpp" + +namespace rba +{ + +/// @brief AllocatableSet object genartor abstract class +class RBAAllocatableSetMaker : public RBAAbstractAllocatableMaker +{ +public: + explicit RBAAllocatableSetMaker(const std::string& label=""); + RBAAllocatableSetMaker(const RBAAllocatableSetMaker&)=delete; + RBAAllocatableSetMaker(const RBAAllocatableSetMaker&&)=delete; + RBAAllocatableSetMaker& operator=(const RBAAllocatableSetMaker&)=delete; + RBAAllocatableSetMaker& operator=(const RBAAllocatableSetMaker&&)=delete; + virtual ~RBAAllocatableSetMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAConstraint.hpp b/src/core/model/RBAConstraint.hpp new file mode 100644 index 0000000..312bedc --- /dev/null +++ b/src/core/model/RBAConstraint.hpp @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Constraint class + */ + +#ifndef RBACONSTRAINT_HPP +#define RBACONSTRAINT_HPP + +#include +#include "RBADllExport.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAConstraint +{ + public: + RBAConstraint()=default; + RBAConstraint(const RBAConstraint&)=delete; + RBAConstraint(const RBAConstraint&&)=delete; + RBAConstraint& operator=(const RBAConstraint&)=delete; + RBAConstraint& operator=(const RBAConstraint&&)=delete; + virtual ~RBAConstraint() = default; + virtual std::string getName() const =0; + const static bool RUNTIME_EDEFAULT = true; +}; + +} + +#endif diff --git a/src/core/model/RBAConstraintImpl.cpp b/src/core/model/RBAConstraintImpl.cpp new file mode 100644 index 0000000..a634621 --- /dev/null +++ b/src/core/model/RBAConstraintImpl.cpp @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Constraint Implementation class + */ + +#include "RBAConstraintImpl.hpp" + +#include "RBAExpression.hpp" +#include "RBALogManager.hpp" + +namespace rba +{ + +RBAConstraintImpl::RBAConstraintImpl(const std::string& name) + : RBAConstraint(), + RBAAbstractConstraint{name} +{ +} + +void +RBAConstraintImpl::setRuntime(const bool newRuntime) +{ + runtime_ = newRuntime; +} + +std::string +RBAConstraintImpl::getName() const +{ + return RBANamedElement::getElementName(); +} + +bool +RBAConstraintImpl::isConstraint() const +{ + return true; +} + +bool +RBAConstraintImpl::isRuntime() const +{ + return runtime_; +} + +bool +RBAConstraintImpl::execute(RBAArbitrator* const arb) +{ + LOG_arbitrateConstraintLogicLogLine(" constraint expression[" + + getExpression()->LOG_getExpressionText() + + "] check start"); + LOG_initConstraintHierarchy(); + LOG_coverageConstraintStartLog(this); + + clearInfo(); + + bool res {getExpression()->execute(getInfo(), arb)}; +#ifdef RBA_USE_LOG + std::string log = " constraint expression[" + getExpression()->getExpressionText(); + + if (res == true) { + log += "] true"; + } else { +#endif + if (getInfo()->isExceptionBeforeArbitrate() == true) { +#ifdef RBA_USE_LOG + log += "] before arbitrate skip"; +#endif + res = true; +#ifdef RBA_USE_LOG + } else { + log += "] false"; + } +#endif + } + LOG_arbitrateConstraintLogicLogLine(log + "\n"); + + LOG_coverageConstraintEndLog(this); + + return res; +} + +} diff --git a/src/core/model/RBAConstraintImpl.hpp b/src/core/model/RBAConstraintImpl.hpp new file mode 100644 index 0000000..eb4d6ab --- /dev/null +++ b/src/core/model/RBAConstraintImpl.hpp @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Constraint Implementation class header + */ + +#ifndef RBACONSTRAINTIMPL_HPP +#define RBACONSTRAINTIMPL_HPP + +#include "RBAConstraint.hpp" +#include "RBAAbstractConstraint.hpp" + +namespace rba +{ + +class RBAArbitrator; + +class DLL_EXPORT RBAConstraintImpl : public RBAConstraint, + public RBAAbstractConstraint +{ +public: + explicit RBAConstraintImpl(const std::string& name=""); + RBAConstraintImpl(const RBAConstraintImpl&)=delete; + RBAConstraintImpl(const RBAConstraintImpl&&)=delete; + RBAConstraintImpl& operator=(const RBAConstraintImpl&)=delete; + RBAConstraintImpl& operator=(const RBAConstraintImpl&&)=delete; + virtual ~RBAConstraintImpl()=default; + +public: + void setRuntime(const bool newRuntime); + std::string getName() const override; + bool isConstraint() const override; + bool isRuntime() const; + bool execute(RBAArbitrator* const arb); + +private: + bool runtime_ {RUNTIME_EDEFAULT}; +}; + +} + +#endif diff --git a/src/core/model/RBAConstraintMaker.cpp b/src/core/model/RBAConstraintMaker.cpp new file mode 100644 index 0000000..7363c16 --- /dev/null +++ b/src/core/model/RBAConstraintMaker.cpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAConstraintMaker.cpp +/// @brief Constraint object genartor class implementation + +#include "RBAConstraintMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAConstraintImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAConstraintMaker::RBAConstraintMaker() + : RBAAbstractConstraintMaker{"constraints"} +{ +} + +std::unique_ptr +RBAConstraintMaker::createInstance(const std::string& name) +{ + return std::make_unique(name); +} + +RBAModelElement* +RBAConstraintMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBAAbstractConstraintMaker::setProperty(element, jsonElem, model, owner)); + + const auto constraint = dynamic_cast(element); + + // Set runtime + bool runtime {false}; + if(jsonElem->findChildren("runtime")->getString() == "true") { + runtime = true; + } + constraint->setRuntime(runtime); + + model->addConstraint(constraint); + + return constraint; +} + +} diff --git a/src/core/model/RBAConstraintMaker.hpp b/src/core/model/RBAConstraintMaker.hpp new file mode 100644 index 0000000..4bcb250 --- /dev/null +++ b/src/core/model/RBAConstraintMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAConstraintMaker.jhp +/// @brief Constraint object generator class header + +#ifndef RBACONSTRAINTMAKER_HPP +#define RBACONSTRAINTMAKER_HPP + +#include "RBAAbstractConstraintMaker.hpp" + +namespace rba +{ + +/// @brief Constraint object generator class +class RBAConstraintMaker : public RBAAbstractConstraintMaker +{ +public: + RBAConstraintMaker(); + RBAConstraintMaker(const RBAConstraintMaker&)=delete; + RBAConstraintMaker(const RBAConstraintMaker&&)=delete; + RBAConstraintMaker& operator=(const RBAConstraintMaker&)=delete; + RBAConstraintMaker& operator=(const RBAConstraintMaker&&)=delete; + virtual ~RBAConstraintMaker()=default; + +protected: + /// @brief Create an empty instance + /// @details Create an empty class of unique_ptr in derived class + /// @return unique_ptr for instance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAContent.cpp b/src/core/model/RBAContent.cpp new file mode 100644 index 0000000..e2e3c9f --- /dev/null +++ b/src/core/model/RBAContent.cpp @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Content class + */ + +#include "RBAContent.hpp" +#include "RBAResultImpl.hpp" +#include "RBAResultSet.hpp" +#include "RBAExpression.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +RBAContent::RBAContent(const std::string& name) + : RBARuleObject{name}, + RBAAbstractContent{name} +{ +} + +bool +RBAContent::isViewContent() const +{ + return false; +} + +bool +RBAContent::isSoundContent() const +{ + return false; +} + +const std::list& +RBAContent::getStates() const +{ + return states_; +} + +void +RBAContent::addState(const RBAContentState* const state) +{ + states_.push_back(state); +} + +const std::list& +RBAContent::getAllocatables() const +{ + return allocatableSet_->getLeafAllocatable(); +} + +void +RBAContent::addAllocatable(const RBAAllocatable* const alloc) +{ + allocatableSet_->addTarget(alloc); +} + +RBAContentLoserType +RBAContent::getContentLoserType() const +{ + return loserType_; +} + +void +RBAContent::setLoserType(const RBAContentLoserType newLoserType) +{ + loserType_ = newLoserType; +} + +const RBAAllocatableSet* +RBAContent::getAllocatableSet() const +{ + return allocatableSet_.get(); +} + +void RBAContent::updateRequestStatus(RBAResultSet* const resultset, const bool isOnRequest) +{ + resultset->updateRequestStatus(this, isOnRequest); +} + +void RBAContent::updateStatus(RBAResultImpl* const result) +{ + result->updateStatus(this); +} + +const std::list& +RBAContent::getSizes() const +{ + static const std::list sizes; + return sizes; +} + +} diff --git a/src/core/model/RBAContent.hpp b/src/core/model/RBAContent.hpp new file mode 100644 index 0000000..17e912c --- /dev/null +++ b/src/core/model/RBAContent.hpp @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Content class header + */ + +#ifndef RBACONTENT_HPP +#define RBACONTENT_HPP + +#include +#include +#include "RBAAbstractContent.hpp" +#include "RBAAllocatableSet.hpp" +#include "RBAContentLoserType.hpp" + +namespace rba +{ + +class RBAArbitrator; +class RBAAllocatable; +class RBAContentState; +class RBAResultImpl; +class RBAResultSet; +class RBAExpression; +class RBASize; + +class DLL_EXPORT RBAContent : public RBAAbstractContent +{ +public: + explicit RBAContent(const std::string& name=""); + RBAContent(const RBAContent&)=delete; + RBAContent(const RBAContent&&)=delete; + RBAContent& operator=(const RBAContent&)=delete; + RBAContent& operator=(const RBAContent&&)=delete; + virtual ~RBAContent()=default; + +public: + virtual bool isViewContent() const; + virtual bool isSoundContent() const; + + const std::list& getStates() const; + void addState(const RBAContentState* const state); + const std::list& getAllocatables() const; + void addAllocatable(const RBAAllocatable* const alloc); + RBAContentLoserType getContentLoserType() const; + void setLoserType(const RBAContentLoserType newLoserType); + const RBAAllocatableSet* getAllocatableSet() const; + void updateRequestStatus(RBAResultSet* const resultset, const bool isOnRequest); + void updateStatus(RBAResultImpl* const result); + virtual const std::list& getSizes() const; + +#ifdef RBA_USE_LOG + virtual std::string getSymbol() const = 0; + virtual std::string getVisibleSymbol() const = 0; +#endif + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list states_; + std::unique_ptr allocatableSet_ {std::make_unique()}; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + RBAContentLoserType loserType_ {RBAContentLoserType::DO_NOT_GIVEUP_UNTIL_WIN}; + +}; + +} + +#endif diff --git a/src/core/model/RBAContentMaker.cpp b/src/core/model/RBAContentMaker.cpp new file mode 100644 index 0000000..a9828ba --- /dev/null +++ b/src/core/model/RBAContentMaker.cpp @@ -0,0 +1,126 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAContentMaker.cpp +/// @brief Content obecjt generator abstract class + +#include +#include "RBAContentMaker.hpp" +#include "RBAContent.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBAViewContentStateMaker.hpp" +#include "RBASoundContentStateMaker.hpp" + +namespace rba +{ + +RBAContentMaker::RBAContentMaker(const std::string& label) + : RBARuleObjectMaker{label}, + RBAAbstractContentMaker{label} +{ +} + +RBAModelElement* +RBAContentMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBAAbstractContentMaker::setProperty(element, jsonElem, model, owner)); + + RBAContent* const content {dynamic_cast(element)}; + + // loserType + const RBAJsonElement* const loserTypeElem {jsonElem->findChildren("loserType")}; + if(loserTypeElem == nullptr) { + std::cerr << content->getElementName() + << ": loserType not found" << &std::endl; + return nullptr; + } + content->setLoserType(loserTypeElem->getLoserType()); + + // allocatable + for(auto& allocElem : jsonElem->findChildren("allocatable")->getChildren()) { + const auto str = allocElem->getName(); + std::string allocName {""}; + std::string className {""}; + if (str.find(':') != std::string::npos) { + allocName = str.substr(0U, str.find(':')); + className = str.substr(str.find(':') + 1U); + } else { + allocName = str; + } + + auto alloc = model->findAllocatable(allocName); + if (alloc == nullptr) { + alloc = dynamic_cast(getMaker(className)->getInstance(model, allocName)); + } + const_cast(alloc)->addContent(content); + content->addAllocatable(alloc); + } + + // state + if (content->isViewContent()) { + RBAViewContentStateMaker csMaker; + for(const auto& state : jsonElem->findChildren("states")->getChildren()) { + RBAModelElement* const s {csMaker.create(state.get(), model, content)}; + content->addMember(dynamic_cast(s)); + content->addState(dynamic_cast(s)); + } + } + else if (content->isSoundContent()) { + RBASoundContentStateMaker csMaker; + for(const auto& state : jsonElem->findChildren("states")->getChildren()) { + RBAModelElement* const s {csMaker.create(state.get(), model, content)}; + content->addMember(dynamic_cast(s)); + content->addState(dynamic_cast(s)); + } + } + // Expand Content + else { + auto alloc = content->getAllocatables().front(); + // Seek until it becomes an Area or Zone + while (!alloc->isArea() && !alloc->isZone()) { + alloc = dynamic_cast(alloc)->getAllocatables().front(); + } + if (alloc->isArea()) { + RBAViewContentStateMaker csMaker; + for(const auto& state : jsonElem->findChildren("states")->getChildren()) { + RBAModelElement* const s {csMaker.create(state.get(), model, content)}; + content->addMember(dynamic_cast(s)); + content->addState(dynamic_cast(s)); + } + } else if (alloc->isZone()) { + RBASoundContentStateMaker csMaker; + for(const auto& state : jsonElem->findChildren("states")->getChildren()) { + RBAModelElement* const s {csMaker.create(state.get(), model, content)}; + content->addMember(dynamic_cast(s)); + content->addState(dynamic_cast(s)); + } + } else { + ; + } + } + + model->addContent(content); + + return content; +} + +} diff --git a/src/core/model/RBAContentMaker.hpp b/src/core/model/RBAContentMaker.hpp new file mode 100644 index 0000000..5564fc1 --- /dev/null +++ b/src/core/model/RBAContentMaker.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAContentMaker.hpp +/// @brief Content obecjt generator class header + +#ifndef RBACONTENTMAKER_HPP +#define RBACONTENTMAKER_HPP + +#include "RBAAbstractContentMaker.hpp" + +namespace rba +{ + +/// @brief Content obecjt generator class +class DLL_EXPORT RBAContentMaker : public RBAAbstractContentMaker +{ +public: + explicit RBAContentMaker(const std::string& label=""); + RBAContentMaker(const RBAContentMaker&)=delete; + RBAContentMaker(const RBAContentMaker&&)=delete; + RBAContentMaker& operator=(const RBAContentMaker&)=delete; + RBAContentMaker& operator=(const RBAContentMaker&&)=delete; + virtual ~RBAContentMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAContentSet.cpp b/src/core/model/RBAContentSet.cpp new file mode 100644 index 0000000..00da62e --- /dev/null +++ b/src/core/model/RBAContentSet.cpp @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * ContentSet class + */ + +#include +#include "RBAContentSet.hpp" +#include "RBAContent.hpp" + +namespace rba +{ + +RBAContentSet::RBAContentSet(const std::string& name) + : RBARuleObject{name}, + RBAAbstractContent{name} +{ +} + +void +RBAContentSet::addTarget(const RBAContent* content) +{ + leafContent_.push_back(content); +#ifdef RBA_USE_LOG + std::string newName = "["; + for (auto& c : leafContent_) { + newName += c->getElementName() + ","; + } + if (newName.size() != 1U) { + newName.erase(newName.end() - 1); // Remove the trailing "," + } + newName += "]"; + setDynamicName(newName); +#endif +} + +void +RBAContentSet::clear() +{ + leafContent_.clear(); +#ifdef RBA_USE_LOG + setDynamicName("[]"); +#endif +} + +const std::list& +RBAContentSet::getLeafContent() const +{ + return leafContent_; +} + +} diff --git a/src/core/model/RBAContentSet.hpp b/src/core/model/RBAContentSet.hpp new file mode 100644 index 0000000..3997f07 --- /dev/null +++ b/src/core/model/RBAContentSet.hpp @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ContentSet class header + */ + +#ifndef RBACONTENTSET_HPP +#define RBACONTENTSET_HPP + +#include +#include "RBAAbstractContent.hpp" + +namespace rba +{ + +class RBAContent; + +class DLL_EXPORT RBAContentSet : public RBAAbstractContent +{ +public: + explicit RBAContentSet(const std::string& name=""); + RBAContentSet(const RBAContentSet&)=delete; + RBAContentSet(const RBAContentSet&&)=delete; + RBAContentSet& operator=(const RBAContentSet&)=delete; + RBAContentSet& operator=(const RBAContentSet&&)=delete; + virtual ~RBAContentSet()=default; + +public: + virtual void addTarget(const RBAContent* content); + virtual void clear(); + const std::list& getLeafContent() const; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list leafContent_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBAContentSetMaker.cpp b/src/core/model/RBAContentSetMaker.cpp new file mode 100644 index 0000000..cbc8db9 --- /dev/null +++ b/src/core/model/RBAContentSetMaker.cpp @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// @file RBAContentSetMaker.cpp +/// @brief ContentSet object generator class + +#include "RBAContentSetMaker.hpp" +#include "RBAContentSet.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBAContentSetMaker::RBAContentSetMaker(const std::string& label) + : RBARuleObjectMaker{label}, + RBAAbstractContentMaker{label} +{ +} + +RBAModelElement* +RBAContentSetMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBAAbstractContentMaker::setProperty(element, jsonElem, model, owner)); + + const auto contentSet = dynamic_cast(element); + + // content + for(const auto& content : jsonElem->findChildren("target")->getChildren()) { + const auto cont = model->findContent(content->getName()); + contentSet->addTarget(cont); + } + + return contentSet; +} + +} diff --git a/src/core/model/RBAContentSetMaker.hpp b/src/core/model/RBAContentSetMaker.hpp new file mode 100644 index 0000000..182764c --- /dev/null +++ b/src/core/model/RBAContentSetMaker.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAContentSetMaker.hpp +/// @brief ContentSet object generator class header + +#ifndef RBACONTENTSETMAKER_HPP +#define RBACONTENTSETMAKER_HPP + +#include "RBAAbstractContentMaker.hpp" + +namespace rba +{ + +/// @brief ContentSet object generator class +class RBAContentSetMaker : public RBAAbstractContentMaker +{ +public: + explicit RBAContentSetMaker(const std::string& label=""); + RBAContentSetMaker(const RBAContentSetMaker&)=delete; + RBAContentSetMaker(const RBAContentSetMaker&&)=delete; + RBAContentSetMaker& operator=(const RBAContentSetMaker&)=delete; + RBAContentSetMaker& operator=(const RBAContentSetMaker&&)=delete; + virtual ~RBAContentSetMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAContentState.cpp b/src/core/model/RBAContentState.cpp new file mode 100644 index 0000000..f149129 --- /dev/null +++ b/src/core/model/RBAContentState.cpp @@ -0,0 +1,133 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +] +/** + * ContentState class + */ + +#include + +#include "RBAViewContentState.hpp" +#include "RBAContent.hpp" +#include "RBAContentState.hpp" + +namespace rba +{ + +RBAContentState::RBAContentState(const std::string& name) + : RBARuleObject{name} +{ +} + +void +RBAContentState::clearStatus() +{ + order_ = 0; +} + +bool +RBAContentState::isViewContentState() const +{ + return false; +} + +bool +RBAContentState::isSoundContentState() const +{ + return false; +} + +std::string +RBAContentState::getUniqueName() const +{ + return getOwner()->getElementName() + RBAViewContentState::CONTEXT_SEPARATER + getElementName(); +} + +std::int32_t +RBAContentState::getContentStatePriority() const +{ + return priority_; +} + +void +RBAContentState::setPriority(const std::int32_t newPriority) +{ + priority_ = newPriority; +} + +std::int32_t +RBAContentState::getContentStateOrder() const +{ + return order_; +} + +void +RBAContentState::setOrder(const std::int32_t newOrder) +{ + order_ = newOrder; +} + +bool +RBAContentState::compareFirstComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs) +{ + return lhs->getContentStateOrder() < rhs->getContentStateOrder(); +} + +bool +RBAContentState::compareLastComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs) +{ + return lhs->getContentStateOrder() > rhs->getContentStateOrder(); +} + +bool +RBAContentState::comparePriorityFirstComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs) +{ + if(lhs->getContentStatePriority() == rhs->getContentStatePriority()) { + return compareFirstComeFirst(lhs, rhs); + } + else { + return lhs->getContentStatePriority() > rhs->getContentStatePriority(); + } +} + +bool +RBAContentState::comparePriorityLastComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs) +{ + if(lhs->getContentStatePriority() == rhs->getContentStatePriority()) { + return compareLastComeFirst(lhs, rhs); + } + else { + return lhs->getContentStatePriority() > rhs->getContentStatePriority(); + } +} + +const std::string +RBAContentState::getPriorityString() const +{ + return std::to_string(priority_); +} + +const std::string +RBAContentState::getOrderString() const +{ + return std::to_string(order_); +} + +} diff --git a/src/core/model/RBAContentState.hpp b/src/core/model/RBAContentState.hpp new file mode 100644 index 0000000..7d4a81f --- /dev/null +++ b/src/core/model/RBAContentState.hpp @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * ContentState class header + */ + +#ifndef RBACONTENTSTATE_HPP +#define RBACONTENTSTATE_HPP + +#include +#include "RBARuleObject.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAContentState : public RBARuleObject +{ +protected: + explicit RBAContentState(const std::string& name); + RBAContentState(const RBAContentState&)=delete; + RBAContentState(const RBAContentState&&)=delete; + RBAContentState& operator=(const RBAContentState&)=delete; + RBAContentState& operator=(const RBAContentState&&)=delete; + +public: + virtual ~RBAContentState()=default; + +public: + void clearStatus() final; + virtual bool isViewContentState() const; + virtual bool isSoundContentState() const; + + std::string getUniqueName() const override; + std::int32_t getContentStatePriority() const; + void setPriority(const std::int32_t newPriority); + std::int32_t getContentStateOrder() const; + void setOrder(const std::int32_t newOrder); + + static bool compareFirstComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs); + static bool compareLastComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs); + static bool comparePriorityFirstComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs); + static bool comparePriorityLastComeFirst(const RBAContentState* const lhs, + const RBAContentState* const rhs); + + // Log + const std::string getPriorityString() const; + const std::string getOrderString() const; + +private: + std::int32_t priority_ {0}; + std::int32_t order_ {0}; + +}; + +} + +#endif diff --git a/src/core/model/RBAContentStateMaker.cpp b/src/core/model/RBAContentStateMaker.cpp new file mode 100644 index 0000000..92129ef --- /dev/null +++ b/src/core/model/RBAContentStateMaker.cpp @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAContentStateMaker.cpp +/// @brief ContentState object generator abstract class + +#include "RBAContentStateMaker.hpp" +#include "RBAContentState.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" +#include "RBAConstraintInfo.hpp" + +namespace rba +{ + +RBAContentStateMaker::RBAContentStateMaker(const std::string& label) + : RBARuleObjectMaker{label} +{ +} + +RBAModelElement* +RBAContentStateMaker::getInstance(RBAModelImpl* model, + const std::string& name, + RBAModelElement* owner) +{ + RBAModelElement* ret {nullptr}; + + const auto content = dynamic_cast(owner); + const auto uniqueName = content->getUniqueName() + "/" + name; + + const auto element = model->findModelElement(uniqueName); + // exists in model + if(element != nullptr) { + ret = const_cast(element); + } + // not exists in modelmodel + else { + std::unique_ptr inst {createInstance(name)}; + const auto contentState = dynamic_cast(inst.get()); + contentState->setOwner(content); + ret = model->addNamedElement(std::move(inst)); + } + + return ret; +} + +RBAModelElement* +RBAContentStateMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBARuleObjectMaker::setProperty(element, jsonElem, model, owner)); + + RBAContentState* const state {dynamic_cast(element)}; + + // Set priority + state->setPriority(jsonElem->findChildren("priority")->getInt()); + + model->addContentState(state); + + return state; +} + +} diff --git a/src/core/model/RBAContentStateMaker.hpp b/src/core/model/RBAContentStateMaker.hpp new file mode 100644 index 0000000..4082739 --- /dev/null +++ b/src/core/model/RBAContentStateMaker.hpp @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAContentStateMaker.hpp +/// @brief ContentState object generator abstract class header + +#ifndef RBACONTENTSTATEMAKER_HPP +#define RBACONTENTSTATEMAKER_HPP + +#include "RBARuleObjectMaker.hpp" + +namespace rba +{ + +/// @brief ContentState object generator abstract class +class RBAContentStateMaker : public RBARuleObjectMaker +{ +public: + explicit RBAContentStateMaker(const std::string& label); + RBAContentStateMaker(const RBAContentStateMaker&)=delete; + RBAContentStateMaker(const RBAContentStateMaker&&)=delete; + RBAContentStateMaker& operator=(const RBAContentStateMaker&)=delete; + RBAContentStateMaker& operator=(const RBAContentStateMaker&&)=delete; + virtual ~RBAContentStateMaker()=default; + +public: + + RBAModelElement* getInstance(RBAModelImpl* model, + const std::string& name="", + RBAModelElement* owner=nullptr) override; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBAContentStatusType.hpp b/src/core/model/RBAContentStatusType.hpp new file mode 100644 index 0000000..d6cd161 --- /dev/null +++ b/src/core/model/RBAContentStatusType.hpp @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// +// State transition type of content +// + +#ifndef RBACONTENTSTATUSTYPE_HPP +#define RBACONTENTSTATUSTYPE_HPP + +namespace rba +{ + +enum class RBAContentStatusType : std::uint8_t +{ + NoRequest, + Undisplayed, + Displayed, + StandBy, + Canceled +}; +} + +#endif /* RBACONTENTSTATUSTYPE_HPP */ diff --git a/src/core/model/RBAIntegerProperty.cpp b/src/core/model/RBAIntegerProperty.cpp new file mode 100644 index 0000000..aeee3b0 --- /dev/null +++ b/src/core/model/RBAIntegerProperty.cpp @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Integer property class + */ + +#include "RBAIntegerProperty.hpp" +#include "RBASceneImpl.hpp" + +namespace rba +{ + +RBAIntegerProperty::RBAIntegerProperty(const RBASceneImpl* const scene, + const std::string& newName, + const std::int32_t newValue) + : RBAAbstractProperty{scene, newName}, + value_{newValue} +{ +} + +std::int32_t +RBAIntegerProperty::getValue() const +{ + return value_; +} + +#ifdef RBA_USE_LOG +const std::string +RBAIntegerProperty::getExpressionText() const +{ + return getScene()->getElementName() + "." + getElementName(); +} +#endif + +} diff --git a/src/core/model/RBAIntegerProperty.hpp b/src/core/model/RBAIntegerProperty.hpp new file mode 100644 index 0000000..f174f0a --- /dev/null +++ b/src/core/model/RBAIntegerProperty.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** + * Integer property class header + */ + +#ifndef RBAINTEGERPROPERTY_HPP +#define RBAINTEGERPROPERTY_HPP + +#include "RBAAbstractProperty.hpp" + +namespace rba +{ + +class RBAIntegerProperty : public RBAAbstractProperty +{ +public: + RBAIntegerProperty(const RBASceneImpl* const scene, + const std::string& newName, const std::int32_t newValue); + RBAIntegerProperty(const RBAIntegerProperty&)=delete; + RBAIntegerProperty(const RBAIntegerProperty&&)=delete; + RBAIntegerProperty& operator=(const RBAIntegerProperty&)=delete; + RBAIntegerProperty& operator=(const RBAIntegerProperty&&)=delete; + +public: + std::int32_t getValue() const override; + + // Log +#ifdef RBA_USE_LOG + const std::string getExpressionText() const override; +#endif + +private: + std::int32_t value_; + +}; + +} + +#endif diff --git a/src/core/model/RBAModelElement.cpp b/src/core/model/RBAModelElement.cpp new file mode 100644 index 0000000..b4308e5 --- /dev/null +++ b/src/core/model/RBAModelElement.cpp @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * ModelElment class + */ + +#include "RBAModelElement.hpp" +#include "RBAModelElementType.hpp" + +namespace rba +{ + +void RBAModelElement::clearStatus() +{ + // This function is called from a ModelElement that has no internal state + // to clear. + // The overridden function is called from the ModelElement + // that has the internal state to clear. +} +RBAModelElementType +RBAModelElement::getModelElementType() const +{ + // This function is never called because the function of + // the derived class is called. + return RBAModelElementType::None; +} + +bool +RBAModelElement::isModelElementType(const RBAModelElementType elemType) const +{ + return (elemType == getModelElementType()); +} + +} diff --git a/src/core/model/RBAModelElement.hpp b/src/core/model/RBAModelElement.hpp new file mode 100644 index 0000000..7ee7557 --- /dev/null +++ b/src/core/model/RBAModelElement.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * ModelElment class header + */ + +#ifndef RBAMODELELEMENT_HPP +#define RBAMODELELEMENT_HPP + +#include +#include "RBADllExport.hpp" + +namespace rba +{ + +enum class RBAModelElementType : std::uint8_t; + +class DLL_EXPORT RBAModelElement +{ +protected: + RBAModelElement()=default; + RBAModelElement(const RBAModelElement&)=delete; + RBAModelElement(const RBAModelElement&&)=delete; + RBAModelElement& operator=(const RBAModelElement&)=delete; + RBAModelElement& operator=(const RBAModelElement&&)=delete; + +public: + virtual ~RBAModelElement()=default; + +public: + virtual void clearStatus(); + virtual RBAModelElementType getModelElementType() const; + bool isModelElementType(const RBAModelElementType elemType) const; + +}; + +} + +#endif diff --git a/src/core/model/RBAModelElementMaker.cpp b/src/core/model/RBAModelElementMaker.cpp new file mode 100644 index 0000000..9d750c0 --- /dev/null +++ b/src/core/model/RBAModelElementMaker.cpp @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAModelElementMaker.cpp +/// @brief ModelElement object genartor abstract class + +#include "RBAModelElementMaker.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelFactory.hpp" +#include "RBAModelImpl.hpp" + +namespace rba +{ + +std::unordered_map> RBAModelElementMaker::makerMap_; + +RBAModelElementMaker::RBAModelElementMaker(const std::string& label) + : factory_{nullptr}, + label_{label} +{ +} + +void +RBAModelElementMaker::setFactory(RBAModelFactory* const factory) +{ + factory_ = factory; +} + +RBAModelFactory* RBAModelElementMaker::getFactory() const +{ + return factory_; +} + +const std::string& +RBAModelElementMaker::getLabel() const +{ + return label_; +} + +RBAModelElement* +RBAModelElementMaker::create(const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + const auto nameElement = jsonElem->findChildren("name"); + + RBAModelElement* element {nullptr}; + if (nameElement != nullptr) { + element = getInstance(model, nameElement->getString(), owner); + } else { + element = getInstance(model, "", owner); + } + + return setProperty(element, jsonElem, model, owner); +} + +RBAModelElement* +RBAModelElementMaker::getInstance(RBAModelImpl* model, + const std::string& name, + RBAModelElement* owner) +{ + RBAModelElement* ret {nullptr}; + + // If there is a class name, delete the class name + std::string fullName {name}; + while (fullName.find(':') != std::string::npos) { + const auto start = fullName.find(':'); + const auto end = fullName.find('/', start); + static_cast(fullName.erase(start, end - start)); + } + + // In case of Elemetn with name +   if(fullName != "") { + const auto elem = model->findModelElement(fullName); + // exists in model + if(elem != nullptr) { + ret = const_cast(elem); + } + // not exists in model + else { + std::unique_ptr inst {createInstance(fullName)}; + ret = model->addNamedElement(std::move(inst)); + } + } + // In case of Elemetn without name + else { + std::unique_ptr inst {createInstance()}; + ret = model->addModelElement(std::move(inst)); + } + + return ret; +} + +void +RBAModelElementMaker::addMaker(const std::string& typeName, std::unique_ptr maker) +{ + makerMap_[typeName] = std::move(maker); +} + +RBAModelElementMaker* +RBAModelElementMaker::getMaker(const std::string& typeName) +{ + if (makerMap_.find(typeName) == makerMap_.end()) { + return nullptr; + } + return makerMap_[typeName].get(); +} + +} diff --git a/src/core/model/RBAModelElementMaker.hpp b/src/core/model/RBAModelElementMaker.hpp new file mode 100644 index 0000000..c038f5a --- /dev/null +++ b/src/core/model/RBAModelElementMaker.hpp @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAModelElementMaker.hpp +/// @brief ModelElement object genartor abstract class header + +#ifndef RBAMODELELEMENTMAKER_HPP +#define RBAMODELELEMENTMAKER_HPP + +#include +#include +#include "RBADllExport.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +class RBAModelElement; +class RBAJsonElement; +class RBAModelImpl; + +/// @brief ModelElement object genartor abstract class +class DLL_EXPORT RBAModelElementMaker +{ +public: + /// @brief Constructor that specifies the label + /// @details Set label and generate + /// @param[in] label labe to set + RBAModelElementMaker()=default; + explicit RBAModelElementMaker(const std::string& label); + virtual ~RBAModelElementMaker()=default; + +protected: + RBAModelElementMaker(const RBAModelElementMaker& maker)=delete; + RBAModelElementMaker& operator=(const RBAModelElementMaker& maker)=delete; + // Use "move" in RBAAbstractModelTable::addMaker() + RBAModelElementMaker(RBAModelElementMaker&&)=default; + RBAModelElementMaker& operator=(RBAModelElementMaker&&)=default; + +public: + /// @brief Set model factory + /// @param[in] factory model factory + void setFactory(RBAModelFactory* const factory); + + /// @brief Get label + /// @details Returns the label of the corresponding JSON element + /// @return Label string + const std::string& getLabel() const; + + /// @brief Create ModelElement object + /// @details create ModelElement object and register unique_ptr to model + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The moder to store created object + /// @param[in,out] owner Parent object (Not in use) + /// @return ModelElement object + virtual RBAModelElement* create(const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr); + + /// @brief Get instance + /// @details Get the element corresponding to name from model. + /// If there is no name or it is not in model, + /// create an instance and register it in model. + /// @return ModelElement object + virtual RBAModelElement* getInstance(RBAModelImpl* model, + const std::string& name="", + RBAModelElement* owner=nullptr); + + /// @brief Register Maker + /// @details Register the Maker corresponding to the class name + /// used in JSON in the map + /// @return void + static void addMaker(const std::string& typeName, + std::unique_ptr maker); + + /// @brief Get Maker + /// @details Get the Maker corresponding to the class name from the map + /// @return Corresponding Maker. If it doesn't exist, return null. + static RBAModelElementMaker* getMaker(const std::string& typeName); + +protected: + /// @brief Create an empty instance + /// @details Create an empty instance of unique_ptr in derived class + /// @return unique_ptr for instance + virtual std::unique_ptr createInstance(const std::string& name="")=0; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + virtual RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr)=0; + + /// @brief Get model factory + /// @details Get model factory + /// @return model factory + RBAModelFactory* getFactory() const; + +private: + /// @brief Factory for recursively generating objects + RBAModelFactory* factory_; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + /// @brief Label of corresponding JSON element + const std::string label_; + + /// @brief Correspondence map of each Maker and the character string that + /// represents the class used in JSON + static std::unordered_map> makerMap_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBAModelElementType.hpp b/src/core/model/RBAModelElementType.hpp new file mode 100644 index 0000000..756f22b --- /dev/null +++ b/src/core/model/RBAModelElementType.hpp @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * ModelElementType class header + */ + +#ifndef RBAMODELELEMENTTYPE_HPP +#define RBAMODELELEMENTTYPE_HPP + +namespace rba +{ + +enum class RBAModelElementType : std::uint8_t +{ + AllInstanceOfArea, + AllInstanceOfViewContent, + AllInstanceOfZone, + AllInstanceOfSoundContent, + Allocatable, + AllocatedContent, + AndOperator, + Area, + AreaSet, + ArithmeticOperator, + Constraint, + ViewContent, + ViewContentSet, + ViewContentState, + ContentValue, + DisplayingContent, + ExistsOperator, + ForAllOperator, + GetAllocatables, + ActiveState, + ActiveContents, + GetContentsList, + IfStatement, + IfActionOperator, + ImpliesOperator, + IntegerValue, + IsActive, + IsDisplayed, + IsEqualToOperator, + IsGreaterThanEqualOperator, + IsGreaterThanOperator, + IsHidden, + IsLowerThanEqualOperator, + IsLowerThanOperator, + IsVisible, + LambdaContext, + LambdaExpression, + LetStatement, + NotOperator, + ObjectCompare, + ObjectReference, + MemberFeatureReference, + OrOperator, + PlusOperator, + PreviousModifier, + RuleObject, + Scene, + Property, + SetExpression, + SetOfOperator, + SetOperator, + ValueExpression, + Variable, + IsOn, + Zone, + ZoneSet, + SoundContent, + SoundContentSet, + SoundContentState, + IsAttenuated, + IsOutputted, + IsMuted, + IsSounding, + Rule, + OnScene, + OffScene, + GetProperty, + SetProperty, + IntegerProperty, + OutputtingSound, + StateValue, + HasBeenCanceled, + HasBeenDisplayed, + HasComeEarlier, + HasComeLater, + EventProcessing, + MaxOperator, + MinOperator, + SelectOperator, + SizeOperator, + Undisplayed, + IsTypeOfOperator, + Displayed, + None +}; + +} + +#endif diff --git a/src/core/model/RBAModelImpl.cpp b/src/core/model/RBAModelImpl.cpp new file mode 100644 index 0000000..081607c --- /dev/null +++ b/src/core/model/RBAModelImpl.cpp @@ -0,0 +1,823 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAModelmpl.cpp +/// @brief Model implementation class + +#include "RBAModelImpl.hpp" +#include "RBAConstraintImpl.hpp" + +namespace rba +{ + +const RBAContentState* +RBAModelImpl::findContentState(const std::string& stateName) +{ + const auto elem = findModelElementImpl(stateName); + auto contentState = dynamic_cast(elem); + if (contentState == nullptr) { + const auto content = dynamic_cast(elem); + if (content != nullptr) { + contentState = content->getStates().front(); + } + } + return contentState; +} + +const RBAArea* +RBAModelImpl::findArea(const std::string& areaName) const +{ + return findAreaImpl(areaName); +} + +const RBAViewContent* +RBAModelImpl::findViewContent(const std::string& contName) const +{ + return findViewContentImpl(contName); +} + +const RBAViewContentState* +RBAModelImpl::findViewContentState(const std::string& stateName) const +{ + return findViewContentStateImpl(stateName); +} + +const RBASize* +RBAModelImpl::findSize(const std::string& sizeName) const +{ + return findSizeImpl(sizeName); +} + +const RBAZone* +RBAModelImpl::findZone(const std::string& zoneName) const +{ + return findZoneImpl(zoneName); +} + +const RBASoundContent* +RBAModelImpl::findSoundContent(const std::string& contName) const +{ + return findSoundContentImpl(contName); +} + +const RBASoundContentState* +RBAModelImpl::findSoundContentState(const std::string& stateName) const +{ + return findSoundContentStateImpl(stateName); +} + +const RBAScene* +RBAModelImpl::findScene(const std::string& sceneName) const +{ + return findSceneImpl(sceneName); +} + +const RBADisplay* +RBAModelImpl::findDisplay(const std::string& displayName) const +{ + return findDisplayImpl(displayName); +} + +const RBAModelElement* +RBAModelImpl::findModelElement(const std::string& elementName) const +{ + return findModelElementImpl(elementName); +} + +const std::list& +RBAModelImpl::getAreas() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAArea is the base class of RBAAreaImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getAreaImpls()); +} + +const std::list& +RBAModelImpl::getViewContents() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAViewContent is the base class of + // RBAViewContentImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getViewContentImpls()); +} + +const std::list& +RBAModelImpl::getViewContentStates() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAViewContentState is the base class of + // RBAViewContentStateImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getViewContentStateImpls()); +} + +const std::list& +RBAModelImpl::getSizes() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBASize is the base class of RBASizeImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getSizeImpls()); +} + +const std::list& +RBAModelImpl::getZones() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAZone is the base class of RBAZoneImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getZoneImpls()); +} + +const std::list& +RBAModelImpl::getSoundContents() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBASoundContent is the base class of + // RBASoundContentImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getSoundContentImpls()); +} + +const std::list& +RBAModelImpl::getSoundContentStates() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBASoundContentState is the base class of + // RBASoundContentStateImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getSoundContentStateImpls()); +} + +const std::list& +RBAModelImpl::getScenes() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAScene is the base class of + // RBASceneImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getSceneImpls()); +} + +const std::list& +RBAModelImpl::getAreaSets() const +{ + return getAreaSetImpls(); +} + +const std::list& +RBAModelImpl::getViewContentSets() const +{ + return getViewContentSetImpls(); +} + +const std::list& +RBAModelImpl::getZoneSets() const +{ + return getZoneSetImpls(); +} + +const std::list& +RBAModelImpl::getSoundContentSets() const +{ + return getSoundContentSetImpls(); +} + +const std::list& +RBAModelImpl::getPositionContainers() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAPositionContainer is the base class of + // RBAPositionContainerImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getPositionContainerImpls()); +} + +const std::list& +RBAModelImpl::getDisplays() const +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBADisplay is the base class of RBADisplayImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getDisplayImpls()); +} + +std::list& +RBAModelImpl::getConstraints() +{ + // @Deviation (A5-2-4) + // [Contents that deviate from the rules] + // reinterpret_cast shall not be used. + // [Reason that there is no problem if the rule is deviated] + // There is no problem because RBAConstraint is the base class of + // RBAConstraintImpl. + // Since the conversion process is costly, it deviates because it hides + // the internal structure. + return reinterpret_cast&>(getConstraintImpls()); +} + +void RBAModelImpl::clearElementsStatus() +{ + for (auto& o : unnamedObjects_) { + o->clearStatus(); + } + for (auto& o : nameToObject_) { + o.second->clearStatus(); + } +} + +const RBAAllocatable* +RBAModelImpl::findAllocatable(const std::string& allocatableName) const +{ + auto it = nameToObject_.find(allocatableName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAContent* +RBAModelImpl::findContent(const std::string& contentName) const +{ + auto it = nameToObject_.find(contentName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAAreaImpl* +RBAModelImpl::findAreaImpl(const std::string& areaName) const +{ + auto it = nameToObject_.find(areaName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAViewContentImpl* +RBAModelImpl::findViewContentImpl(const std::string& contName) const +{ + auto it = nameToObject_.find(contName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAViewContentStateImpl* +RBAModelImpl::findViewContentStateImpl(const std::string& stateName) const +{ + const RBAViewContentStateImpl* ret {nullptr}; + if(RBAViewContentState::isUniqueName(stateName)) { + auto it = nameToObject_.find(stateName); + if(it != nameToObject_.end()) { + ret = dynamic_cast(it->second.get()); + } + } + else { + const RBAViewContentImpl* const content {findViewContentImpl(stateName)}; + if(content != nullptr) { + const RBAContentState* const state {content->getStates().front()}; + ret = dynamic_cast(state); + } + } + + return ret; +} + +const RBASizeImpl* +RBAModelImpl::findSizeImpl(const std::string& sizeName) const +{ + auto it = nameToObject_.find(sizeName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAZoneImpl* +RBAModelImpl::findZoneImpl(const std::string& zoneName) const +{ + auto it = nameToObject_.find(zoneName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBASoundContentImpl* +RBAModelImpl::findSoundContentImpl(const std::string& contName) const +{ + auto it = nameToObject_.find(contName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBASoundContentStateImpl* +RBAModelImpl::findSoundContentStateImpl(const std::string& stateName) const +{ + const RBASoundContentStateImpl* ret {nullptr}; + if(RBASoundContentState::isUniqueName(stateName)) { + auto it = nameToObject_.find(stateName); + if(it != nameToObject_.end()) { + ret = dynamic_cast(it->second.get()); + } + } + else { + const RBASoundContentImpl* const content {findSoundContentImpl(stateName)}; + if(content != nullptr) { + const RBAContentState* const state {content->getStates().front()}; + ret = dynamic_cast(state); + } + } + + return ret; +} + +const RBASceneImpl* +RBAModelImpl::findSceneImpl(const std::string& sceneName) const +{ + auto it = nameToObject_.find(sceneName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBADisplayImpl* +RBAModelImpl::findDisplayImpl(const std::string& displayName) const +{ + auto it = nameToObject_.find(displayName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAModelElement* +RBAModelImpl::findModelElementImpl(const std::string& elementName) const +{ + auto it = nameToObject_.find(elementName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const std::list& +RBAModelImpl::getAllocatables() const +{ + return allocatables_; +} + +const std::list& +RBAModelImpl::getContents() const +{ + return contents_; +} + +const std::list& +RBAModelImpl::getContentStates() const +{ + return contentStates_; +} + +const std::list& +RBAModelImpl::getAreaImpls() const +{ + return areas_; +} + +const std::list& +RBAModelImpl::getViewContentImpls() const +{ + return viewContents_; +} + +const std::list& +RBAModelImpl::getViewContentStateImpls() const +{ + return viewContentStates_; +} + +const std::list& +RBAModelImpl::getSizeImpls() const +{ + return sizes_; +} + +const std::list& +RBAModelImpl::getZoneImpls() const +{ + return zones_; +} + +const std::list& +RBAModelImpl::getSoundContentImpls() const +{ + return soundContents_; +} + +const std::list& +RBAModelImpl::getSoundContentStateImpls() const +{ + return soundContentStates_; +} + +const std::list& +RBAModelImpl::getSceneImpls() const +{ + return scenes_; +} + +const std::list& +RBAModelImpl::getPositionContainerImpls() const +{ + return positionContainers_; +} + +const std::list& +RBAModelImpl::getDisplayImpls() const +{ + return displays_; +} + +void +RBAModelImpl::createSortedAllocatables() +{ + if(!(sortedAllocatables_.empty())) { + sortedAllocatables_.clear(); + } + + for(auto& alloc : allocatables_) { + sortedAllocatables_.push_back(const_cast(alloc)); + } + sortedAllocatables_.sort(&RBAAllocatable::compare); + + std::int32_t index{0}; + for(RBAAllocatable* const allocatable : sortedAllocatables_) { + allocatable->setIndex(index); + index++; + } +} + +std::list& +RBAModelImpl::getSortedAllocatables() +{ + return sortedAllocatables_; +} + +RBAConstraintImpl* +RBAModelImpl::findConstraintImpl(const std::string& consName) const +{ + auto it = nameToObject_.find(consName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAAreaSet* +RBAModelImpl::findAreaSetImpl(const std::string& areaSetName) const +{ + auto it = nameToObject_.find(areaSetName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAZoneSet* +RBAModelImpl::findZoneSetImpl(const std::string& zoneSetName) const +{ + auto it = nameToObject_.find(zoneSetName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAViewContentSet* +RBAModelImpl::findViewContentSetImpl(const std::string& contSetName) const +{ + auto it = nameToObject_.find(contSetName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBASoundContentSet* +RBAModelImpl::findSoundContentSetImpl(const std::string& contSetName) const +{ + auto it = nameToObject_.find(contSetName); + if(it != nameToObject_.end()) { + return dynamic_cast(it->second.get()); + } + + return nullptr; +} + +const RBAPositionContainerImpl* +RBAModelImpl::findPositionContainerImpl(const std::string& areaName) const +{ + auto it = areaNameToPositionContainer_.find(areaName); + if(it != areaNameToPositionContainer_.end()) { + return dynamic_cast(it->second); + } + + return nullptr; +} + +/* + * get list functions + */ + +std::list& +RBAModelImpl::getConstraintImpls() +{ + return constraints_; +} + +const std::list& +RBAModelImpl::getAreaSetImpls() const +{ + return areaSets_; +} + +const std::list& +RBAModelImpl::getZoneSetImpls() const +{ + return zoneSets_; +} + +const std::list& +RBAModelImpl::getViewContentSetImpls() const +{ + return viewContentSets_; +} + +const std::list& +RBAModelImpl::getSoundContentSetImpls() const +{ + return soundContentSets_; +} + +RBAModelElement* +RBAModelImpl::addModelElement(std::unique_ptr newElement) +{ + RBAModelElement* const element {newElement.get()}; + unnamedObjects_.push_back(std::move(newElement)); + return element; +} + +RBANamedElement* +RBAModelImpl::addNamedElement(std::unique_ptr newElement) +{ + RBANamedElement* const element {dynamic_cast(newElement.get())}; + nameToObject_[element->getUniqueName()] = std::move(newElement); + return element; +} + +void +RBAModelImpl::addAllocatable(const RBAAllocatable* newAlloc) +{ + allocatables_.push_back(newAlloc); + if(newAlloc->isArea()) { + areas_.push_back(dynamic_cast(newAlloc)); + } + else if (newAlloc->isZone()) { + zones_.push_back(dynamic_cast(newAlloc)); + } else { + ; + } +} + +void +RBAModelImpl::addContent(const RBAContent* newContent) +{ + contents_.push_back(newContent); + if(newContent->isViewContent()) { + viewContents_.push_back(dynamic_cast(newContent)); + } + else if (newContent->isSoundContent()) { + soundContents_.push_back(dynamic_cast(newContent)); + } else { + ; + } +} + +void +RBAModelImpl::addContentState(const RBAContentState* newState) +{ + contentStates_.push_back(newState); + if(newState->isViewContentState()) { + viewContentStates_.push_back(dynamic_cast(newState)); + } + else { + soundContentStates_.push_back(dynamic_cast(newState)); + } +} + +void +RBAModelImpl::addAreaSet(const RBAAreaSet* newAreaSet) +{ + areaSets_.push_back(newAreaSet); +} + +void +RBAModelImpl::addZoneSet(const RBAZoneSet* newZoneSet) +{ + zoneSets_.push_back(newZoneSet); +} + +void +RBAModelImpl::addConstraint(const RBAConstraintImpl* newConstraint) +{ + constraints_.push_back(newConstraint); +} + +void +RBAModelImpl::addViewContentSet(const RBAViewContentSet* newContentSet) +{ + viewContentSets_.push_back(newContentSet); +} + +void +RBAModelImpl::addSoundContentSet(const RBASoundContentSet* newContentSet) +{ + soundContentSets_.push_back(newContentSet); +} + +void +RBAModelImpl::addScene(const RBASceneImpl* newScene) +{ + scenes_.push_back(newScene); +} + +RBASizeImpl* +RBAModelImpl::addSizeInstance(const std::string& ownerName, + std::unique_ptr newSize) +{ + RBASizeImpl* sizeImpl {dynamic_cast(newSize.get())}; + sizes_.push_back(sizeImpl); + nameToObject_[ownerName+std::string("/")+sizeImpl->getName()] + = std::move(newSize); + return sizeImpl; +} + +void +RBAModelImpl::addPositionContainer(const RBAPositionContainerImpl* newPositionContainer) +{ + positionContainers_.push_back(newPositionContainer); + areaNameToPositionContainer_[newPositionContainer->getArea()->getName()] + = newPositionContainer; +} + +void +RBAModelImpl::addDisplay(const RBADisplayImpl* newDisplay) +{ + displays_.push_back(newDisplay); +} + +void +RBAModelImpl::addLabeledElement(const std::string& label, + RBAModelElement* element) +{ + labelToElements_[label].push_back(element); +} + +void +RBAModelImpl::addLabeledConstraint(const std::string& label, + RBAAbstractConstraint* constraint) +{ + labelToConstraints_[label].push_back(constraint); +} + +const std::list +RBAModelImpl::getLabeledElements(const std::string& label) const +{ + auto it = labelToElements_.find(label); + if(it != labelToElements_.end()) { + return it->second; + } + + const std::list emp; + return emp; +} + +const std::list +RBAModelImpl::getLabeledConstraints(const std::string& label) const +{ + auto it = labelToConstraints_.find(label); + if(it != labelToConstraints_.end()) { + return it->second; + } + + const std::list emp; + return emp; +} + +const RBAModelElement* +RBAModelImpl::findLabeledElement(const std::string& label, + const std::string& name) const +{ + const std::list elems {getLabeledElements(label)}; + for(const RBAModelElement* const elem : elems) { + if(dynamic_cast(elem)->getElementName() == name) { + return elem; + } + } + + return nullptr; +} + +void +RBAModelImpl::addAffectedAllocsMap(const RBAModelElement* const owner, RBAAllocatable* const alloc) +{ + affectedAllocsMap_[owner].push_back(alloc); +} + +const std::list* +RBAModelImpl::getAffectedAllocs(const RBAModelElement* const owner) +{ + auto itr = affectedAllocsMap_.find(owner); + if (itr != affectedAllocsMap_.end()) { + return &itr->second; + } + return nullptr; +} + +} diff --git a/src/core/model/RBAModelImpl.hpp b/src/core/model/RBAModelImpl.hpp new file mode 100644 index 0000000..5773506 --- /dev/null +++ b/src/core/model/RBAModelImpl.hpp @@ -0,0 +1,221 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBAModelImplhpp +/// @brief Model implementaion class header + +#ifndef RBAMODELIMPL_HPP +#define RBAMODELIMPL_HPP + +#include +#include +#include + +#include "RBAAreaImpl.hpp" +#include "RBAConstraintImpl.hpp" +#include "RBADisplayImpl.hpp" +#include "RBAExpression.hpp" +#include "RBAModel.hpp" +#include "RBAModelElement.hpp" +#include "RBAPositionContainerImpl.hpp" +#include "RBASceneImpl.hpp" +#include "RBASizeImpl.hpp" +#include "RBASoundContentImpl.hpp" +#include "RBASoundContentStateImpl.hpp" +#include "RBAVariable.hpp" +#include "RBAViewContentImpl.hpp" +#include "RBAViewContentStateImpl.hpp" +#include "RBAZoneImpl.hpp" + +namespace rba +{ + +class DLL_EXPORT RBAModelImpl : public RBAModel +{ +public: + RBAModelImpl()=default; + RBAModelImpl(const RBAModelImpl&)=delete; + RBAModelImpl(const RBAModelImpl&&)=delete; + RBAModelImpl& operator=(const RBAModelImpl&)=delete; + RBAModelImpl& operator=(const RBAModelImpl&&)=delete; + virtual ~RBAModelImpl()=default; + +public: + const RBAArea* findArea(const std::string& areaName) const override; + const RBAViewContent* findViewContent(const std::string& contName) const override; + const RBAViewContentState* findViewContentState(const std::string& stateName) const override; + const RBASize* findSize(const std::string& sizeName) const override; + const RBAZone* findZone(const std::string& zoneName) const override; + const RBASoundContent* findSoundContent(const std::string& contName) const override; + const RBASoundContentState* findSoundContentState(const std::string& stateName) const override; + const RBAScene* findScene(const std::string& sceneName) const override; + const RBADisplay* findDisplay(const std::string& displayName) const override; + const RBAModelElement* findModelElement(const std::string& elementName) const override; + + const std::list& getAreas() const override; + const std::list& getViewContents() const override; + const std::list& getViewContentStates() const override; + const std::list& getSizes() const override; + const std::list& getZones() const override; + const std::list& getSoundContents() const override; + const std::list& getSoundContentStates() const override; + const std::list& getScenes() const override; + const std::list& getAreaSets() const override; + const std::list& getViewContentSets() const override; + virtual const std::list& getZoneSets() const; + virtual const std::list& getSoundContentSets() const; + const std::list& getPositionContainers() const override; + const std::list& getDisplays() const override; + std::list& getConstraints() override; + + virtual void clearElementsStatus(); + virtual const RBAContentState* findContentState(const std::string& stateName); + const RBAAllocatable* findAllocatable(const std::string& allocatableName) const; + const RBAContent* findContent(const std::string& contentName) const; + virtual const RBAAreaImpl* findAreaImpl(const std::string& areaName) const; + virtual const RBAViewContentImpl* findViewContentImpl(const std::string& contName) const; + virtual const RBAViewContentStateImpl* findViewContentStateImpl(const std::string& stateName) const; + virtual const RBASizeImpl* findSizeImpl(const std::string& sizeName) const; + virtual const RBAZoneImpl* findZoneImpl(const std::string& zoneName) const; + virtual const RBASoundContentImpl* findSoundContentImpl(const std::string& contName) const; + virtual const RBASoundContentStateImpl* findSoundContentStateImpl(const std::string& stateName) const; + virtual const RBASceneImpl* findSceneImpl(const std::string& sceneName) const; + virtual const RBADisplayImpl* findDisplayImpl(const std::string& displayName) const; + virtual const RBAModelElement* findModelElementImpl(const std::string& elementName) const; + + virtual const std::list& getAllocatables() const; + virtual const std::list& getContents() const; + virtual const std::list& getContentStates() const; + + virtual const std::list& getAreaImpls() const; + virtual const std::list& getViewContentImpls() const; + virtual const std::list& getViewContentStateImpls() const; + virtual const std::list& getSizeImpls() const; + virtual const std::list& getZoneImpls() const; + virtual const std::list& getSoundContentImpls() const; + virtual const std::list& getSoundContentStateImpls() const; + virtual const std::list& getSceneImpls() const; + virtual const std::list& getPositionContainerImpls() const; + virtual const std::list& getDisplayImpls() const; + + virtual void createSortedAllocatables(); + + virtual RBAConstraintImpl* findConstraintImpl(const std::string& consName) const; + virtual const RBAAreaSet* findAreaSetImpl(const std::string& areaSetName) const; + virtual const RBAZoneSet* findZoneSetImpl(const std::string& zoneSetName) const; + virtual const RBAViewContentSet* findViewContentSetImpl(const std::string& contSetName) const; + virtual const RBASoundContentSet* findSoundContentSetImpl(const std::string& contSetName) const; + virtual const RBAPositionContainerImpl* findPositionContainerImpl(const std::string& areaName) const; + + virtual std::list& getConstraintImpls(); + virtual const std::list& getAreaSetImpls() const; + virtual const std::list& getZoneSetImpls() const; + virtual const std::list& getViewContentSetImpls() const; + virtual const std::list& getSoundContentSetImpls() const; + // Do not set to const because the internal state is changed by arbitration + // processing + virtual std::list& getSortedAllocatables(); + + virtual RBAModelElement* addModelElement(std::unique_ptr newElement); + virtual RBANamedElement* addNamedElement(std::unique_ptr newElement); + virtual RBASizeImpl* addSizeInstance(const std::string& ownerName, + std::unique_ptr newSize); + + virtual void addAllocatable(const RBAAllocatable* newAlloc); + virtual void addContent(const RBAContent* newContent); + virtual void addContentState(const RBAContentState* newState); + virtual void addAreaSet(const RBAAreaSet* newAreaSet); + virtual void addZoneSet(const RBAZoneSet* newZoneSet); + virtual void addConstraint(const RBAConstraintImpl* newConstraint); + virtual void addViewContentSet(const RBAViewContentSet* newContentSet); + virtual void addSoundContentSet(const RBASoundContentSet* newContentSet); + virtual void addScene(const RBASceneImpl* newScene); + virtual void addPositionContainer(const RBAPositionContainerImpl* newPositionContainer); + virtual void addDisplay(const RBADisplayImpl* newDisplay); + /// Add element with label + virtual void addLabeledElement(const std::string& label, + RBAModelElement* element); + /// Add constraint expression with label + virtual void addLabeledConstraint(const std::string& label, + RBAAbstractConstraint* constraint); + + /// Add element list with label + virtual const std::list getLabeledElements(const std::string& label) const; + /// Add constraint expression list with label + virtual const std::list getLabeledConstraints(const std::string& label) const; + /// Search element with label + virtual const RBAModelElement* findLabeledElement(const std::string& label, + const std::string& name) const; + + // Add to Allcatable map + void addAffectedAllocsMap(const RBAModelElement* const owner, RBAAllocatable* const alloc); + // Get affected Allocatable list + const std::list* getAffectedAllocs(const RBAModelElement* const owner); + + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::list allocatables_; + std::list contents_; + std::list contentStates_; + std::list areas_; + std::list viewContents_; + std::list viewContentStates_; + std::list sizes_; + std::list zones_; + std::list soundContents_; + std::list soundContentStates_; + std::list constraints_; + std::list areaSets_; + std::list zoneSets_; + std::list scenes_; + std::list viewContentSets_; + std::list soundContentSets_; + std::list positionContainers_; + std::list displays_; + + // Do not set to const because the internal state is changed by arbitration + // processing + std::list sortedAllocatables_; + + // For storing objects not managed by name + // expression, variable are applicable. + std::list> unnamedObjects_; + + // Managing RBARuleObject and RBASize + std::unordered_map> nameToObject_; + // Position container is managed by map paired with Area name + std::unordered_map areaNameToPositionContainer_; + + // Managing Labeled element model for extensions + std::unordered_map> labelToElements_; + // Managing Labeled Constraint Expressions for extensions + std::unordered_map> labelToConstraints_; + + // Allocatable map + std::unordered_map> affectedAllocsMap_; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBANamedElement.cpp b/src/core/model/RBANamedElement.cpp new file mode 100644 index 0000000..9bfd1c0 --- /dev/null +++ b/src/core/model/RBANamedElement.cpp @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * NamedElement clsass + */ + +#include "RBANamedElement.hpp" + +namespace rba +{ + +RBANamedElement::RBANamedElement(const std::string& newName) + : RBAModelElement(), + name_(newName) +{ +} + +std::string +RBANamedElement::getUniqueName() const +{ + return getElementName(); +} + +const std::string& +RBANamedElement::getElementName() const +{ + return name_; +} + +const std::string& +RBANamedElement::getDynamicName() const +{ + return dynamic_name_; +} + +void +RBANamedElement::setDynamicName(const std::string& newName) +{ + dynamic_name_ = newName; +} +} diff --git a/src/core/model/RBANamedElement.hpp b/src/core/model/RBANamedElement.hpp new file mode 100644 index 0000000..81db36d --- /dev/null +++ b/src/core/model/RBANamedElement.hpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * NamedElement clsass header + */ + +#ifndef RBANAMEDELEMENT_HPP +#define RBANAMEDELEMENT_HPP + +#include +#include "RBAModelElement.hpp" + +namespace rba +{ + +class DLL_EXPORT RBANamedElement : public RBAModelElement +{ +protected: + explicit RBANamedElement(const std::string& newName = ""); + RBANamedElement(const RBANamedElement&)=delete; + RBANamedElement(const RBANamedElement&&)=delete; + RBANamedElement& operator=(const RBANamedElement&)=delete; + RBANamedElement& operator=(const RBANamedElement&&)=delete; + +public: + virtual ~RBANamedElement()=default; + virtual std::string getUniqueName() const; + const std::string& getElementName() const; + const std::string& getDynamicName() const; + void setDynamicName(const std::string& newName); + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + const std::string name_; + std::string dynamic_name_; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBARuleObject.cpp b/src/core/model/RBARuleObject.cpp new file mode 100644 index 0000000..62aa1a5 --- /dev/null +++ b/src/core/model/RBARuleObject.cpp @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * RuleObject class + */ + +#include +#include +#include "RBARuleObject.hpp" + +namespace rba +{ + +RBARuleObject::RBARuleObject(const std::string& name) + : RBANamedElement{name} +{ +} + +bool +RBARuleObject::isPrevious() const +{ + return false; +} + +const RBARuleObject* +RBARuleObject::getRawObject() const +{ + return this; +} + +void RBARuleObject::addTag(const std::string& tag) +{ + static_cast(tags_.insert(tag)); +} + +bool RBARuleObject::containsTag(const std::string& tag) const +{ + return (tags_.find(tag) != tags_.end()); +} + +void RBARuleObject::addMember(RBARuleObject* member) +{ + members_[member->getElementName()] = member; +} + +const RBARuleObject* RBARuleObject::getMember(const std::string& memberName) const +{ + if (members_.find(memberName) != members_.end()) { + return (members_.at(memberName)); + } else { + return nullptr; + } +} + +void RBARuleObject::addMember(const std::string& memberName, RBARuleObject* const val) +{ + members_[memberName] = val; +} + +RBARuleObject* +RBARuleObject::getOwner() const +{ + return owner_; +} + +void +RBARuleObject::setOwner(RBARuleObject* owner) +{ + owner_ = owner; +} + +std::string +RBARuleObject::getUniqueName() const +{ + if (owner_ != nullptr) { + // @Deviation (MEM05-CPP,Rule-7_5_4,A7-5-2) + // [Contents that deviate from the rules] + // Calling getUniqueName() recursively. + // [Reason that there is no problem if the rule is deviated] + //  Since the number of elements in the rule model is finite and + // there is no cyclic relationship, stack overflow does not occur. + return owner_->getUniqueName() + "/" + getElementName(); + } + return getElementName(); +} + +const std::unordered_map& RBARuleObject::getMembers() const +{ + return members_; +} + +} diff --git a/src/core/model/RBARuleObject.hpp b/src/core/model/RBARuleObject.hpp new file mode 100644 index 0000000..3f03ddc --- /dev/null +++ b/src/core/model/RBARuleObject.hpp @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * RuleObject class header + */ + +#ifndef RBARULEOBJECT_HPP +#define RBARULEOBJECT_HPP + +#include +#include +#include + +#include "RBANamedElement.hpp" + +namespace rba +{ + +class DLL_EXPORT RBARuleObject : public RBANamedElement +{ +protected: + explicit RBARuleObject(const std::string& name=""); + RBARuleObject(const RBARuleObject&)=delete; + RBARuleObject(const RBARuleObject&&)=delete; + RBARuleObject& operator=(const RBARuleObject&)=delete; + RBARuleObject& operator=(const RBARuleObject&&)=delete; + +public: + virtual ~RBARuleObject()=default; + virtual bool isPrevious() const; + virtual const RBARuleObject* getRawObject() const; + bool containsTag(const std::string& tag) const; + void addTag(const std::string& tag); + virtual void addMember(RBARuleObject* member); + virtual const RBARuleObject* getMember(const std::string& memberName) const; + RBARuleObject* getOwner() const; + virtual void setOwner(RBARuleObject* owner); + std::string getUniqueName() const override; + +protected: + void addMember(const std::string& memberName, RBARuleObject* const val); + const std::unordered_map& getMembers() const; + +private: +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4251) +#endif + std::unordered_set tags_; + std::unordered_map members_; + RBARuleObject* owner_ {nullptr}; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +}; + +} + +#endif diff --git a/src/core/model/RBARuleObjectMaker.cpp b/src/core/model/RBARuleObjectMaker.cpp new file mode 100644 index 0000000..7b384e1 --- /dev/null +++ b/src/core/model/RBARuleObjectMaker.cpp @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBARuleObjectMaker.cpp +/// @brief RuleObject generator class + +#include "RBARuleObjectMaker.hpp" +#include "RBARuleObject.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAModelFactory.hpp" + +namespace rba +{ + +RBARuleObjectMaker::RBARuleObjectMaker(const std::string& label) + : RBAModelElementMaker{label} +{ +} + +RBAModelElement* +RBARuleObjectMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + const auto ruleObj = dynamic_cast(element); + + // Tag + const RBAJsonElement* const tags {jsonElem->findChildren("tags")}; + if (tags != nullptr) { + for (const auto& tag : tags->getChildren()) { + const RBAJsonElement* const tagName {tag->findChildren("name")}; + if (tagName != nullptr) { + ruleObj->addTag(tagName->getString()); + } + } + } + + // owner + const auto ownerRuleObj = dynamic_cast(owner); + if (ownerRuleObj != nullptr) { + ruleObj->setOwner(ownerRuleObj); + } + + return ruleObj; +} + +} diff --git a/src/core/model/RBARuleObjectMaker.hpp b/src/core/model/RBARuleObjectMaker.hpp new file mode 100644 index 0000000..661b0b7 --- /dev/null +++ b/src/core/model/RBARuleObjectMaker.hpp @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBARuleObjectMaker.cpp +/// @brief RuleObject generator class header + +#ifndef RBARULEOBJECTMAKER_HPP +#define RBARULEOBJECTMAKER_HPP + +#include "RBAModelElementMaker.hpp" + +namespace rba +{ + +/// @brief RuleObject generator class header +class DLL_EXPORT RBARuleObjectMaker : public RBAModelElementMaker +{ +public: + explicit RBARuleObjectMaker(const std::string& label=""); + RBARuleObjectMaker(const RBARuleObjectMaker&)=delete; + RBARuleObjectMaker(const RBARuleObjectMaker&&)=delete; + RBARuleObjectMaker& operator=(const RBARuleObjectMaker&)=delete; + RBARuleObjectMaker& operator=(const RBARuleObjectMaker&&)=delete; + virtual ~RBARuleObjectMaker()=default; + +protected: + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/core/model/RBASceneImpl.cpp b/src/core/model/RBASceneImpl.cpp new file mode 100644 index 0000000..82ecab2 --- /dev/null +++ b/src/core/model/RBASceneImpl.cpp @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Scene implementation class + */ + +#include "RBASceneImpl.hpp" +#include "RBAModelElementType.hpp" +#include "RBAAbstractProperty.hpp" +#include "RBAIntegerProperty.hpp" + +namespace rba +{ + +RBASceneImpl::RBASceneImpl(const std::string& name) + : RBAScene(), + RBARuleObject{name} +{ +} + +std::string +RBASceneImpl::getName() const +{ + return RBARuleObject::getElementName(); +} + +RBAModelElementType +RBASceneImpl::getModelElementType() const +{ + return RBAModelElementType::Scene; +} + +bool +RBASceneImpl::isGlobal() const +{ + return global_; +} + +const std::list& +RBASceneImpl::getPropertyNames() const +{ + return propertyNames_; +} + +std::int32_t +RBASceneImpl::getPropertyValue(const std::string& propertyName) const +{ + const RBAAbstractProperty* const prop {getProperty(propertyName)}; + if(prop == nullptr) { + // Returns "-1" if the property is not registered + return -1; + } + + // Returns default value + return prop->getValue(); +} + +const RBARuleObject* RBASceneImpl::getMember(const std::string& memberName) const +{ + return getProperty(memberName); +} + +const RBAAbstractProperty* +RBASceneImpl::getProperty(const std::string& propertyName) const +{ + auto p = nameToProperty_.find(propertyName); + if(p == nameToProperty_.end()) { + // Returns nullptr if the property is not registered + return nullptr; + } + + return p->second; +} + +void +RBASceneImpl::setGlobal(const bool newGlobal) +{ + global_ = newGlobal; +} + +const RBAAbstractProperty* +RBASceneImpl::addProperty(const std::string& newName, std::int32_t newValue) +{ + auto p = nameToProperty_.find(newName); + if(p != nameToProperty_.end()) { + // No operation if the property is registered + return p->second; + } + + // Registration + properties_.push_back(std::make_unique(this, + newName, + newValue)); + propertyNames_.push_back(newName); + nameToProperty_[newName] = properties_.back().get(); + + return properties_.back().get(); +} + +} diff --git a/src/core/model/RBASceneImpl.hpp b/src/core/model/RBASceneImpl.hpp new file mode 100644 index 0000000..dd1fe3a --- /dev/null +++ b/src/core/model/RBASceneImpl.hpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Scene implementation class header + */ + +#ifndef RBASCENEIMPL_HPP +#define RBASCENEIMPL_HPP + +#include +#include "RBAScene.hpp" +#include "RBARuleObject.hpp" + +namespace rba +{ + +class RBAAbstractProperty; + +class RBASceneImpl : public RBAScene, public RBARuleObject +{ +public: + explicit RBASceneImpl(const std::string& name=""); + RBASceneImpl(const RBASceneImpl&)=delete; + RBASceneImpl(const RBASceneImpl&&)=delete; + RBASceneImpl& operator=(const RBASceneImpl&)=delete; + RBASceneImpl& operator=(const RBASceneImpl&&)=delete; + virtual ~RBASceneImpl()=default; + +public: + std::string getName() const override; + RBAModelElementType getModelElementType() const override; + bool isGlobal() const override; + const std::list& getPropertyNames() const override; + std::int32_t getPropertyValue(const std::string& propertyName) const override; + const RBARuleObject* getMember(const std::string& memberName) const override; + const RBAAbstractProperty* getProperty(const std::string& propertyName) const; + + void setGlobal(const bool newGlobal); + const RBAAbstractProperty* addProperty(const std::string& newName, + std::int32_t newValue); + +private: + bool global_ {false}; + // Used to get property name in RBAScene + std::list propertyNames_; + std::list> properties_; + std::unordered_map nameToProperty_; +}; + +} + +#endif diff --git a/src/core/model/RBASceneMaker.cpp b/src/core/model/RBASceneMaker.cpp new file mode 100644 index 0000000..9c55f84 --- /dev/null +++ b/src/core/model/RBASceneMaker.cpp @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBASceneMaker.cpp +/// @brief Scene object generator class + +#include "RBASceneMaker.hpp" +#include "RBASceneImpl.hpp" +#include "RBAJsonElement.hpp" +#include "RBAModelElement.hpp" +#include "RBAModelImpl.hpp" +#include "RBAAbstractProperty.hpp" + +namespace rba +{ + +RBASceneMaker::RBASceneMaker() + : RBARuleObjectMaker{"scenes"} +{ +} + +std::unique_ptr +RBASceneMaker::createInstance(const std::string& name) +{ + return std::make_unique(name); +} + +RBAModelElement* +RBASceneMaker::setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner) +{ + static_cast(RBARuleObjectMaker::setProperty(element, jsonElem, model, owner)); + + RBASceneImpl* const scene {dynamic_cast(element)}; + + // Set global + const std::string global {jsonElem->findChildren("global")->getString()}; + if(global == "true") { + scene->setGlobal(true); + } + else { + scene->setGlobal(false); + } + + // Set property + const RBAJsonElement* const properties {jsonElem->findChildren("property")}; + if(properties != nullptr) { + for(const auto& property : properties->getChildren()) { + const std::string propertyName {property->findChildren("name")->getString()}; + const std::int32_t value {property->findChildren("value")->getInt()}; + static_cast(scene->addProperty(propertyName, value)); + } + } + + model->addScene(scene); + + return scene; +} + +} diff --git a/src/core/model/RBASceneMaker.hpp b/src/core/model/RBASceneMaker.hpp new file mode 100644 index 0000000..6d2ea5e --- /dev/null +++ b/src/core/model/RBASceneMaker.hpp @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2019 DENSO CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/// @file RBASceneMaker.hpp +/// @brief Scene object generator class header + +#ifndef RBASCENEMAKER_HPP +#define RBASCENEMAKER_HPP + +#include "RBARuleObjectMaker.hpp" + +namespace rba +{ + +/// @brief Scene object generator class +class RBASceneMaker : public RBARuleObjectMaker +{ +public: + RBASceneMaker(); + RBASceneMaker(const RBASceneMaker&)=delete; + RBASceneMaker(const RBASceneMaker&&)=delete; + RBASceneMaker& operator=(const RBASceneMaker&)=delete; + RBASceneMaker& operator=(const RBASceneMaker&&)=delete; + virtual ~RBASceneMaker()=default; + +protected: + /// @brief Create an empty instance + /// @details Create an empty instance of unique_ptr in derived class + /// @return unique_ptr for insitance + std::unique_ptr createInstance(const std::string& name="") override; + + /// @brief Set model element attributes for each derived class + /// @param[in] jsonElem JSON element of ModelElement + /// @param[in] model The model to store generated RBARuleObjectMaker + /// @param[in,out] owner Parent object (Not in use) + RBAModelElement* setProperty(RBAModelElement* element, + const RBAJsonElement* jsonElem, + RBAModelImpl* model, + RBAModelElement* owner=nullptr) override; + +}; + +} + +#endif diff --git a/src/doc/ArbitrationFW.md b/src/doc/ArbitrationFW.md new file mode 100644 index 0000000..3e83d2f --- /dev/null +++ b/src/doc/ArbitrationFW.md @@ -0,0 +1,99 @@ +# Explanatory material of JSON file to be read by RBA-FW + +## Table of Contents + +* [Overview](#anchor1) + +* [JSON rule file format](#anchor2) + +* [Class property types](#anchor3) + + * Attribute + + * Relation + + * Composition + +* [JSON object configuration](#anchor4) + +
+ + + +## Overview + +The format of the JSON rule file is shown in UML class diagram notation. + + + +## JSON rule file format + +The JSON object in the JSON rule file becomes an instance of the UML class. +What is defined as a class property becomes a property of the JSON object. +The property name of the class becomes the property name of the JSON object. +The value of the property of the JSON object differs depending on the property type (attribute, association, composition) of the class. + + + +## Class property types + +### Attribute + +That value becomes the value of the JSON property as it is. +The int type attribute is an integer value, and the other attributes are the string representation of that value as the value of the JSON property. +If it is an enumerated type, it will be the string of its value. + +### Relation + +The value is either the value of the name of the referencing object or [name]: [class name]. +Which value is used should be compatible with both, as specifications may change in the future. + +### Composition + +The value will be a JSON object. +If the class being referred to is an abstract class, a property named className is created in the JSON object that will be its value, and the value of that property will be the name of the class. +If the class being referred to is a concrete class, className is omitted. +If the composition multiplicity is multiple, it will be an array of JSON objects. + +
+ + + +## JSON object configuration + +### #1. + +![config1](images/JSON_configuration1.png) + +The root object of the JSON rule file is RBAModel, and the attributes are "model" that describes the name and version name of the rule model and "template" that is the version information of the tool that generates the JSON rule file. +Version information is given to "template" with a six-digit numerical value of "xx.yy.zz". +zz is updated when there is no change in the format of the JSON rule file due to a bug fix of the JSON generation tool. +yy is updated when there is a change in the format but it is compatible with the past format. +xx is updated when there is a change in the format and the compatibility with the past format is lost. +"areas" stores all areas included in the rule model, "zones" stores all zones, "viewcontents" stores all display contents, and "soundcontents" stores all audio contents. + +### #2. + +![config2](images/JSON_configuration2.png) + +"displays" stores all display objects, and the size and layout information of the display are stored below the object. +"areasets", "zonesets", "viewcontentsets", and "soundcontentsets" are all area sets, zone sets, display content sets, and audio content sets defined in the model. +"scenes" stores all scenes defined in the model. + +### #3. + +![config3](images/JSON_configuration3.png) + +"constraints" contains all the constraint expressions defined in the model, the action determination processing constraint expression at the time of defeat, and the control execution expression. +These objects have an expression. +The type of Expression is a derived attribute, and its value is determined by the subclass of Expression. +See the notes in the figure for details. +"area_constraint_map", "area_hidden_true_check_constraint_map", "area_hidden_false_check_constraint_map", "zone_constraint_map", "zone_mute_true_check_constraint_map", "zone_mute_false_check_constraint_map", and "zone__check_contain_map_int" are maps using the area / zone ID (name) as keys, and correspond to the maps described in the constraint expressions to be evaluated in each area / zone. + +### #4. + +![config4](images/JSON_configuration4.png) + +![config5](images/JSON_configuration5.png) + +![config6](images/JSON_configuration6.png) diff --git a/src/doc/Doxygen b/src/doc/Doxygen new file mode 100755 index 0000000..19030a7 --- /dev/null +++ b/src/doc/Doxygen @@ -0,0 +1,2473 @@ +# Doxyfile 1.8.13 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Arbitration FW API Reference Manual" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 1.0 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = NO + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 0 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +#ENABLED_SECTIONS = english + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = ../include/rba + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /