Skip to content

Commit

Permalink
Merge pull request #24313 from ianna/dd-name-cleanup
Browse files Browse the repository at this point in the history
DD Name Cleanup
  • Loading branch information
cmsbuild committed Aug 22, 2018
2 parents eb3f27d + e8c55f2 commit b36a732
Show file tree
Hide file tree
Showing 33 changed files with 309 additions and 682 deletions.
4 changes: 1 addition & 3 deletions DetectorDescription/Core/interface/DDAlgorithmHandler.h
Expand Up @@ -21,7 +21,7 @@ class DDAlgorithmHandler
//! initializes the wrapped algorithm algo_ and does some pre- and post-processing
/** pre- and postprocessing mainly covers exception handling,
the algorithm object algo_ is fetched from the plugin-manager */
void initialize( const std::string & algoName,
void initialize( const DDName & algoName,
const DDLogicalPart & parent,
const DDNumericArguments & nArgs,
const DDVectorArguments & vArgs,
Expand All @@ -34,8 +34,6 @@ class DDAlgorithmHandler

private:
std::unique_ptr<DDAlgorithm> algo_; //!< the wrapped algorithm object
std::string algoname_; //!< name of the algorithm object
DDLogicalPart parent_; //!< parent logical part
};

#endif // DD_DDALGORITHMHANDLER_H
16 changes: 0 additions & 16 deletions DetectorDescription/Core/interface/DDINumberingScheme.h

This file was deleted.

55 changes: 9 additions & 46 deletions DetectorDescription/Core/interface/DDName.h
@@ -1,5 +1,5 @@
#ifndef DDName_h
#define DDName_h
#ifndef DETECTOR_DESCRIPTION_CORE_DDNAME_H
#define DETECTOR_DESCRIPTION_CORE_DDNAME_H

#include <iosfwd>
#include <map>
Expand All @@ -14,32 +14,23 @@ class DDCurrentNamespace;
*/
class DDName
{
friend class DStreamer; // intrusive!

public:

typedef DDCurrentNamespace CNS;
typedef int id_type;
typedef std::map<std::pair<std::string,std::string>,id_type> Registry;
typedef std::vector<Registry::const_iterator> IdToName;
using id_type = int;
using Registry = std::map<std::pair<std::string, std::string>, id_type>;
using IdToName = std::vector<Registry::const_iterator>;

//! Constructs a DDName with name \a name and assigns \a name to the namespace \a ns.
DDName( const std::string & name,
const std::string & ns);
const std::string & ns );

//! Creates a DDName with \a name in the current namespace defined in the singleton DDCurrentNamespace
DDName( const std::string & name );
DDName( const char* name );
DDName( const char* name, const char* ns );
// DDName(pair<int,int>);
DDName(id_type);
//! register pre-defined ids
static void defineId( const std::pair<std::string,std::string> &, id_type id);

explicit DDName();

//! true, if a DDName with given name and namespace (ns) already is registerd, otherwise false
static bool exists(const std::string & name, const std::string & ns);
//! Returns the \a name
const std::string & name() const;

Expand All @@ -51,44 +42,16 @@ class DDName
*/
const std::string fullname() const { return ns() + ":" + name(); }

// DEPRECATED!!!
operator std::string() const { return ns() + ":" + name(); }

id_type id() const { return id_;}

bool operator<(const DDName & rhs) const { return id_ < rhs.id_; }
bool operator==(const DDName & rhs) const { return id_ == rhs.id_; }

private:

id_type id_;

static Registry::iterator registerName(const std::pair<std::string,std::string> & s);
};

//! DDNameInterface provides a common interface to DDD entities
/** DDLogicalPart, DDMaterial, DDSolids, ... all are uniquely identified by
their class and the value of their associated DDName.
DDNameInterface provides read-access to their DDName.
*/
struct DDNameInterface
{
virtual ~DDNameInterface() {}

//! Returns the \a name without the \a namespace
virtual const std::string & name() const=0; // name without namespace

//! Return the \a namespace
virtual const std::string & ns() const=0; // only the namespace

//! Return the DDName
DDName ddname() const { return DDName(name(),ns()); }

virtual operator bool() const=0;

//! \b don't \b use \b!
virtual int id() const=0; // dont't know if usefull ...
static Registry::iterator registerName( const std::pair<std::string, std::string> & s );
};

std::ostream & operator<<(std::ostream & os, const DDName & n);
std::ostream & operator<<( std::ostream & os, const DDName & n );

#endif
33 changes: 0 additions & 33 deletions DetectorDescription/Core/interface/DDNodeSelector.h

This file was deleted.

94 changes: 0 additions & 94 deletions DetectorDescription/Core/interface/DDNumberingScheme.h

This file was deleted.

5 changes: 2 additions & 3 deletions DetectorDescription/Core/src/DDAlgorithmHandler.cc
Expand Up @@ -6,16 +6,15 @@
class DDCompactView;

void
DDAlgorithmHandler::initialize( const std::string & algoName,
DDAlgorithmHandler::initialize( const DDName & algoName,
const DDLogicalPart & parent,
const DDNumericArguments & nArgs,
const DDVectorArguments & vArgs,
const DDMapArguments & mArgs,
const DDStringArguments & sArgs,
const DDStringVectorArguments & svArgs )
{
algoname_ = algoName;
algo_ = std::unique_ptr<DDAlgorithm>(DDAlgorithmFactory::get()->create( algoname_ ));
algo_ = std::unique_ptr<DDAlgorithm>(DDAlgorithmFactory::get()->create( algoName.fullname()));
algo_->setParent( parent );
algo_->initialize( nArgs, vArgs, mArgs, sArgs, svArgs );
}
Expand Down

0 comments on commit b36a732

Please sign in to comment.