12 bool alreadyIn(
false );
13 for(
const auto&
p : ns )
33 os << *(defined.first) <<
" ";
36 part.
rep().stream( os );
40 os <<
"* logicalpart not defined * ";
45 os <<
"* logicalpart not declared * ";
123 DCOUT(
'C',
"create LogicalPart ddname=" << ddname <<
" mat=" << material.
name() <<
" sol=" << solid.
name());
138 return rep().category();
144 return rep().material();
150 return rep().solid();
167 return rep().weight();
226 std::vector<const DDsvalues_type*>
result;
227 rep().specificsV(result);
235 rep().mergedSpecificsV(result);
243 rep().addSpecifics(s);
247 rep().removeSpecifics(s);
251 return rep().hasDDValue(v);
270 size_t p = me.find(
".");
271 m_ok = p != std::string::npos;
276 m_range.first = me.substr( 0, p );
277 m_range.second = m_range.first +
"{";
280 regcomp( &m_regex, me.c_str(), 0 );
284 ~Regex(
void ) {
if( m_ok ) regfree( &m_regex ); }
286 bool empty(
void )
const {
return me.empty(); }
288 bool notRegex(
void )
const {
return !m_ok; }
294 return !regexec( &m_regex, s.c_str(), 0, 0, 0 );
299 const std::pair< std::string, std::string> & range(
void )
const {
return m_range; }
305 std::pair<std::string, std::string> m_range;
309 std::pair<bool, std::string>
316 return std::make_pair(
true,
"" );
320 Regex aNsRegex( ns );
321 bool emptyNs = aNsRegex.empty();
334 typedef std::vector< LPNAMES::value_type::const_iterator> Candidates;
336 if ( aRegex.notRegex() ) {
337 LPNAMES::value_type::const_iterator it =
LPNAMES::instance().find(aRegex.value());
338 if (it!=ed) candidates.push_back(it);
341 if ( !aRegex.range().first.empty()) {
345 for (LPNAMES::value_type::const_iterator it=bn; it != ed; ++it)
346 if(aRegex.match(it->first)) candidates.push_back(it);
348 for (
int i=0;
i<int(candidates.size()); ++
i) {
349 LPNAMES::value_type::const_iterator it = candidates[
i];
352 if ( emptyNs && (sz==1) ) {
353 result.push_back(it->second[0]);
360 else if ( !emptyNs ) {
361 std::vector<DDName>::const_iterator nsit(it->second.begin()), nsed(it->second.end());
362 for (; nsit !=nsed; ++nsit) {
364 bool another_doit = aNsRegex.match(nsit->ns());
365 if ( another_doit ) {
373 + nm +
"\" has been found at least in following namespaces:\n";
374 std::vector<DDName>::const_iterator vit = it->second.begin();
375 for(; vit != it->second.end(); ++vit) {
376 message += vit->ns();
379 message +=
"\nQualify the name with a regexp for the namespace, i.e \".*:name-regexp\" !";
380 return std::make_pair(
false,message);
388 std::vector<DDLogicalPart>::const_iterator lpit(result.begin()), lped(result.end());
389 for (; lpit != lped; ++lpit) {
391 if (!lpit->isDefined().second) {
392 message = message +
"LogicalPart " + lpit->name().fullname() +
" not (yet) defined!\n";
399 message =
"No regex-match for namespace=" + ns +
" name=" + nm +
"\n";
402 return std::make_pair(flag,message);
405 const std::vector< std::pair<const DDPartSelection*, const DDsvalues_type*> > &
408 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) ...
static value_type & instance()
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 ...
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
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.
volatile std::atomic< bool > shutdown_flag false
const std::vector< std::pair< const DDPartSelection *, const DDsvalues_type * > > & attachedSpecifics(void) const
#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.