src: Updating code style to conform (more or less) to ndn-cxx style
Also, adding .clang-format that describes the applied style. Note that
this style requires a slightly customized version of clang-format.
diff --git a/utils/trie/multi-policy.hpp b/utils/trie/multi-policy.hpp
index 125df02..170f691 100644
--- a/utils/trie/multi-policy.hpp
+++ b/utils/trie/multi-policy.hpp
@@ -40,144 +40,148 @@
namespace ndnSIM {
template<typename Policies> // e.g., mpl::vector1< lru_policy_traits >
-struct multi_policy_traits
-{
+struct multi_policy_traits {
typedef Policies policy_traits;
- struct getHook { template<class Item> struct apply { typedef typename Item::policy_hook_type type; }; };
- typedef detail::multi_type_container< typename boost::mpl::transform1<policy_traits, getHook>::type > policy_hook_type;
-
+ struct getHook {
+ template<class Item>
+ struct apply {
+ typedef typename Item::policy_hook_type type;
+ };
+ };
+ typedef detail::multi_type_container<
+ typename boost::mpl::transform1<policy_traits, getHook>::type> policy_hook_type;
+
template<class Container>
- struct container_hook
- {
+ struct container_hook {
typedef policy_hook_type type;
};
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- typedef boost::mpl::range_c<int, 0, boost::mpl::size<policy_traits>::type::value> policies_range;
+ template<class Base, class Container, class Hook>
+ struct policy {
+ typedef boost::mpl::range_c<int, 0, boost::mpl::size<policy_traits>::type::value>
+ policies_range;
- struct getPolicy
- {
+ struct getPolicy {
template<class Number>
- struct apply
- {
- typedef
- typename boost::mpl::at_c<policy_traits, Number::value>::type::
- template policy<Base,
- Container,
- boost::intrusive::function_hook< detail::FunctorHook <Hook,
- Container,
- Number::value> > >::type
- type;
+ struct apply {
+ typedef typename boost::mpl::at_c<policy_traits, Number::value>::type::
+ template policy<Base, Container,
+ boost::intrusive::function_hook<detail::FunctorHook<Hook, Container,
+ Number::value>>>::type
+ type;
};
};
-
- typedef
- typename boost::mpl::transform1<policies_range,
- getPolicy,
- boost::mpl::back_inserter< boost::mpl::vector0<> > >::type policies;
-
-
- typedef detail::multi_policy_container< Base, policies > policy_container;
-
- class type : public policy_container
- {
+
+ typedef typename boost::mpl::transform1<policies_range, getPolicy,
+ boost::mpl::back_inserter<boost::mpl::vector0<>>>::type
+ policies;
+
+ typedef detail::multi_policy_container<Base, policies> policy_container;
+
+ class type : public policy_container {
public:
typedef policy policy_base; // to get access to get_time methods from outside
typedef Container parent_trie;
- type (Base &base)
- : policy_container (base)
+ type(Base& base)
+ : policy_container(base)
{
}
inline void
- update (typename parent_trie::iterator item)
+ update(typename parent_trie::iterator item)
{
- policy_container::update (item);
+ policy_container::update(item);
}
-
+
inline bool
- insert (typename parent_trie::iterator item)
+ insert(typename parent_trie::iterator item)
{
- return policy_container::insert (item);
- }
-
- inline void
- lookup (typename parent_trie::iterator item)
- {
- policy_container::lookup (item);
- }
-
- inline void
- erase (typename parent_trie::iterator item)
- {
- policy_container::erase (item);
- }
-
- inline void
- clear ()
- {
- policy_container::clear ();
+ return policy_container::insert(item);
}
- struct max_size_setter
+ inline void
+ lookup(typename parent_trie::iterator item)
{
- max_size_setter (policy_container &container, size_t size) : m_container (container), m_size (size) { }
-
- template< typename U > void operator() (U index)
+ policy_container::lookup(item);
+ }
+
+ inline void
+ erase(typename parent_trie::iterator item)
+ {
+ policy_container::erase(item);
+ }
+
+ inline void
+ clear()
+ {
+ policy_container::clear();
+ }
+
+ struct max_size_setter {
+ max_size_setter(policy_container& container, size_t size)
+ : m_container(container)
+ , m_size(size)
{
- m_container.template get<U::value> ().set_max_size (m_size);
+ }
+
+ template<typename U>
+ void
+ operator()(U index)
+ {
+ m_container.template get<U::value>().set_max_size(m_size);
}
private:
- policy_container &m_container;
+ policy_container& m_container;
size_t m_size;
};
-
+
inline void
- set_max_size (size_t max_size)
+ set_max_size(size_t max_size)
{
- boost::mpl::for_each< boost::mpl::range_c<int, 0, boost::mpl::size<policy_traits>::type::value> >
- (max_size_setter (*this, max_size));
+ boost::mpl::for_each<boost::mpl::range_c<int, 0,
+ boost::mpl::size<policy_traits>::type::value>>(
+ max_size_setter(*this, max_size));
}
inline size_t
- get_max_size () const
+ get_max_size() const
{
// as max size should be the same everywhere, get the value from the first available policy
- return policy_container::template get<0> ().get_max_size ();
+ return policy_container::template get<0>().get_max_size();
}
-
};
};
-
- struct name_getter
- {
- name_getter (std::string &name) : m_name (name) { }
-
- template< typename U > void operator() (U index)
+ struct name_getter {
+ name_getter(std::string& name)
+ : m_name(name)
{
- if (!m_name.empty ())
- m_name += "::";
- m_name += boost::mpl::at_c< policy_traits, U::value >::type::GetName ();
}
- std::string &m_name;
+ template<typename U>
+ void
+ operator()(U index)
+ {
+ if (!m_name.empty())
+ m_name += "::";
+ m_name += boost::mpl::at_c<policy_traits, U::value>::type::GetName();
+ }
+
+ std::string& m_name;
};
/// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string GetName ()
+ static std::string
+ GetName()
{
// combine names of all internal policies
std::string name;
- boost::mpl::for_each< boost::mpl::range_c<int, 0, boost::mpl::size<policy_traits>::type::value> > (name_getter (name));
-
+ boost::mpl::for_each<boost::mpl::range_c<int, 0, boost::mpl::size<policy_traits>::type::value>>(
+ name_getter(name));
+
return name;
}
};