void CallSimObjects(SomeSimulatedObject& in_simA, SomeSimulatedObject& in_simB, SomeSimulatedObject& in_simC)
{
in_simA.DoSomething();
in_simA.DoSomethingElse();
in_simB.DoSomething();
in_simB.DoSomethingElse();
in_simC.DoSomething();
in_simC.DoSomethingElse();
}
TTB_TEST_FUNC(SetAndRestoreOptionValues)
{
SomeSimulatedObject a("SimObjectA");
SomeSimulatedObject b("SimObjectB");
SomeSimulatedObject c("SimObjectC");
TTB_SECTION("Calling sim objects with global default settings");
TTB_CMD1(TTB::DumpAllOptions, TTB::CTX_TEST_EVENT);
TTB_EXP("GlobalOptions");
TTB_EXP(" objectName:all: PERMANENTLY_ACTIVE");
TTB_EXP(" xValall: VALUE 47.11");
TTB_EXP("RegisteredSimulatedObjects");
TTB_EXP("SimObjectA");
TTB_EXP("SimObjectB");
TTB_EXP("SimObjectC");
TTB_CMD3(CallSimObjects, a, b, c);
TTB_EXP("DoSomething xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectC)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectC)");
TTB_SECTION("Specific instrumentation for each object:"
"\n - globally defined xVal changed to 15.08"
"\n - A now has separate values for each method"
"\n - B overrides default values for all methods"
"\n - C method DoSomething shall not find any definition (->use default value 0)"
"\n and all methods of C hide their names"
);
{
TTB::AutoRestoreOptions whenLeavingScope;
TTB::TheGlobalOptions()->SetValue("xVal", "15.08");
SimObject("SimObjectA")->_SetOptionValue("xVal", "3.14", "DoSomething");
SimObject("SimObjectA")->_SetOptionValue("xVal", "8.99", "DoSomethingElse");
SimObject("SimObjectB")->_SetOptionValue("xVal", "10.01");
SimObject("SimObjectC")->_SetOption("xVal", "DoSomething", TTB::OptionType::NOT_ACTIVE);
SimObject("SimObjectC")->_SetOption(TTB::Option::oOBJECT_NAME, TTB::Option::ALL, TTB::OptionType::NOT_ACTIVE);
TTB_CMD3(CallSimObjects, a, b, c);
TTB_EXP("DoSomething xVal=3.14 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=8.99 (SimObjectA)");
TTB_EXP("DoSomething xVal=10.01 (SimObjectB)");
TTB_EXP("DoSomethingElse xVal=10.01 (SimObjectB)");
TTB_EXP("DoSomething xVal=0 (xVal not defined)");
TTB_EXP("DoSomethingElse xVal=15.08");
TTB_CMD(TTB::DumpAllOptions);
TTB_CMD1(TTB::DumpAllOptions, TTB::CTX_TEST_EVENT);
TTB_EXP("GlobalOptions");
TTB_EXP(" objectName:all: PERMANENTLY_ACTIVE");
TTB_EXP(" xValall: VALUE 15.08");
TTB_EXP("RegisteredSimulatedObjects");
TTB_EXP("SimObjectA");
TTB_EXP(" xValDoSomething: VALUE 3.14");
TTB_EXP(" xValDoSomethingElse: VALUE 8.99");
TTB_EXP("SimObjectB");
TTB_EXP(" xValall: VALUE 10.01");
TTB_EXP("SimObjectC");
TTB_EXP(" objectName:all: NOT_ACTIVE");
TTB_EXP(" xValDoSomething: NOT_ACTIVE");
}
TTB_INFO("\nafter end of block all settings are automatically restored");
TTB_CMD3(CallSimObjects, a, b, c);
TTB_EXP("DoSomething xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectC)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectC)");
TTB_CMD1(TTB::DumpAllOptions, TTB::CTX_TEST_EVENT);
TTB_EXP("GlobalOptions");
TTB_EXP(" objectName:all: PERMANENTLY_ACTIVE");
TTB_EXP(" xValall: VALUE 47.11");
TTB_EXP("RegisteredSimulatedObjects");
TTB_EXP("SimObjectA");
TTB_EXP("SimObjectB");
TTB_EXP("SimObjectC");
TTB_SECTION("Set object B completely and method DoSomething of object C to silent");
{
TTB::AutoRestoreOptions whenLeavingScope;
SimObject("SimObjectB")->_SetOption(TTB::Option::oSILENT);
SimObject("SimObjectC")->_SetOption(TTB::Option::oSILENT, "DoSomething");
TTB_CMD3(CallSimObjects, a, b, c);
TTB_EXP("DoSomething xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectC)");
TTB_CMD1(TTB::DumpAllOptions, TTB::CTX_TEST_EVENT);
TTB_EXP("GlobalOptions");
TTB_EXP(" objectName:all: PERMANENTLY_ACTIVE");
TTB_EXP(" xValall: VALUE 47.11");
TTB_EXP("RegisteredSimulatedObjects");
TTB_EXP("SimObjectA");
TTB_EXP("SimObjectB");
TTB_EXP(" silent:all: PERMANENTLY_ACTIVE");
TTB_EXP("SimObjectC");
TTB_EXP(" silent:DoSomething: PERMANENTLY_ACTIVE");
}
TTB_INFO("\nafter end of block all settings are automatically restored");
TTB_CMD3(CallSimObjects, a, b, c);
TTB_EXP("DoSomething xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectA)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectB)");
TTB_EXP("DoSomething xVal=47.11 (SimObjectC)");
TTB_EXP("DoSomethingElse xVal=47.11 (SimObjectC)");
}