Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
berry::IAdapterManager Struct Referenceabstract

#include <berryIAdapterManager.h>

Inheritance diagram for berry::IAdapterManager:
Collaboration diagram for berry::IAdapterManager:

Public Member Functions

 berryObjectMacro (berry::IAdapterManager)
 
template<typename A >
A * GetAdapter (const Object *adaptable)
 
virtual ObjectGetAdapter (const Object *adaptable, const QString &adapterTypeName)=0
 
virtual bool HasAdapter (const Object *adaptableType, const QString &adapterType)=0
 
template<typename A >
int QueryAdapter (const Object *adaptable)
 
virtual int QueryAdapter (const Object *adaptableType, const QString &adapterType)=0
 
template<typename A >
A * LoadAdapter (const Object *adaptable)
 
virtual void RegisterAdapters (IAdapterFactory *factory, const QString &adaptableTypeName)=0
 
virtual void UnregisterAdapters (IAdapterFactory *factory)=0
 
virtual void UnregisterAdapters (IAdapterFactory *factory, const QString &adaptableTypeName)=0
 
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
 
virtual Reflection::TypeInfo GetTypeInfo () const
 
virtual QList< Reflection::TypeInfoGetSuperclasses () const
 
virtual void Delete ()
 
QDebug Print (QDebug os, Indent Indent=0) const
 
virtual QString ToString () const
 
virtual uint HashCode () const
 
virtual bool operator< (const Object *) const
 
void Register () const
 
void UnRegister (bool del=true) const
 
int GetReferenceCount () const
 
void SetReferenceCount (int)
 
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
virtual bool operator== (const Object *) const
 

Static Public Attributes

static const int NONE
 
static const int NOT_LOADED
 
static const int LOADED
 

Additional Inherited Members

- Public Types inherited from berry::Object
typedef Object Self
 
typedef berry::SmartPointer< SelfPointer
 
typedef berry::SmartPointer< const SelfConstPointer
 
typedef berry::WeakPointer< SelfWeakPtr
 
typedef berry::WeakPointer< const SelfConstWeakPtr
 
- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
 
static Reflection::TypeInfo GetStaticTypeInfo ()
 
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
 
- Protected Member Functions inherited from berry::Object
 Object ()
 
virtual ~Object ()
 
virtual QDebug PrintSelf (QDebug os, Indent indent) const
 
virtual QDebug PrintHeader (QDebug os, Indent indent) const
 
virtual QDebug PrintTrailer (QDebug os, Indent indent) const
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Detailed Description

An adapter manager maintains a registry of adapter factories. Clients directly invoke methods on an adapter manager to register and unregister adapters. All adaptable objects (that is, objects that implement the IAdaptable interface) tunnel IAdaptable.getAdapter invocations to their adapter manager's IAdapterManager.getAdapter method. The adapter manager then forwards this request unmodified to the IAdapterFactory.getAdapter method on one of the registered adapter factories.

Adapter factories can be registered programmatically using the registerAdapters method. Alternatively, they can be registered declaratively using the org.blueberry.core.runtime.adapters extension point. Factories registered with this extension point will not be able to provide adapters until their corresponding plugin has been activated.

The following code snippet shows how one might register an adapter of type com.example.acme.Sticky on resources in the workspace.

IAdapterFactory pr = new IAdapterFactory() {
public Class[] getAdapterList() {
return new Class[] { com.example.acme.Sticky.class };
}
public Object getAdapter(Object adaptableObject, Class adapterType) {
IResource res = (IResource) adaptableObject;
QualifiedName key = new QualifiedName(&quot;com.example.acme&quot;, &quot;sticky-note&quot;);
try {
com.example.acme.Sticky v = (com.example.acme.Sticky) res.getSessionProperty(key);
if (v == null) {
v = new com.example.acme.Sticky();
res.setSessionProperty(key, v);
}
} catch (CoreException e) {
// unable to access session property - ignore
}
return v;
}
}
Platform.getAdapterManager().registerAdapters(pr, IResource.class);

This interface can be used without OSGi running.

This interface is not intended to be implemented by clients.

See also
IAdaptable
IAdapterFactory

Definition at line 80 of file berryIAdapterManager.h.

Member Function Documentation

◆ berryObjectMacro()

berry::IAdapterManager::berryObjectMacro ( berry::IAdapterManager  )

◆ GetAdapter() [1/2]

template<typename A >
A* berry::IAdapterManager::GetAdapter ( const Object adaptable)
inline

Returns a Poco::Any object which contains an instance of the given name associated with the given adaptable. Returns an empty Poco::Any if no such object can be found.

Note that this method will never cause plug-ins to be loaded. If the only suitable factory is not yet loaded, this method will return an empty Poco::Any. If activation of the plug-in providing the factory is required, use the LoadAdapter method instead.

Parameters
adaptablethe adaptable object being queried (usually an instance of IAdaptable)
Returns
a Poco::Any castable to the given adapter type, or empty if the given adaptable object does not have an available adapter of the given type

Definition at line 122 of file berryIAdapterManager.h.

References BERRY_WARN, and berry::Reflection::GetClassName().

