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 * ";
142 return rep().category();
148 return rep().material();
154 return rep().solid();
171 return rep().weight();
230 std::vector<const DDsvalues_type*>
result;
231 rep().specificsV(result);
239 rep().mergedSpecificsV(result);
246 rep().addSpecifics(s);
250 rep().removeSpecifics(s);
254 return rep().hasDDValue(v);
273 size_t p = me.find(
".");
274 m_ok = p != std::string::npos;
279 m_range.first = me.substr( 0, p );
280 m_range.second = m_range.first +
"{";
283 regcomp( &m_regex, me.c_str(), 0 );
287 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
289 bool empty(
void )
const {
return me.empty(); }
291 bool notRegex(
void )
const {
return !m_ok; }
297 return !regexec( &m_regex, s.c_str(), 0, 0, 0 );
302 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
308 std::pair<std::string, std::string> m_range;
312 std::pair<bool, std::string>
319 return std::make_pair(
true,
"" );
323 Regex aNsRegex( ns );
324 bool emptyNs = aNsRegex.empty();
337 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
339 if ( aRegex.notRegex() ) {
340 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
341 if (it!=ed) candidates.push_back(it);
344 if ( !aRegex.range().first.empty()) {
348 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
349 if(aRegex.match(it->first)) candidates.push_back(it);
351 for (
int i=0;
i<
int(candidates.size()); ++
i) {
352 LPNAMES::value_type::const_iterator it = candidates[
i];
355 if ( emptyNs && (sz==1) ) {
356 result.push_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);
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