Otawa  0.10
ParamProcessor.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * (Abstract)ParamProcessor class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2010, IRIT UPS <casse@irit.fr>
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_PROC_PARAMPROCESSOR_H_
23 #define OTAWA_PROC_PARAMPROCESSOR_H_
24 
25 #include <otawa/prop/Identifier.h>
26 #include <otawa/proc/Processor.h>
27 
28 namespace otawa {
29 
30 // external definitions
31 class ActualFeature;
32 
33 
34 // AbstractParamProcessor class
36 public:
38  virtual ~AbstractParamProcessor(void);
39  virtual Processor *instantiate(const ActualFeature& feature) const = 0;
40  inline const Version& version(void) const { return vers; }
41 
42 private:
44 };
45 
46 // ParamProcessor class
48 public:
49 
50  class AbstractMaker {
51  public:
52  virtual ~AbstractMaker(void) { }
53  virtual Processor *instantiate(cstring name, Version version, const ActualFeature& feature) const = 0;
54  };
55 
56  template <class T>
57  class Maker: public AbstractMaker {
58  public:
59  virtual Processor *instantiate(cstring name, Version version, const ActualFeature& feature) const
60  { return new T(name, version, feature); }
61  };
62 
64  : AbstractParamProcessor(name, version), _maker(maker) { }
66  { delete _maker; }
67  virtual Processor *instantiate(const ActualFeature& feature) const
68  { return _maker->instantiate(&name(), version(), feature); }
69 
70 private:
72 };
73 
74 } // otawa
75 
76 #endif /* OTAWA_PROC_PARAMPROCESSOR_H_ */
77 
virtual ~AbstractMaker(void)
Definition: ParamProcessor.h:52
A parametric processor allows to generate processor for parametric feature.
Definition: ParamProcessor.h:47
const string name(void) const
Get the string name of the identifier.
Definition: AbstractIdentifier.h:43
Abstract form of a parametric processor.
Definition: ParamProcessor.h:35
Represents a unique identifier used by the annotation system.
Definition: AbstractIdentifier.h:32
ParamProcessor(cstring name, Version version, AbstractMaker *maker)
Definition: ParamProcessor.h:63
The processor class is implemented by all code processor.
Definition: Processor.h:49
Version vers
Definition: ParamProcessor.h:43
~ParamProcessor(void)
Definition: ParamProcessor.h:65
AbstractMaker * _maker
Definition: ParamProcessor.h:71
virtual Processor * instantiate(const ActualFeature &feature) const
Called to instantiate a processor.
Definition: ParamProcessor.h:67
virtual Processor * instantiate(cstring name, Version version, const ActualFeature &feature) const =0
An actual feature is the result of the instantiation of a parametric feature.
Definition: ParamFeature.h:37
virtual ~AbstractParamProcessor(void)
Definition: proc_ParamProcessor.cpp:45
Definition: ParamProcessor.h:50
AbstractParamProcessor(cstring name, Version version)
Definition: proc_ParamProcessor.cpp:39
virtual Processor * instantiate(cstring name, Version version, const ActualFeature &feature) const
Definition: ParamProcessor.h:59
virtual Processor * instantiate(const ActualFeature &feature) const =0
Called to instantiate a processor.
const Version & version(void) const
Get the version of the parametric processor.
Definition: ParamProcessor.h:40
Definition: ParamProcessor.h:57