CMS 3D CMS Logo

DDErrorDetection.h
Go to the documentation of this file.
1 #ifndef DD_DDErrorDetection_h
2 #define DD_DDErrorDetection_h
3 
5 #include <map>
6 #include <ostream>
7 #include <set>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
18 
19 class DDCompactView;
20 class DDLogicalPart;
21 class DDMaterial;
22 class DDName;
23 class DDRotation;
24 class DDSolid;
26 
32 
33 typedef std::map<std::string, std::set<std::string> > ns_type;
34 typedef std::map<std::string, std::set<DDName> > ns_nm_type;
35 
36 template<class T> std::ostream & operator<<(std::ostream & o, const std::set<T> & v)
37 {
38  typename std::set<T>::const_iterator it(v.begin()), ed(v.end());
39  for(; it != ed; ++it) {
40  o << it->ddname() << ' ';
41  }
42  return o;
43 }
44 
45 template<class T> std::ostream & operator<<(std::ostream & o, const std::map<std::string, std::set<T> > & m) {
46  typedef typename std::map<std::string, std::set<T> >::const_iterator c_it;
47  c_it it(m.begin()), ed(m.end());
48  for (; it != ed; ++it) {
49  o << it->first << ": " << it->second;
50  o << std::endl;
51  }
52  return o;
53 }
54 
55 template<class T, class N> std::ostream & operator<<(std::ostream & o, const std::map<N, std::set<T> > & m) {
56  typedef typename std::map<N, std::set<T> >::const_iterator c_it;
57  c_it it(m.begin()), ed(m.end());
58  for (; it != ed; ++it) {
59  o << it->first.ddname() << ": " << it->second;
60  o << std::endl;
61  }
62  return o;
63 }
64 
65 template<typename T>
67 {
68  bool result=true;
69  typename T::template iterator<T> it,ed;
70  ed.end();
71  for (; it != ed; ++it) {
72  result = it->isDefined().second;
73  if (!result)
74  DDI::Singleton<std::map<std::string,std::set<T> > >::instance()[it->name().ns()].insert(*it);
75  m[it->name().ns()].insert(it->name().name());
76  }
77  return result;
78 }
79 
80 
81 template<typename T>
83 {
84  bool result=true;
85  typename T::template iterator<T> it,ed;
86  ed.end();
87  for (; it != ed; ++it) {
88  result = it->isDefined().second;
89  if (!result)
90  DDI::Singleton<std::map<std::string,std::set<T> > >::instance()[it->name().ns()].insert(*it);
91  m[it->name().ns()].insert(it->name().name());
92  }
93  return result;
94 }
95 
96 
97 template <class C> const std::map<std::string, std::set<C> > & dd_error_scan(const C &)
98 {
99  typedef std::map<std::string, std::set<C> > error_type;
100  static error_type result_;
101  typename C::template iterator<C> it;
102  typename C::template iterator<C> ed(C::end());
103  for (; it != ed; ++it) {
104  if (!it->isDefined().second) {
105  result_[it->name().ns()].insert(*it);
106  }
107  }
108  return result_;
109 }
110 
112 {
113 public:
114  DDErrorDetection(const DDCompactView& cpv);
116 
117  void scan( const DDCompactView& cpv);
118 
119  void errors();
120 
121  void warnings();
122 
123  const std::map<std::string, std::set<DDLogicalPart> > & lp_cpv(const DDCompactView& cpv);
124  const std::map<DDMaterial, std::set<DDLogicalPart> > & ma_lp();
125  const std::map<DDSolid, std::set<DDLogicalPart> > & so_lp();
126  const std::map<DDSolid, std::set<DDSolid> > & so();
127 
128  void nix();
129 
130  const std::vector<std::pair<std::string,DDName> > & ma();
131 
132  void report(const DDCompactView& cpv, std::ostream & o);
133 
134  bool noErrorsInTheReport(const DDCompactView& cpv);
135 
136  private:
138 
139 };
140 
141 #endif
void scan(const DDCompactView &cpv)
DDI::Singleton< std::map< std::string, std::set< DDLogicalPart > > > lp_err
const std::map< DDSolid, std::set< DDSolid > > & so()
std::map< std::string, std::set< DDName > > ns_nm_type
static PFTauRenderPlugin instance
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
DDI::Singleton< std::map< std::string, std::set< DDMaterial > > > ma_err
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
bool noErrorsInTheReport(const DDCompactView &cpv)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
#define end
Definition: vmac.h:39
const std::vector< std::pair< std::string, DDName > > & ma()
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
void report(const DDCompactView &cpv, std::ostream &o)
DDI::Singleton< std::map< std::string, std::set< DDSpecifics > > > sp_err
bool findNameSpaces(T dummy, ns_type &m)
long double T
std::map< std::string, std::set< std::string > > ns_type
DDI::Singleton< std::map< std::string, std::set< DDSolid > > > so_err
DDI::Singleton< std::map< std::string, std::set< DDRotation > > > ro_err
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:42