OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ProcessorConfigurationFile Class Reference

#include <ProcessorConfigurationFile.hh>

Inheritance diagram for ProcessorConfigurationFile:
Inheritance graph
Collaboration diagram for ProcessorConfigurationFile:
Collaboration graph

Public Member Functions

 ProcessorConfigurationFile (std::istream &inputStream)
 
virtual ~ProcessorConfigurationFile ()
 
void setPCFDirectory (const std::string &path)
 
std::string architectureName ()
 
unsigned int architectureSize ()
 
unsigned int architectureModified ()
 
std::string implementationName ()
 
unsigned int implementationSize ()
 
unsigned int implementationModified ()
 
std::string encodingMapName ()
 
unsigned int encodingMapSize ()
 
unsigned int encodingMapModified ()
 
int errorCount ()
 
std::string errorString (int index)
 
bool errors ()
 
- Public Member Functions inherited from ConfigurationFile
 ConfigurationFile (bool doChecking=false)
 
virtual ~ConfigurationFile ()
 
void load (std::istream &inputStream)
 
bool hasKey (const std::string &key)
 
std::string value (const std::string &key, int index=0)
 
int itemCount (const std::string &key)
 
int intValue (const std::string &key, int index=0)
 
float floatValue (const std::string &key, int index=0)
 
std::string stringValue (const std::string &key, int index=0)
 
bool booleanValue (const std::string &key, int index=0)
 
unsigned int timeStampValue (const std::string &key)
 

Protected Member Functions

virtual bool handleError (int lineNumber, ConfigurationFile::ConfigurationFileError error, const std::string &line)
 
- Protected Member Functions inherited from ConfigurationFile
void addSupportedKey (const std::string &key, ConfigurationValueType type, bool caseSensitive=false)
 

Private Member Functions

std::string realPath (const std::string &pathInPCF) const
 

Private Attributes

std::vector< std::string > errors_
 
std::string pcfDir_
 

Static Private Attributes

static const std::string ARCHITECTURE = "Architecture"
 
static const std::string ARCHITECTURE_SIZE = "ArchitectureSize"
 
static const std::string ARCHITECTURE_MODIFIED
 
static const std::string ENCODING_MAP = "EncodingMap"
 
static const std::string ENCODING_MAP_SIZE = "EncodingSize"
 
static const std::string ENCODING_MAP_MODIFIED
 
static const std::string IMPLEMENTATION = "Implementation"
 
static const std::string IMPLEMENTATION_SIZE
 
static const std::string IMPLEMENTATION_MODIFIED
 

Additional Inherited Members

- Protected Types inherited from ConfigurationFile
enum  ConfigurationValueType {
  VT_INTEGER, VT_FLOAT, VT_STRING, VT_BOOLEAN,
  VT_READABLE_TIME, VT_UNIX_TIMESTAMP
}
 
enum  ConfigurationFileError { FE_SYNTAX, FE_ILLEGAL_TYPE, FE_UNKNOWN_KEY, FE_MISSING_VALUE }
 

Detailed Description

Has knowledge of the format of the processor configuration file.

It knows its supported keys and provides shortcut methods for querying the values of the keys.

Definition at line 46 of file ProcessorConfigurationFile.hh.

Constructor & Destructor Documentation

◆ ProcessorConfigurationFile()

ProcessorConfigurationFile::ProcessorConfigurationFile ( std::istream &  inputStream)
explicit

◆ ~ProcessorConfigurationFile()

ProcessorConfigurationFile::~ProcessorConfigurationFile ( )
virtual

Destructor.

Definition at line 82 of file ProcessorConfigurationFile.cc.

82  {
83 }

Member Function Documentation

◆ architectureModified()

unsigned int ProcessorConfigurationFile::architectureModified ( )

Returns the timestamp of the architecture modified time.

Returns
Architecture modified timestamp.
Exceptions
KeyNotFoundIf architecture modified time is not found.

