OpenWalnut  1.4.0
Public Member Functions | Protected Types | Protected Attributes
WModuleProjectFileCombiner Class Reference

This class is able to parse project files and create the appropriate module graph inside a specified container. More...

#include <WModuleProjectFileCombiner.h>

+ Inheritance diagram for WModuleProjectFileCombiner:

List of all members.

Public Member Functions

 WModuleProjectFileCombiner (boost::shared_ptr< WModuleContainer > target)
 Creates an empty combiner.
 WModuleProjectFileCombiner ()
 Creates an empty combiner.
virtual ~WModuleProjectFileCombiner ()
 Destructor.
virtual void apply ()
 Apply the internal module structure to the target container.
virtual bool parse (std::string line, unsigned int lineNumber)
 This method parses the specified line and interprets it to fill the internal module graph structure.
virtual void done ()
 Called whenever the end of the project file has been reached.
virtual void save (std::ostream &output)
 Saves the state to the specified stream.
virtual SPtr clone (WProjectFile *project) const
 Create a clone of the IO.
virtual boost::shared_ptr
< WModule
mapToModule (unsigned int id) const
 Map a given project file ID to a module.
virtual unsigned int mapFromModule (boost::shared_ptr< WModule > module) const
 Map a given module to project file ID.

Protected Types

typedef std::pair< unsigned
int, boost::shared_ptr
< WModule > > 
ModuleID
 The module ID type.
typedef std::map< unsigned int,
boost::shared_ptr< WModule > > 
ModuleIDMap
 Map between ID and Module.
typedef std::pair< unsigned
int, std::string > 
Connector
 A connector is described by ID and name.
typedef std::pair< Connector,
Connector
Connection
 A connection is a pair of connectors.
typedef std::pair< unsigned
int, std::string > 
Property
 A property is a pair of ID and name.
typedef std::pair< Property,
std::string > 
PropertyValue
 A property value is a property and the new value as string.

Protected Attributes

std::map< unsigned int,
boost::shared_ptr< WModule > > 
m_modules
 All Modules.
std::list< Connectionm_connections
 All connections.
std::list< PropertyValuem_properties
 All properties.

Detailed Description

This class is able to parse project files and create the appropriate module graph inside a specified container.

It is also derived from WProjectFileIO to allow WProjectFile to fill this combiner.

Definition at line 47 of file WModuleProjectFileCombiner.h.


Member Typedef Documentation

typedef std::pair< Connector, Connector > WModuleProjectFileCombiner::Connection [protected]

A connection is a pair of connectors.

Definition at line 156 of file WModuleProjectFileCombiner.h.

typedef std::pair< unsigned int, std::string > WModuleProjectFileCombiner::Connector [protected]

A connector is described by ID and name.

Definition at line 151 of file WModuleProjectFileCombiner.h.

typedef std::pair< unsigned int, boost::shared_ptr< WModule > > WModuleProjectFileCombiner::ModuleID [protected]

The module ID type.

A pair of ID and pointer to module.

Definition at line 136 of file WModuleProjectFileCombiner.h.

typedef std::map< unsigned int, boost::shared_ptr< WModule > > WModuleProjectFileCombiner::ModuleIDMap [protected]

Map between ID and Module.

Definition at line 141 of file WModuleProjectFileCombiner.h.

typedef std::pair< unsigned int, std::string > WModuleProjectFileCombiner::Property [protected]

A property is a pair of ID and name.

Definition at line 166 of file WModuleProjectFileCombiner.h.

typedef std::pair< Property, std::string > WModuleProjectFileCombiner::PropertyValue [protected]

A property value is a property and the new value as string.

Definition at line 171 of file WModuleProjectFileCombiner.h.


Constructor & Destructor Documentation

WModuleProjectFileCombiner::WModuleProjectFileCombiner ( boost::shared_ptr< WModuleContainer target) [explicit]

Creates an empty combiner.

Parameters:
targetthe target container where to add the modules to.

Definition at line 57 of file WModuleProjectFileCombiner.cpp.

Creates an empty combiner.

This constructor automatically uses the kernel's root container as target container.

Definition at line 63 of file WModuleProjectFileCombiner.cpp.

