2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief Packet non-inline template implementation */
17 //#include "Packet.ih"
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 template <class OtherPacket>
28 prefix_ OtherPacket senf::Packet::find(NoThrow_t)
32 while (p && ! p.is<OtherPacket>())
35 return p.as<OtherPacket>();
40 template <class OtherPacket>
41 prefix_ OtherPacket senf::Packet::rfind(NoThrow_t)
45 while (p && ! p.is<OtherPacket>())
48 return p.as<OtherPacket>();
53 //-/////////////////////////////////////////////////////////////////////////////////////////////////
54 // senf::ConcretePacket<PacketType>
56 template <class PacketType>
57 template <class OtherPacket>
58 prefix_ OtherPacket senf::ConcretePacket<PacketType>::next(NoThrow_t)
61 PacketInterpreterBase::ptr p (Packet::ptr()->next());
63 return (p->typeId() == typeIdValue<OtherPacket>()) ?
64 OtherPacket(p->as<typename OtherPacket::type>()) : OtherPacket();
65 PacketInterpreterBase::optional_range r (type::nextPacketRange(*this));
66 if (r && ! r->empty()) {
67 PacketInterpreterBase::ptr nxt (getNext(r));
68 if (nxt && nxt->typeId() == typeIdValue<OtherPacket>())
69 return OtherPacket(nxt->as<typename OtherPacket::type>());
74 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 // c-file-style: "senf"
82 // indent-tabs-mode: nil
83 // ispell-local-dictionary: "american"
84 // compile-command: "scons -u test"