Otawa  0.10
Dynamic Identifier, Feature and Processor

As some identifier, feature and processors are located in plug-ins, they can be retrieved at linking time. More...

Classes

class  otawa::DynFeature
 This class is used to resolve feature found in plugins using ProcessorPlugin::getFeature() method. More...
 
class  otawa::DynIdentifier< T >
 An identifier dynamically resolved. More...
 
class  otawa::ProcessorNotFound
 This exception is thrown when a code processor can not be found. More...
 

Functions

 otawa::DynProcessor::DynProcessor (cstring name) throw (ProcessorNotFound)
 Find the processor whose name is given. More...
 

Detailed Description

As some identifier, feature and processors are located in plug-ins, they can be retrieved at linking time.

To use them, one has to load automatically the matching plug-in and then to access the required object.

This achieved automatically using the three classes:

These classes works as proxies using the symbolic name of the looked object. If not already resolved, they try tore load the plug-in from the name of object (must be full qualified C++ name) and look the matching actual object.

The example below show the use of these classes. First, we have an header file provided by the plugin: MyPlugin.h.

#define USE_MY_FEATURE static DynFeature MY_FEATURE("mine::MyFeature");
#define USE_MY_IDENTIFIER static Identifier<int> MY_IDENTIFIER("mine::MyIdentifier");

The MyPlugin.cpp file declare the feature and the identifier as usual:

Feature<MyProcessor> MY_FEATURE("mine::MyFeature");
Identifier<int> MY_IDENTIFIER("mine::MyIdentifier", -1);

The user application includes the header file, uses the macro definition and use identifiers as usual.

#include <MyPlugin.h>
USE_MY_FEATURE;
USE_MY_FEATURE;
class AnotherProcessor: public Processor {
public:
AnotherProcessor(void) {
require(MY_FEATURE);
}
void processWorkSpace(WorkSpace *ws) {
int v = MY_IDENTIFIER(ws);
...
}

Function Documentation

otawa::DynProcessor::DynProcessor ( cstring  name)
throw (ProcessorNotFound
)

Find the processor whose name is given.

Parameters
nameName of the processor.
Exceptions
ProcessorNotFoundIf the processor can not be found.

References otawa::ProcessorPlugin::getProcessor(), name, and proc.