Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

FileReader Class Reference

Communication class to read an input file generated by Traplas containing a simulation. Offers a choise between a 'dumb' parser and a flex parser. More...

#include <FileReader.h>

Inheritance diagram for FileReader:

Inheritance graph
[legend]
Collaboration diagram for FileReader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileReader (string nfilename, MessageController *ptr)
 ~FileReader ()
bool sendMessage (shared_ptr< vector< shared_ptr< string > > > messagebody)

Private Attributes

string filename
pthread_t filereadthread
bool filereadthread_run
MessageControllermsgcontroller

Friends

void * readFile (void *ptr)
void * flexRead (void *ptr)
bool send (char *)

Detailed Description

Communication class to read an input file generated by Traplas containing a simulation. Offers a choise between a 'dumb' parser and a flex parser.

Definition at line 45 of file FileReader.h.


Constructor & Destructor Documentation

FileReader::FileReader string  nfilename,
MessageController ptr
 

Constructor.

Parameters:
nfilename The filename of the file to be processed.
ptr A reference to the MessageController.

Definition at line 143 of file FileReader.cpp.

References filename, filereadthread, filereadthread_run, flexRead, and msgcontroller.

FileReader::~FileReader  ) 
 

Definition at line 160 of file FileReader.cpp.

References filereadthread, and filereadthread_run.


Member Function Documentation

bool FileReader::sendMessage shared_ptr< vector< shared_ptr< string > > >  messagebody  )  [virtual]
 

Method used by the MessageController to send messages to Traplas. Obviously, when reading a file no messages can be sent. Therefore this method always returns false.

Parameters:
messagebody A reference to the message.
Returns:
false. The filereader has no connection to Traplas so it can't send the message anywhere.

Implements Comm.

Definition at line 168 of file FileReader.cpp.


Friends And Related Function Documentation

void* flexRead void *  ptr  )  [friend]
 

Thread to read the input file generated by Traplas containing a simulation. This thread uses flex to process the input file. Entire messages are matched, then these messages are sent to the MessageController. When a line in the inputfile is not recognised, a message is send to cout containing the linenumber and the unrecognised message itself.

Definition at line 89 of file FileReader.cpp.

Referenced by FileReader().

void* readFile void *  ptr  )  [friend]
 

Thread to read the input file generated by Traplas containing a simulation. This thread uses a simple way the read a file, it offers no checks whatsoever on what it reads. It just reads lines using a getline(), then it makes token using a space(" ") as delimiter. Then it sends the messages to the MessageController.

Definition at line 100 of file FileReader.cpp.

bool send char *  line  )  [friend]
 

Helper function for yylex() to send messages to the MessageController. It sends the message to the MessageController.

Definition at line 73 of file FileReader.cpp.


Member Data Documentation

string FileReader::filename [private]
 

Definition at line 47 of file FileReader.h.

Referenced by FileReader(), flexRead(), and readFile().

pthread_t FileReader::filereadthread [private]
 

Definition at line 49 of file FileReader.h.

Referenced by FileReader(), and ~FileReader().

bool FileReader::filereadthread_run [private]
 

Definition at line 50 of file FileReader.h.

Referenced by FileReader(), readFile(), and ~FileReader().

MessageController* FileReader::msgcontroller [private]
 

Definition at line 52 of file FileReader.h.

Referenced by FileReader(), readFile(), and send().


The documentation for this class was generated from the following files:
Generated on Mon Jun 19 10:22:18 2006 for TraplasVisualisation by  doxygen 1.4.4