From 062d0a13db505636b186084d42c527a49637f380 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 11 Nov 2009 07:41:50 -0500 Subject: 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. --- indra/llcommon/lleventapi.h | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 indra/llcommon/lleventapi.h (limited to 'indra/llcommon/lleventapi.h') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h new file mode 100644 index 0000000000..fef12988cb --- /dev/null +++ b/indra/llcommon/lleventapi.h @@ -0,0 +1,53 @@ +/** + * @file lleventapi.h + * @author Nat Goodspeed + * @date 2009-10-28 + * @brief LLEventAPI is the base class for every class that wraps a C++ API + * in an event API + * (see https://wiki.lindenlab.com/wiki/Incremental_Viewer_Automation/Event_API). + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLEVENTAPI_H) +#define LL_LLEVENTAPI_H + +#include "lleventdispatcher.h" +#include "llinstancetracker.h" +#include + +/** + * LLEventAPI not only provides operation dispatch functionality, inherited + * from LLDispatchListener -- it also gives us event API introspection. + * Deriving from LLInstanceTracker lets us enumerate instances. + */ +class LLEventAPI: public LLDispatchListener, + public LLInstanceTracker +{ + typedef LLDispatchListener lbase; + typedef LLInstanceTracker ibase; + +public: + /** + * @param name LLEventPump name on which this LLEventAPI will listen. This + * also serves as the LLInstanceTracker instance key. + * @param desc Documentation string shown to a client trying to discover + * available event APIs. + * @param field LLSD::Map key used by LLDispatchListener to look up the + * subclass method to invoke [default "op"]. + */ + LLEventAPI(const std::string& name, const std::string& desc, const std::string& field="op"); + virtual ~LLEventAPI(); + + /// Get the string name of this LLEventAPI + std::string getName() const { return ibase::getKey(); } + /// Get the documentation string + std::string getDesc() const { return mDesc; } + +private: + std::string mDesc; +}; + +#endif /* ! defined(LL_LLEVENTAPI_H) */ -- cgit v1.2.3 From d4846af9fbd4a8b78071724d6e04cef70a982a81 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Wed, 11 Nov 2009 12:30:23 -0500 Subject: Fix for DLL linkage error in new LLEventAPI class. --- indra/llcommon/lleventapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lleventapi.h') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index fef12988cb..2cd3b5bf89 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -23,7 +23,7 @@ * from LLDispatchListener -- it also gives us event API introspection. * Deriving from LLInstanceTracker lets us enumerate instances. */ -class LLEventAPI: public LLDispatchListener, +class LL_COMMON_API LLEventAPI: public LLDispatchListener, public LLInstanceTracker { typedef LLDispatchListener lbase; -- cgit v1.2.3 From 2f97829aab549a4d65daead298361a0c25399be2 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 12 Nov 2009 20:11:53 -0500 Subject: Introduce LLEventDispatcher::begin()/end() to iterate over (name, desc) pairs for all registered operations. (untested) Introduce LLEventDispatcher::getMetadata(name) query so you can discover, for a given named operation, its query string and required parameters. (untested) Introduce LLEventDispatcher::add() convenience methods allowing you to omit description strings. Fix LLLoginInstance (which uses a non-LLEventAPI LLEventDispatcher) back to description-less add() calls. However, filter LLEventDispatcher::add() methods inherited by LLEventAPI so that an LLEventAPI subclass *must* provide a description string. --- indra/llcommon/lleventapi.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/llcommon/lleventapi.h') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index fef12988cb..b45be6802b 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -46,6 +46,19 @@ public: /// Get the documentation string std::string getDesc() const { return mDesc; } + /** + * Publish only selected add() methods from LLEventDispatcher. + * Every LLEventAPI add() @em must have a description string. + */ + template + void add(const std::string& name, + const std::string& desc, + CALLABLE callable, + const LLSD& required=LLSD()) + { + LLEventDispatcher::add(name, desc, callable, required); + } + private: std::string mDesc; }; -- cgit v1.2.3