From 88081fae1295151bc96c4b3785db456c2e8adc0d Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 27 Jan 2021 10:57:35 +0100 Subject: [PATCH] Added Path::contains(Instance*) method. --- hurricane/src/hurricane/Path.cpp | 11 +++++++++++ hurricane/src/hurricane/hurricane/Path.h | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hurricane/src/hurricane/Path.cpp b/hurricane/src/hurricane/Path.cpp index db9639c6..821d6a26 100644 --- a/hurricane/src/hurricane/Path.cpp +++ b/hurricane/src/hurricane/Path.cpp @@ -233,6 +233,17 @@ bool Path::isEmpty() const return (_sharedPath == NULL); } +int32_t Path::contains(Instance* element) const +// ******************************************** +{ + int32_t depth = 0; + for ( Instance* instance : getInstances() ) { + if (instance == element) return depth; + ++depth; + } + return -1; +} + void Path::makeEmpty() // ******************* { diff --git a/hurricane/src/hurricane/hurricane/Path.h b/hurricane/src/hurricane/hurricane/Path.h index b7de9067..0af8604c 100644 --- a/hurricane/src/hurricane/hurricane/Path.h +++ b/hurricane/src/hurricane/hurricane/Path.h @@ -17,9 +17,7 @@ // not, see . // **************************************************************************************************** -#ifndef HURRICANE_PATH -#define HURRICANE_PATH - +#pragma once #include "hurricane/Instances.h" #include "hurricane/Transformation.h" @@ -87,6 +85,7 @@ class Path { // ********** public: bool isEmpty() const; + public: int32_t contains(Instance*) const; // Updators // ******** @@ -115,9 +114,6 @@ class Path { INSPECTOR_PR_SUPPORT(Hurricane::Path); -#endif // HURRICANE_PATH - - // **************************************************************************************************** // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved // ****************************************************************************************************