Commands: adjustments due to the change to anonymous instances
this is indeed a change of concept. A 'command instance' can not be found through the official Command front-end anymore, since we do not create a registration. This allows us to avoid decorating command IDs with running counters
This commit is contained in:
parent
97e42f75ee
commit
16737eb74c
4 changed files with 64 additions and 10 deletions
|
|
@ -87,6 +87,7 @@ namespace control {
|
|||
~CommandInstanceManager();
|
||||
|
||||
Symbol newInstance (Symbol prototypeID, string invocationID);
|
||||
Command& getInstance(Symbol instanceID);
|
||||
void dispatch (Symbol instanceID);
|
||||
|
||||
bool contains (Symbol instanceID) const;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ using lib::Symbol;
|
|||
using lumiera::LifecycleHook;
|
||||
using lumiera::ON_GLOBAL_INIT;
|
||||
using std::string;
|
||||
using util::unConst;
|
||||
using util::_Fmt;
|
||||
|
||||
|
||||
|
|
@ -175,6 +176,18 @@ namespace control {
|
|||
}
|
||||
|
||||
|
||||
Command&
|
||||
CommandInstanceManager::getInstance (Symbol instanceID)
|
||||
{
|
||||
Command& instance = table_[instanceID];
|
||||
if (not instance)
|
||||
throw error::Invalid (_Fmt{"Command instance '%s' is not (yet/anymore) active"}
|
||||
% instanceID
|
||||
, LUMIERA_ERROR_INVALID_COMMAND);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
/** */
|
||||
void
|
||||
CommandInstanceManager::dispatch (Symbol instanceID)
|
||||
|
|
@ -184,7 +197,7 @@ namespace control {
|
|||
throw error::Logic (_Fmt{"attempt to dispatch command instance '%s' "
|
||||
"without creating a new instance from prototype beforehand"}
|
||||
% instanceID
|
||||
, LUMIERA_ERROR_INVALID_COMMAND);
|
||||
, error::LUMIERA_ERROR_LIFECYCLE);
|
||||
if (not instance.canExec())
|
||||
throw error::State (_Fmt{"attempt to dispatch command instance '%s' "
|
||||
"without binding all arguments properly beforehand"}
|
||||
|
|
@ -193,14 +206,15 @@ namespace control {
|
|||
|
||||
REQUIRE (instance and instance.canExec());
|
||||
dispatcher_.enqueue(move (instance));
|
||||
ENSURE (not instance);
|
||||
instance.close();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CommandInstanceManager::contains (Symbol instanceID) const
|
||||
{
|
||||
return util::contains (table_, instanceID);
|
||||
return util::contains (table_, instanceID)
|
||||
and unConst(this)->table_[instanceID].isValid();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -119,19 +119,18 @@ namespace test {
|
|||
Fixture fixture;
|
||||
CommandInstanceManager iManager{fixture};
|
||||
Symbol instanceID = iManager.newInstance(COMMAND_PROTOTYPE, INVOCATION_ID);
|
||||
CHECK (Command::defined(instanceID));
|
||||
CHECK (not Command::canExec(instanceID));
|
||||
|
||||
Command cmd{instanceID};
|
||||
Command cmd = iManager.getInstance(instanceID);
|
||||
CHECK (cmd);
|
||||
CHECK (not cmd.canExec());
|
||||
|
||||
cmd.bind(42);
|
||||
CHECK (Command::canExec(instanceID));
|
||||
CHECK (cmd.canExec());
|
||||
|
||||
iManager.dispatch (instanceID);
|
||||
CHECK (not iManager.contains (instanceID));
|
||||
CHECK (fixture.contains (instanceID));
|
||||
CHECK (Command::canExec(instanceID));
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1089
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1089
|
||||
VERIFY_ERROR (INVALID_COMMAND, iManager.getInstance (instanceID));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11714,6 +11714,46 @@
|
|||
<icon BUILTIN="forward"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1491008040105" ID="ID_662216926" MODIFIED="1491008043901" TEXT="Implementierung">
|
||||
<node COLOR="#338800" CREATED="1491008045936" ID="ID_1071153669" MODIFIED="1491008146180" TEXT="CommandInstanceManager_test">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1491008059366" ID="ID_1809405076" MODIFIED="1491008147195" TEXT="CommandInstanceManager">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1491008067046" ID="ID_1905446877" MODIFIED="1491008148076" TEXT="einfache Map-Impl">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1491008073989" ID="ID_1954195404" MODIFIED="1491008148995" TEXT="Symbol-Tabelle">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1491008079676" ID="ID_1262786130" MODIFIED="1491008142008" TEXT="Test">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1491008088699" ID="ID_1501876595" MODIFIED="1491008114361" TEXT="Basisfall läuft noch nicht">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
die Instanz kommt nicht in der Fixture-Queue an
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1491008118695" ID="ID_1595821007" MODIFIED="1491008138125" TEXT="Invocation abdecken">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1491008124550" ID="ID_249252999" MODIFIED="1491008138788" TEXT="Duplikate abdecken">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1491008129165" ID="ID_118623494" MODIFIED="1491008139405" TEXT="Lebenszyklus-Fehler">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1489191252503" ID="ID_1621107057" MODIFIED="1489191308469" TEXT="#1090 Command access for UI-Elements">
|
||||
<arrowlink COLOR="#758ba4" DESTINATION="ID_827179653" ENDARROW="Default" ENDINCLINATION="173;83;" ID="Arrow_ID_57938013" STARTARROW="None" STARTINCLINATION="550;-93;"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue