Main Page
Namespaces
Classes
Files
File List
File Members
test
state_machine_visited_states_queue.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_visited_states_queue.h
"
19
#include <functional>
20
21
StateMachineVisitedStatesQueue::StateMachineVisitedStatesQueue
(std::shared_ptr<packml_sm::AbstractStateMachine> sm)
22
: observer_(sm)
23
{
24
observer_
.
setStateChangedCallback
(
25
std::bind(&
StateMachineVisitedStatesQueue::stateChanged
,
this
, std::placeholders::_1));
26
}
27
28
bool
StateMachineVisitedStatesQueue::isEmpty
()
29
{
30
return
visited_states_
.size() == 0;
31
}
32
33
void
StateMachineVisitedStatesQueue::clear
()
34
{
35
visited_states_
.empty();
36
}
37
38
int
StateMachineVisitedStatesQueue::nextState
()
39
{
40
auto
result = -1;
41
if
(
visited_states_
.size() > 0)
42
{
43
result =
visited_states_
.front();
44
visited_states_
.pop();
45
}
46
47
return
result;
48
}
49
50
void
StateMachineVisitedStatesQueue::stateChanged
(
int
new_state)
51
{
52
visited_states_
.push(new_state);
53
}
StateMachineVisitedStatesQueue::observer_
StateMachineObserver observer_
Definition:
state_machine_visited_states_queue.h:33
StateMachineVisitedStatesQueue::StateMachineVisitedStatesQueue
StateMachineVisitedStatesQueue(std::shared_ptr< packml_sm::AbstractStateMachine > sm)
Definition:
state_machine_visited_states_queue.cpp:21
StateMachineVisitedStatesQueue::clear
void clear()
Definition:
state_machine_visited_states_queue.cpp:33
StateMachineObserver::setStateChangedCallback
void setStateChangedCallback(std::function< void(int)> callback)
Definition:
state_machine_observer.cpp:31
StateMachineVisitedStatesQueue::isEmpty
bool isEmpty()
Definition:
state_machine_visited_states_queue.cpp:28
StateMachineVisitedStatesQueue::stateChanged
void stateChanged(int new_state)
Definition:
state_machine_visited_states_queue.cpp:50
StateMachineVisitedStatesQueue::visited_states_
std::queue< int > visited_states_
Definition:
state_machine_visited_states_queue.h:34
state_machine_visited_states_queue.h
StateMachineVisitedStatesQueue::nextState
int nextState()
Definition:
state_machine_visited_states_queue.cpp:38
packml_sm
Author(s): Shaun Edwards
autogenerated on Fri Jul 12 2019 03:30:55