Go to the documentation of this file.
6 #ifndef CNOID_UTIL_TASK_H
7 #define CNOID_UTIL_TASK_H
9 #include <cnoid/Referenced>
10 #include <cnoid/Signal>
14 #include "exportdecl.h"
19 class AbstractTaskSequencer;
25 virtual int currentPhaseIndex()
const = 0;
26 virtual bool isAutoMode()
const = 0;
27 virtual void breakSequence() = 0;
28 virtual void setNextCommand(
int commandIndex) = 0;
29 virtual void setNextPhase(
int phaseIndex) = 0;
30 virtual void setCommandLinkAutomatic() = 0;
31 virtual bool executeCommand(
int index) = 0;
32 virtual bool wait(
double sec) = 0;
33 virtual bool waitForCommandToFinish(
double timeout = 0.0) = 0;
34 virtual bool waitForCommandToFinish(
Connection connectionToDisconnect,
double timeout) = 0;
35 virtual void notifyCommandFinish(
bool isCompleted =
true) = 0;
37 bool waitForSignal(
SignalProxy<
void()> signalProxy,
double timeout = 0.0);
38 bool waitForBooleanSignal(
SignalProxy<
void(
bool)> signalProxy,
double timeout = 0.0);
49 void setChecked(
bool on);
55 Signal<void(
bool on)> sigToggled_;
68 const std::string&
caption()
const {
return caption_; }
74 const std::string&
description()
const {
return description_; }
76 description_ = description;
return this; }
78 TaskFunc function()
const {
return function_; }
88 bool isChecked()
const;
90 int nextPhaseIndex(
int currentPhaseIndex)
const;
95 int nextCommandIndex(
int currentCommandIndex)
const;
97 TaskCommand* setCommandLinkStep(
int commandIndexStep);
103 int level()
const {
return level_; }
108 std::string caption_;
109 std::string description_;
112 int nextCommandIndex_;
115 bool isNextPhaseRelative_;
116 bool isNextCommandRelative_;
117 bool isCommandLinkAutomatic_;
137 virtual TaskPhase* clone(
bool doDeepCopy =
true);
139 const std::string&
caption()
const {
return caption_; }
140 void setCaption(
const std::string&
str);
149 TaskCommand* addCommand(
const std::string& caption);
151 TaskCommand* addToggleCommand(
const std::string& caption);
158 int maxCommandLevel()
const;
161 std::string caption_;
163 std::vector<TaskCommandPtr> commands;
175 void setCommandLevel(
int level);
179 TaskCommand* addCommand(
const std::string& caption);
181 TaskCommand* addToggleCommand(
const std::string& caption);
196 virtual void addMenuItem(
const std::string& caption, std::function<
void()> func) = 0;
197 virtual void addCheckMenuItem(
const std::string& caption,
bool isChecked, std::function<
void(
bool on)> func) = 0;
198 virtual void addMenuSeparator() = 0;
206 Task(
const std::string& name,
const std::string& caption);
207 Task(
const Task& org,
bool doDeepCopy =
true);
210 const std::string&
name()
const {
return name_; }
211 void setName(
const std::string&
str);
212 const std::string&
caption()
const {
return caption_; }
213 void setCaption(
const std::string&
str);
219 TaskPhase* addPhase(
const std::string& caption);
225 TaskCommand* addCommand(
const std::string& caption);
227 TaskCommand* addToggleCommand(
const std::string& caption);
229 int lastCommandIndex();
231 int maxCommandLevel()
const;
233 TaskFunc funcToSetCommandLink(
int commandIndex)
const;
241 virtual void onMenuRequest(
TaskMenu& menu);
245 std::string caption_;
246 std::vector<TaskPhasePtr> phases_;
bool isCommandLinkAutomatic() const
Definition: Task.h:99
bool isSkipped() const
Definition: Task.h:142
const std::string & caption() const
Definition: Task.h:212
int numPhases() const
Definition: Task.h:215
TaskCommand * linkToNextPhase()
Definition: Task.h:93
Definition: ValueTree.h:253
ref_ptr< Task > TaskPtr
Definition: Task.h:249
ref_ptr< TaskCommand > TaskCommandPtr
Definition: Task.h:123
bool isChecked() const
Definition: Task.h:48
ref_ptr< TaskToggleState > TaskToggleStatePtr
Definition: Task.h:58
TaskCommand * lastCommand() const
Definition: Task.h:155
TaskCommand * setDescription(const std::string &description)
Definition: Task.h:75
std::string str(const Vector3 &v)
Definition: EigenUtil.cpp:206
void setSkipped(bool on)
Definition: Task.h:143
ref_ptr< TaskPhase > TaskPhasePtr
Definition: Task.h:167
TaskCommand * linkToNextCommand()
Definition: Task.h:98
TaskCommand * setCaption(const std::string &caption)
Definition: Task.h:69
std::function< void(TaskProc *proc)> TaskFunc
Definition: Task.h:42
const std::string & caption() const
Definition: Task.h:139
int numCommands() const
Definition: Task.h:152
const std::string & caption() const
Definition: Task.h:68
int lastCommandIndex() const
Definition: Task.h:154
Definition: AbstractSceneLoader.h:11
TaskCommand * setDefault(bool on=true)
Definition: Task.h:81
const std::string & description() const
Definition: Task.h:74
SignalProxy< void(bool on)> sigToggled()
Definition: Task.h:51
int level() const
Definition: Task.h:103
Definition: Referenced.h:54
bool isDefault() const
Definition: Task.h:82
TaskFunc preCommand() const
Definition: Task.h:146
ref_ptr< TaskPhaseProxy > TaskPhaseProxyPtr
Definition: Task.h:126
int commandLevel() const
Definition: Task.h:176
TaskCommand * setFunction(TaskFunc func)
Definition: Task.h:79
TaskCommand * setCommandLinkAutomatic(bool on=true)
Definition: Task.h:100
TaskCommand * setLevel(int level)
Definition: Task.h:102
Definition: AbstractTaskSequencer.h:14
const std::string & name() const
Definition: Task.h:210