Commit Graph

17 Commits (b3a549b8b5e01809b2dd2006d6bf92a7a4d6baf7)

Author SHA1 Message Date
Andrey Lihatskiy 1b68f71348 #824 Process source files in bulk: replace tabs with spaces, convert CRLF to LF, and trim trailing whitespaces as needed 2024-04-29 07:56:09 +03:00
Nat Goodspeed 490de3ab6e DRTVWR-564: We don't need LLEventAPI to befriend LazyEventAPI. 2022-06-21 14:46:59 -04:00
Nat Goodspeed af4fbc1f8a DRTVWR-564: WIP: Add LazyEventAPI and tests. Tests don't yet pass.
LazyEventAPI is a registrar that implicitly instantiates some particular
LLEventAPI subclass on demand: that is, when LLEventPumps::obtain() tries to
find an LLEventPump by the registered name.

This leverages the new LLEventPumps::registerPumpFactory() machinery. Fix
registerPumpFactory() to adapt the passed PumpFactory to accept TypeFactory
parameters (two of which it ignores). Supplement it with
unregisterPumpFactory() to support LazyEventAPI instances with lifespans
shorter than the process -- which may be mostly test programs, but still a
hole worth closing. Similarly, add unregisterTypeFactory().

A LazyEventAPI subclass takes over responsibility for specifying the
LLEventAPI's name, desc, field, plus whatever add() calls will be needed to
register the LLEventAPI's operations. This is so we can (later) enhance
LLLeapListener to consult LazyEventAPI instances for not-yet-instantiated
LLEventAPI metadata, as well as enumerating existing LLEventAPI instances.

The trickiest part of this is capturing calls to the various
LLEventDispatcher::add() overloads in such a way that, when the LLEventAPI
subclass is eventually instantiated, we can replay them in the new instance.

LLEventAPI acquires a new protected constructor specifically for use by a
subclass registered by a companion LazyEventAPI. It accepts a const reference
to LazyEventAPIParams, intended to be opaque to the LLEventAPI subclass; the
subclass must declare a constructor that accepts and forwards the parameter
block to the new LLEventAPI constructor. The implementation delegates to the
existing LLEventAPI constructor, plus it runs deferred add() calls.

LLDispatchListener now derives from LLEventStream instead of containing it as
a data member. The reason is that if LLEventPumps::obtain() implicitly
instantiates it, LLEventPumps's destructor will try to destroy it by deleting
the LLEventPump*. If the LLEventPump returned by the factory function is a
data member of an outer class, that won't work so well. But if
LLDispatchListener (and by implication, LLEventAPI and any subclass) is
derived from LLEventPump, then the virtual destructor will Do The Right Thing.

Change LLDispatchListener to *not* allow tweaking the LLEventPump name. Since
the overwhelming use case for LLDispatchListener is LLEventAPI, accepting but
silently renaming an LLEventAPI subclass would ensure nobody could reach it.

Change LLEventDispatcher's use of std::enable_if to control the set of add()
overloads available for the intended use cases. Apparently this formulation is
just as functional at the method declaration point, while avoiding the need to
restate the whole enable_if expression at the method definition point.

Add lazyeventapi_test.cpp to exercise.
2022-06-18 11:57:10 -04:00
Nat Goodspeed f134eace91 DRTVWR-558: LLEventAPI allows all LLEventDispatcher add() overloads.
Previously, LLEventAPI intentionally hid all but one of the many add()
overloads supported by its LLEventDispatcher base class. The reason was that
certain of the add() methods take an optional fourth parameter that's an
LLSD::Map describing the expected parameter structure, while others take a
fourth templated parameter that's an instance getter callable. This led to
ambiguity, especially when passed an LLSDMap instance that's convertible to
LLSD but isn't literally LLSD. At the time, it was simpler to constrain the
add() methods inherited from LLEventDispatcher.

But by adding new std::enable_if constraints to certain LLEventDispatcher
add() methods, we've resolved the ambiguities, so LLEventAPI subclasses can
now use any add() overload (as claimed on the relevant Confluence page).

LLEventDispatcher comments have always loftily claimed that an instance getter
callable may return either a pointer or a reference, doesn't matter. But it
does when trying to pass the getter's result to boost::fusion::push_back(): a
reference must be wrapped with std::ref() while a pointer cannot be.
std::ref(pointer) produces errors. Introduce LLEventDispatcher::invoker::
bindable() overloads to Do The Right Thing whether passed a pointer or a
reference.

(cherry picked from commit 743f487c2e123171c9fc6d5b84d768f1d856d569)
2022-06-15 20:04:34 -04:00
Oz Linden c8726aba30 remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
simon ee2fce8790 Merge downstream code and viewer-beta 2013-05-09 14:10:45 -07:00
simon 87ba85eaab diff -r 59c7bed66dfd indra/llcommon/lleventapi.h 2013-04-24 09:35:38 -07:00
Graham Madarasz bf6182daa8 Update Mac and Windows breakpad builds to latest 2013-03-29 07:50:08 -07:00
Graham Madarasz (Graham) 93eaccae6f Modify LLInstanceTracker to avoid using a map of strings to find a map of foo to find some pointers 2013-02-28 15:35:14 -08:00
Andrew A. de Laix 2d19a20025 add getInfo to LLView to get state information about ui elements. 2011-09-08 09:46:04 -05:00
Nat Goodspeed ecba41419f CHOP-763: Nested LLEventAPI::Response class needs LL_COMMON_API too.
Apparently the outer class's LL_COMMON_API marker affects all outer class
members, but not nested classes. Making it explicit fixes Windows link errors.
2011-09-06 13:25:27 -04:00
Nat Goodspeed 3ddf3aef9b CHOP-763: Promote Response class from llwindowlistener.cpp to LLEventAPI.
This is a generally-useful idiom, extending the sendReply() convenience
function -- it shouldn't remain buried in a single .cpp file.
2011-09-01 13:12:23 -04:00
Oz Linden 06b0d72efa Change license from GPL to LGPL (version 2.1) 2010-08-13 07:24:57 -04:00
Nat Goodspeed 8dda668fc4 Automated merge with ssh://hg.lindenlab.com/viewer/viewer-2-0/ 2009-11-13 12:22:40 -05:00
Nat Goodspeed 2f97829aab 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.
2009-11-12 20:11:53 -05:00
brad kittenbrink d4846af9fb Fix for DLL linkage error in new LLEventAPI class. 2009-11-11 12:30:23 -05:00
Nat Goodspeed 062d0a13db 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.
2009-11-11 07:41:50 -05:00