summaryrefslogtreecommitdiff
path: root/indra/newview/llstartuplistener.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2019-05-31 16:42:07 -0400
committerNat Goodspeed <nat@lindenlab.com>2020-03-25 16:05:09 -0400
commit7fbbd4b766a86c3b8d0d0ed3b9e2ebf3fd27a889 (patch)
tree2f90733ce38876a0f0aa8376e1845697bb833baf /indra/newview/llstartuplistener.cpp
parente6a9523d2753da50b164c5a7b08ab80ae79179b9 (diff)
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).
Diffstat (limited to 'indra/newview/llstartuplistener.cpp')
-rw-r--r--indra/newview/llstartuplistener.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/indra/newview/llstartuplistener.cpp b/indra/newview/llstartuplistener.cpp
index d9a21f908e..5770b595d0 100644
--- a/indra/newview/llstartuplistener.cpp
+++ b/indra/newview/llstartuplistener.cpp
@@ -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;
+}