CMS 3D CMS Logo

Public Member Functions | Private Attributes

DDLLogicalPart Class Reference

DDLLogicalPart processes LogicalPart elements. More...

#include <DDLLogicalPart.h>

Inheritance diagram for DDLLogicalPart:
DDXMLElement

List of all members.

Public Member Functions

 DDLLogicalPart (DDLElementRegistry *myreg)
 Constructor.
void preProcessElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Called by loadAttributes AFTER attributes are loaded.
void processElement (const std::string &name, const std::string &nmspace, DDCompactView &cpv)
 Processing the element.
 ~DDLLogicalPart (void)
 Destructor.

Private Attributes

std::map< std::string,
DDEnums::Category
catMap_

Detailed Description

DDLLogicalPart processes LogicalPart elements.

Author:
Michael Case

DDLLogicalPart.h - description ------------------- begin: Tue Oct 31 2001 email: case@ucdhep.ucdavis.edu

LogicalPart elements simply have the name attribute. However, they also contain elements rSolid and rMaterial. These come together in implementation, but as an XML element the only relevant information to the DDCore is the name attribute. Optionally, they can have instead any Solid or Material elements. To handle the fact that those elements must "stand alone" and also work within LogicalParts, each of those must create a reference (rMaterial or rSolid) to the most recently processed such element.

Definition at line 30 of file DDLLogicalPart.h.


Constructor & Destructor Documentation

DDLLogicalPart::DDLLogicalPart ( DDLElementRegistry myreg)

Constructor.

Definition at line 21 of file DDLLogicalPart.cc.

References DDEnums::cable, catMap_, DDEnums::cooling, DDEnums::envelope, DDEnums::sensitive, DDEnums::support, and DDEnums::unspecified.

  : DDXMLElement( myreg )
{
  // initialize category map
  catMap_["sensitive"]   = DDEnums::sensitive;
  catMap_["cable"]       = DDEnums::cable;
  catMap_["cooling"]     = DDEnums::cooling;
  catMap_["support"]     = DDEnums::support;
  catMap_["envelope"]    = DDEnums::envelope;
  catMap_["unspecified"] = DDEnums::unspecified;
}
DDLLogicalPart::~DDLLogicalPart ( void  )

Destructor.

Definition at line 33 of file DDLLogicalPart.cc.

{}

Member Function Documentation

void DDLLogicalPart::preProcessElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
) [virtual]

Called by loadAttributes AFTER attributes are loaded.

The preProcessElement method can assume that the attributes are loaded and perform any code that is necessary at the start of an element.

This would allow users to call their own code to setup anything necessary for the continued processing of the child elements.

Reimplemented from DDXMLElement.

Definition at line 38 of file DDLLogicalPart.cc.

References DDXMLElement::clear(), DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.

{
  myRegistry_->getElement( "rMaterial" )->clear();
  myRegistry_->getElement( "rSolid" )->clear();
}
void DDLLogicalPart::processElement ( const std::string &  name,
const std::string &  nmspace,
DDCompactView cpv 
) [virtual]

Processing the element.

The processElement method completes any necessary work to process the XML element.

For example, this can be used to call the DDCore to make the geometry in memory. There is a default for this so that if not declared in the inheriting class, no processing is done.

Reimplemented from DDXMLElement.

Definition at line 57 of file DDLLogicalPart.cc.

References catMap_, DDXMLElement::clear(), DCOUT_V, DDXMLElement::getAttributeSet(), DDXMLElement::getDDName(), DDLElementRegistry::getElement(), and DDXMLElement::myRegistry_.

{
  DCOUT_V('P', "DDLLogicalPart::processElement started");

  // rMaterial and rSolid  
  DDXMLElement* myrMaterial = myRegistry_->getElement("rMaterial"); // get Material reference child
  DDXMLElement* myrSolid = myRegistry_->getElement("rSolid"); // get Solid reference child

  DDXMLAttribute atts = getAttributeSet();

  // this check really is overkill so I'm commenting it out for now.
  // validation of the XML should PREVENT this.
//    if (myrSolid->size() > 1)
//      {
//        std::string s = "DDLLogicalPart::processElement:  When looking at rSolid, found more than one. ";
//        s += " Logical part name was: ";
//        s += atts.find("name")->second;
//        throw DDException(s);
//      }

  DDSolid mySolid = DDSolid(myrSolid->getDDName(nmspace));
  DDMaterial myMaterial = DDMaterial(myrMaterial->getDDName(nmspace));

  DDEnums::Category cat;

  if (atts.find("category") != atts.end())
    cat = catMap_[atts.find("category")->second];
  else
    cat = catMap_["unspecified"];

  DDLogicalPart lp( getDDName( nmspace ), myMaterial, mySolid, cat );

  // clear all "children" and attributes
  myrMaterial->clear();
  myrSolid->clear();

  // after each logical part is made, we can clear it
  clear();

  DCOUT_V('P', "DDLLogicalPart::processElement completed");
}

Member Data Documentation

std::map<std::string, DDEnums::Category> DDLLogicalPart::catMap_ [private]

Definition at line 45 of file DDLLogicalPart.h.

Referenced by DDLLogicalPart(), and processElement().