µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::posix::net_stack_implementable< T > Class Template Reference

#include <net-stack.h>

+ Inheritance diagram for os::posix::net_stack_implementable< T >:

Public Types

using value_type = T
 

Public Member Functions

Constructors & Destructor
template<typename... Args>
 net_stack_implementable (const char *name, net_interface &interface, Args &&... args)
 
virtual ~net_stack_implementable ()
 
Public Member Functions
value_typeimpl (void) const
 

Public Static Member Functions

using deferred_sockets_list_t = utils::intrusive_list< class socket, utils::double_list_links, &socket::deferred_links_ >
 
virtual class socketsocket (int domain, int type, int protocol)
 
const char * name (void) const
 
void add_deferred_socket (class socket *sock)
 
deferred_sockets_list_tdeferred_sockets_list (void)
 
template<typename T >
T * allocate_socket (void)
 
template<typename T , typename L >
T * allocate_socket (L &locker)
 
net_interfaceinterface (void) const
 

Detailed Description

template<typename T>
class os::posix::net_stack_implementable< T >

Definition at line 286 of file net-stack.h.

Member Typedef Documentation

◆ deferred_sockets_list_t

Definition at line 132 of file net-stack.h.

◆ value_type

template<typename T >
using os::posix::net_stack_implementable< T >::value_type = T

Definition at line 291 of file net-stack.h.

Constructor & Destructor Documentation

◆ net_stack_implementable()

template<typename T >
template<typename... Args>
os::posix::net_stack_implementable< T >::net_stack_implementable ( const char *  name,
net_interface interface,
Args &&...  args 
)

Definition at line 564 of file net-stack.h.

566 : net_stack{ impl_instance_, name }, //
567 impl_instance_{ interface, std::forward<Args> (args)... }
568 {
569#if defined(OS_TRACE_POSIX_IO_NET_STACK)
570 trace::printf ("net_stack_implementable::%s(\"%s\")=@%p\n", __func__,
571 name_, this);
572#endif
573 }
net_stack(net_stack_impl &impl, const char *name)
Definition net-stack.cpp:81
net_interface & interface(void) const
const char * name(void) const
Definition net-stack.h:450
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::trace::printf().

◆ ~net_stack_implementable()

template<typename T >
os::posix::net_stack_implementable< T >::~net_stack_implementable
virtual

Definition at line 576 of file net-stack.h.

577 {
578#if defined(OS_TRACE_POSIX_IO_NET_STACK)
579 trace::printf ("net_stack_implementable::%s() @%p %s\n", __func__, this,
580 name_);
581#endif
582 }

References os::trace::printf().

Member Function Documentation

◆ add_deferred_socket()

void os::posix::net_stack::add_deferred_socket ( class socket sock)
inlineinherited

Definition at line 469 of file net-stack.h.

470 {
471 deferred_sockets_list_.link (*sock);
472 }

◆ allocate_socket() [1/2]

template<typename T , typename L >
T * os::posix::net_stack::allocate_socket ( L &  locker)
inherited

Definition at line 518 of file net-stack.h.

519 {
520 using socket_type = T;
521
522 socket_type* sock;
523
524 if (deferred_sockets_list_.empty ())
525 {
526 sock = new socket_type (*this, locker);
527 }
528 else
529 {
530 sock = static_cast<socket_type*> (
531 deferred_sockets_list_.unlink_head ());
532
533 // Call the constructor before reusing the object,
534 sock->~socket_type ();
535
536 // Placement new, run only the constructor.
537 new (sock) socket_type (*this, locker);
538
539 // Deallocate all remaining elements in the list.
540 while (!deferred_sockets_list_.empty ())
541 {
542 socket_type* s = static_cast<socket_type*> (
543 deferred_sockets_list_.unlink_head ());
544
545 // Call the destructor and the deallocator.
546 delete s;
547 }
548 }
549 return sock;
550 }

◆ allocate_socket() [2/2]

template<typename T >
T * os::posix::net_stack::allocate_socket ( void  )
inherited

Definition at line 482 of file net-stack.h.

483 {
484 using socket_type = T;
485
486 socket_type* sock;
487
488 if (deferred_sockets_list_.empty ())
489 {
490 sock = new socket_type (*this);
491 }
492 else
493 {
494 sock = static_cast<socket_type*> (
495 deferred_sockets_list_.unlink_head ());
496
497 // Call the constructor before reusing the object,
498 sock->~socket_type ();
499
500 // Placement new, run only the constructor.
501 new (sock) socket_type (*this);
502
503 // Deallocate all remaining elements in the list.
504 while (!deferred_sockets_list_.empty ())
505 {
506 socket_type* s = static_cast<socket_type*> (
507 deferred_sockets_list_.unlink_head ());
508
509 // Call the destructor and the deallocator.
510 delete s;
511 }
512 }
513 return sock;
514 }

◆ deferred_sockets_list()

net_stack::deferred_sockets_list_t & os::posix::net_stack::deferred_sockets_list ( void  )
inlineinherited

Definition at line 475 of file net-stack.h.

476 {
477 return deferred_sockets_list_;
478 }

◆ impl()

template<typename T >
net_stack_implementable< T >::value_type & os::posix::net_stack_implementable< T >::impl ( void  ) const

Definition at line 586 of file net-stack.h.

587 {
588 return static_cast<value_type&> (impl_);
589 }

◆ interface()

net_interface & os::posix::net_stack::interface ( void  ) const
inherited

◆ name()

const char * os::posix::net_stack::name ( void  ) const
inlineinherited

Definition at line 450 of file net-stack.h.

451 {
452 return name_;
453 }

◆ socket()

class socket * os::posix::net_stack::socket ( int  domain,
int  type,
int  protocol 
)
virtualinherited

Definition at line 104 of file net-stack.cpp.

105 {
106 errno = 0;
107
108 return impl ().do_socket (domain, type, protocol);
109 }
virtual class socket * do_socket(int domain, int type, int protocol)=0
net_stack_impl & impl(void) const
Definition net-stack.h:456

References os::posix::net_stack_impl::do_socket(), and os::posix::net_stack::impl().

Referenced by os::posix::socket().


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