OpenWalnut  1.4.0
WModule.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <algorithm>
26 #include <set>
27 #include <string>
28 #include <sstream>
29 
30 #include <boost/shared_ptr.hpp>
31 #include <boost/uuid/uuid.hpp>
32 #include <boost/uuid/uuid_generators.hpp>
33 #include <boost/uuid/uuid_io.hpp>
34 
35 #include "WModuleInputConnector.h"
36 #include "WModuleOutputConnector.h"
37 #include "WModuleInputData.h"
38 #include "WModuleOutputData.h"
39 #include "WModuleConnectorSignals.h"
40 #include "WModuleContainer.h"
41 #include "WModuleFactory.h"
42 #include "WModuleMetaInformation.h"
43 #include "exceptions/WModuleConnectorInitFailed.h"
44 #include "exceptions/WModuleConnectorNotFound.h"
45 #include "exceptions/WModuleUninitialized.h"
46 #include "exceptions/WModuleRequirementNotMet.h"
47 #include "../common/WException.h"
48 #include "../common/exceptions/WNameNotUnique.h"
49 #include "../common/exceptions/WSignalUnknown.h"
50 #include "../common/exceptions/WSignalSubscriptionFailed.h"
51 #include "../common/WLogger.h"
52 #include "../common/WCondition.h"
53 #include "../common/WConditionOneShot.h"
54 #include "../common/WConditionSet.h"
55 #include "../common/WPathHelper.h"
56 #include "../common/WProgressCombiner.h"
57 #include "../common/WPredicateHelper.h"
58 
59 #include "WModule.h"
60 
63  WPrototyped(),
64  m_initialized( new WCondition(), false ),
65  m_isAssociated( new WCondition(), false ),
66  m_isUsable( new WCondition(), false ),
67  m_isReady( new WConditionOneShot(), false ),
68  m_isReadyOrCrashed( new WConditionSet(), false ),
69  m_isRunning( new WCondition(), false ),
70  m_isLoadFinished( new WConditionOneShot(), false ),
71  m_restoreMode( false ),
72  m_readyProgress( boost::shared_ptr< WProgress >( new WProgress( "Initializing Module" ) ) ),
73  m_moduleState(),
74  m_localPath( WPathHelper::getSharePath() )
75 {
76  // initialize members
77  m_properties = boost::shared_ptr< WProperties >( new WProperties( "Properties", "Module's properties" ) );
78  m_infoProperties = boost::shared_ptr< WProperties >( new WProperties( "Informational Properties", "Module's information properties" ) );
79  m_infoProperties->setPurpose( PV_PURPOSE_INFORMATION );
80 
81  m_runtimeName = m_properties->addProperty( "Name", "The name of the module defined by the user. This is, by default, the module name but "
82  "can be changed by the user to provide some kind of simple identification upon many modules.",
83  std::string( "" ), false );
84 
85  m_active = m_properties->addProperty( "active", "Determines whether the module should be activated.", true, true );
86  m_active->getCondition()->subscribeSignal( boost::bind( &WModule::activate, this ) );
87 
88  // the isReadyOrCrashed condition set needs to be set up here
89  WConditionSet* cs = static_cast< WConditionSet* >( m_isReadyOrCrashed.getCondition().get() ); // NOLINT
90  cs->setResetable( true, false );
91  cs->add( m_isReady.getCondition() );
92  cs->add( m_isCrashed.getCondition() );
93 
94  m_container = boost::shared_ptr< WModuleContainer >();
95  m_progress = boost::shared_ptr< WProgressCombiner >( new WProgressCombiner() );
96 
97  // add a progress indicator which finishes on "ready()"
98  m_progress->addSubProgress( m_readyProgress );
99 
100  // our internal state consist out of two conditions: data changed and the exit flag from WThreadedRunner.
102 }
103 
105 {
106  // cleanup
107 }
108 
109 void WModule::addConnector( boost::shared_ptr< WModuleInputConnector > con )
110 {
111  size_t c = std::count_if( m_inputConnectors.begin(), m_inputConnectors.end(),
113  );
114  // well ... we want it to be unique in both:
115  c += std::count_if( m_outputConnectors.begin(), m_outputConnectors.end(),
117  );
118 
119  // if there already is one ... exception
120  if( c )
121  {
122  throw WNameNotUnique( std::string( "Could not add the connector " + con->getCanonicalName() + " since names must be unique." ) );
123  }
124 
125  m_inputConnectors.push_back( con );
126 }
127 
128 void WModule::addConnector( boost::shared_ptr< WModuleOutputConnector > con )
129 {
130  size_t c = std::count_if( m_inputConnectors.begin(), m_inputConnectors.end(),
132  );
133  // well ... we want it to be unique in both:
134  c += std::count_if( m_outputConnectors.begin(), m_outputConnectors.end(),
136  );
137 
138  // if there already is one ... exception
139  if( c )
140  {
141  throw WNameNotUnique( std::string( "Could not add the connector " + con->getCanonicalName() + " since names must be unique." ) );
142  }
143 
144  m_outputConnectors.push_back( con );
145 }
146 
148 {
149  // remove connections and their signals
150  for( InputConnectorList::iterator listIter = m_inputConnectors.begin();
151  listIter != m_inputConnectors.end(); ++listIter )
152  {
153  ( *listIter )->disconnectAll();
154  }
155  for( OutputConnectorList::iterator listIter = m_outputConnectors.begin();
156  listIter != m_outputConnectors.end(); ++listIter )
157  {
158  ( *listIter )->disconnectAll();
159  }
160 }
161 
162 WCombinerTypes::WDisconnectList WModule::getPossibleDisconnections()
163 {
164  WCombinerTypes::WDisconnectList discons;
165 
166  // iterate inputs
167  for( InputConnectorList::iterator listIter = m_inputConnectors.begin(); listIter != m_inputConnectors.end(); ++listIter )
168  {
169  // get all connections of the current connector:
170  WCombinerTypes::WDisconnectGroup g = WCombinerTypes::WDisconnectGroup( ( *listIter )->getName(),
171  ( *listIter )->getPossibleDisconnections() );
172 
173  if( g.second.size() )
174  {
175  discons.push_back( g );
176  }
177  }
178 
179  // iterate outputs
180  for( OutputConnectorList::iterator listIter = m_outputConnectors.begin(); listIter != m_outputConnectors.end(); ++listIter )
181  {
182  // get all connections of the current connector:
183  WCombinerTypes::WDisconnectGroup g = WCombinerTypes::WDisconnectGroup( ( *listIter )->getName(),
184  ( *listIter )->getPossibleDisconnections() );
185 
186  if( g.second.size() )
187  {
188  discons.push_back( g );
189  }
190  }
191 
192  return discons;
193 }
194 
196 {
197  m_initialized( false );
199 
200  // remove connections and their signals, this is flat removal. The module container can do deep removal
201  disconnect();
202 
203  // clean up list
204  // this should delete the connector since nobody else *should* have another shared_ptr to them
205  m_inputConnectors.clear();
206  m_outputConnectors.clear();
207 }
208 
210 {
211 }
212 
214 {
215 }
216 
218 {
219 }
220 
222 {
223 }
224 
225 std::string WModule::deprecated() const
226 {
227  return "";
228 }
229 
231 {
232  return m_meta;
233 }
234 
236 {
237  // doing it twice is not allowed
238  if( isInitialized()() )
239  {
240  throw WModuleConnectorInitFailed( std::string( "Could not initialize connectors for Module " ) + getName() +
241  std::string( ". Reason: already initialized." ) );
242  }
243 
244  // set the module name as default runtime name
245  m_runtimeName->set( getName() );
246 
247  // initialize module meta information
248  m_meta = WModuleMetaInformation::SPtr( new WModuleMetaInformation( shared_from_this() ) );
249 
250  // initialize connectors and properties
251  requirements();
252  connectors();
253  properties();
254 
255  // now, the module is initialized but not necessarily usable (if not associated with a container)
256  m_initialized( true );
258 
259  // also set thread name
260  setThreadName( getName() );
261 }
262 
264 {
265  // currently just removes connectors
267 }
268 
269 boost::shared_ptr< WModuleContainer > WModule::getAssociatedContainer() const
270 {
271  return m_container;
272 }
273 
274 void WModule::setAssociatedContainer( boost::shared_ptr< WModuleContainer > container )
275 {
276  m_container = container;
277 
278  // true if the pointer is set
279  m_isAssociated( m_container != boost::shared_ptr< WModuleContainer >() );
281 }
282 
283 MODULE_TYPE WModule::getType() const
284 {
285  return MODULE_ARBITRARY;
286 }
287 
289 {
290  return m_inputConnectors;
291 }
292 
294 {
295  return m_outputConnectors;
296 }
297 
298 boost::shared_ptr< WModuleInputConnector > WModule::findInputConnector( std::string name )
299 {
300  // simply search
301  for( InputConnectorList::const_iterator listIter = m_inputConnectors.begin();
302  listIter != m_inputConnectors.end(); ++listIter )
303  {
304  // try the canonical name
305  if( ( name == ( *listIter )->getCanonicalName() ) || ( name == ( *listIter )->getName() ) )
306  {
307  return ( *listIter );
308  }
309  }
310 
311  return boost::shared_ptr< WModuleInputConnector >();
312 }
313 
314 boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
315 {
316  boost::shared_ptr< WModuleInputConnector > p = findInputConnector( name );
317 
318  if( !p )
319  {
320  throw WModuleConnectorNotFound( std::string( "The connector \"" ) + name +
321  std::string( "\" does not exist in the module \"" ) + getName() + std::string( "\"." ) );
322  }
323 
324  return p;
325 }
326 
327 boost::shared_ptr< WModuleOutputConnector > WModule::findOutputConnector( std::string name )
328 {
329  // simply search
330  for( OutputConnectorList::const_iterator listIter = m_outputConnectors.begin();
331  listIter != m_outputConnectors.end(); ++listIter )
332  {
333  // try the canonical name
334  if( ( name == ( *listIter )->getCanonicalName() ) || ( name == ( *listIter )->getName() ) )
335  {
336  return ( *listIter );
337  }
338  }
339 
340  return boost::shared_ptr< WModuleOutputConnector >();
341 }
342 
343 boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
344 {
345  boost::shared_ptr< WModuleOutputConnector > p = findOutputConnector( name );
346 
347  if( !p )
348  {
349  throw WModuleConnectorNotFound( std::string( "The connector \"" ) + name +
350  std::string( "\" does not exist in the module \"" ) + getName() +
351  std::string( "\"." ) );
352  }
353 
354  return p;
355 }
356 
357 boost::shared_ptr< WModuleConnector > WModule::findConnector( std::string name )
358 {
359  // simply search both
360  boost::shared_ptr< WModuleConnector > p = findInputConnector( name );
361  if( p ) // found?
362  {
363  return p;
364  }
365 
366  // search in output list
367  return findOutputConnector( name );
368 }
369 
370 boost::shared_ptr< WModuleConnector > WModule::getConnector( std::string name )
371 {
372  boost::shared_ptr< WModuleConnector > p = findConnector( name );
373 
374  if( !p )
375  {
376  throw WModuleConnectorNotFound( std::string( "The connector \"" ) + name +
377  std::string( "\" does not exist in the module \"" ) + getName() +
378  std::string( "\"." ) );
379  }
380 
381  return p;
382 }
383 
384 boost::signals2::connection WModule::subscribeSignal( MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier )
385 {
386  switch( signal )
387  {
388  case WM_READY:
389  return signal_ready.connect( notifier );
390  default:
391  std::ostringstream s;
392  s << "Could not subscribe to unknown signal.";
393  throw WSignalSubscriptionFailed( s.str() );
394  break;
395  }
396 }
397 
398 boost::signals2::connection WModule::subscribeSignal( MODULE_SIGNAL signal, t_ModuleErrorSignalHandlerType notifier )
399 {
400  switch( signal)
401  {
402  case WM_ERROR:
403  return signal_error.connect( notifier );
404  default:
405  std::ostringstream s;
406  s << "Could not subscribe to unknown signal.";
407  throw WSignalSubscriptionFailed( s.str() );
408  break;
409  }
410 }
411 
412 const t_GenericSignalHandlerType WModule::getSignalHandler( MODULE_CONNECTOR_SIGNAL signal )
413 {
414  switch( signal )
415  {
416  case CONNECTION_ESTABLISHED:
417  return boost::bind( &WModule::notifyConnectionEstablished, this, _1, _2 );
418  case CONNECTION_CLOSED:
419  return boost::bind( &WModule::notifyConnectionClosed, this, _1, _2 );
420  case DATA_CHANGED:
421  return boost::bind( &WModule::notifyDataChange, this, _1, _2 );
422  default:
423  std::ostringstream s;
424  s << "Could not subscribe to unknown signal. You need to implement this signal type explicitly in your module.";
425  throw WSignalUnknown( s.str() );
426  break;
427  }
428 }
429 
431 {
432  return m_initialized;
433 }
434 
436 {
437  return m_isAssociated;
438 }
439 
441 {
442  return m_isUsable;
443  //return isInitialized() && isAssociated();
444 }
445 
447 {
448  return m_isReady;
449 }
450 
452 {
453  return m_isReadyOrCrashed;
454 }
455 
457 {
458  return m_isRunning;
459 }
460 
461 void WModule::notifyConnectionEstablished( boost::shared_ptr< WModuleConnector > /*here*/,
462  boost::shared_ptr< WModuleConnector > /*there*/ )
463 {
464  // By default this callback does nothing. Overwrite it in your module.
465 }
466 
467 void WModule::notifyConnectionClosed( boost::shared_ptr< WModuleConnector > /*here*/,
468  boost::shared_ptr< WModuleConnector > /*there*/ )
469 {
470  // By default this callback does nothing. Overwrite it in your module.
471 }
472 
473 void WModule::notifyDataChange( boost::shared_ptr< WModuleConnector > /*input*/,
474  boost::shared_ptr< WModuleConnector > /*output*/ )
475 {
476  // By default this callback does nothing. Overwrite it in your module.
477 }
478 
479 boost::shared_ptr< WProperties > WModule::getProperties() const
480 {
481  return m_properties;
482 }
483 
484 boost::shared_ptr< WProperties > WModule::getInformationProperties() const
485 {
486  return m_infoProperties;
487 }
488 
489 boost::shared_ptr< WProgressCombiner > WModule::getRootProgressCombiner()
490 {
491  return m_progress;
492 }
493 
494 const char** WModule::getXPMIcon() const
495 {
496  // return empty 1x1 icon by default.
497  static const char * o_xpm[] =
498  {
499  "1 1 1 1",
500  " c None",
501  " "
502  };
503  return o_xpm;
504 }
505 
507 {
508  m_isReady( true );
509  m_readyProgress->finish();
510  signal_ready( shared_from_this() );
511 }
512 
514 {
515  // simply iterate all requirements and return the first found that is not fulfilled
516  for( Requirements::const_iterator i = m_requirements.begin(); i != m_requirements.end(); ++i )
517  {
518  if( !( *i )->isComplied() )
519  {
520  return *i;
521  }
522  }
523 
524  return NULL;
525 }
526 
528 {
529  WLogger::getLogger()->addLogMessage( "Starting module main method.", "Module (" + getName() + ")", LL_INFO );
530 
531  // check requirements
532  const WRequirement* failedReq = checkRequirements();
533  if( failedReq )
534  {
535  throw WModuleRequirementNotMet( failedReq );
536  }
537 
538  // call main thread function
539  m_isRunning( true );
540  moduleMain();
541 
542  // NOTE: if there is any exception in the module thread, WThreadedRunner calls onThreadException for us. We can then disconnect the
543  // module and call our own error notification mechanism.
544 
545  // remove all pending connections. This is important as connections that still exists after module deletion can cause segfaults when they get
546  // disconnected in the connector destructor.
547  disconnect();
548  m_isRunning( false );
549 }
550 
552 {
553  // use our own error callback which includes the exact module pointer which caused the problem
554  signal_error( shared_from_this(), e );
555 
556  // ensure the module is properly disconnected
557  disconnect();
558 
559  // module is not running anymore.
560  m_isRunning( false );
561 
562  // let WThreadedRunner do the remaining tasks.
563  handleDeadlyException( e, "Module (" + getName() +")" );
564 }
565 
567 {
568  return wlog::info( getName() );
569 }
570 
572 {
573  return wlog::error( getName() );
574 }
575 
577 {
578  return wlog::debug( getName() );
579 }
580 
582 {
583  return wlog::warn( getName() );
584 }
585 
586 void WModule::setLocalPath( boost::filesystem::path path )
587 {
588  m_localPath = path;
589 }
590 
591 boost::filesystem::path WModule::getLocalPath() const
592 {
593  return m_localPath;
594 }
595 
596 void WModule::setLibPath( boost::filesystem::path path )
597 {
598  m_libPath = path;
599 }
600 
601 boost::filesystem::path WModule::getLibPath() const
602 {
603  return m_libPath;
604 }
605 
606 void WModule::setPackageName( std::string name )
607 {
608  m_packageName = name;
609 }
610 
611 std::string WModule::getPackageName() const
612 {
613  return m_packageName;
614 }
615 
617 {
618  return !deprecated().empty();
619 }
620 
622 {
623  return deprecated();
624 }
625 
627 {
628  if( m_restoreMode )
629  {
630  // this returns if the flag was set in the past since it uses a OneShot Condition.
632  // after load has finished, the module is not in restore mode anymore
633  m_restoreMode = false;
634  }
635 }
636 
638 {
639  return m_restoreMode;
640 }
641 
642 void WModule::setRestoreNeeded( bool restore )
643 {
644  m_restoreMode = restore;
645 }
646 
648 {
649  m_isLoadFinished.set( true );
650 }
651 
652 const std::string& WModule::getUUID() const
653 {
654  return m_uuid;
655 }
656 
657 void WModule::setUUID( std::string uuid )
658 {
659  m_uuid = uuid;
660 
661  // create one if none was specified
662  if( m_uuid.empty() )
663  {
664  // simple random uuid generator
665  boost::uuids::random_generator gen;
666  m_uuid = boost::uuids::to_string( gen() );
667  }
668 }
669 
671 {
672  return WModuleFactory::findByUUID( uuid );
673 }
674 
t_ModuleErrorSignalType signal_error
Signal fired whenever a module main thread throws an exception/error.
Definition: WModule.h:778
WStreamedLogger error(const std::string &source)
Logging an error message.
Definition: WLogger.h:302
virtual boost::signals2::connection subscribeSignal(MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier)
Connects a specified notify function with a signal this module instance is offering.
Definition: WModule.cpp:384
boost::shared_ptr< WModuleContainer > m_container
The container this module belongs to.
Definition: WModule.h:706
void reportRestoreComplete()
Called by loaders to tell the module that loading has been completed.
Definition: WModule.cpp:647
virtual const std::string getName() const =0
Gets the name of this prototype.
wlog::WStreamedLogger errorLog() const
Logger instance for comfortable error logging.
Definition: WModule.cpp:571
virtual void connectors()
Initialize connectors in this function.
Definition: WModule.cpp:209
virtual WModuleMetaInformation::ConstSPtr getMetaInformation() const
The meta information of this module.
Definition: WModule.cpp:230
void setUUID(std::string uuid)
Set a uuid.
Definition: WModule.cpp:657
WBoolFlag m_isReadyOrCrashed
It is true whenever m_isReady or WThreadedRunner::m_isCrashed is true.
Definition: WModule.h:676
void ready()
Call this whenever your module is ready and can react on property changes.
Definition: WModule.cpp:506
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
Definition: WModule.cpp:494
boost::shared_ptr< const WModuleMetaInformation > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WModuleMetaInformation >.
WStreamedLogger info(const std::string &source)
Logging an information message.
Definition: WLogger.h:324
virtual void moduleMain()=0
Entry point after loading the module.
virtual void onThreadException(const WException &e)
This method is called if an exception was caught, which came from the custom thread code...
Definition: WModule.cpp:551
boost::shared_ptr< WProperties > getProperties() const
Return a pointer to the properties object of the module.
Definition: WModule.cpp:479
void removeConnectors()
Removes all connectors properly.
Definition: WModule.cpp:195
Class managing progress inside of modules.
Definition: WProgress.h:43
WBoolFlag m_isUsable
True if associated && initialized.
Definition: WModule.h:665
std::vector< boost::shared_ptr< WModuleOutputConnector > > OutputConnectorList
The type for the list of output connectors.
Definition: WModule.h:116
void setAssociatedContainer(boost::shared_ptr< WModuleContainer > container)
Sets the container this module is associated with.
Definition: WModule.cpp:274
void setLibPath(boost::filesystem::path path)
Set the path to the library which contains this module.
Definition: WModule.cpp:596
boost::shared_ptr< WCondition > getCondition()
Returns the condition that is used by this flag.
Definition: WFlag.h:320
virtual void add(boost::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
boost::shared_ptr< WModuleMetaInformation > SPtr
Convenience typedef for a boost::shared_ptr< WModuleMetaInformation >.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
Definition: WLogger.cpp:64
WModuleMetaInformation::SPtr m_meta
Lock for m_inputConnectors.
Definition: WModule.h:768
boost::shared_ptr< WModuleOutputConnector > getOutputConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:343
WBoolFlag m_isRunning
True if the module currently is running.
Definition: WModule.h:681
std::string getPackageName() const
Returns the name of the package the module belongs to, The package name basically is the name of the ...
Definition: WModule.cpp:611
boost::shared_ptr< WModuleConnector > findConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:357
bool isRestoreNeeded() const
Check whether this module is in restore mode.
Definition: WModule.cpp:637
boost::shared_ptr< WProperties > getInformationProperties() const
Return a pointer to the information properties object of the module.
Definition: WModule.cpp:484
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
Definition: WLogger.cpp:84
boost::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
Definition: WModule.h:650
void waitRestored()
This method waits for the module to be restored completely.
Definition: WModule.cpp:626
boost::filesystem::path getLocalPath() const
Returns the local path of the module.
Definition: WModule.cpp:591
const WBoolFlag & isReadyOrCrashed() const
This is the logical or of isReady and isCrashed.
Definition: WModule.cpp:451
Implements a WCondition, but can be fired only ONCE.
WCombinerTypes::WDisconnectList getPossibleDisconnections()
Gives a list of all WDisconnectCombiners possible.
Definition: WModule.cpp:162
virtual void notifyConnectionClosed(boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
Gets called whenever a connection between a remote and local connector gets closed.
Definition: WModule.cpp:467
General purpose exception and therefore base class for all kernel related exceptions.
static SPtr findByUUID(std::string uuid)
Find a module instance by UUID.
Definition: WModule.cpp:670
WPropBool m_active
True whenever the module should be active.
Definition: WModule.h:721
virtual void activate()
Callback for m_active.
Definition: WModule.cpp:221
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 h...
General purpose exception and therefore base class for all kernel related exceptions.
virtual void requirements()
Initialize requirements in this function.
Definition: WModule.cpp:217
Interface class for the concept "Prototype".
Definition: WPrototyped.h:39
Singleton class helping to find files and paths.
Definition: WPathHelper.h:42
Base class for all classes needing to be executed in a separate thread.
const WBoolFlag & isReady() const
Checks whether this module is ready.
Definition: WModule.cpp:446
virtual void properties()
Initialize properties in this function.
Definition: WModule.cpp:213
void setRestoreNeeded(bool restore=true)
Change the restore mode.
Definition: WModule.cpp:642
Thrown whenever a module should be run but its requirements are not completely met.
WBoolFlag m_isReady
True if ready() was called.
Definition: WModule.h:670
virtual ~WModule()
Destructor.
Definition: WModule.cpp:104
static WModule::SPtr findByUUID(std::string uuid)
Find a module instance by UUID.
boost::shared_ptr< WModuleContainer > getAssociatedContainer() const
The container this module is associated with.
Definition: WModule.cpp:269
General purpose exception and therefore base class for all kernel related exceptions.
Base class for all kinds of progress combinations.
Resource class for streamed logging.
Definition: WLogger.h:183
const InputConnectorList & getInputConnectors() const
Gives back input connectors.
Definition: WModule.cpp:288
Class allowing multiple conditions to be used for one waiting cycle.
Definition: WConditionSet.h:46
WBoolFlag m_isAssociated
True if container got associated with this flag.
Definition: WModule.h:660
boost::filesystem::path m_localPath
The path where the module binary resides in.
Definition: WModule.h:732
const OutputConnectorList & getOutputConnectors() const
Gives back output connectors.
Definition: WModule.cpp:293
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
Base class for all possible kinds of requirements.
Definition: WRequirement.h:37
boost::shared_ptr< WProperties > m_properties
The property object for the module.
Definition: WModule.h:638
void disconnect()
Completely disconnects all connected connectors of this module.
Definition: WModule.cpp:147
virtual MODULE_TYPE getType() const
Gets the type of the module.
Definition: WModule.cpp:283
boost::shared_ptr< WModuleOutputConnector > findOutputConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:327
WModule()
Constructs a new WModule instance.
Definition: WModule.cpp:61
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
std::string m_packageName
The name of the lib/the package containing this module.
Definition: WModule.h:742
const WRequirement * checkRequirements() const
This method checks whether all the requirements of the module are complied.
Definition: WModule.cpp:513
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
boost::filesystem::path m_libPath
The absolute path to the library containing this module.
Definition: WModule.h:737
WBoolFlag m_isCrashed
True whenever an exception is thrown during threadMain.
const WBoolFlag & isRunning() const
Returns a flag denoting whether the thread currently is running or nor.
Definition: WModule.cpp:456
virtual std::string deprecated() const
This function allows module programmers to mark their modules deprecated in a user-friendly way...
Definition: WModule.cpp:225
virtual void wait() const
Wait for the flag to change its value.
Definition: WFlag.h:280
boost::filesystem::path getLibPath() const
Returns the absolute path to the library containing this module.
Definition: WModule.cpp:601
Indicates that a given name is not unique in a group of names.
boost::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
Definition: WModule.h:121
Class to encapsulate boost::condition_variable_any.
Definition: WCondition.h:47
void initialize()
Manages initialization.
Definition: WModule.cpp:235
boost::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION"...
Definition: WModule.h:645
WBoolFlag m_initialized
True if everything is initialized and ready to be used.
Definition: WModule.h:655
boost::shared_ptr< WModuleInputConnector > getInputConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:314
virtual bool set(const T &value, bool suppressNotification=false)
Sets the new value for this flag.
Definition: WFlag.h:292
std::vector< boost::shared_ptr< WModuleInputConnector > > InputConnectorList
The type for the list of input connectors.
Definition: WModule.h:111
const WBoolFlag & isUseable() const
Checks whether the module instance is ready to be used.
Definition: WModule.cpp:440
General purpose exception and therefore base class for all kernel related exceptions.
void setThreadName(std::string name)
Set the name of the thread.
virtual boost::shared_ptr< WProgressCombiner > getRootProgressCombiner()
Gets the modules base progress.
Definition: WModule.cpp:489
virtual void cleanup()
Called whenever the module should shutdown.
Definition: WModule.cpp:263
WPropString m_runtimeName
This property holds a user specified name for the current module instance.
Definition: WModule.h:726
wlog::WStreamedLogger warnLog() const
Logger instance for comfortable warning- logs.
Definition: WModule.cpp:581
boost::shared_ptr< WModuleConnector > getConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:370
std::string getDeprecationMessage() const
Queries the deprecation message of a module if specified.
Definition: WModule.cpp:621
void setPackageName(std::string name)
Set the package name.
Definition: WModule.cpp:606
const std::string & getUUID() const
Get the UUID of the module instance.
Definition: WModule.cpp:652
A class abstracting module meta information.
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
Definition: WModule.cpp:566
InputConnectorList m_inputConnectors
Set of input connectors associated with this module.
Definition: WModule.h:711
const WBoolFlag & isAssociated() const
Checks whether this module is associated with an container.
Definition: WModule.cpp:435
virtual void notifyConnectionEstablished(boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
Gets called whenever a connector gets connected to the specified input.
Definition: WModule.cpp:461
void setLocalPath(boost::filesystem::path path)
Sets the local module path.
Definition: WModule.cpp:586
t_ModuleGenericSignalType signal_ready
Signal fired whenever a module main thread is ready.
Definition: WModule.h:773
Basic exception handler.
Definition: WException.h:38
Requirements m_requirements
The list of requirements.
Definition: WModule.h:752
WBoolFlag m_isLoadFinished
Flag to denote whether the module container and the project loader have finished their work...
Definition: WModule.h:686
const WBoolFlag & isInitialized() const
Determines whether the module instance is properly initialized.
Definition: WModule.cpp:430
bool m_restoreMode
Flag denoting the current restore mode.
Definition: WModule.h:691
WConditionSet m_moduleState
The internal state of the module.
Definition: WModule.h:701
virtual void notifyDataChange(boost::shared_ptr< WModuleConnector > input, boost::shared_ptr< WModuleConnector > output)
Gets called when the data on one input connector changed.
Definition: WModule.cpp:473
void addConnector(boost::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
Definition: WModule.cpp:109
WStreamedLogger debug(const std::string &source)
Logging a debug message.
Definition: WLogger.h:335
boost::shared_ptr< WModuleInputConnector > findInputConnector(std::string name)
Finds the named connector for the module.
Definition: WModule.cpp:298
This class tests against the getName() method of the instances of type T.
void threadMain()
Thread entry point.
Definition: WModule.cpp:527
WStreamedLogger warn(const std::string &source)
Logging a warning message.
Definition: WLogger.h:313
boost::shared_ptr< WProgress > m_readyProgress
Progress indicator for the "ready" state.
Definition: WModule.h:696
bool isDeprecated() const
Checks whether the module was marked as deprecated.
Definition: WModule.cpp:616
std::string m_uuid
The unique ID of the module instance.
Definition: WModule.h:790
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
Definition: WModule.cpp:576
OutputConnectorList m_outputConnectors
Set of output connectors associated with this module.
Definition: WModule.h:716
virtual const t_GenericSignalHandlerType getSignalHandler(MODULE_CONNECTOR_SIGNAL signal)
Gives the signal handler function responsible for a given signal.
Definition: WModule.cpp:412