state_machine_observer.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (Apache License)
3  *
4  * Copyright (c) 2018 Plus One Robotics
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #include "state_machine_observer.h"
20 
21 StateMachineObserver::StateMachineObserver(std::shared_ptr<packml_sm::AbstractStateMachine> sm) : sm_(sm)
22 {
23  sm_->stateChangedEvent.bind_member_func(this, &StateMachineObserver::handleStateChanged);
24 }
25 
27 {
28  sm_->stateChangedEvent.unbind_member_func(this, &StateMachineObserver::handleStateChanged);
29 }
30 
31 void StateMachineObserver::setStateChangedCallback(std::function<void(int)> callback)
32 {
33  state_changed_callback_ = callback;
34 }
35 
38 {
39  state_changed_callback_(static_cast<int>(args.value));
40 }
std::function< void(int)> state_changed_callback_
The StateMachineInterface class defines a implementation independent interface to a PackML state mach...
void setStateChangedCallback(std::function< void(int)> callback)
StateMachineObserver(std::shared_ptr< packml_sm::AbstractStateMachine > sm)
std::shared_ptr< packml_sm::AbstractStateMachine > sm_
void handleStateChanged(packml_sm::AbstractStateMachine &state_machine, const packml_sm::StateChangedEventArgs &args)


packml_sm
Author(s): Shaun Edwards
autogenerated on Fri Jul 12 2019 03:30:55