OpenASIP  2.0
DesignSpaceExplorerPlugin.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DesignSpaceExplorerPlugin.hh
26  *
27  * Declaration of DesignSpaceExplorerPlugin class.
28  *
29  * @author Jari Mäntyneva 2007 (jari.mantyneva-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_DESIGN_SPACE_EXPLORER_PLUGIN_HH
34 #define TTA_DESIGN_SPACE_EXPLORER_PLUGIN_HH
35 
36 #include <string>
37 #include <map>
38 
39 #include "DesignSpaceExplorer.hh"
41 
42 #include "Exception.hh"
43 #include "Application.hh"
44 
45 
46 
47 /**
48  * A base interface for all classes that implement pluggable
49  * design space explorer algorithms.
50  *
51  * Plugins are allowed to store state data to itself, thus, the plugin
52  * instances are not allowed to be "recycled" for multiple uses, but a
53  * new instance should be created always.
54  */
56 public:
57 
59 
60  virtual bool requiresStartingPointArchitecture() const = 0;
61  virtual bool producesArchitecture() const = 0;
62  virtual bool requiresHDB() const = 0;
63  virtual bool requiresSimulationData() const = 0;
64  virtual bool requiresApplication() const { return true; }
65 
66  typedef std::pair<std::string,
68  typedef std::map<std::string,
70  typedef std::map<std::string,
72  typedef std::map<std::string,
73  ExplorerPluginParameter>::const_iterator PMCIt;
74 
75  virtual void giveParameter(
76  const std::string& name, const std::string& value);
77 
78  virtual inline std::string description() const;
79  virtual std::string name() const;
80  virtual void setPluginName(const std::string& pluginName);
81 
82  virtual std::vector<RowID> explore(
83  const RowID& startPointConfigurationID,
84  const unsigned int& maxIter = 0);
85 
86  virtual bool hasParameter(const std::string& paramName) const;
87 
88  ParameterMap parameters() const;
89 
90  inline void addParameter(
91  TCEString name,
93  bool compulsory = true,
94  TCEString defaultValue = "",
95  TCEString description = "");
96 
97  template <typename T>
98  void readCompulsoryParameter(const std::string paramName, T& param) const;
99 
100  template <typename T>
101  void readOptionalParameter(const std::string paramName, T& param) const;
102 
103  template <typename RT>
104  RT parameterValue(const std::string& paramName) const;
105 
106  virtual bool booleanValue(const std::string& parameter) const;
107 
108 protected:
110 
111  void checkParameters() const;
112 
113  /// the name of the explorer plugin
114  std::string pluginName_;
115  /// Parameters for the plugin.
117 };
118 
120 
121 
122 /**
123  * Exports the given class as a DesignSpaceExplorer plugin.
124  */
125 #define EXPORT_DESIGN_SPACE_EXPLORER_PLUGIN(PLUGIN_NAME__) \
126 extern "C" { \
127  DesignSpaceExplorerPlugin* create_explorer_plugin_##PLUGIN_NAME__() { \
128  PLUGIN_NAME__* instance = new PLUGIN_NAME__(); \
129  instance->setPluginName(#PLUGIN_NAME__);\
130  return instance;\
131  }\
132  void delete_explorer_plugin_##PLUGIN_NAME__(\
133  DesignSpaceExplorerPlugin* target) { \
134  delete target;\
135  }\
136 }
137 
138 /**
139  * Defines the description string for the plugin.
140  *
141  * Can be used only inside a plugin class definition.
142  *
143  * @param TEXT__ The description string.
144  */
145 #define PLUGIN_DESCRIPTION(TEXT__) \
146 public:\
147  virtual std::string description() const { return TEXT__; }
148 
149 #endif
DesignSpaceExplorerPlugin::readCompulsoryParameter
void readCompulsoryParameter(const std::string paramName, T &param) const
ExplorerPluginParameterType
ExplorerPluginParameterType
Definition: ExplorerPluginParameter.hh:40
Exception.hh
ExplorerPluginParameter.hh
DesignSpaceExplorerPlugin::booleanValue
virtual bool booleanValue(const std::string &parameter) const
Definition: DesignSpaceExplorerPlugin.cc:132
DesignSpaceExplorerPlugin::checkParameters
void checkParameters() const
Definition: DesignSpaceExplorerPlugin.cc:147
DesignSpaceExplorerPlugin::Parameter
std::pair< std::string, ExplorerPluginParameter > Parameter
Definition: DesignSpaceExplorerPlugin.hh:67
DesignSpaceExplorerPlugin
Definition: DesignSpaceExplorerPlugin.hh:55
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
DesignSpaceExplorerPlugin::DesignSpaceExplorerPlugin
DesignSpaceExplorerPlugin()
Definition: DesignSpaceExplorerPlugin.cc:48
DesignSpaceExplorerPlugin::~DesignSpaceExplorerPlugin
virtual ~DesignSpaceExplorerPlugin()
Definition: DesignSpaceExplorerPlugin.cc:56
DesignSpaceExplorerPlugin::pluginName_
std::string pluginName_
the name of the explorer plugin
Definition: DesignSpaceExplorerPlugin.hh:114
DesignSpaceExplorerPlugin::setPluginName
virtual void setPluginName(const std::string &pluginName)
Definition: DesignSpaceExplorerPlugin.cc:66
DesignSpaceExplorerPlugin::readOptionalParameter
void readOptionalParameter(const std::string paramName, T &param) const
DesignSpaceExplorerPlugin::requiresStartingPointArchitecture
virtual bool requiresStartingPointArchitecture() const =0
ExplorerPluginParameter
Definition: ExplorerPluginParameter.hh:46
DesignSpaceExplorerPlugin::parameters_
ParameterMap parameters_
Parameters for the plugin.
Definition: DesignSpaceExplorerPlugin.hh:116
Application.hh
DesignSpaceExplorerPlugin::giveParameter
virtual void giveParameter(const std::string &name, const std::string &value)
Definition: DesignSpaceExplorerPlugin.cc:89
DesignSpaceExplorerPlugin::requiresHDB
virtual bool requiresHDB() const =0
DesignSpaceExplorerPlugin::explore
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
Definition: DesignSpaceExplorerPlugin.cc:174
DesignSpaceExplorer.hh
DesignSpaceExplorerPlugin::parameterValue
RT parameterValue(const std::string &paramName) const
DesignSpaceExplorerPlugin::producesArchitecture
virtual bool producesArchitecture() const =0
TCEString
Definition: TCEString.hh:53
DesignSpaceExplorerPlugin::name
virtual std::string name() const
Definition: DesignSpaceExplorerPlugin.cc:77
DesignSpaceExplorerPlugin::description
virtual std::string description() const
DesignSpaceExplorerPlugin::PMCIt
std::map< std::string, ExplorerPluginParameter >::const_iterator PMCIt
Definition: DesignSpaceExplorerPlugin.hh:73
DesignSpaceExplorerPlugin::hasParameter
virtual bool hasParameter(const std::string &paramName) const
Definition: DesignSpaceExplorerPlugin.cc:106
DesignSpaceExplorer
Definition: DesignSpaceExplorer.hh:70
DesignSpaceExplorerPlugin::ParameterMap
std::map< std::string, ExplorerPluginParameter > ParameterMap
Definition: DesignSpaceExplorerPlugin.hh:69
DesignSpaceExplorerPlugin::PMIt
std::map< std::string, ExplorerPluginParameter >::iterator PMIt
Definition: DesignSpaceExplorerPlugin.hh:71
DesignSpaceExplorerPlugin::requiresApplication
virtual bool requiresApplication() const
Definition: DesignSpaceExplorerPlugin.hh:64
DesignSpaceExplorerPlugin.icc
DesignSpaceExplorerPlugin::parameters
ParameterMap parameters() const
Definition: DesignSpaceExplorerPlugin.cc:117
DesignSpaceExplorerPlugin::addParameter
void addParameter(TCEString name, ExplorerPluginParameterType type, bool compulsory=true, TCEString defaultValue="", TCEString description="")
DesignSpaceExplorerPlugin::requiresSimulationData
virtual bool requiresSimulationData() const =0