Definition at line 129 of file ProcessorConfigurationFile.cc.

129  {
131 }

References ARCHITECTURE_MODIFIED, and ConfigurationFile::timeStampValue().

Here is the call graph for this function:

◆ architectureName()

string ProcessorConfigurationFile::architectureName ( )

Returns the name of the architecture.

Returns
The name of the architecture.
Exceptions
KeyNotFoundIf architecture is not found.

Definition at line 107 of file ProcessorConfigurationFile.cc.

107  {
108  return realPath(value(ARCHITECTURE));
109 }

References ARCHITECTURE, realPath(), and ConfigurationFile::value().

Referenced by ProGe::ProGeUI::loadProcessorConfiguration(), SimulatorFrontend::loadProcessorConfiguration(), and MDFDocument::openCFG().

Here is the call graph for this function:

◆ architectureSize()

unsigned int ProcessorConfigurationFile::architectureSize ( )

Returns the size of the architecture.

Returns
The size of the architecture.
Exceptions
KeyNotFoundIf architecture size is not found.

Definition at line 118 of file ProcessorConfigurationFile.cc.

118  {
119  return intValue(ARCHITECTURE_SIZE);
120 }

References ARCHITECTURE_SIZE, and ConfigurationFile::intValue().

Here is the call graph for this function:

◆ encodingMapModified()

unsigned int ProcessorConfigurationFile::encodingMapModified ( )

Returns the timestamp of encoding map modified time.

Returns
The timestamp of encoding map modified time.
Exceptions
KeyNotFoundIf timestamp is not found.

Definition at line 195 of file ProcessorConfigurationFile.cc.

195  {
197 }

References ENCODING_MAP_MODIFIED, and ConfigurationFile::timeStampValue().

Here is the call graph for this function:

◆ encodingMapName()

string ProcessorConfigurationFile::encodingMapName ( )

Returns the name of the encoding map.

Returns
The name of the encoding map.
Exceptions
KeyNotFoundIf encoding map is not found.

Definition at line 173 of file ProcessorConfigurationFile.cc.

173  {
174  return realPath(value(ENCODING_MAP));
175 }

References ENCODING_MAP, realPath(), and ConfigurationFile::value().

Referenced by ProGe::ProGeUI::loadProcessorConfiguration().

Here is the call graph for this function:

◆ encodingMapSize()

unsigned int ProcessorConfigurationFile::encodingMapSize ( )

Returns the size of the encoding map.

Returns
The size of the encoding map.
Exceptions
KeyNotFoundIf encoding map size is not found.

Definition at line 184 of file ProcessorConfigurationFile.cc.

184  {
185  return intValue(ENCODING_MAP_SIZE);
186 }

References ENCODING_MAP_SIZE, and ConfigurationFile::intValue().

Here is the call graph for this function:

◆ errorCount()

int ProcessorConfigurationFile::errorCount ( )

Returns the number of errors.

Returns
The number of errors.

Definition at line 205 of file ProcessorConfigurationFile.cc.

205  {
206  return errors_.size();
207 }

References errors_.

Referenced by MDFDocument::openCFG().

◆ errors()

bool ProcessorConfigurationFile::errors ( )

Returns true if errors were found.

Returns
True if errors were found.

Definition at line 231 of file ProcessorConfigurationFile.cc.

231  {
232  return !errors_.empty();
233 }

References errors_.

Referenced by MDFDocument::openCFG().

◆ errorString()

string ProcessorConfigurationFile::errorString ( int  index)

Returns the error string with a given index.

If such error string is not found, returns empty string.

Returns
Error string with a given index.

Definition at line 217 of file ProcessorConfigurationFile.cc.

217  {
218 
219  if (index < 0 || index > static_cast<int>(errors_.size()) - 1) {
220  return "";
221  }
222  return errors_[index];
223 }

References errors_.

