![]() |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
#include <Libs/PluginFramework/service/debug/ctkDebugOptionsListener.h>
Public Member Functions | |
virtual void | optionsChanged (const ctkDebugOptions &options)=0 |
virtual | ~ctkDebugOptionsListener () |
A debug options listener is notified whenever one of its plug-in option-path entries is changed. A listener is registered as a service using the ctkDebugOptions::LISTENER_SYMBOLICNAME service property to specify the symbolic name of the debug options listener.
The ctkDebugOptionsListener::optionsChanged(const ctkDebugOptions&) method will automatically be called upon registration of the debug options listener service. This allows the listener to obtain the initial debug options. This initial call to the listener will happen even if debug is not enabled at the time of registration ctkDebugOptions::isDebugEnabled() will return false in this case).
A debug options listener allows a plug-in to cache trace option values in boolean fields for performance and code cleanliness. For example:
class Activator : ctkPluginActivator, ctkDebugOptionsListener { static bool DEBUG_FLAG = false; void start(ctkPluginContext* context) { ctkDictionary props; props.insert(ctkDebugOptions::LISTENER_SYMBOLICNAME, "com.mycompany.mybundle"); context->registerService<ctkDebugOptionsListener>(this, props); } void optionsChanged(const ctkDebugOptions& options) { DEBUG_FLAG = options->getBooleanOption("com.mycompany.mybundle/debug", false); } void doSomeWork() { if (DEBUG_FLAG) BERRY_INFO << "foo"; } ... }
Definition at line 67 of file ctkDebugOptionsListener.h.
|
inlinevirtual |
Definition at line 69 of file ctkDebugOptionsListener.h.
|
pure virtual |
Notifies this listener that an option-path for its plug-in has changed. This method is also called initially by the ctkDebugOptions implementation when the listener is registered as a service. This allows the listener to obtain the initial set of debug options without the need to acquire the debug options service.
options | a reference to the ctkDebugOptions |