OpenASIP 2.2
Loading...
Searching...
No Matches
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

Constructor.

Parameters
inputStreamStream where configuration file is read from.

Definition at line 58 of file ProcessorConfigurationFile.cc.

59 : ConfigurationFile(true), pcfDir_(".") {
60
64 true);
65
69 true);
70
75
76 load(inputStream);
77}
void addSupportedKey(const std::string &key, ConfigurationValueType type, bool caseSensitive=false)
void load(std::istream &inputStream)
@ VT_STRING
String value.
@ VT_READABLE_TIME
Time in readable format.
@ VT_INTEGER
Integer value.
static const std::string IMPLEMENTATION_SIZE
static const std::string IMPLEMENTATION
static const std::string ENCODING_MAP_MODIFIED
static const std::string ARCHITECTURE_SIZE
static const std::string IMPLEMENTATION_MODIFIED
static const std::string ARCHITECTURE_MODIFIED
static const std::string ENCODING_MAP_SIZE
static const std::string ARCHITECTURE
static const std::string ENCODING_MAP

References ConfigurationFile::addSupportedKey(), ARCHITECTURE, ARCHITECTURE_MODIFIED, ARCHITECTURE_SIZE, ENCODING_MAP, ENCODING_MAP_MODIFIED, ENCODING_MAP_SIZE, IMPLEMENTATION, IMPLEMENTATION_MODIFIED, IMPLEMENTATION_SIZE, ConfigurationFile::load(), ConfigurationFile::VT_INTEGER, ConfigurationFile::VT_READABLE_TIME, and ConfigurationFile::VT_STRING.

Here is the call graph for this function:

◆ ~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}
unsigned int timeStampValue(const std::string &key)

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}
std::string value(const std::string &key, int index=0)
std::string realPath(const std::string &pathInPCF) const

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 {
120}
int intValue(const std::string &key, int index=0)

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 {
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}
std::vector< std::string > errors_

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}
@ FE_UNKNOWN_KEY
Unknown key error.
@ FE_SYNTAX
Syntax error.
@ FE_MISSING_VALUE
Missing value error.
@ FE_ILLEGAL_TYPE
Illegal type error.
static std::string toString(const T &source)

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 {
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}
static bool isAbsolutePath(const std::string &pathName)
static const std::string DIRECTORY_SEPARATOR

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: