17 bool alreadyIn(
false );
18 for(
const auto&
p : ns )
38 os << *(defined.first) <<
" ";
41 part.
rep().stream( os );
45 os <<
"* logicalpart not defined * ";
50 os <<
"* logicalpart not declared * ";
128 create( ddname, std::make_unique<DDI::LogicalPart>( material, solid, cat ));
134 return rep().category();
139 return rep().material();
144 return rep().solid();
202 std::vector<const DDsvalues_type*>
result;
203 rep().specificsV(result);
210 rep().mergedSpecificsV(result);
218 rep().addSpecifics(s);
224 rep().removeSpecifics(s);
230 return rep().hasDDValue(v);
249 size_t p = me.find(
".");
250 m_ok = p != std::string::npos;
255 m_range.first = me.substr( 0, p );
256 m_range.second = m_range.first +
"{";
259 regcomp( &m_regex, me.c_str(), 0 );
263 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
265 bool empty(
void )
const {
return me.empty(); }
267 bool notRegex(
void )
const {
return !m_ok; }
273 return !regexec( &m_regex, s.c_str(), 0,
nullptr, 0 );
278 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
284 std::pair<std::string, std::string> m_range;
288 std::pair<bool, std::string>
295 return std::make_pair(
true,
"" );
299 Regex aNsRegex( ns );
300 bool emptyNs = aNsRegex.empty();
313 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
315 if ( aRegex.notRegex() ) {
316 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
317 if (it!=ed) candidates.emplace_back(it);
320 if ( !aRegex.range().first.empty()) {
324 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
325 if(aRegex.match(it->first)) candidates.emplace_back(it);
327 for (
const auto & it : candidates) {
330 if ( emptyNs && (sz==1) ) {
331 result.emplace_back(it->second[0]);
338 else if ( !emptyNs ) {
339 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
340 for (; nsit !=nsed; ++nsit) {
342 bool another_doit = aNsRegex.match(nsit->ns());
343 if ( another_doit ) {
350 std::string message =
"DDLogicalPart-name \"" + it->first +
"\" matching regex \"" 351 + nm +
"\" has been found at least in following namespaces:\n";
352 std::vector<DDName>::const_iterator vit = it->second.begin();
353 for(; vit != it->second.end(); ++vit) {
354 message += vit->ns();
357 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
358 return std::make_pair(
false,message);
365 if (!result.empty()) {
366 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
367 for (; lpit != lped; ++lpit) {
369 if (!lpit->isDefined().second) {
370 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
377 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
380 return std::make_pair(flag,message);
383 const std::vector< std::pair<const DDPartSelection*, const DDsvalues_type*> > &
386 return rep().attachedSpecifics();
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) ...
const DDI::rep_traits< N, C >::reference rep() const
static value_type & instance()
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< const N *, bool > def_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
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
void create(const DDName &name, std::unique_ptr< DDI::LogicalPart > vals)