CARMA C++
SpawnableTask.h
Go to the documentation of this file.
1 // $Id: SpawnableTask.h,v 1.3 2013/07/09 17:12:00 eml Exp $
2 
3 #ifndef SZA_UTIL_SPAWNABLETASK_H
4 #define SZA_UTIL_SPAWNABLETASK_H
5 
19 
21 
22 #include <iostream>
23 
24 namespace sza {
25  namespace util {
26 
33  template <class Msg>
35  public RunnableTask {
36 
37  public:
38 
43  SpawnableTask(bool spawn) : RunnableTask(spawn) {}
44 
48  virtual ~SpawnableTask() {};
49 
50  protected:
51 
52  // All the work in this class is done by processMsg().
53  //
54  // Inheritors need only define what this function does for
55  // different message types, and the rest will run itself.
56 
57  virtual void processMsg(Msg* msg) {};
58 
59  public:
60 
61  void run() {
62  try {
64  } catch(Exception& err) {
65  COUT("Caught an exception: " << err.what());
66  } catch(carma::util::ErrorException& err) {
67  COUT("Caught a CARMA exception: " << err.what());
68  } catch(...) {
69  COUT("Caught an unknown exception (ST 0)");
70  }
71  }
72 
73  }; // End class SpawnableTask
74 
75  } // End namespace util
76 } // End namespace sza
77 
78 
79 
80 #endif // End #ifndef SZA_UTIL_SPAWNABLETASK_H
virtual void processMsg(Msg *msg)
This method should be defined by each inheriting task to process its own task-specific messages...
Definition: SpawnableTask.h:57
void run()
Force inheritors to define a run method.
Definition: SpawnableTask.h:61
Exception class for errors.
Tagged: Fri Nov 14 12:39:33 UTC 2003.
SpawnableTask(bool spawn)
Constructor.
Definition: SpawnableTask.h:43
All tasks will have the following functionality:
Definition: GenericTask.h:32
virtual const char * what() const
Get the error message; overrides BaseException &amp; std::exception.what()
virtual ~SpawnableTask()
Destructor.
Definition: SpawnableTask.h:48
Exception class for errors The exception comes with a text string that can be printed or logged...
......................................................................
Definition: SpawnableTask.h:34
Tagged: Fri Jan 26 17:59:28 NZDT 2007.
virtual void run(void)
Force inheritors to define a run method.
Definition: GenericTask.h:336
Tagged: Fri Nov 14 12:39:33 UTC 2003.