CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OneToValue.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_OneToValue_h
2 #define DataFormats_Common_OneToValue_h
6 #include <map>
7 
8 namespace edm {
9  template<typename CKey, typename Val, typename index = unsigned int>
10  class OneToValue {
14  typedef Val map_assoc;
15  public:
17  typedef Val val_type;
21  typedef Val data_type;
23  typedef index index_type;
25  typedef std::map<index_type, map_assoc> map_type;
29  typedef std::map<const typename CKey::value_type *, Val> transient_map_type;
31  typedef std::vector<const typename CKey::value_type *> transient_key_vector;
33  typedef std::vector<Val> transient_val_vector;
35  static void insert(ref_type & ref, map_type & m,
36  const key_type & k, const data_type & v) {
37  if (k.isNull())
39  "can't insert null references in AssociationMap");
40  if (ref.key.isNull()) {
41  ref.key = KeyRefProd(k);
42  }
43  helpers::checkRef(ref.key, k);
44  index_type ik = index_type(k.key());
45  m[ik] = v;
46  }
48  static val_type val(const ref_type & ref, const map_assoc & v) {
49  return v;
50  }
52  static typename map_type::size_type size(const map_assoc &) { return 1; }
54  static void sort(map_type &) { }
56  static transient_map_type transientMap(const ref_type & ref, const map_type & map) {
58  const CKey & ckey = * ref.key;
59  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++ i) {
60  const typename CKey::value_type * k = & ckey[i->first];
61  m.insert(std::make_pair(k, i->second));
62  }
63  return m;
64  }
68  const CKey & ckey = * ref.key;
69  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++ i)
70  m.push_back(& ckey[i->first]);
71  return m;
72  }
76  for(typename map_type::const_iterator i = map.begin(); i != map.end(); ++ i)
77  m.push_back(i->second);
78  return m;
79  }
80  };
81 }
82 
83 #endif
Val map_assoc
internal map associated data
Definition: OneToValue.h:14
int i
Definition: DBlmapReader.cc:9
helpers::Key< KeyRefProd > ref_type
reference set type
Definition: OneToValue.h:27
index index_type
index type
Definition: OneToValue.h:23
static void sort(map_type &)
sort
Definition: OneToValue.h:54
Val val_type
values reference collection type
Definition: OneToValue.h:17
uint16_t size_type
static map_type::size_type size(const map_assoc &)
size of data_type
Definition: OneToValue.h:52
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:81
static val_type val(const ref_type &ref, const map_assoc &v)
return values collection
Definition: OneToValue.h:48
std::vector< const typename CKey::value_type * > transient_key_vector
transient key vector
Definition: OneToValue.h:31
static transient_map_type transientMap(const ref_type &ref, const map_type &map)
fill transient map
Definition: OneToValue.h:56
bool isNull() const
Checks for null.
Definition: Ref.h:246
static transient_key_vector transientKeyVector(const ref_type &ref, const map_type &map)
fill transient key vector
Definition: OneToValue.h:66
edm::Ref< CKey > key_type
insert key type
Definition: OneToValue.h:19
static void insert(ref_type &ref, map_type &m, const key_type &k, const data_type &v)
insert in the map
Definition: OneToValue.h:35
Container::value_type value_type
edm::RefProd< CKey > KeyRefProd
reference to &quot;key&quot; collection
Definition: OneToValue.h:12
int k[5][pyjets_maxn]
Val data_type
insert val type
Definition: OneToValue.h:21
std::map< index_type, map_assoc > map_type
map type
Definition: OneToValue.h:25
static transient_val_vector transientValVector(const ref_type &ref, const map_type &map)
fill transient val vector
Definition: OneToValue.h:74
key_type key() const
Accessor for product key.
Definition: Ref.h:265
std::vector< Val > transient_val_vector
transient val vector
Definition: OneToValue.h:33
std::map< const typename CKey::value_type *, Val > transient_map_type
transient map type
Definition: OneToValue.h:29
void checkRef(const RP &rp, const R &r)
throw if r hasn&#39;t the same id as rp
mathSSE::Vec4< T > v