OpenWalnut
1.3.1
|
Class loading project files. More...
#include <WProjectFile.h>
Public Types | |
typedef boost::shared_ptr < WProjectFile > | SPtr |
Abbreviation for a shared pointer. More... | |
typedef boost::shared_ptr < const WProjectFile > | ConstSPtr |
Abbreviation for const shared pointer. More... | |
typedef boost::function< void(boost::filesystem::path, std::vector< std::string >) > | ProjectLoadCallback |
A callback function type reporting bach a finished load job. More... | |
typedef boost::signals2::signal< void(boost::filesystem::path, std::vector< std::string >) > | ProjectLoadCallbackSignal |
A callback function signal type reporting bach a finished load job. More... | |
![]() | |
typedef boost::function< void(void) > | THREADFUNCTION |
Type used for simple thread functions. More... | |
Public Member Functions | |
WProjectFile (boost::filesystem::path project) | |
Default constructor. More... | |
WProjectFile (boost::filesystem::path project, ProjectLoadCallback doneCallback) | |
Default constructor. More... | |
virtual | ~WProjectFile () |
Destructor. More... | |
virtual void | load () |
Parses the project file and applies it. More... | |
virtual void | save () |
Saves the current state to the file specified in the constructor. More... | |
virtual void | save (const std::vector< boost::shared_ptr< WProjectFileIO > > &writer) |
Saves the current state to the file specified in the constructor. More... | |
![]() | |
WThreadedRunner () | |
Default constructor. More... | |
virtual | ~WThreadedRunner () |
Destructor. More... | |
virtual void | run () |
Run thread. More... | |
void | run (THREADFUNCTION f) |
Run thread. More... | |
void | wait (bool requestFinish=false) |
Wait for the thread to be finished. More... | |
virtual void | requestStop () |
This method's purpose is to request a stop without waiting for it. More... | |
virtual boost::signals2::connection | subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier) |
Connects a specified notify function with a signal this thread instance is offering. More... | |
const WBoolFlag & | isCrashed () const |
Checks whether this thread has been crashed. More... | |
const std::string & | getCrashMessage () const |
Get the message of the exception finally causing the crash. More... | |
void | setThreadName (std::string name) |
Set the name of the thread. More... | |
std::string | getThreadName () const |
Returns the current thread name. More... | |
Static Public Member Functions | |
static boost::shared_ptr < WProjectFileIO > | getCameraWriter () |
Returns an instance of the Camera writer. More... | |
static boost::shared_ptr < WProjectFileIO > | getModuleWriter () |
Returns an instance of the module writer. More... | |
static boost::shared_ptr < WProjectFileIO > | getROIWriter () |
Returns an instance of the ROI writer. More... | |
![]() | |
static void | setThisThreadName (std::string name) |
Static function to set the name of the calling thread. More... | |
Protected Member Functions | |
virtual void | threadMain () |
Function that has to be overwritten for execution. More... | |
virtual void | onThreadException (const WException &e) |
Do custom exception handling. More... | |
![]() | |
virtual void | notifyStop () |
Gets called when the thread should be stopped. More... | |
void | yield () const |
Give remaining execution timeslice to another thread. More... | |
void | sleep (const int32_t t) const |
Sets thread asleep. More... | |
void | msleep (const int32_t t) const |
Sets thread asleep. More... | |
void | waitForStop () |
Let the thread sleep until a stop request was given. More... | |
void | handleDeadlyException (const WException &e, std::string sender="WThreadedRunner") |
Handle the specified exception which was not caught in the thread, which basically means the thread has crashed. More... | |
Protected Attributes | |
boost::filesystem::path | m_project |
The project file to parse. More... | |
std::vector< boost::shared_ptr < WProjectFileIO > > | m_parsers |
The parser instances. More... | |
![]() | |
boost::thread | m_thread |
Thread instance. More... | |
WBoolFlag | m_shutdownFlag |
Condition getting fired whenever the thread should quit. More... | |
WBoolFlag | m_isCrashed |
True whenever an exception is thrown during threadMain. More... | |
std::string | m_crashMessage |
The crash message. More... | |
Private Attributes | |
ProjectLoadCallbackSignal | m_signalLoadDone |
Signal used to callback someone that the loader was finished. More... | |
boost::signals2::connection | m_signalLoadDoneConnection |
Connection managing the signal m_signalLoadDone. More... | |
Class loading project files.
This class opens an file and reads it line by line. It delegates the actual parsing to each of the known WProjectFileIO instances which then do their job.
Definition at line 43 of file WProjectFile.h.
typedef boost::shared_ptr< const WProjectFile > WProjectFile::ConstSPtr |
Abbreviation for const shared pointer.
Definition at line 55 of file WProjectFile.h.
typedef boost::function< void( boost::filesystem::path, std::vector< std::string > ) > WProjectFile::ProjectLoadCallback |
A callback function type reporting bach a finished load job.
The given string vector contains a list of errors if any.
Definition at line 60 of file WProjectFile.h.
typedef boost::signals2::signal< void( boost::filesystem::path, std::vector< std::string > ) > WProjectFile::ProjectLoadCallbackSignal |
A callback function signal type reporting bach a finished load job.
The given string vector contains a list of errors if any.
Definition at line 65 of file WProjectFile.h.
typedef boost::shared_ptr< WProjectFile > WProjectFile::SPtr |
Abbreviation for a shared pointer.
Definition at line 50 of file WProjectFile.h.
|
explicit |
Default constructor.
It does NOT parse the file. Parsing is done by using load.
project | the project file to load or save. |
Definition at line 43 of file WProjectFile.cpp.
References m_parsers.
WProjectFile::WProjectFile | ( | boost::filesystem::path | project, |
ProjectLoadCallback | doneCallback | ||
) |
Default constructor.
It does NOT parse the file. Parsing is done by using load.
project | the project file to load. |
doneCallback | gets called whenever the load thread finishes. |
Definition at line 60 of file WProjectFile.cpp.
References m_parsers.
|
virtual |
Destructor.
Definition at line 76 of file WProjectFile.cpp.
References m_parsers, and m_signalLoadDoneConnection.
|
static |
Returns an instance of the Camera writer.
Definition at line 83 of file WProjectFile.cpp.
|
static |
Returns an instance of the module writer.
Definition at line 88 of file WProjectFile.cpp.
|
static |
Returns an instance of the ROI writer.
Definition at line 93 of file WProjectFile.cpp.
|
virtual |
Parses the project file and applies it.
It applies the project file asynchronously!
Definition at line 98 of file WProjectFile.cpp.
References WKernel::getRootContainer(), WKernel::getRunningKernel(), and WThreadedRunner::run().
|
protectedvirtual |
Do custom exception handling.
e | the exception |
Reimplemented from WThreadedRunner.
Definition at line 223 of file WProjectFile.cpp.
References WKernel::getRootContainer(), WKernel::getRunningKernel(), and WThreadedRunner::handleDeadlyException().
|
virtual |
Saves the current state to the file specified in the constructor.
Definition at line 129 of file WProjectFile.cpp.
References m_parsers.
|
virtual |
Saves the current state to the file specified in the constructor.
This also supports a custom list of writers. This is useful to only write some parts of the state.
writer | the list of writers to use. |
Definition at line 107 of file WProjectFile.cpp.
References wlog::info(), and m_project.
|
protectedvirtual |
Function that has to be overwritten for execution.
It gets executed in a separate thread after run() has been called.
Reimplemented from WThreadedRunner.
Definition at line 134 of file WProjectFile.cpp.
References wlog::error(), WKernel::getRootContainer(), WKernel::getRunningKernel(), wlog::info(), m_parsers, m_project, m_signalLoadDone, m_signalLoadDoneConnection, string_utils::toString(), and wlog::warn().
|
protected |
The parser instances.
They are used to parse the file.
Definition at line 141 of file WProjectFile.h.
Referenced by save(), threadMain(), WProjectFile(), and ~WProjectFile().
|
protected |
The project file to parse.
Definition at line 136 of file WProjectFile.h.
Referenced by save(), and threadMain().
|
private |
Signal used to callback someone that the loader was finished.
Definition at line 153 of file WProjectFile.h.
Referenced by threadMain().
|
private |
Connection managing the signal m_signalLoadDone.
This is the one and only connection allowed and will be disconnected upon thread has finished.
Definition at line 159 of file WProjectFile.h.
Referenced by threadMain(), and ~WProjectFile().