18 typedef std::vector<DDName>::iterator
IT;
19 bool alreadyIn(
false);
20 for(IT
p = ns.begin();
p != ns.end() ; ++
p) {
21 if (
p->ns() == n.
ns()) {
37 os << *(defined.first) <<
" ";
39 part.
rep().stream(os);
42 os <<
"* logicalpart not defined * ";
46 os <<
"* logicalpart not declared * ";
123 DCOUT(
'C',
"create LogicalPart ddname=" << ddname <<
" mat=" << material.
name() <<
" sol=" << solid.
name());
138 return rep().category();
144 return rep().material();
150 return rep().solid();
167 return rep().weight();
226 std::vector<const DDsvalues_type*>
result;
227 rep().specificsV(result);
235 rep().mergedSpecificsV(result);
243 rep().addSpecifics(s);
247 rep().removeSpecifics(s);
251 return rep().hasDDValue(v);
279 explicit Regex(
const std::string &
s) : m_ok(
false), me(s) {
280 size_t p = me.find(
".");
281 m_ok = p!=std::string::npos;
284 m_range.first = me.substr(0,p);
285 m_range.second = m_range.first+
"{";
288 regcomp(&m_regex,me.c_str(),0);
292 ~Regex() {
if(m_ok) regfree(&m_regex); }
294 bool empty()
const {
return me.empty();}
296 bool notRegex()
const {
return !m_ok;}
298 const std::string &
value()
const {
return me;}
300 bool match(
const std::string & s)
const {
302 return !regexec(&m_regex, s.c_str(), 0,0,0);
307 const std::pair< std::string, std::string> & range()
const {
return m_range;}
313 std::pair<std::string, std::string> m_range;
318 std::pair<bool,std::string>
DDIsValid(
const std::string & ns,
const std::string & nm, std::vector<DDLogicalPart> &
result,
bool doRegex)
324 return std::make_pair(
true,
"");
329 bool emptyNs = aNsRegex.empty();
346 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
347 Candidates candidates;
348 if ( aRegex.notRegex() ) {
349 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
350 if (it!=ed) candidates.push_back(it);
353 if ( !aRegex.range().first.empty()) {
357 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
358 if(aRegex.match(it->first)) candidates.push_back(it);
360 for (
int i=0;
i<int(candidates.size()); ++
i) {
361 LPNAMES::value_type::const_iterator it = candidates[
i];
364 if ( emptyNs && (sz==1) ) {
365 result.push_back(it->second[0]);
372 else if ( !emptyNs ) {
373 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
374 for (; nsit !=nsed; ++nsit) {
376 bool another_doit = aNsRegex.match(nsit->ns());
377 if ( another_doit ) {
384 std::string
message =
"DDLogicalPart-name \"" + it->first +
"\" matching regex \""
385 + nm +
"\" has been found at least in following namespaces:\n";
386 std::vector<DDName>::const_iterator vit = it->second.begin();
387 for(; vit != it->second.end(); ++vit) {
388 message += vit->ns();
391 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
392 return std::make_pair(
false,message);
400 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
401 for (; lpit != lped; ++lpit) {
403 if (!lpit->isDefined().second) {
404 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
411 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
415 return std::make_pair(flag,message);
419 const std::vector< std::pair<DDPartSelection*,DDsvalues_type*> > &
422 return rep().attachedSpecifics();
const DDI::rep_traits< N, C >::reference rep() const
bool hasDDValue(const DDValue &) const
def_type isDefined() const
DDMaterial is used to define and access material information.
std::vector< const DDsvalues_type * > specifics() const
returns the specific-data attached to the LogicalPart only (not to a DDExpandedNode) ...
const std::string & ns() const
Returns the namespace.
DDName is used to identify DDD entities uniquely.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
DDLogicalPart()
The default constructor provides an uninitialzed reference object.
A DDSolid represents the shape of a part.
const std::vector< std::pair< DDPartSelection *, DDsvalues_type * > > & attachedSpecifics() const
static value_type & instance()
void addSpecifics(const std::pair< DDPartSelection *, DDsvalues_type * > &)
don't use, internal only /todo make it private
void DD_NC(const DDName &)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
DDsvalues_type mergedSpecifics() const
returns the merged-specifics, i.e. the last specified specifics of this logical-part ...
std::vector< LinkConnSpec >::const_iterator IT
void removeSpecifics(const std::pair< DDPartSelection *, DDsvalues_type * > &)
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
std::pair< bool, std::string > DDIsValid(const std::string &ns, const std::string &name, std::vector< DDLogicalPart > &result, bool doRegex=true)
double & weight()
Weight of the LogicalPart viewed as a component, if cached, else -1.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
#define DCOUT(M_v_Y, M_v_S)
DDEnums::Category category() const
Returns the categorization of the DDLogicalPart (sensitive detector element, cable, ...)
const std::string & name() const
Returns the name.