Skip to content

Commit

Permalink
Added code to return full name re #5659
Browse files Browse the repository at this point in the history
Compiles but still needs testing

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Sep 7, 2012
1 parent 3cad034 commit 0697b0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "MantidGeometry/DllConfig.h"
#include "MantidGeometry/Instrument/ParameterMap.h"
#include <string>
#include <iostream>
#include <sstream>
#include <typeinfo>
#include <vector>
#include <Poco/SAX/Attributes.h>
Expand Down Expand Up @@ -101,6 +103,9 @@ namespace Mantid
//! Get the IComponent name
std::string getName() const;

//! Get the full pathname
std::string getFullName() const;

//! Set the IComponent position, x, y, z respective to parent (if present) otherwise absolute
void setPos(double, double, double);
void setPos(const Kernel::V3D&);
Expand Down
19 changes: 19 additions & 0 deletions Code/Mantid/Framework/Geometry/src/Instrument/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ namespace Geometry
return m_name;
}

/** Get the full path name of the Component
* @return this.name
*/
std::string Component::getFullName() const
{
std::vector<boost::shared_ptr<const IComponent> > ancestors = this->getAncestors();
if( ancestors.size() == 0) {
return this->getName();
} else {
std::ostringstream oss;
std::vector<boost::shared_ptr<const IComponent> >::reverse_iterator rit;
for ( rit=ancestors.rbegin() ; rit < ancestors.rend(); ++rit ) {
oss << *rit << "/";
}
oss << this->getName();
return oss.str();
}
}

/** Set the position of the Component
* The position is with respect to the parent Component
* @param x :: x position
Expand Down

0 comments on commit 0697b0d

Please sign in to comment.