Dripline-Cpp  v2.4.2
Dripline Implementation in C++
agent.hh
Go to the documentation of this file.
1 /*
2  * agent.hh
3  *
4  * Created on: Jun 2, 2016
5  * Author: nsoblath
6  *
7  */
8 
9 #ifndef DRIPLINE_AGENT_HH_
10 #define DRIPLINE_AGENT_HH_
11 
12 #include "message.hh"
13 
14 #include "param.hh"
15 
16 
17 namespace dripline
18 {
19  class core;
20 
64  {
65  public:
67  {
68  public:
69  sub_agent( agent* an_agent ) : f_agent( an_agent ) {};
70  virtual ~sub_agent() {};
71 
72  void execute( const scarab::param_node& a_config );
73  void execute( const scarab::param_node& a_config, const scarab::param_array& a_ord_args );
74 
75  virtual void create_and_send_message( scarab::param_node& a_config, const core& a_core ) = 0;
76  virtual void create_and_send_message( const core& a_core );
77 
78  protected:
80  };
81 
83  {
84  public:
85  sub_agent_request( agent* an_agent ) : sub_agent( an_agent ) {}
86  virtual ~sub_agent_request() {}
87 
88  virtual void create_and_send_message( scarab::param_node& a_config, const core& a_core );
89 
90  virtual request_ptr_t create_request( scarab::param_node& a_config ) = 0;
91  };
92 
94  {
95  public:
96  sub_agent_reply( agent* an_agent ) : sub_agent( an_agent ) {}
97  virtual ~sub_agent_reply() {}
98 
99  virtual void create_and_send_message( scarab::param_node& a_config, const core& a_core );
100  };
101 
103  {
104  public:
105  sub_agent_alert( agent* an_agent ) : sub_agent( an_agent ) {}
106  virtual ~sub_agent_alert() {}
107 
108  virtual void create_and_send_message( scarab::param_node& a_config, const core& a_core );
109  };
110 
112  {
113  public:
114  sub_agent_run( agent* an_agent ) : sub_agent_request( an_agent ) {}
115  virtual ~sub_agent_run() {}
116 
117  virtual request_ptr_t create_request( scarab::param_node& a_config );
118  };
119 
121  {
122  public:
123  sub_agent_get( agent* an_agent ) : sub_agent_request( an_agent ) {}
124  virtual ~sub_agent_get() {}
125 
126  virtual request_ptr_t create_request( scarab::param_node& a_config );
127  };
128 
130  {
131  public:
132  sub_agent_set( agent* an_agent ) : sub_agent_request( an_agent ) {}
133  virtual ~sub_agent_set() {}
134 
135  virtual request_ptr_t create_request( scarab::param_node& a_config );
136  };
137 
139  {
140  public:
141  sub_agent_cmd( agent* an_agent ) : sub_agent_request( an_agent ) {}
142  virtual ~sub_agent_cmd() {}
143 
144  virtual request_ptr_t create_request( scarab::param_node& a_config );
145  };
146 
147  public:
148  agent();
149  virtual ~agent();
150 
151  template< typename sub_agent_type >
152  void execute( const scarab::param_node& a_config );
153  template< typename sub_agent_type >
154  void execute( const scarab::param_node& a_config, const scarab::param_array& a_ord_args );
155 
156  mv_accessible( bool, is_dry_run );
157 
158  // all message types
159  mv_referrable( std::string, routing_key );
160  mv_referrable( std::string, specifier );
161 
162  // requests only
163  mv_referrable( uuid_t, lockout_key );
164 
165  // alerts only
166  mv_accessible( unsigned, return_code );
167  mv_referrable( std::string, return_message );
168 
169  // use only for requests
170  mv_accessible( unsigned, timeout );
171  mv_accessible( bool, suppress_output );
172  mv_accessible( bool, json_print );
173  mv_accessible( bool, pretty_print );
174  mv_referrable( std::string, save_filename );
175 
176  mv_accessible( reply_ptr_t, reply );
177 
178  mv_accessible( int, return );
179 
180  };
181 
182  template< typename sub_agent_type >
183  void agent::execute( const scarab::param_node& a_config )
184  {
185  sub_agent_type t_sub_agent( this );
186  scarab::param_array t_ord_args;
187  t_sub_agent.execute( a_config, t_ord_args );
188  return;
189  }
190 
191  template< typename sub_agent_type >
192  void agent::execute( const scarab::param_node& a_config, const scarab::param_array& a_ord_args )
193  {
194  sub_agent_type t_sub_agent( this );
195  t_sub_agent.execute( a_config, a_ord_args );
196  return;
197  }
198 
199  inline void agent::sub_agent::create_and_send_message( const core& a_core )
200  {
201  scarab::param_node t_config;
202  create_and_send_message( t_config, a_core );
203  return;
204  }
205 
206 } /* namespace dripline */
207 
208 #endif /* DRIPLINE_AGENT_HH_ */
Base class for return codes.
Definition: return_codes.hh:39
sub_agent(agent *an_agent)
Definition: agent.hh:69
sub_agent_request(agent *an_agent)
Definition: agent.hh:85
Parses routing keys and stores the tokenized information.
Definition: specifier.hh:27
sub_agent_run(agent *an_agent)
Definition: agent.hh:114
std::shared_ptr< msg_request > request_ptr_t
Definition: dripline_fwd.hh:23
void execute(const scarab::param_node &a_config)
Definition: agent.hh:183
sub_agent_reply(agent *an_agent)
Definition: agent.hh:96
#define DRIPLINE_API
Definition: dripline_api.hh:34
boost::uuids::uuid uuid_t
Universally-unique-identifier type containing 16 hexadecimal characters.
Definition: uuid.hh:26
virtual void create_and_send_message(scarab::param_node &a_config, const core &a_core)=0
sub_agent_cmd(agent *an_agent)
Definition: agent.hh:141
std::shared_ptr< msg_reply > reply_ptr_t
Definition: dripline_fwd.hh:24
Parses specifiers and stores the tokenized information.
Definition: specifier.hh:55
Basic AMQP interactions, including sending messages and interacting with AMQP channels.
Definition: core.hh:72
Takes command-line arguments and sends messages.
Definition: agent.hh:63
sub_agent_get(agent *an_agent)
Definition: agent.hh:123
sub_agent_set(agent *an_agent)
Definition: agent.hh:132
sub_agent_alert(agent *an_agent)
Definition: agent.hh:105