◆ GetAdapter() [2/2]

virtual Object* berry::IAdapterManager::GetAdapter ( const Object adaptable,
const QString &  adapterTypeName 
)
pure virtual

Returns an object which is an instance of the given class name associated with the given object. Returns null if no such object can be found.

Note that this method will never cause plug-ins to be loaded. If the only suitable factory is not yet loaded, this method will return null. If activation of the plug-in providing the factory is required, use the loadAdapter method instead.

Parameters
adaptablethe adaptable object being queried (usually an instance of IAdaptable)
adapterTypeNamethe fully qualified name of the type of adapter to look up
Returns
an object castable to the given adapter type, or null if the given adaptable object does not have an available adapter of the given type

◆ HasAdapter()

virtual bool berry::IAdapterManager::HasAdapter ( const Object adaptableType,
const QString &  adapterType 
)
pure virtual

Returns whether there is an adapter factory registered that may be able to convert adaptable to an object of type adapterTypeName.

Note that a return value of true does not guarantee that a subsequent call to GetAdapter with the same arguments will return a non-empty result. If the factory's plug-in has not yet been loaded, or if the factory itself returns nothing, then GetAdapter will still return an empty Poco::Any.

Parameters
adaptableTypethe adaptable object being queried (usually an instance of IAdaptable)
adapterTypethe fully qualified class name of an adapter to look up
Returns
true if there is an adapter factory that claims it can convert adaptable to an object of type adapterType, and false otherwise.

◆ LoadAdapter()

template<typename A >
A* berry::IAdapterManager::LoadAdapter ( const Object adaptable)
inline

Returns an object that is an instance of the given class name associated with the given object. Returns an empty Poco::Any if no such object can be found.

Note that unlike the GetAdapter methods, this method will cause the plug-in that contributes the adapter factory to be loaded if necessary. As such, this method should be used judiciously, in order to avoid unnecessary plug-in activations. Most clients should avoid activation by using GetAdapter instead.

Parameters
adaptablethe adaptable object being queried (usually an instance of IAdaptable)
Returns
a Poco::Any castable to the given adapter type, or empty if the given adaptable object does not have an available adapter of the given type

Definition at line 223 of file berryIAdapterManager.h.

References BERRY_WARN, and berry::Reflection::GetClassName().

◆ QueryAdapter() [1/2]

template<typename A >
int berry::IAdapterManager::QueryAdapter ( const Object adaptable)
inline

Definition at line 175 of file berryIAdapterManager.h.

References BERRY_WARN, and berry::Reflection::GetClassName().

◆ QueryAdapter() [2/2]

virtual int berry::IAdapterManager::QueryAdapter ( const Object adaptableType,
const QString &  adapterType 
)
pure virtual

Returns a status of an adapter factory registered that may be able to convert adaptable to an object of type adapterTypeName.

One of the following values can be returned:

Parameters
adaptableTypethe adaptable object being queried (usually an instance of IAdaptable)
adapterTypethe fully qualified class name of an adapter to look up
Returns
a status of the adapter

◆ RegisterAdapters()

virtual void berry::IAdapterManager::RegisterAdapters ( IAdapterFactory factory,
const QString &  adaptableTypeName 
)
pure virtual

Registers the given adapter factory as extending objects of the given type.

Parameters
factorythe adapter factory
adaptableTypeNamethe fully qualified typename being extended
See also
UnregisterAdapters

◆ UnregisterAdapters() [1/2]

virtual void berry::IAdapterManager::UnregisterAdapters ( IAdapterFactory factory)
pure virtual

Removes the given adapter factory completely from the list of registered factories. Equivalent to calling UnregisterAdapters(IAdapterFactory*, const std::string&) on all classes against which it had been explicitly registered. Does nothing if the given factory is not currently registered.

Parameters
factorythe adapter factory to remove
See also
RegisterAdapters

◆ UnregisterAdapters() [2/2]

virtual void berry::IAdapterManager::UnregisterAdapters ( IAdapterFactory factory,
const QString &  adaptableTypeName 
)
pure virtual

Removes the given adapter factory from the list of factories registered as extending the given class. Does nothing if the given factory and type combination is not registered.

Parameters
factorythe adapter factory to remove
adaptableTypeNameone of the type names against which the given factory is registered
See also
RegisterAdapters

Member Data Documentation

◆ LOADED

const int berry::IAdapterManager::LOADED
static

This value can be returned to indicate that an adapter factory is loaded.

Since
org.blueberry.equinox.common 3.3

Definition at line 103 of file berryIAdapterManager.h.

◆ NONE

const int berry::IAdapterManager::NONE
static

This value can be returned to indicate that no applicable adapter factory was found.

Since
org.blueberry.equinox.common 3.3

Definition at line 90 of file berryIAdapterManager.h.

◆ NOT_LOADED

const int berry::IAdapterManager::NOT_LOADED
static

This value can be returned to indicate that an adapter factory was found, but has not been loaded.

Since
org.blueberry.equinox.common 3.3

Definition at line 97 of file berryIAdapterManager.h.


The documentation for this struct was generated from the following file:
berry::Object::Object
Object()