Referenced by handleError(), and MDFDocument::openCFG().

◆ handleError()

bool ProcessorConfigurationFile::handleError ( int  lineNumber,
ConfigurationFile::ConfigurationFileError  error,
const std::string &  line 
)
protectedvirtual

Handles the errors.

Error string are added in internal data structure.

Parameters
lineNumberThe line number.
errorThe type of the error.
lineThe line in which error occurred.
Returns
True.

Reimplemented from ConfigurationFile.

Definition at line 246 of file ProcessorConfigurationFile.cc.

249  {
250 
251  string errorString;
252  switch (error) {
254  errorString += "Syntax error ";
255  break;
257  errorString += "Illegal type error ";
258  break;
260  errorString += "Unknown key error ";
261  break;
263  errorString += "Missing value error ";
264  break;
265  }
266  errorString += "in line " + Conversion::toString(lineNumber) +
267  ": " + line;
268 
269  errors_.push_back(errorString);
270  return true;
271 }

References errors_, errorString(), ConfigurationFile::FE_ILLEGAL_TYPE, ConfigurationFile::FE_MISSING_VALUE, ConfigurationFile::FE_SYNTAX, ConfigurationFile::FE_UNKNOWN_KEY, and Conversion::toString().

Here is the call graph for this function:

◆ implementationModified()

unsigned int ProcessorConfigurationFile::implementationModified ( )

Returns the implementation modified timestamp.

Returns
Timestamp of implementation modified time.
Exceptions
KeyNotFoundIf implementation modified timestamp is not found.

Definition at line 162 of file ProcessorConfigurationFile.cc.

162  {
164 }

References IMPLEMENTATION_MODIFIED, and ConfigurationFile::timeStampValue().

Here is the call graph for this function:

◆ implementationName()

string ProcessorConfigurationFile::implementationName ( )

Returns the name of the implementation.

Returns
The name of the implementation.
Exceptions
KeyNotFoundIf implementation is not found.

Definition at line 140 of file ProcessorConfigurationFile.cc.

140  {
141  return realPath(value(IMPLEMENTATION));
142 }

References IMPLEMENTATION, realPath(), and ConfigurationFile::value().

Referenced by ProGe::ProGeUI::loadProcessorConfiguration().

Here is the call graph for this function:

◆ implementationSize()

unsigned int ProcessorConfigurationFile::implementationSize ( )

Returns the size of the implementation.

Returns
The size of the implementation.
Exceptions
KeyNotFoundIf implementation size is not found.

Definition at line 151 of file ProcessorConfigurationFile.cc.

151  {
153 }

References IMPLEMENTATION_SIZE, and ConfigurationFile::intValue().

Here is the call graph for this function:

◆ realPath()

std::string ProcessorConfigurationFile::realPath ( const std::string &  pathInPCF) const
private

Creates real path to the file referred to in PCF.

The path is constructed assuming the PCF is in the directory set with setPCFDirectory method.

Parameters
pathInPCFThe path that reads in the PCF.
Returns
Real path to the file.

Definition at line 284 of file ProcessorConfigurationFile.cc.

284  {
285  if (FileSystem::isAbsolutePath(pathInPCF) || pcfDir_ == "") {
286  return pathInPCF;
287  } else {
288  return pcfDir_ + FileSystem::DIRECTORY_SEPARATOR + pathInPCF;
289  }
290 }

References FileSystem::DIRECTORY_SEPARATOR, FileSystem::isAbsolutePath(), and pcfDir_.

Referenced by architectureName(), encodingMapName(), and implementationName().

Here is the call graph for this function:

◆ setPCFDirectory()

void ProcessorConfigurationFile::setPCFDirectory ( const std::string &  directory)

Sets the directory of PCF file itself.

Path of the ADF, IDF and BEM files are constructed relative to the PCF directory if a relative path is given in PCF.

Parameters
directoryThe directory of the PCF file.

