summaryrefslogtreecommitdiff
path: root/indra/llcommon/lleventdispatcher.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2009-11-11 07:41:50 -0500
committerNat Goodspeed <nat@lindenlab.com>2009-11-11 07:41:50 -0500
commit062d0a13db505636b186084d42c527a49637f380 (patch)
treeb2ae497f8b3f0c0829e739e1cca698f5fa21de4c /indra/llcommon/lleventdispatcher.h
parent43ae94ab0f35dafaa0e1787a155290e371e317a1 (diff)
Add LLEventAPI class, formalizing the mechanism by which we wrap a C++ API
with an event API. In addition to the LLEventPump name on which to listen, LLEventAPI accepts a documentation string for event API introspection. Give every LLEventDispatcher::add() overload a new documentation string parameter for event API introspection. Convert every existing event API to new conventions, introducing suitable documentation strings for the API and each of its operations.
Diffstat (limited to 'indra/llcommon/lleventdispatcher.h')
-rw-r--r--indra/llcommon/lleventdispatcher.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/indra/llcommon/lleventdispatcher.h b/indra/llcommon/lleventdispatcher.h
index 5a86b90bff..eba7b607f1 100644
--- a/indra/llcommon/lleventdispatcher.h
+++ b/indra/llcommon/lleventdispatcher.h
@@ -44,7 +44,10 @@ public:
* is used to validate the structure of each incoming event (see
* llsd_matches()).
*/
- void add(const std::string& name, const Callable& callable, const LLSD& required=LLSD());
+ void add(const std::string& name,
+ const std::string& desc,
+ const Callable& callable,
+ const LLSD& required=LLSD());
/**
* Special case: a subclass of this class can pass an unbound member
@@ -52,18 +55,22 @@ public:
* <tt>boost::bind()</tt> expression.
*/
template <class CLASS>
- void add(const std::string& name, void (CLASS::*method)(const LLSD&),
+ void add(const std::string& name,
+ const std::string& desc,
+ void (CLASS::*method)(const LLSD&),
const LLSD& required=LLSD())
{
- addMethod<CLASS>(name, method, required);
+ addMethod<CLASS>(name, desc, method, required);
}
/// Overload for both const and non-const methods
template <class CLASS>
- void add(const std::string& name, void (CLASS::*method)(const LLSD&) const,
+ void add(const std::string& name,
+ const std::string& desc,
+ void (CLASS::*method)(const LLSD&) const,
const LLSD& required=LLSD())
{
- addMethod<CLASS>(name, method, required);
+ addMethod<CLASS>(name, desc, method, required);
}
/// Unregister a callable
@@ -86,7 +93,8 @@ public:
private:
template <class CLASS, typename METHOD>
- void addMethod(const std::string& name, const METHOD& method, const LLSD& required)
+ void addMethod(const std::string& name, const std::string& desc,
+ const METHOD& method, const LLSD& required)
{
CLASS* downcast = dynamic_cast<CLASS*>(this);
if (! downcast)
@@ -95,7 +103,7 @@ private:
}
else
{
- add(name, boost::bind(method, downcast, _1), required);
+ add(name, desc, boost::bind(method, downcast, _1), required);
}
}
void addFail(const std::string& name, const std::string& classname) const;
@@ -103,7 +111,18 @@ private:
bool attemptCall(const std::string& name, const LLSD& event) const;
std::string mDesc, mKey;
- typedef std::map<std::string, std::pair<Callable, LLSD> > DispatchMap;
+ struct DispatchEntry
+ {
+ DispatchEntry(const Callable& func, const std::string& desc, const LLSD& required):
+ mFunc(func),
+ mDesc(desc),
+ mRequired(required)
+ {}
+ Callable mFunc;
+ std::string mDesc;
+ LLSD mRequired;
+ };
+ typedef std::map<std::string, DispatchEntry> DispatchMap;
DispatchMap mDispatch;
};