36#ifndef __BASE_EXTENSIBLE_HH__
37#define __BASE_EXTENSIBLE_HH__
59 virtual std::unique_ptr<ExtensionBase>
clone()
const = 0;
64 static unsigned int max_num = 0;
106template <
typename Target,
typename T>
115template <
typename Target,
typename T>
119template <
typename Target>
140 template <
typename T>
144 static_assert(std::is_base_of<ExtensionBase, T>::value,
145 "Extension should inherit from ExtensionBase.");
146 assert(
ext.get() !=
nullptr);
153 *it = std::move(
ext);
165 template <
typename T>
169 static_assert(std::is_base_of<ExtensionBase, T>::value,
170 "Extension should inherit from ExtensionBase.");
180 template <
typename T>
184 static_assert(std::is_base_of<ExtensionBase, T>::value,
185 "Extension should inherit from ExtensionBase.");
189 return std::static_pointer_cast<T>(*it);
201 template <
typename T>
207 if ((*it)->getExtensionID() == T::extensionID)
Extensible(const Extensible &other)
void setExtension(std::shared_ptr< T > ext)
Set a new extension to the packet and replace the old one, if there already exists the same type of e...
virtual ~Extensible()=default
std::shared_ptr< T > getExtension()
Get the extension pointer by linear search with the extensionID.
std::list< std::shared_ptr< ExtensionBase > > extensions
std::list< std::shared_ptr< ExtensionBase > >::iterator findExtension()
Go through the extension list and return the iterator to the instance of the type of extension.
void removeExtension(void)
Remove the extension based on its type.
This is base of every extension.
ExtensionBase(const unsigned int id)
unsigned int getExtensionID() const
virtual ~ExtensionBase()=default
virtual std::unique_ptr< ExtensionBase > clone() const =0
static unsigned int maxNumExtensions()
This is the extension for carrying additional information.
static const unsigned int extensionID
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.