1 #ifndef DataFormats_Common_OneToValue_h 2 #define DataFormats_Common_OneToValue_h 11 template<
typename CKey,
typename Val,
typename index =
unsigned int>
27 typedef std::map<index_type, map_assoc>
map_type;
37 static void insert(ref_type& ref, map_type&
m,
38 key_type
const&
k, data_type
const&
v) {
41 "can't insert null references in AssociationMap");
43 if(ref.
key.isNull()) {
46 "can't insert transient references in uninitialized AssociationMap");
49 auto getter =ref.
key.productGetter();
50 if(getter ==
nullptr) {
52 "Can't insert into AssociationMap unless it was properly initialized.\n" 53 "The most common fix for this is to add an argument to the call to the\n" 54 "AssociationMap constructor that is a valid Handle to the container.\n" 55 "If you don't have a valid handle or the template parameter to the\n" 56 "AssociationMap is a View, then see the comments in AssociationMap.h.\n" 57 "(note this was a new requirement added in the 7_5_X release series)\n");
66 static val_type
val(ref_type
const&, map_assoc
const&
v) {
72 static void sort(map_type&) { }
74 static transient_map_type
transientMap(ref_type
const& ref, map_type
const&
map) {
77 CKey
const& ckey = *ref.
key;
78 for(
typename map_type::const_iterator
i = map.begin();
i != map.end(); ++
i) {
80 m.insert(std::make_pair(k,
i->second));
87 transient_key_vector
m;
89 CKey
const& ckey = *ref.
key;
90 for(
typename map_type::const_iterator
i = map.begin();
i != map.end(); ++
i) {
91 m.push_back(& ckey[
i->first]);
98 transient_val_vector
m;
100 for(
typename map_type::const_iterator
i = map.begin();
i != map.end(); ++
i) {
101 m.push_back(
i->second);
Val map_assoc
internal map associated data
std::map< typename CKey::value_type const *, Val > transient_map_type
transient map type
helpers::Key< KeyRefProd > ref_type
reference set type
static transient_map_type transientMap(ref_type const &ref, map_type const &map)
fill transient map
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
static map_type::size_type size(map_assoc const &)
size of data_type
index index_type
index type
static void sort(map_type &)
sort
Val val_type
values reference collection type
static val_type val(ref_type const &, map_assoc const &v)
return values collection
key_type key() const
Accessor for product key.
ProductID id() const
Accessor for product ID.
Ref< CKey > key_type
insert key type
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
std::vector< typename CKey::value_type const * > transient_key_vector
transient key vector
Container::value_type value_type
bool isNull() const
Checks for null.
Val data_type
insert val type
std::map< index_type, map_assoc > map_type
map type
RefProd< CKey > KeyRefProd
reference to "key" collection
std::vector< Val > transient_val_vector
transient val vector
static transient_key_vector transientKeyVector(ref_type const &ref, map_type const &map)
fill transient key vector
void checkRef(const RP &rp, const R &r)
throw if r hasn't the same id as rp
static void insert(ref_type &ref, map_type &m, key_type const &k, data_type const &v)
insert in the map
static transient_val_vector transientValVector(ref_type const &ref, map_type const &map)
fill transient val vector