Definition at line 95 of file ProcessorConfigurationFile.cc.

95  {
96  pcfDir_ = directory;
97 }

References pcfDir_.

Referenced by ProGe::ProGeUI::loadProcessorConfiguration(), SimulatorFrontend::loadProcessorConfiguration(), and MDFDocument::openCFG().

Member Data Documentation

◆ ARCHITECTURE

const string ProcessorConfigurationFile::ARCHITECTURE = "Architecture"
staticprivate

Definition at line 80 of file ProcessorConfigurationFile.hh.

Referenced by architectureName(), and ProcessorConfigurationFile().

◆ ARCHITECTURE_MODIFIED

const string ProcessorConfigurationFile::ARCHITECTURE_MODIFIED
staticprivate
Initial value:
=
"ArchitectureModified"

Definition at line 82 of file ProcessorConfigurationFile.hh.

Referenced by architectureModified(), and ProcessorConfigurationFile().

◆ ARCHITECTURE_SIZE

const string ProcessorConfigurationFile::ARCHITECTURE_SIZE = "ArchitectureSize"
staticprivate

Definition at line 81 of file ProcessorConfigurationFile.hh.

Referenced by architectureSize(), and ProcessorConfigurationFile().

◆ ENCODING_MAP

const string ProcessorConfigurationFile::ENCODING_MAP = "EncodingMap"
staticprivate

Definition at line 84 of file ProcessorConfigurationFile.hh.

Referenced by encodingMapName(), and ProcessorConfigurationFile().

◆ ENCODING_MAP_MODIFIED

const string ProcessorConfigurationFile::ENCODING_MAP_MODIFIED
staticprivate
Initial value:
=
"EncodingModified"

Definition at line 86 of file ProcessorConfigurationFile.hh.

Referenced by encodingMapModified(), and ProcessorConfigurationFile().

◆ ENCODING_MAP_SIZE

const string ProcessorConfigurationFile::ENCODING_MAP_SIZE = "EncodingSize"
staticprivate

Definition at line 85 of file ProcessorConfigurationFile.hh.

Referenced by encodingMapSize(), and ProcessorConfigurationFile().

◆ errors_

std::vector<std::string> ProcessorConfigurationFile::errors_
private

Definition at line 92 of file ProcessorConfigurationFile.hh.

Referenced by errorCount(), errors(), errorString(), and handleError().

◆ IMPLEMENTATION

const string ProcessorConfigurationFile::IMPLEMENTATION = "Implementation"
staticprivate

Definition at line 88 of file ProcessorConfigurationFile.hh.

Referenced by implementationName(), and ProcessorConfigurationFile().

◆ IMPLEMENTATION_MODIFIED

const string ProcessorConfigurationFile::IMPLEMENTATION_MODIFIED
staticprivate
Initial value:
=
"ImplementationModified"

Definition at line 90 of file ProcessorConfigurationFile.hh.

Referenced by implementationModified(), and ProcessorConfigurationFile().

◆ IMPLEMENTATION_SIZE

const string ProcessorConfigurationFile::IMPLEMENTATION_SIZE
staticprivate
Initial value:
=
"ImplementationSize"

Definition at line 89 of file ProcessorConfigurationFile.hh.

Referenced by implementationSize(), and ProcessorConfigurationFile().

◆ pcfDir_

std::string ProcessorConfigurationFile::pcfDir_
private

Directory of the PCF file, affects the path returned when ADF, IDF or BEM is requested.

Definition at line 98 of file ProcessorConfigurationFile.hh.

Referenced by realPath(), and setPCFDirectory().


