Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD Name Unit Test #24326

Merged
merged 11 commits into from Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
8 changes: 5 additions & 3 deletions DetectorDescription/Core/interface/DDBase.h
Expand Up @@ -67,7 +67,8 @@ template <class N, class C>
static auto end() { return StoreT::instance().end(); }
static auto begin() { return StoreT::instance().begin(); }

DDBase() : prep_(nullptr) { }
DDBase()
: prep_( nullptr ) { }
virtual ~DDBase() { /*never do this here: if (prep_) delete prep_;*/ }

const N & name() const { return prep_->name(); }
Expand Down Expand Up @@ -118,14 +119,15 @@ template <class N, class C>
: false;
}
void create( const N& name, C vals ) {
prep_ = StoreT::instance().create( name, vals );
prep_ = StoreT::instance().create( name, std::move( vals ) );
}
void create( const N& name ) {
prep_ = StoreT::instance().create( name );
}

private:
DDI::rep_type<N, C>* prep_;

DDI::rep_type<N, C>* prep_;
};

#endif
14 changes: 6 additions & 8 deletions DetectorDescription/Core/interface/DDCompactView.h
Expand Up @@ -7,6 +7,7 @@
#include <utility>
#include <vector>

#include "DetectorDescription/Core/interface/DDCompactViewImpl.h"
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include "DetectorDescription/Core/interface/DDTranslation.h"
#include "DetectorDescription/Core/interface/Store.h"
Expand All @@ -16,7 +17,6 @@
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDCompactViewImpl;
class DDDivision;
class DDName;
struct DDPosData;
Expand Down Expand Up @@ -92,8 +92,6 @@ class DDCompactView
//! \b EXPERIMENTAL! Creates a compact-view using a different root of the geometrical hierarchy
explicit DDCompactView(const DDLogicalPart & rootnodedata);

~DDCompactView();

//! Provides read-only access to the data structure of the compact-view.
const Graph & graph() const;
GraphWalker walker() const;
Expand Down Expand Up @@ -136,11 +134,11 @@ class DDCompactView
std::unique_ptr<DDCompactViewImpl> rep_;
std::unique_ptr<DDPosData> worldpos_ ;

DDI::Store<DDName, DDI::Material*> matStore_;
DDI::Store<DDName, DDI::Solid*> solidStore_;
DDI::Store<DDName, DDI::LogicalPart*> lpStore_;
DDI::Store<DDName, DDI::Specific*> specStore_;
DDI::Store<DDName, DDRotationMatrix*> rotStore_;
DDI::Store<DDName, std::unique_ptr<DDI::Material>> matStore_;
DDI::Store<DDName, std::unique_ptr<DDI::Solid>> solidStore_;
DDI::Store<DDName, std::unique_ptr<DDI::LogicalPart>> lpStore_;
DDI::Store<DDName, std::unique_ptr<DDI::Specific>> specStore_;
DDI::Store<DDName, std::unique_ptr<DDRotationMatrix>> rotStore_;
};

#endif
7 changes: 4 additions & 3 deletions DetectorDescription/Core/interface/DDConstant.h
Expand Up @@ -3,6 +3,7 @@

#include <iostream>
#include <vector>
#include <memory>

#include "DetectorDescription/Core/interface/DDBase.h"
#include "DetectorDescription/Core/interface/DDName.h"
Expand All @@ -14,7 +15,7 @@ class ClhepEvaluator;
std::ostream & operator<<(std::ostream & o, const DDConstant & cons);

//! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>
class DDConstant : public DDBase<DDName, double * >
class DDConstant : public DDBase<DDName, std::unique_ptr<double> >
{
public:
//! an uninitialized constant; one can assign an initialized constant to make it valid
Expand All @@ -24,7 +25,7 @@ class DDConstant : public DDBase<DDName, double * >
DDConstant(const DDName & name);

//! creation of a new named constant; if it already existed with the given name, it's overwritten with new values
DDConstant(const DDName & name, double* value);
DDConstant(const DDName & name, std::unique_ptr<double> value);

//! creates all DDConstants from the variables of the ClhepEvaluator
static void createConstantsFromEvaluator(ClhepEvaluator&);
Expand All @@ -37,6 +38,6 @@ class DDConstant : public DDBase<DDName, double * >
};

