OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4NetpuncherPacketID< TYPE > Class Template Reference

#include <C4PuncherPacket.h>

Inheritance diagram for C4NetpuncherPacketID< TYPE >:
[legend]
Collaboration diagram for C4NetpuncherPacketID< TYPE >:
[legend]

Public Types

typedef std::unique_ptr
< C4NetpuncherPacket
uptr
 

Public Member Functions

C4NetpuncherPacketType GetType () const final
 
CID GetID () const
 
 ~C4NetpuncherPacketID () override=default
 
C4NetIOPacket PackTo (const C4NetIO::addr_t &) const
 

Static Public Member Functions

static std::unique_ptr
< C4NetpuncherPacket
Construct (const C4NetIOPacket &rpack)
 

Protected Types

typedef C4NetpuncherID::value CID
 

Protected Member Functions

 C4NetpuncherPacketID (const C4NetIOPacket &rpack)
 
 C4NetpuncherPacketID (CID id)
 

Detailed Description

template<C4NetpuncherPacketType TYPE>
class C4NetpuncherPacketID< TYPE >

Definition at line 52 of file C4PuncherPacket.h.

Member Typedef Documentation

typedef C4NetpuncherID::value C4NetpuncherPacket::CID
protectedinherited

Definition at line 48 of file C4PuncherPacket.h.

typedef std::unique_ptr<C4NetpuncherPacket> C4NetpuncherPacket::uptr
inherited

Definition at line 41 of file C4PuncherPacket.h.

Constructor & Destructor Documentation

template<C4NetpuncherPacketType TYPE>
C4NetpuncherPacketID< TYPE >::C4NetpuncherPacketID ( const C4NetIOPacket rpack)
protected

Definition at line 66 of file C4PuncherPacket.cpp.

References C4NetIOPacket::getPData(), and C4NetIOPacket::getPSize().

66  {
67  std::istringstream iss(std::string(rpack.getPData(), rpack.getPSize()));
68  iss >> id;
69 }
size_t getPSize() const
Definition: C4NetIO.h:319
const char * getPData() const
Definition: C4NetIO.h:318

Here is the call graph for this function:

template<C4NetpuncherPacketType TYPE>
C4NetpuncherPacketID< TYPE >::C4NetpuncherPacketID ( CID  id)
inlineprotected

Definition at line 58 of file C4PuncherPacket.h.

58 : id(id) {};
template<C4NetpuncherPacketType TYPE>
C4NetpuncherPacketID< TYPE >::~C4NetpuncherPacketID ( )
overridedefault

Member Function Documentation

std::unique_ptr< C4NetpuncherPacket > C4NetpuncherPacket::Construct ( const C4NetIOPacket rpack)
staticinherited

Definition at line 26 of file C4PuncherPacket.cpp.

References C4NetIOPacket::getPData(), C4NetIOPacket::getStatus(), PID_Puncher_AssID, PID_Puncher_CReq, and PID_Puncher_SReq.

Referenced by C4Network2IO::HandlePuncherPacket().

26  {
27  if (!rpack.getPData()) return nullptr;
28  try {
29  switch (rpack.getStatus())
30  {
31  case PID_Puncher_AssID: return uptr(new C4NetpuncherPacketAssID(rpack));
32  case PID_Puncher_SReq: return uptr(new C4NetpuncherPacketSReq(rpack));
33  case PID_Puncher_CReq: return uptr(new C4NetpuncherPacketCReq(rpack));
34  default: return nullptr;
35  }
36  }
37  catch (StdCompiler::Exception *e) { delete e; return nullptr; }
38  catch (...) { return nullptr; }
39 }
std::unique_ptr< C4NetpuncherPacket > uptr
uint8_t getStatus() const
Definition: C4NetIO.h:317
const char * getPData() const
Definition: C4NetIO.h:318

Here is the call graph for this function:

Here is the caller graph for this function:

template<C4NetpuncherPacketType TYPE>
CID C4NetpuncherPacketID< TYPE >::GetID ( ) const
inline

Definition at line 61 of file C4PuncherPacket.h.

61 { return id; }
template<C4NetpuncherPacketType TYPE>
C4NetpuncherPacketType C4NetpuncherPacketID< TYPE >::GetType ( ) const
inlinefinalvirtual

Implements C4NetpuncherPacket.

Definition at line 60 of file C4PuncherPacket.h.

60 { return TYPE; }
C4NetIOPacket C4NetpuncherPacket::PackTo ( const C4NetIO::addr_t addr) const
inherited

Definition at line 40 of file C4PuncherPacket.cpp.

References StdBuf::getSize(), C4NetpuncherPacket::GetType(), StdBuf::New(), C4NetpuncherPacket::PackInto(), C4NetIOPacket::SetAddr(), and StdBuf::Write().

Referenced by C4Network2IO::SendPuncherPacket().

40  {
41  C4NetIOPacket pkt;
42  pkt.SetAddr(addr);
43  StdBuf content(PackInto());
44  char type = GetType();
45  pkt.New(sizeof(type) + content.getSize());
46  pkt.Write(&type, sizeof(type));
47  pkt.Write(content, /*offset*/sizeof(type));
48  return pkt;
49 }
Definition: StdBuf.h:29
void New(size_t inSize)
Definition: StdBuf.h:146
virtual C4NetpuncherPacketType GetType() const =0
void Write(const void *pnData, size_t inSize, size_t iAt=0)
Definition: StdBuf.h:153
void SetAddr(const C4NetIO::addr_t &naddr)
Definition: C4NetIO.h:326
virtual StdBuf PackInto() const =0

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: