18 bool alreadyIn(
false );
19 for(
const auto&
p : ns )
39 os << *(defined.first) <<
" ";
42 part.
rep().stream( os );
46 os <<
"* logicalpart not defined * ";
51 os <<
"* logicalpart not declared * ";
143 return rep().category();
149 return rep().material();
155 return rep().solid();
172 return rep().weight();
231 std::vector<const DDsvalues_type*>
result;
232 rep().specificsV(result);
240 rep().mergedSpecificsV(result);
247 rep().addSpecifics(s);
251 rep().removeSpecifics(s);
255 return rep().hasDDValue(v);
274 size_t p = me.find(
".");
275 m_ok = p != std::string::npos;
280 m_range.first = me.substr( 0, p );
281 m_range.second = m_range.first +
"{";
284 regcomp( &m_regex, me.c_str(), 0 );
288 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
290 bool empty(
void )
const {
return me.empty(); }
292 bool notRegex(
void )
const {
return !m_ok; }
298 return !regexec( &m_regex, s.c_str(), 0,
nullptr, 0 );
303 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
309 std::pair<std::string, std::string> m_range;
313 std::pair<bool, std::string>
320 return std::make_pair(
true,
"" );
324 Regex aNsRegex( ns );
325 bool emptyNs = aNsRegex.empty();
338 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
340 if ( aRegex.notRegex() ) {
341 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
342 if (it!=ed) candidates.emplace_back(it);
345 if ( !aRegex.range().first.empty()) {
349 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
350 if(aRegex.match(it->first)) candidates.emplace_back(it);
352 for (
const auto & it : candidates) {
355 if ( emptyNs && (sz==1) ) {
356 result.emplace_back(it->second[0]);
363 else if ( !emptyNs ) {
364 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
365 for (; nsit !=nsed; ++nsit) {
367 bool another_doit = aNsRegex.match(nsit->ns());
368 if ( another_doit ) {
376 + nm +
"\" has been found at least in following namespaces:\n";
377 std::vector<DDName>::const_iterator vit = it->second.begin();
378 for(; vit != it->second.end(); ++vit) {
379 message += vit->ns();
382 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
383 return std::make_pair(
false,message);
390 if (!result.empty()) {
391 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
392 for (; lpit != lped; ++lpit) {
394 if (!lpit->isDefined().second) {
395 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
402 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
405 return std::make_pair(flag,message);
408 const std::vector< std::pair<const DDPartSelection*, const DDsvalues_type*> > &
411 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, ...)
std::ostream & operator<<(std::ostream &os, const DDLogicalPart &part)
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.
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) ...
static value_type & instance()
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::...
std::pair< bool, std::string > DDIsValid(const std::string &ns, const std::string &nm, std::vector< DDLogicalPart > &result, bool doRegex)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
void DD_NC(const DDName &n)
DDsvalues_type mergedSpecifics(void) const
returns the merged-specifics, i.e. the last specified specifics of this logical-part ...
void addSpecifics(const std::pair< const DDPartSelection *, const DDsvalues_type * > &)
don't use, internal only /todo make it private
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.
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
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.
const DDName & ddname() const