12 typedef std::vector<DDName>::iterator
IT;
13 bool alreadyIn(
false );
14 for( IT
p = ns.begin();
p != ns.end(); ++
p )
16 if(
p->ns() == n.
ns())
34 os << *(defined.first) <<
" ";
37 part.
rep().stream( os );
41 os <<
"* logicalpart not defined * ";
46 os <<
"* logicalpart not declared * ";
124 DCOUT(
'C',
"create LogicalPart ddname=" << ddname <<
" mat=" << material.
name() <<
" sol=" << solid.
name());
139 return rep().category();
145 return rep().material();
151 return rep().solid();
168 return rep().weight();
227 std::vector<const DDsvalues_type*>
result;
228 rep().specificsV(result);
236 rep().mergedSpecificsV(result);
244 rep().addSpecifics(s);
248 rep().removeSpecifics(s);
252 return rep().hasDDValue(v);
267 explicit Regex(
const std::string &
s )
271 size_t p = me.find(
".");
272 m_ok = p != std::string::npos;
277 m_range.first = me.substr( 0, p );
278 m_range.second = m_range.first +
"{";
281 regcomp( &m_regex, me.c_str(), 0 );
285 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
287 bool empty(
void )
const {
return me.empty(); }
289 bool notRegex(
void )
const {
return !m_ok; }
291 const std::string &
value(
void )
const {
return me;}
293 bool match(
const std::string & s )
const {
295 return !regexec( &m_regex, s.c_str(), 0, 0, 0 );
300 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
306 std::pair<std::string, std::string> m_range;
310 std::pair<bool, std::string>
311 DDIsValid(
const std::string & ns,
const std::string & nm, std::vector<DDLogicalPart> &
result,
bool doRegex )
317 return std::make_pair(
true,
"" );
321 Regex aNsRegex( ns );
322 bool emptyNs = aNsRegex.empty();
335 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
336 Candidates candidates;
337 if ( aRegex.notRegex() ) {
338 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
339 if (it!=ed) candidates.push_back(it);
342 if ( !aRegex.range().first.empty()) {
346 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
347 if(aRegex.match(it->first)) candidates.push_back(it);
349 for (
int i=0;
i<int(candidates.size()); ++
i) {
350 LPNAMES::value_type::const_iterator it = candidates[
i];
353 if ( emptyNs && (sz==1) ) {
354 result.push_back(it->second[0]);
361 else if ( !emptyNs ) {
362 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
363 for (; nsit !=nsed; ++nsit) {
365 bool another_doit = aNsRegex.match(nsit->ns());
366 if ( another_doit ) {
373 std::string
message =
"DDLogicalPart-name \"" + it->first +
"\" matching regex \""
374 + nm +
"\" has been found at least in following namespaces:\n";
375 std::vector<DDName>::const_iterator vit = it->second.begin();
376 for(; vit != it->second.end(); ++vit) {
377 message += vit->ns();
380 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
381 return std::make_pair(
false,message);
389 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
390 for (; lpit != lped; ++lpit) {
392 if (!lpit->isDefined().second) {
393 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
400 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
403 return std::make_pair(flag,message);
406 const std::vector< std::pair<DDPartSelection*,DDsvalues_type*> > &
409 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.
DDEnums::Category category(void) const
Returns the categorization of the DDLogicalPart (sensitive detector element, cable, ...)
const std::string & ns() const
Returns the namespace.
DDName is used to identify DDD entities uniquely.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
double & weight(void)
Weight of the LogicalPart viewed as a component, if cached, else -1.
A DDSolid represents the shape of a part.
std::vector< const DDsvalues_type * > specifics(void) const
returns the specific-data attached to the LogicalPart only (not to a DDExpandedNode) ...
const std::vector< std::pair< DDPartSelection *, DDsvalues_type * > > & attachedSpecifics(void) 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 ...
std::vector< LinkConnSpec >::const_iterator IT
DDsvalues_type mergedSpecifics(void) const
returns the merged-specifics, i.e. the last specified specifics of this logical-part ...
std::pair< bool, std::string > DDIsValid(const std::string &ns, const std::string &name, std::vector< DDLogicalPart > &result, bool doRegex=true)
void removeSpecifics(const std::pair< DDPartSelection *, DDsvalues_type * > &)
DDLogicalPart(void)
The default constructor provides an uninitialzed reference object.
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)
const std::string & name() const
Returns the name.
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.