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();
213 std::vector<const DDsvalues_type*>
result;
214 rep().specificsV(result);
222 rep().mergedSpecificsV(result);
229 rep().addSpecifics(s);
233 rep().removeSpecifics(s);
237 return rep().hasDDValue(v);
256 size_t p = me.find(
".");
257 m_ok = p != std::string::npos;
262 m_range.first = me.substr( 0, p );
263 m_range.second = m_range.first +
"{";
266 regcomp( &m_regex, me.c_str(), 0 );
270 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
272 bool empty(
void )
const {
return me.empty(); }
274 bool notRegex(
void )
const {
return !m_ok; }
280 return !regexec( &m_regex, s.c_str(), 0,
nullptr, 0 );
285 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
291 std::pair<std::string, std::string> m_range;
295 std::pair<bool, std::string>
302 return std::make_pair(
true,
"" );
306 Regex aNsRegex( ns );
307 bool emptyNs = aNsRegex.empty();
320 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
322 if ( aRegex.notRegex() ) {
323 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
324 if (it!=ed) candidates.emplace_back(it);
327 if ( !aRegex.range().first.empty()) {
331 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
332 if(aRegex.match(it->first)) candidates.emplace_back(it);
334 for (
const auto & it : candidates) {
337 if ( emptyNs && (sz==1) ) {
338 result.emplace_back(it->second[0]);
345 else if ( !emptyNs ) {
346 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
347 for (; nsit !=nsed; ++nsit) {
349 bool another_doit = aNsRegex.match(nsit->ns());
350 if ( another_doit ) {
357 std::string message =
"DDLogicalPart-name \"" + it->first +
"\" matching regex \"" 358 + nm +
"\" has been found at least in following namespaces:\n";
359 std::vector<DDName>::const_iterator vit = it->second.begin();
360 for(; vit != it->second.end(); ++vit) {
361 message += vit->ns();
364 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
365 return std::make_pair(
false,message);
372 if (!result.empty()) {
373 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
374 for (; lpit != lped; ++lpit) {
376 if (!lpit->isDefined().second) {
377 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
384 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
387 return std::make_pair(flag,message);
390 const std::vector< std::pair<const DDPartSelection*, const DDsvalues_type*> > &
393 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.
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