mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Delete special member functions where they are not used. (as part of applying suggestions from cppcoreguidelines-special-member-functions) These classes don't need to be copyable/movable: # copy/move not used: zmq:: TransportFactory, Socket, Message, UnmanagedRegion, Poller, Context shm:: TransportFactory, Socket, Message, UnmanagedRegion, Poller ofi:: TransportFactory, Socket, Message, Context shm:: ZMsg, Region, Monitor, TerminalConfig, Manager plugins:: Config, Control, TerminalConfig fairmq::StateQueue, StateMachine, ProgOptions, PluginServices, PluginManager, Plugin, Device, StateSubscription TestData, BadDevice, TestDevice (test suite heplers) # used via ptr interface: fairmq::UnmanagedRegion, TransportFactory, Socket, Poller, Message These classes need to be movable/copyable: MyClass (test suite helper), fairmq::Channel, fairmq::Parts
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
/********************************************************************************
|
|
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
|
* *
|
|
* This software is distributed under the terms of the *
|
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
|
* copied verbatim in the file "LICENSE" *
|
|
********************************************************************************/
|
|
|
|
#ifndef FAIRMQSTATEMACHINE_H_
|
|
#define FAIRMQSTATEMACHINE_H_
|
|
|
|
#include <fairmq/States.h>
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <functional>
|
|
#include <stdexcept>
|
|
|
|
namespace fair::mq
|
|
{
|
|
|
|
class StateMachine
|
|
{
|
|
public:
|
|
StateMachine();
|
|
StateMachine(const StateMachine&) = delete;
|
|
StateMachine(StateMachine&&) = delete;
|
|
StateMachine& operator=(const StateMachine&) = delete;
|
|
StateMachine& operator=(StateMachine&&) = delete;
|
|
~StateMachine();
|
|
|
|
bool ChangeState(Transition transition);
|
|
bool ChangeState(const std::string& transition) { return ChangeState(GetTransition(transition)); }
|
|
|
|
void SubscribeToStateChange(const std::string& key, std::function<void(const State)> callback);
|
|
void UnsubscribeFromStateChange(const std::string& key);
|
|
|
|
void HandleStates(std::function<void(const State)> callback);
|
|
void StopHandlingStates();
|
|
|
|
void SubscribeToNewTransition(const std::string& key, std::function<void(const Transition)> callback);
|
|
void UnsubscribeFromNewTransition(const std::string& key);
|
|
|
|
bool NewStatePending() const;
|
|
void WaitForPendingState() const;
|
|
bool WaitForPendingStateFor(int durationInMs) const;
|
|
|
|
State GetCurrentState() const;
|
|
std::string GetCurrentStateName() const;
|
|
|
|
void Start();
|
|
|
|
void ProcessWork();
|
|
|
|
struct ErrorStateException : std::runtime_error { using std::runtime_error::runtime_error; };
|
|
|
|
private:
|
|
std::shared_ptr<void> fFsm;
|
|
};
|
|
|
|
} // namespace fair::mq
|
|
|
|
#endif /* FAIRMQSTATEMACHINE_H_ */
|