SL-11216: Add a "getStateTable" op to "LLStartUp" listener.

getStateTable returns a list of the EStartupState symbolic names, implicitly
mapping each to its index (its enum numeric value).
meow-7.2.2
Nat Goodspeed 2019-05-31 16:42:07 -04:00
parent 16ef497e18
commit 2efaa8533c
3 changed files with 27 additions and 1 deletions

View File

@ -130,6 +130,7 @@ public:
static LLViewerStats::PhaseMap& getPhases() { return *sPhases; }
private:
friend class LLStartupListener;
static LLSLURL sStartSLURL;
static std::string startupStateToString(EStartupState state);

View File

@ -35,7 +35,7 @@
// external library headers
// other Linden headers
#include "llstartup.h"
#include "stringize.h"
LLStartupListener::LLStartupListener(/* LLStartUp* instance */):
LLEventAPI("LLStartUp", "Access e.g. LLStartup::postStartupState()") /* ,
@ -43,9 +43,33 @@ LLStartupListener::LLStartupListener(/* LLStartUp* instance */):
{
add("postStartupState", "Refresh \"StartupState\" listeners with current startup state",
&LLStartupListener::postStartupState);
add("getStateTable", "Reply with array of EStartupState string names",
&LLStartupListener::getStateTable);
}
void LLStartupListener::postStartupState(const LLSD&) const
{
LLStartUp::postStartupState();
}
void LLStartupListener::getStateTable(const LLSD& event) const
{
Response response(LLSD(), event);
// This relies on our knowledge that STATE_STARTED is the very last
// EStartupState value. If that ever stops being true, we're going to lie
// without realizing it. I can think of no reliable way to test whether
// the enum has been extended *beyond* STATE_STARTED. We could, of course,
// test whether stuff has been inserted before it, by testing its
// numerical value against the constant value as of the last time we
// looked; but that's pointless, as values inserted before STATE_STARTED
// will continue to work fine. The bad case is if new symbols get added
// *after* it.
LLSD table;
// note <= comparison: we want to *include* STATE_STARTED.
for (LLSD::Integer istate{0}; istate <= LLSD::Integer(STATE_STARTED); ++istate)
{
table.append(LLStartUp::startupStateToString(EStartupState(istate)));
}
response["table"] = table;
}

View File

@ -40,6 +40,7 @@ public:
private:
void postStartupState(const LLSD&) const;
void getStateTable(const LLSD&) const;
//LLStartup* mStartup;
};