The documentation for this class was generated from the following files:
ConfigurationFile::ConfigurationFile
ConfigurationFile(bool doChecking=false)
Definition: ConfigurationFile.cc:72
ProcessorConfigurationFile::ENCODING_MAP
static const std::string ENCODING_MAP
Definition: ProcessorConfigurationFile.hh:84
ProcessorConfigurationFile::ARCHITECTURE_MODIFIED
static const std::string ARCHITECTURE_MODIFIED
Definition: ProcessorConfigurationFile.hh:82
ProcessorConfigurationFile::ENCODING_MAP_SIZE
static const std::string ENCODING_MAP_SIZE
Definition: ProcessorConfigurationFile.hh:85
ConfigurationFile::VT_STRING
@ VT_STRING
String value.
Definition: ConfigurationFile.hh:76
ProcessorConfigurationFile::IMPLEMENTATION_MODIFIED
static const std::string IMPLEMENTATION_MODIFIED
Definition: ProcessorConfigurationFile.hh:90
ConfigurationFile::VT_INTEGER
@ VT_INTEGER
Integer value.
Definition: ConfigurationFile.hh:74
ProcessorConfigurationFile::ARCHITECTURE_SIZE
static const std::string ARCHITECTURE_SIZE
Definition: ProcessorConfigurationFile.hh:81
ProcessorConfigurationFile::realPath
std::string realPath(const std::string &pathInPCF) const
Definition: ProcessorConfigurationFile.cc:284
Conversion::toString
static std::string toString(const T &source)
ConfigurationFile::FE_UNKNOWN_KEY
@ FE_UNKNOWN_KEY
Unknown key error.
Definition: ConfigurationFile.hh:88
ProcessorConfigurationFile::ARCHITECTURE
static const std::string ARCHITECTURE
Definition: ProcessorConfigurationFile.hh:80
ConfigurationFile::value
std::string value(const std::string &key, int index=0)
Definition: ConfigurationFile.cc:114
ProcessorConfigurationFile::IMPLEMENTATION_SIZE
static const std::string IMPLEMENTATION_SIZE
Definition: ProcessorConfigurationFile.hh:89
ProcessorConfigurationFile::errors_
std::vector< std::string > errors_
Definition: ProcessorConfigurationFile.hh:92
ProcessorConfigurationFile::pcfDir_
std::string pcfDir_
Definition: ProcessorConfigurationFile.hh:98
ProcessorConfigurationFile::ENCODING_MAP_MODIFIED
static const std::string ENCODING_MAP_MODIFIED
Definition: ProcessorConfigurationFile.hh:86
ProcessorConfigurationFile::errorString
std::string errorString(int index)
Definition: ProcessorConfigurationFile.cc:217
ConfigurationFile::FE_SYNTAX
@ FE_SYNTAX
Syntax error.
Definition: ConfigurationFile.hh:86
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
ConfigurationFile::FE_ILLEGAL_TYPE
@ FE_ILLEGAL_TYPE
Illegal type error.
Definition: ConfigurationFile.hh:87
ConfigurationFile::load
void load(std::istream &inputStream)
Definition: ConfigurationFile.cc:88
ConfigurationFile::intValue
int intValue(const std::string &key, int index=0)
Definition: ConfigurationFile.cc:146
ConfigurationFile::timeStampValue
unsigned int timeStampValue(const std::string &key)
Definition: ConfigurationFile.cc:228
ProcessorConfigurationFile::IMPLEMENTATION
static const std::string IMPLEMENTATION
Definition: ProcessorConfigurationFile.hh:88
ConfigurationFile::addSupportedKey
void addSupportedKey(const std::string &key, ConfigurationValueType type, bool caseSensitive=false)
Definition: ConfigurationFile.cc:292
FileSystem::isAbsolutePath
static bool isAbsolutePath(const std::string &pathName)
Definition: FileSystem.cc:234
ConfigurationFile::FE_MISSING_VALUE
@ FE_MISSING_VALUE
Missing value error.
Definition: ConfigurationFile.hh:89
ConfigurationFile::VT_READABLE_TIME
@ VT_READABLE_TIME
Time in readable format.
Definition: ConfigurationFile.hh:78