Referenced by clone().

Destructor.

Definition at line 69 of file WModuleProjectFileCombiner.cpp.

References m_modules.


Member Function Documentation

Apply the internal module structure to the target container.

Be aware, that this operation might take some time, as modules can be connected only if they are "ready", which, at least with WDataModule modules, might take some time. It applies the loaded project file.

Notes:
the loader for project files is very tolerant. It does not abort. It tries to load as much as possible. The only exception that gets thrown whenever the file could not be opened.
Exceptions:
WFileNotFoundwhenever the project file could not be opened.

Implements WModuleCombiner.

Definition at line 185 of file WModuleProjectFileCombiner.cpp.

References WProjectFileIO::addError(), WProjectFileIO::addWarning(), WGEColormapping::instance(), m_connections, WModuleCombiner::m_container, m_modules, m_properties, and string_utils::toString().

Referenced by done().

Create a clone of the IO.

This is especially useful for custom parsers registered at WProjectFile::registerParser. Implement this function.

Parameters:
projectthe project file using this parser instance.
Returns:
Cloned instance.

Implements WProjectFileIO.

Definition at line 75 of file WModuleProjectFileCombiner.cpp.

References WModuleProjectFileCombiner().

Called whenever the end of the project file has been reached.

This is useful if your specific parser class wants to do some post processing after parsing line by line.

Reimplemented from WProjectFileIO.

Definition at line 332 of file WModuleProjectFileCombiner.cpp.

References apply().

unsigned int WModuleProjectFileCombiner::mapFromModule ( boost::shared_ptr< WModule module) const [virtual]

Map a given module to project file ID.

This method must not be used by WModuleProjectFileCombiner, as it builds this mapping. All other WProjectFileIO implementations are allowed to use it in their save and apply methods (NOT in parse()).

Parameters:
modulethe module to map
Returns:
the ID, or numeric_limits< unisigned int >::max() if module not known.

Definition at line 420 of file WModuleProjectFileCombiner.cpp.

References m_modules.

boost::shared_ptr< WModule > WModuleProjectFileCombiner::mapToModule ( unsigned int  id) const [virtual]

Map a given project file ID to a module.

This method must not be used by WModuleProjectFileCombiner, as it builds this mapping. All other WProjectFileIO implementations are allowed to use it in their save and apply methods (NOT in parse()).

Parameters:
idthe id
Returns:
the module, or NULL if ID is not known.

Definition at line 408 of file WModuleProjectFileCombiner.cpp.

References m_modules.

bool WModuleProjectFileCombiner::parse ( std::string  line,
unsigned int  lineNumber 
) [virtual]

This method parses the specified line and interprets it to fill the internal module graph structure.

Parameters:
linethe current line as string
lineNumberthe current line number. Useful for error/warning/debugging output.
Returns:
true if the line could be parsed.

Implements WProjectFileIO.

Definition at line 83 of file WModuleProjectFileCombiner.cpp.

References WProjectFileIO::addError(), wlog::debug(), WModuleFactory::getModuleFactory(), m_connections, m_modules, and m_properties.

void WModuleProjectFileCombiner::save ( std::ostream &  output) [virtual]

Saves the state to the specified stream.

Parameters:
outputthe stream to print the state to.

Implements WProjectFileIO.

Definition at line 337 of file WModuleProjectFileCombiner.cpp.

References WPrototyped::getName(), WKernel::getRootContainer(), WKernel::getRunningKernel(), WGEColormapping::instance(), m_modules, and WProjectFileIO::printProperties().


Member Data Documentation

All connections.

Definition at line 161 of file WModuleProjectFileCombiner.h.

Referenced by apply(), and parse().

std::map< unsigned int, boost::shared_ptr< WModule > > WModuleProjectFileCombiner::m_modules [protected]

All Modules.

Definition at line 146 of file WModuleProjectFileCombiner.h.

Referenced by apply(), mapFromModule(), mapToModule(), parse(), save(), and ~WModuleProjectFileCombiner().

All properties.

Definition at line 176 of file WModuleProjectFileCombiner.h.

Referenced by apply(), and parse().


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