2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 * @file RootConversions/VectorConverter.icc
8 * @author scott snyder <snyder@bnl.gov>
9 * @date Oct, 2009, from previous code.
10 * @brief Template for streamer converter for vector<T> -> vector<U>,
11 * assuming T is convertable to U.
15 namespace RootConversions {
20 * @param tname The name of the vector element type T.
22 template <typename T, typename U>
23 VectorConverter<T, U>::VectorConverter (const char* tname)
25 std::string vname = "vector<";
27 if (vname[vname.size()-1] == '>')
30 m_cl = gROOT->GetClass (vname.c_str());
35 * @brief Run the streamer.
36 * @param b Buffer from which to read.
37 * @param pmember Pointer to the object into which to read.
38 * @param size Number of instances to read.
40 template <typename T, typename U>
41 void VectorConverter<T, U>::operator() (TBuffer& b,
45 // This only works for reading!
46 assert (b.IsReading());
48 // The transient object.
49 std::vector<U>* obj = reinterpret_cast<std::vector<U>*> (pmember);
51 // We'll read into this object.
55 // Read into tmp and copy data to *obj.
57 m_cl->Streamer (&tmp, b);
58 obj->assign (tmp.begin(), tmp.end());
64 } // namespace RootConversions