NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
multi-type-container.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef MULTI_TYPE_CONTAINER_H_
21 #define MULTI_TYPE_CONTAINER_H_
22 
24 
25 #include <boost/mpl/inherit_linearly.hpp>
26 #include <boost/mpl/inherit.hpp>
27 #include <boost/mpl/at.hpp>
28 
29 namespace ns3 {
30 namespace ndn {
31 namespace ndnSIM {
32 namespace detail {
33 
34 template<class T>
35 struct wrap {
36  T value_;
37 };
38 
39 template<class Vector>
40 struct multi_type_container
41  : public boost::mpl::inherit_linearly<Vector, boost::mpl::inherit<wrap<boost::mpl::_2>,
42  boost::mpl::_1>>::type {
43  template<int N>
44  struct index {
45  typedef typename boost::mpl::at_c<Vector, N>::type type;
46  };
47 
48  template<class T>
49  T&
50  get()
51  {
52  return static_cast<wrap<T>&>(*this).value_;
53  }
54 
55  template<class T>
56  const T&
57  get() const
58  {
59  return static_cast<const wrap<T>&>(*this).value_;
60  }
61 
62  template<int N>
63  typename boost::mpl::at_c<Vector, N>::type&
64  get()
65  {
66  typedef typename boost::mpl::at_c<Vector, N>::type T;
67  return static_cast<wrap<T>&>(*this).value_;
68  }
69 
70  template<int N>
71  const typename boost::mpl::at_c<Vector, N>::type&
72  get() const
73  {
74  typedef typename boost::mpl::at_c<Vector, N>::type T;
75  return static_cast<const wrap<T>&>(*this).value_;
76  }
77 };
78 
79 } // detail
80 } // ndnSIM
81 } // ndn
82 } // ns3
83 
85 
86 #endif // MULTI_TYPE_CONTAINER_H_
Copyright (c) 2011-2015 Regents of the University of California.
Copyright (c) 2011-2015 Regents of the University of California.