mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
cleanup operator<<(ostream, *)
- basic implementation for StagePrivate - implementation for Stage calls this - implementation for ContainerBase recursively calls this - implementation for Task added
This commit is contained in:
parent
1f4264c8c8
commit
a4feb705d0
@ -76,6 +76,7 @@ public:
|
||||
protected:
|
||||
ContainerBase(ContainerBasePrivate* impl);
|
||||
};
|
||||
std::ostream& operator<<(std::ostream& os, const ContainerBase& stage);
|
||||
|
||||
|
||||
class SerialContainerPrivate;
|
||||
|
||||
@ -86,7 +86,7 @@ typedef std::pair<const InterfaceState&, const InterfaceState&> InterfaceStatePa
|
||||
/// exception thrown by Stage::init()
|
||||
/// It collects individual errors in stages throughout the pipeline to allow overall error reporting
|
||||
class InitStageException : public std::exception {
|
||||
friend std::ostream& operator<<(std::ostream &os, const InitStageException& e);
|
||||
friend std::ostream& operator<<(std::ostream& os, const InitStageException& e);
|
||||
|
||||
public:
|
||||
explicit InitStageException() {}
|
||||
@ -112,8 +112,6 @@ std::ostream& operator<<(std::ostream &os, const InitStageException& e);
|
||||
class ContainerBase;
|
||||
class StagePrivate;
|
||||
class Stage {
|
||||
friend std::ostream& operator<<(std::ostream &os, const Stage& stage);
|
||||
|
||||
public:
|
||||
PRIVATE_CLASS(Stage)
|
||||
typedef std::unique_ptr<Stage> pointer;
|
||||
@ -175,7 +173,7 @@ protected:
|
||||
protected:
|
||||
StagePrivate* const pimpl_; // constness guarantees one initial write
|
||||
};
|
||||
std::ostream& operator<<(std::ostream &os, const Stage& stage);
|
||||
std::ostream& operator<<(std::ostream& os, const Stage& stage);
|
||||
|
||||
|
||||
class ComputeBasePrivate;
|
||||
@ -299,5 +297,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} }
|
||||
|
||||
@ -52,7 +52,7 @@ namespace moveit { namespace task_constructor {
|
||||
class ContainerBase;
|
||||
class StagePrivate {
|
||||
friend class Stage;
|
||||
friend std::ostream& operator<<(std::ostream &os, const StagePrivate& stage);
|
||||
friend std::ostream& operator<<(std::ostream& os, const StagePrivate& stage);
|
||||
|
||||
public:
|
||||
typedef std::list<Stage::pointer> container_type;
|
||||
@ -120,7 +120,7 @@ private:
|
||||
Introspection* introspection_; // task's introspection instance
|
||||
};
|
||||
PIMPL_FUNCTIONS(Stage)
|
||||
std::ostream& operator<<(std::ostream &os, const StagePrivate& stage);
|
||||
std::ostream& operator<<(std::ostream& os, const StagePrivate& stage);
|
||||
|
||||
|
||||
// ComputeBasePrivate is the base class for all computing stages, i.e. non-containers.
|
||||
|
||||
@ -139,4 +139,9 @@ private:
|
||||
std::list<Task::TaskCallback> task_cbs_; // functions to monitor task's planning progress
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const Task& task) {
|
||||
task.printState(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
@ -225,6 +225,15 @@ void ContainerBase::init(const planning_scene::PlanningSceneConstPtr &scene)
|
||||
throw errors;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ContainerBase& container) {
|
||||
ContainerBase::StageCallback processor = [&os](const Stage& stage, int depth) -> bool {
|
||||
os << std::string(2*depth, ' ') << *stage.pimpl() << std::endl;
|
||||
return true;
|
||||
};
|
||||
container.traverseRecursively(processor);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
struct SolutionCollector {
|
||||
SolutionCollector(size_t max_depth) : max_depth(max_depth) {}
|
||||
|
||||
@ -61,7 +61,7 @@ const char *InitStageException::what() const noexcept
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const InitStageException& e) {
|
||||
std::ostream& operator<<(std::ostream& os, const InitStageException& e) {
|
||||
os << e.what() << std::endl;
|
||||
for (const auto &pair : e.errors_)
|
||||
os << pair.first->name() << ": " << pair.second << std::endl;
|
||||
@ -183,26 +183,25 @@ const char* direction(const StagePrivate& stage) {
|
||||
return "<-";
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream &os, const Stage& stage) {
|
||||
auto impl = stage.pimpl();
|
||||
std::ostream& operator<<(std::ostream& os, const StagePrivate& impl) {
|
||||
// starts
|
||||
for (const InterfaceConstPtr& i : {impl->prevEnds(), impl->starts()}) {
|
||||
for (const InterfaceConstPtr& i : {impl.prevEnds(), impl.starts()}) {
|
||||
os << std::setw(3);
|
||||
if (i) os << i->size();
|
||||
else os << "-";
|
||||
}
|
||||
// trajectories
|
||||
os << std::setw(5) << direction<READS_START, WRITES_PREV_END>(*impl)
|
||||
<< std::setw(3) << stage.numSolutions()
|
||||
<< std::setw(5) << direction<READS_END, WRITES_NEXT_START>(*impl);
|
||||
os << std::setw(5) << direction<READS_START, WRITES_PREV_END>(impl)
|
||||
<< std::setw(3) << impl.me()->numSolutions()
|
||||
<< std::setw(5) << direction<READS_END, WRITES_NEXT_START>(impl);
|
||||
// ends
|
||||
for (const InterfaceConstPtr& i : {impl->ends(), impl->nextStarts()}) {
|
||||
for (const InterfaceConstPtr& i : {impl.ends(), impl.nextStarts()}) {
|
||||
os << std::setw(3);
|
||||
if (i) os << i->size();
|
||||
else os << "-";
|
||||
}
|
||||
// name
|
||||
os << " / " << stage.name();
|
||||
os << " / " << impl.name();
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -550,4 +549,9 @@ void Connecting::connect(const InterfaceState& from, const InterfaceState& to,
|
||||
impl->newSolution(trajectory);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Stage& stage) {
|
||||
os << *stage.pimpl();
|
||||
return os;
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
@ -286,13 +286,8 @@ std::string Task::id() const
|
||||
return id_;
|
||||
}
|
||||
|
||||
void Task::printState(std::ostream& os) const
|
||||
{
|
||||
ContainerBase::StageCallback processor = [&os](const Stage& stage, int depth) -> bool {
|
||||
os << std::string(2*depth, ' ') << stage << std::endl;
|
||||
return true;
|
||||
};
|
||||
stages()->traverseRecursively(processor);
|
||||
void Task::printState(std::ostream& os) const {
|
||||
os << *stages();
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user