DDS  ver. 2.0
worker.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef WORKER_H
6 #define WORKER_H
7 //=============================================================================
8 // std
9 #include <iosfwd>
10 // MiscCommon
11 #include "def.h"
12 // pod-ssh
13 #include "local_types.h"
14 #include "ncf.h"
15 #include "threadPool.h"
16 // boost
17 #include <boost/thread/mutex.hpp>
18 //=============================================================================
19 namespace dds
20 {
21  namespace ssh_cmd
22  {
23  enum ETaskType
24  {
29  };
30  // boost::mutex is not copyable, we therefore should wrap it
31  typedef boost::shared_ptr<boost::mutex> mutexPtr_t;
32  //=============================================================================
33  class CWorker : public CTaskImp<CWorker, ETaskType>
34  {
35  public:
36  CWorker(ncf::configRecord_t _rec, const SWNOptions& _options, const std::string& _path);
37  ~CWorker();
38 
39  void printInfo(std::ostream& _stream) const;
40  bool runTask(ETaskType _param) const;
41  std::string getID() const
42  {
43  return m_rec->m_id;
44  }
45 
46  private:
47  bool exec_command(const std::string& _cmd) const;
48  void log(const std::string& _msg) const;
49 
50  private:
51  ncf::configRecord_t m_rec;
52  SWNOptions m_options;
53  std::string m_path;
54  mutable mutexPtr_t m_mutex;
55  };
56  }
57 }
58 #endif
Definition: worker.h:25
Definition: worker.h:26
CWorker(ncf::configRecord_t _rec, const SWNOptions &_options, const std::string &_path)
Definition: worker.cpp:20
void printInfo(std::ostream &_stream) const
Definition: worker.cpp:37
Definition: worker.h:28
bool runTask(ETaskType _param) const
Definition: worker.cpp:48
Definition: dds-agent/src/AgentConnectionManager.h:18
~CWorker()
Definition: worker.cpp:33
Definition: worker.h:33
boost::shared_ptr< boost::mutex > mutexPtr_t
Definition: worker.h:31
Definition: worker.h:27
boost::shared_ptr< SConfigRecord > configRecord_t
Definition: ncf.h:91
std::string getID() const
Definition: worker.h:41
Definition: local_types.h:15
Definition: threadPool.h:22
ETaskType
Definition: worker.h:23