Skip to content

Commit

Permalink
Revert "DD: Current Namespace is a Singleton, so make it one"
Browse files Browse the repository at this point in the history
  • Loading branch information
ianna committed Sep 4, 2018
1 parent d23b29e commit e8e769a
Show file tree
Hide file tree
Showing 77 changed files with 133 additions and 227 deletions.
17 changes: 5 additions & 12 deletions DetectorDescription/Core/interface/DDCurrentNamespace.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
#ifndef DETECTOR_DESCRIPTION_DD_CURRENT_NAMESPACE_H
#define DETECTOR_DESCRIPTION_DD_CURRENT_NAMESPACE_H
#ifndef DDCurrentNamespace_h
#define DDCurrentNamespace_h

#include "DetectorDescription/Core/interface/DDSingleton.h"
#include <iostream>
#include <string>

struct DDCurrentNamespace;

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

struct DDCurrentNamespace : public dd::DDSingleton<std::string, DDCurrentNamespace>
class DDCurrentNamespace
{
DDCurrentNamespace() : DDSingleton(1) {}
static std::unique_ptr<std::string> init() {
return std::make_unique<std::string>( "GLOBAL" ); }
public:
static std::string & ns();
};

#endif
2 changes: 2 additions & 0 deletions DetectorDescription/Core/interface/DDName.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <utility>
#include <vector>

class DDCurrentNamespace;

//! DDName is used to identify DDD entities uniquely.
/** A DDName consists of a \a name and a \a namespace. Both are represented as std::string.
*/
Expand Down
40 changes: 0 additions & 40 deletions DetectorDescription/Core/interface/DDSingleton.h

This file was deleted.

6 changes: 3 additions & 3 deletions DetectorDescription/Core/plugins/DDAngular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ DDAngular::initialize( const DDNumericArguments & nArgs,
LogDebug( "DDAlgorithm" ) << " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << CONVERT_TO( temp.Angle(), deg );
m_solidRot = temp * m_solidRot;
}
DDCurrentNamespace ns;
m_idNameSpace = *ns;

m_idNameSpace = DDCurrentNamespace::ns();
m_childNmNs = DDSplit( sArgs["ChildName"] );
if( m_childNmNs.second.empty())
m_childNmNs.second = *ns;
m_childNmNs.second = DDCurrentNamespace::ns();

