CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OneToOneGeneric.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_OneToOneGeneric_h
2 #define DataFormats_Common_OneToOneGeneric_h
3 
6 
7 #include <map>
8 
9 namespace edm {
10  template<typename CKey, typename CVal, typename index = unsigned int,
11  typename KeyRefProd = typename helper::MapRefViewTrait<CKey>::refprod_type,
12  typename ValRefProd = typename helper::MapRefViewTrait<CVal>::refprod_type,
13  typename KeyRef = typename helper::MapRefViewTrait<CKey>::ref_type,
14  typename ValRef = typename helper::MapRefViewTrait<CVal>::ref_type>
17  typedef KeyRefProd keyrefprod_type;
19  typedef ValRefProd valrefprod_type;
21  typedef index map_assoc;
22 
23  public:
25  typedef ValRef val_type;
27  typedef KeyRef key_type;
29  typedef ValRef data_type;
31  typedef index index_type;
33  typedef std::map<index_type, map_assoc> map_type;
37  typedef std::map<typename CKey::value_type const*,
40  typedef std::vector<typename CKey::value_type const*> transient_key_vector;
42  typedef std::vector<typename CVal::value_type const*> transient_val_vector;
44  static void insert(ref_type& ref, map_type& m,
45  key_type const& k, data_type const& v) {
46  if(k.isNull() || v.isNull()) {
48  "can't insert null references in AssociationMap");
49  }
50  if(ref.key.isNull()) {
51  ref.key = keyrefprod_type(k);
52  ref.val = valrefprod_type(v);
53  }
54  helpers::checkRef(ref.key, k); helpers::checkRef(ref.val, v);
55  index_type ik = index_type(k.key()), iv = index_type(v.key());
56  m[ik] = iv;
57  }
59  static val_type val(ref_type const& ref, map_assoc iv) {
60  return val_type(ref.val, iv);
61  }
63  static typename map_type::size_type size(map_assoc const&) { return 1; }
65  static void sort(map_type&) { }
67  static transient_map_type transientMap(ref_type const& ref, map_type const& map) {
69  CKey const& ckey = *ref.key;
70  CVal const& cval = *ref.val;
71  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++i) {
72  typename CKey::value_type const* k = &ckey[i->first];
73  typename CVal::value_type const* v = & cval[i->second];
74  m.insert(std::make_pair(k, v));
75  }
76  return m;
77  }
81  CKey const& ckey = *ref.key;
82  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++i)
83  m.push_back(& ckey[i->first]);
84  return m;
85  }
89  CVal const& cval = *ref.val;
90  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++i) {
91  m.push_back(& cval[i->second]);
92  }
93  return m;
94  }
95  };
96 }
97 
98 #endif
KeyRefProd keyrefprod_type
reference to &quot;key&quot; collection
int i
Definition: DBlmapReader.cc:9
KeyRef key_type
insert key type
static transient_map_type transientMap(ref_type const &ref, map_type const &map)
fill transient map
index map_assoc
internal map associated data
std::map< typename CKey::value_type const *, typename CVal::value_type const * > transient_map_type
transient map type
ValRefProd valrefprod_type
reference to &quot;value&quot; collection
ValRef val_type
values reference collection type
std::vector< typename CVal::value_type const * > transient_val_vector
transient val vector
std::vector< typename CKey::value_type const * > transient_key_vector
transient key vector
uint16_t size_type
static void sort(map_type &)
sort
dictionary map
Definition: Association.py:205
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
ValRef data_type
insert val type
Container::value_type value_type
int k[5][pyjets_maxn]
index index_type
index type
static transient_key_vector transientKeyVector(ref_type const &ref, map_type const &map)
fill transient key vector
static val_type val(ref_type const &ref, map_assoc iv)
return values collection
static void insert(ref_type &ref, map_type &m, key_type const &k, data_type const &v)
insert in the map
helpers::KeyVal< keyrefprod_type, valrefprod_type > ref_type
reference set type
static transient_val_vector transientValVector(ref_type const &ref, map_type const &map)
fill transient val vector
static map_type::size_type size(map_assoc const &)
size of data_type
void checkRef(const RP &rp, const R &r)
throw if r hasn&#39;t the same id as rp
std::map< index_type, map_assoc > map_type
map type