//! std::maps the XML naming convention, i.e. <Numeric name='foo' value='4711'/> -> DDNumeric
typedef DDConstant DDNumeric;
using DDNumeric = DDConstant;

#endif
3 changes: 2 additions & 1 deletion DetectorDescription/Core/interface/DDDivision.h
Expand Up @@ -55,6 +55,7 @@

#include <iosfwd>
#include <map>
#include <memory>
#include <string>
#include <vector>

Expand All @@ -75,7 +76,7 @@ namespace DDI {

std::ostream & operator<<( std::ostream &, const DDDivision &);

class DDDivision : public DDBase<DDName, DDI::Division*>
class DDDivision : public DDBase<DDName, std::unique_ptr<DDI::Division> >
{
public:

Expand Down
16 changes: 0 additions & 16 deletions DetectorDescription/Core/interface/DDINumberingScheme.h

This file was deleted.

5 changes: 3 additions & 2 deletions DetectorDescription/Core/interface/DDLogicalPart.h
Expand Up @@ -3,6 +3,7 @@

#include <iosfwd>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -89,11 +90,11 @@ std::ostream & operator<<( std::ostream &, const DDLogicalPart &);
}
\endcode
*/
class DDLogicalPart : public DDBase<DDName,DDI::LogicalPart*>
class DDLogicalPart : public DDBase<DDName,std::unique_ptr<DDI::LogicalPart> >
{
public:
//! The default constructor provides an uninitialzed reference object.
DDLogicalPart( void ) : DDBase<DDName,DDI::LogicalPart*>(){ }
DDLogicalPart( void ) : DDBase<DDName,std::unique_ptr<DDI::LogicalPart> >(){ }

//! Creates a reference object referring to the appropriate XML specification.
DDLogicalPart( const DDName & name );
Expand Down
11 changes: 6 additions & 5 deletions DetectorDescription/Core/interface/DDMap.h
Expand Up @@ -3,6 +3,7 @@

#include <iostream>
#include <map>
#include <memory>
#include <string>

#include "DetectorDescription/Core/interface/DDReadMapType.h"
Expand All @@ -15,17 +16,17 @@ class DDMap;
std::ostream & operator<<(std::ostream & o, const DDMap & cons);

//! simply a std::map<std::string,double> supporting an addional operator[] const
typedef ReadMapType<double> dd_map_type;
using dd_map_type = ReadMapType<double>;

//! a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector>
class DDMap : public DDBase<DDName, dd_map_type* >
class DDMap : public DDBase<DDName, std::unique_ptr<dd_map_type> >
{
public:
//! the type of the managed object
typedef dd_map_type value_type;
using value_type = dd_map_type;

//! size type for the size of the stored values
typedef dd_map_type::size_type size_t;
using size_t = dd_map_type::size_type;

//! an uninitialized constant; one can assign an initialized constant to make it valid
DDMap();
Expand All @@ -34,7 +35,7 @@ class DDMap : public DDBase<DDName, dd_map_type* >
DDMap(const DDName & name);

//! creation of a new named constant; if it already existed with the given name, it's overwritten with new values
DDMap(const DDName & name, dd_map_type* value);
DDMap(const DDName & name, std::unique_ptr<dd_map_type> value);

//! the size of the array of values
size_t size() const { return rep().size(); }
Expand Down
5 changes: 3 additions & 2 deletions DetectorDescription/Core/interface/DDMaterial.h
Expand Up @@ -2,6 +2,7 @@
#define DDMaterial_h

#include <iostream>
#include <memory>
#include <vector>
#include <utility>
#include "DetectorDescription/Core/interface/DDName.h"
Expand Down Expand Up @@ -39,12 +40,12 @@ namespace DDI { class Material; }
to specify the units of the quantities
making up a material.
*/
class DDMaterial : public DDBase<DDName,DDI::Material*>
class DDMaterial : public DDBase<DDName,std::unique_ptr<DDI::Material>>
{
friend std::ostream & operator<<(std::ostream &, const DDMaterial &);

public:
typedef std::vector<std::pair<DDMaterial,double> > FractionV;
using FractionV = std::vector<std::pair<DDMaterial, double>>;

//! Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference objects)
DDMaterial();
Expand Down
57 changes: 11 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,18 @@ class DDName
*/
const std::string fullname() const { return ns() + ":" + name(); }

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

id_type id() const { return id_;}

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.