DDName parentName = parent().name();
LogDebug( "DDAlgorithm" ) << "DDAngular: Parent " << parentName
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/Core/plugins/DDLinear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DDLinear::initialize( const DDNumericArguments & nArgs,

m_childNmNs = DDSplit( sArgs["ChildName"] );
if( m_childNmNs.second.empty())
m_childNmNs.second = *DDCurrentNamespace();
m_childNmNs.second = DDCurrentNamespace::ns();

DDName parentName = parent().name();
LogDebug( "DDAlgorithm" ) << "DDLinear: Parent " << parentName
Expand Down
7 changes: 5 additions & 2 deletions DetectorDescription/Core/src/DDCurrentNamespace.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "DetectorDescription/Core/interface/DDCurrentNamespace.h"

std::ostream & operator<<( std::ostream & os, const DDCurrentNamespace & ns ) {
return os << *ns;
std::string &
DDCurrentNamespace::ns()
{
static std::string ns_ = "GLOBAL";
return ns_;
}
4 changes: 2 additions & 2 deletions DetectorDescription/Core/src/DDName.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DDName::DDName( const std::string & name )
{
std::pair<std::string, std::string> result = DDSplit( name );
if( result.second.empty()) {
id_ = registerName( std::make_pair( result.first, DDCurrentNamespace()->c_str()))->second;
id_ = registerName( std::make_pair( result.first, DDCurrentNamespace::ns()))->second;
}
else {
id_ = registerName( result )->second;
Expand All @@ -34,7 +34,7 @@ DDName::DDName( const char* name )
{
std::pair< std::string, std::string > result = DDSplit( name );
if( result.second.empty()) {
id_ = registerName( std::make_pair( result.first, DDCurrentNamespace()->c_str()))->second;
id_ = registerName( std::make_pair( result.first, DDCurrentNamespace::ns()))->second;
}
else {
id_ = registerName( result )->second;
Expand Down
2 changes: 0 additions & 2 deletions DetectorDescription/Core/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
</bin>
<bin name="testUnits" file="testRunner.cpp,DDUnits.cppunit.cc">
</bin>
<bin name="testDDCurrentNamespace" file="testRunner.cpp,DDCurrentNamespace.cppunit.cc">
</bin>
<bin file="clhepToROOTMath.cpp">
</bin>
<bin file="test_DDRotation.cpp">
Expand Down
49 changes: 0 additions & 49 deletions DetectorDescription/Core/test/DDCurrentNamespace.cppunit.cc

This file was deleted.

10 changes: 5 additions & 5 deletions DetectorDescription/Parser/src/DDLSAX2FileHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ DDLSAX2FileHandler::endElement( const XMLCh* const uri,
// The need for processElement to have the nmspace so that it can
// do the necessary gymnastics made things more complicated in the
// effort to allow fully user-controlled namespaces. So the "magic"
// trick of setting nmspace to "!" is used
// FIXME:
// trick of setting nmspace to "!" is used :(... I don't like this magic trick
// -- Michael Case 2008-11-06
// OPTIMISE in the near future, like the current nmspace_ impl.
// just set nmspace_ to "!" from Parser based on userNS_ so
// userNS_ is set by parser ONCE and no if nec. here.
// userNS_ is set by parser ONCE and no if nec. here. MEC: 2009-06-22
if ( userNS_ ) {
nmspace = "!";
}

DDCurrentNamespace ns;
*ns = nmspace;
DDCurrentNamespace::ns() = nmspace;
// tell the element it's parent name for recording/reporting purposes
myElement->setParent(parent());
myElement->setSelf(self());
Expand Down
3 changes: 1 addition & 2 deletions Geometry/EcalCommonData/src/DDEcalBarrelAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ void DDEcalBarrelAlgo::initialize(const DDNumericArguments & nArgs,
const DDStringVectorArguments & vsArgs) {

LogDebug("EcalGeom") << "DDEcalBarrelAlgo info: Initialize" ;
DDCurrentNamespace ns;
m_idNameSpace = *ns;
m_idNameSpace = DDCurrentNamespace::ns();
// TRICK!
m_idNameSpace = parent().name().ns();
// barrel parent volume
Expand Down
3 changes: 1 addition & 2 deletions Geometry/EcalCommonData/src/DDEcalBarrelNewAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@ void DDEcalBarrelNewAlgo::initialize(const DDNumericArguments & nArgs,
const DDStringVectorArguments & vsArgs) {

LogDebug("EcalGeom") << "DDEcalBarrelAlgo info: Initialize" ;
DDCurrentNamespace ns;
m_idNameSpace = *ns;
m_idNameSpace = DDCurrentNamespace::ns();
// TRICK!
m_idNameSpace = parent().name().ns();
// barrel parent volume
Expand Down
8 changes: 4 additions & 4 deletions Geometry/EcalCommonData/src/DDEcalEndcapAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ void DDEcalEndcapAlgo::initialize(const DDNumericArguments & nArgs,
const DDVectorArguments & vArgs,
const DDMapArguments & /*mArgs*/,
const DDStringArguments & sArgs,
const DDStringVectorArguments & /*vsArgs*/)
{
DDCurrentNamespace ns;
m_idNameSpace = *ns;
const DDStringVectorArguments & /*vsArgs*/) {

// edm::LogInfo("EcalGeom") << "DDEcalEndcapAlgo info: Initialize" ;
m_idNameSpace = DDCurrentNamespace::ns();
// TRICK!
m_idNameSpace = parent().name().ns();
// barrel parent volume
Expand Down
3 changes: 1 addition & 2 deletions Geometry/EcalTestBeam/plugins/DDTBH4Algo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ void DDTBH4Algo::initialize(const DDNumericArguments& nArgs,
const DDStringArguments& sArgs,
const DDStringVectorArguments& vsArgs )
{
DDCurrentNamespace ns;
m_idNameSpace = *ns;
m_idNameSpace = DDCurrentNamespace::ns();
m_BLZBeg = nArgs["BLZBeg"];
m_BLZEnd = nArgs["BLZEnd"];
m_BLZPiv = nArgs["BLZPiv"];
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ void DDAHcalModuleAlgo::initialize(const DDNumericArguments & nArgs,
std::cout << std::endl;
#endif
zMinBlock = nArgs["zMinBlock"];
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
std::cout << "DDAHcalModuleAlgo: NameSpace " << idNameSpace << std::endl;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalCell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ void DDHGCalCell::initialize(const DDNumericArguments & nArgs,
extenSensN_ = vsArgs["ExtendedSensitive"];
cornrCN_ = vsArgs["CornerCell"];
cornrSensN_ = vsArgs["CornerSensitive"];
DDCurrentNamespace ns;
nameSpace_ = *ns;
nameSpace_ = DDCurrentNamespace::ns();
if ((truncCN_.size() != truncSensN_.size()) ||
(extenCN_.size() != extenSensN_.size()) ||
(cornrCN_.size() != cornrSensN_.size()))
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void DDHGCalEEAlgo::initialize(const DDNumericArguments & nArgs,
<< " Rmax " << rMaxFront_[i] << " Slope "
<< slopeT_[i];
#endif
DDCurrentNamespace ns;
nameSpace_ = *ns;
nameSpace_ = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: NameSpace " << nameSpace_;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments & nArgs,
<< " Rmax " << rMaxFront_[i] << " Slope "
<< slopeT_[i];
#endif
DDCurrentNamespace ns;
nameSpace_ = *ns;
nameSpace_ = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: NameSpace " << nameSpace_;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ void DDHGCalModule::initialize(const DDNumericArguments & nArgs,
std::cout << "Block [" << i << "] Zmin " << zFront[i] << " Rmax "
<< rMaxFront[i] << " Slope " << slopeT[i] << std::endl;
#endif
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
std::cout << "DDHGCalModule: NameSpace " << idNameSpace << std::endl;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ void DDHGCalModuleAlgo::initialize(const DDNumericArguments & nArgs,
std::cout << "Block [" << i << "] Zmin " << zFront[i] << " Rmax "
<< rMaxFront[i] << " Slope " << slopeT[i] << std::endl;
#endif
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
std::cout << "DDHGCalModuleAlgo: NameSpace " << idNameSpace << std::endl;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ void DDHGCalNoTaperEndcap::initialize(const DDNumericArguments & nArgs,
m_startCopyNo = int( nArgs["startCopyNo"] );
m_incrCopyNo = int( nArgs["incrCopyNo"] );
m_childName = sArgs["ChildName"];
DDCurrentNamespace ns;
m_idNameSpace = *ns;
m_idNameSpace = DDCurrentNamespace::ns();
edm::LogInfo("HGCalGeom") << "DDHGCalNoTaperEndcap: NameSpace " << m_idNameSpace
<< "\tParent " << parent().name();
}
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalTBModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ void DDHGCalTBModule::initialize(const DDNumericArguments & nArgs,
std::cout << "Block [" << i << "] Zmin " << zFront_[i] << " Rmax "
<< rMaxFront_[i] << " Slope " << slopeT_[i] << std::endl;
#endif
DDCurrentNamespace ns;
idNameSpace_ = *ns;
idNameSpace_ = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
std::cout << "DDHGCalTBModule: NameSpace " << idNameSpace_ << std::endl;
#endif
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalWafer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ void DDHGCalWafer::initialize(const DDNumericArguments & nArgs,
nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]);
angleEdges_ = dbl_to_int(vArgs["AngleEdges"]);
detectorType_= dbl_to_int(vArgs["DetectorType"]);
DDCurrentNamespace ns;
idNameSpace_ = *ns;
idNameSpace_ = DDCurrentNamespace::ns();
parentName_ = parent().name();
#ifdef EDM_ML_DEBUG
std::cout << childNames_.size() << " children: " << childNames_[0] << "; "
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalWafer8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ void DDHGCalWafer8::initialize(const DDNumericArguments & nArgs,
cellType_ = (int)(nArgs["CellType"]);
material_ = sArgs["Material"];
cellNames_ = vsArgs["CellNames"];
DDCurrentNamespace ns;
nameSpace_ = *ns;
nameSpace_ = DDCurrentNamespace::ns();
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: Wafer 2r " << waferSize_
<< " T " << waferT_ << " Half Separation "
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HGCalCommonData/plugins/DDHGCalWaferAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ void DDHGCalWaferAlgo::initialize(const DDNumericArguments & nArgs,
<< std::endl;
#endif
rotns = sArgs["RotNameSpace"];
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
parentName = parent().name();
#ifdef EDM_ML_DEBUG
std::cout << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace "
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HcalAlgo/plugins/DDHCalAngular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ void DDHCalAngular::initialize(const DDNumericArguments & nArgs,
<< ", " << incrCopyNo;

rotns = sArgs["RotNameSpace"];
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
childName = sArgs["ChildName"];
DDName parentName = parent().name();
LogDebug("HCalGeom") << "DDHCalAngular debug: Parent " << parentName
Expand Down
4 changes: 2 additions & 2 deletions Geometry/HcalAlgo/plugins/DDHCalBarrelAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs,
<< detWidth2[i] << "\t" << detPosY[i];
}

// idName = parentName.name();
idName = sArgs["MotherName"];
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
idOffset = int (nArgs["IdOffset"]);
DDName parentName = parent().name();
LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Parent " << parentName
Expand Down
3 changes: 1 addition & 2 deletions Geometry/HcalAlgo/plugins/DDHCalEndcapAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ void DDHCalEndcapAlgo::initialize(const DDNumericArguments & nArgs,
#endif

idName = sArgs["MotherName"];
DDCurrentNamespace ns;
idNameSpace = *ns;
idNameSpace = DDCurrentNamespace::ns();
idOffset = int (nArgs["IdOffset"]);

#ifdef EDM_ML_DEBUG
Expand Down

0 comments on commit e8e769a

Please sign in to comment.