Otawa  0.10
otawa::FeatureRequirer Class Reference

This class provided feature requirement for non-program processor classes. More...

#include <otawa/proc/FeatureRequirer.h>

Protected Member Functions

 FeatureRequirer (WorkSpace *ws, AbstractFeature *features[])
 Check that the features are available. More...
 

Static Protected Member Functions

static void require (Processor &proc, AbstractFeature *features[])
 Added the given array of feature to the requirements of the processor. More...
 

Detailed Description

This class provided feature requirement for non-program processor classes.

It provides two methods that takes as parameter an array of required features ended by the NULL_FEATURE.

The first one, the constructor, takes as parameter the workspace and the feature array and check that the features are available. If not, an assertion failure is raised. If the constant NDEBUG is defined, the check is not performed and no time is lost in this verification.

The second method is static and add to the current processor the array of feature as requirements. To make it working, each requirer must provide to the user processor a static method that calls this one in order to add the feature of the requirer to the feature of the processor. The constructor is only used to assert that the require method has been called.

Below, you may found an example. First, we provided a facility with a requirement:

class MyFacility: public FeatureRequirer {
public:
MyFacility(WorkSpace *ws): FeatureRequirer(ws, res) { }
void doSomethingUseful(void) { ... }
static void require(Processor& proc) { require(proc, reqs); }
private:
static AbstractFeature *reqs[];
};
AbstractFeature *MyFacility::req[] = {
};

Then, my processor uses my facility as below:

class MyProcessor: public Processor {
public:
MyProcessor(void): Processor("MyProcessor", Version(1, 0, 0)) {
provide(MY_FEATURE);
require(LOOP_INFOS_FEATURE);
}
void process(WorkSpace *ws) {
...
MyFacility facility(ws);
...
}
};

Constructor & Destructor Documentation

otawa::FeatureRequirer::FeatureRequirer ( WorkSpace ws,
AbstractFeature features[] 
)
protected

Check that the features are available.

Parameters
wsWorkspace to work on.
featuresArray of feature to check (ended by NULL_FEATURE).

References otawa::WorkSpace::isProvided(), and otawa::AbstractFeature::null.

Member Function Documentation

void otawa::FeatureRequirer::require ( Processor proc,
AbstractFeature features[] 
)
staticprotected

Added the given array of feature to the requirements of the processor.

Parameters
procProcessor to add feature requirements to.
featuresArray of feature to a requirement for (ended by NULL_FEATURE).

References otawa::AbstractFeature::null, and otawa::Processor::require().


The documentation for this class was generated from the following files: