OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WBatchLoader Class Reference

Class for loading many datasets. More...

#include <WBatchLoader.h>

+ Inheritance diagram for WBatchLoader:
+ Collaboration diagram for WBatchLoader:

Public Types

typedef std::shared_ptr< WBatchLoaderSPtr
 Shared ptr abbreviation. More...
 
typedef std::shared_ptr< const WBatchLoaderConstSPtr
 Const shared ptr abbreviation. More...
 
typedef WSharedSequenceContainer< std::vector< WDataModule::SPtr > > DataModuleList
 The type is used to store the list of data modules. More...
 
- Public Types inherited from WThreadedRunner
typedef std::shared_ptr< WThreadedRunnerSPtr
 Abbreviation to a shared_ptr to this type. More...
 
typedef std::shared_ptr< const WThreadedRunnerConstSPtr
 Abbreviation to a const shared_ptr to this type. More...
 
typedef boost::function< void(void) > THREADFUNCTION
 Type used for simple thread functions. More...
 

Public Member Functions

 WBatchLoader (std::vector< std::string > filenames, std::shared_ptr< WModuleContainer > targetContainer)
 Initializes the batchloader but does not start it. More...
 
virtual ~WBatchLoader ()
 Destructor. More...
 
virtual void run ()
 Run thread and load the data. More...
 
DataModuleList::ReadTicket getDataModuleList () const
 Returns a ticket to the list of data modules that have been added so far. More...
 
void setSuppressColormaps (bool suppress=true)
 Allows suppression of colormap registration in data modules. More...
 
bool getSuppressColormaps () const
 Checks whether suppression of colormaps is active. More...
 
- Public Member Functions inherited from WThreadedRunner
 WThreadedRunner ()
 Default constructor. More...
 
virtual ~WThreadedRunner ()
 Destructor. 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 WBoolFlagisCrashed () 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...
 

Protected Member Functions

virtual void threadMain ()
 Function that has to be overwritten for execution. More...
 
- Protected Member Functions inherited from WThreadedRunner
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...
 
virtual void onThreadException (const WException &e)
 This method is called if an exception was caught, which came from the custom thread code. 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

std::vector< std::string > m_filenamesToLoad
 List of files to load. More...
 
std::shared_ptr< WModuleContainerm_targetContainer
 The container which later will contain the loaded datasets. More...
 
DataModuleList m_dataModules
 The list of modules that have been added. More...
 
bool m_suppressColormaps
 If true, data modules are instructed to suppress colormap registration. More...
 
- Protected Attributes inherited from WThreadedRunner
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...
 

Additional Inherited Members

- Static Public Member Functions inherited from WThreadedRunner
static void setThisThreadName (std::string name)
 Static function to set the name of the calling thread. More...
 

Detailed Description

Class for loading many datasets.

It runs in a separate thread.

Definition at line 41 of file WBatchLoader.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WBatchLoader > WBatchLoader::ConstSPtr

Const shared ptr abbreviation.

Definition at line 53 of file WBatchLoader.h.

◆ DataModuleList

The type is used to store the list of data modules.

Definition at line 58 of file WBatchLoader.h.

◆ SPtr

typedef std::shared_ptr< WBatchLoader > WBatchLoader::SPtr

Shared ptr abbreviation.

Definition at line 48 of file WBatchLoader.h.

Constructor & Destructor Documentation

◆ WBatchLoader()

WBatchLoader::WBatchLoader ( std::vector< std::string >  filenames,
std::shared_ptr< WModuleContainer targetContainer 
)

Initializes the batchloader but does not start it.

Use run() to start. The batch-loader will always use the WDataModule which was found first if multiple match to one filename. This is the reason why WBatchLoader will be removed in the future. Follow issue #32.

Parameters
filenamesthe files to load.
targetContainerthe container to which the data modules should be added.

Definition at line 35 of file WBatchLoader.cpp.

◆ ~WBatchLoader()

WBatchLoader::~WBatchLoader ( )
virtual

Destructor.

Definition at line 45 of file WBatchLoader.cpp.

Member Function Documentation

◆ getDataModuleList()

WBatchLoader::DataModuleList::ReadTicket WBatchLoader::getDataModuleList ( ) const

Returns a ticket to the list of data modules that have been added so far.

Returns
the ticket

Definition at line 97 of file WBatchLoader.cpp.

References WSharedObject< T >::getReadTicket(), and m_dataModules.

+ Here is the call graph for this function:

◆ getSuppressColormaps()

bool WBatchLoader::getSuppressColormaps ( ) const

Checks whether suppression of colormaps is active.

Returns
true if colormaps are suppressed.

Definition at line 107 of file WBatchLoader.cpp.

References m_suppressColormaps.

◆ run()

void WBatchLoader::run ( )
virtual

Run thread and load the data.

Reimplemented from WThreadedRunner.

Definition at line 50 of file WBatchLoader.cpp.

References m_targetContainer, and WThreadedRunner::run().

+ Here is the call graph for this function:

◆ setSuppressColormaps()

void WBatchLoader::setSuppressColormaps ( bool  suppress = true)

Allows suppression of colormap registration in data modules.

This can be handy if you use data modules in a container to construct more complex data sets from multiple input files.

Note
call this before run().
Parameters
suppresstrue if suppress

Definition at line 102 of file WBatchLoader.cpp.

References m_suppressColormaps.

◆ threadMain()

void WBatchLoader::threadMain ( )
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 59 of file WBatchLoader.cpp.

References WModuleFactory::getModuleFactory(), m_dataModules, m_filenamesToLoad, m_suppressColormaps, m_targetContainer, WSharedSequenceContainer< S >::push_back(), and wlog::warn().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_dataModules

DataModuleList WBatchLoader::m_dataModules
protected

The list of modules that have been added.

Definition at line 123 of file WBatchLoader.h.

Referenced by getDataModuleList(), and threadMain().

◆ m_filenamesToLoad

std::vector< std::string > WBatchLoader::m_filenamesToLoad
protected

List of files to load.

Definition at line 113 of file WBatchLoader.h.

Referenced by threadMain().

◆ m_suppressColormaps

bool WBatchLoader::m_suppressColormaps
protected

If true, data modules are instructed to suppress colormap registration.

Definition at line 128 of file WBatchLoader.h.

Referenced by getSuppressColormaps(), setSuppressColormaps(), and threadMain().

◆ m_targetContainer

std::shared_ptr< WModuleContainer > WBatchLoader::m_targetContainer
protected

The container which later will contain the loaded datasets.

Definition at line 118 of file WBatchLoader.h.

Referenced by run(), and threadMain().


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