winss
state_listener.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 Morgan Stanley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIB_WINSS_SUPERVISE_STATE_LISTENER_HPP_
18 #define LIB_WINSS_SUPERVISE_STATE_LISTENER_HPP_
19 
20 #include <vector>
21 #include <queue>
22 #include "../control.hpp"
23 #include "state_file.hpp"
24 #include "supervise.hpp"
25 
26 namespace winss {
36 };
37 
42  private:
43  const winss::SuperviseStateFile& state_file;
45  std::queue<winss::SuperviseNotification> waiting;
47  public:
60 
66  bool IsEnabled();
67 
73  bool CanStart();
74 
78  void HandleConnected();
79 
85  bool HandleReceived(const std::vector<char>& message);
86 
91 };
92 } // namespace winss
93 
94 #endif // LIB_WINSS_SUPERVISE_STATE_LISTENER_HPP_
SuperviseStateListener & operator=(const SuperviseStateListener &)=delete
No copy.
Wait for the service to go down and back up.
Definition: state_listener.hpp:35
bool IsEnabled()
Gets if the listener is enabled.
Definition: state_listener.cpp:30
No-op.
Definition: state_listener.hpp:31
bool HandleReceived(const std::vector< char > &message)
Handle the received event.
Definition: state_listener.cpp:74
A listener for inbound control item events.
Definition: control.hpp:217
Wait for the finish process to end.
Definition: state_listener.hpp:34
Wait for the run process to end.
Definition: state_listener.hpp:33
A supervisor state listener which is race-condition free.
Definition: state_listener.hpp:41
Definition: case_ignore.hpp:23
Wait for the run process to start.
Definition: state_listener.hpp:32
SuperviseStateListener(const winss::SuperviseStateFile &state_file, SuperviseStateListenerAction action)
Supervise state listener constructor.
Definition: state_listener.cpp:25
SuperviseStateListenerAction
The actions which the listener can wait for.
Definition: state_listener.hpp:30
Serializes the state file but can also read it as a human-readable message.
Definition: state_file.hpp:31
bool CanStart()
Gets if the listener can start.
Definition: state_listener.cpp:34
void HandleConnected()
Handle the connected event.
Definition: state_listener.cpp:38