My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
SpawnableTask.h
Go to the documentation of this file.
1 // $Id: SpawnableTask.h,v 1.2 2009/08/13 21:34:51 eml Exp $
2 
3 #ifndef GCP_UTIL_SPAWNABLETASK_H
4 #define GCP_UTIL_SPAWNABLETASK_H
5 
16 #include "gcp/util/common/GenericTask.h"
17 #include "gcp/util/common/RunnableTask.h"
18 
19 #include <iostream>
20 
21 namespace gcp {
22  namespace util {
23 
30  template <class Msg>
32  public RunnableTask {
33 
34  public:
35 
40  SpawnableTask(bool spawn) : RunnableTask(spawn) {}
41 
45  virtual ~SpawnableTask() {};
46 
47  protected:
48 
49  // All the work in this class is done by processMsg().
50  //
51  // Inheritors need only define what this function does for
52  // different message types, and the rest will run itself.
53 
54  virtual void processMsg(Msg* msg) {};
55 
56  void run() {
57  try {
59  } catch(Exception& err) {
60  COUT("Caught an exception: " << err.what());
61  } catch(...) {
62  COUT("Caught an exception");
63  }
64  }
65 
66  }; // End class SpawnableTask
67 
68  } // End namespace util
69 } // End namespace gcp
70 
71 
72 
73 #endif // End #ifndef GCP_UTIL_SPAWNABLETASK_H
Definition: RunnableTask.h:23
void run()
Definition: SpawnableTask.h:56
virtual void run(void)
Definition: GenericTask.h:358
SpawnableTask(bool spawn)
Definition: SpawnableTask.h:40
Definition: SpawnableTask.h:31
virtual ~SpawnableTask()
Definition: SpawnableTask.h:45
virtual void processMsg(Msg *msg)
Definition: SpawnableTask.h:54
Definition: Exception.h:30
Definition: GenericTask.h:33