ORIGINAL
Loading...
Searching...
No Matches
original::containerAdapter< TYPE, SERIAL, ALLOC > Class Template Reference

Adapter class that provides unified interface for various container types. More...

#include <containerAdapter.h>

Inheritance diagram for original::containerAdapter< TYPE, SERIAL, ALLOC >:
Inheritance graph
Collaboration diagram for original::containerAdapter< TYPE, SERIAL, ALLOC >:
Collaboration graph

Public Member Functions

u_integer size () const override
 Returns the number of elements in the adapter.
 
void clear ()
 Removes all elements from the adapter.
 
bool contains (const TYPE &e) const override
 Checks for element existence in the adapter.
 
integer compareTo (const containerAdapter &other) const override
 Compares two container adapters lexicographically.
 
std::string className () const override
 Gets class name identifier for type information.
 
std::string toString (bool enter) const override
 Generates formatted string representation.
 
 ~containerAdapter () override=default
 Virtual destructor for proper polymorphic cleanup.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const char * toCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE>
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE>
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatString (TYPE *const &ptr) -> std::string
 
- Public Member Functions inherited from original::container< TYPE, ALLOC< TYPE > >
bool empty () const
 Checks if the container is empty.
 
virtual ~container ()=default
 Destructor for the container class.
 
- Public Member Functions inherited from original::comparable< containerAdapter< TYPE, SERIAL, ALLOC > >
bool operator== (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is less than another.
 
bool operator> (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const containerAdapter< TYPE, SERIAL, ALLOC > &other) const
 Checks if the current object is greater than or equal to another.
 
virtual ~comparable ()=default
 Virtual destructor for proper cleanup of derived objects.
 

Protected Member Functions

 containerAdapter (const SERIAL< TYPE, ALLOC< TYPE > > &serial)
 Constructs a container adapter with specified underlying container.
 
- Protected Member Functions inherited from original::container< TYPE, ALLOC< TYPE > >
 container (ALLOC alloc=ALLOC{})
 Constructs a container with specified allocator.
 
TYPE * allocate (u_integer size)
 Allocates raw memory for elements.
 
void deallocate (TYPE *ptr, u_integer size)
 Deallocates memory previously allocated by allocate()
 
void construct (O_TYPE *o_ptr, Args &&... args)
 Constructs an element in-place.
 
void destroy (O_TYPE *o_ptr)
 Destroys an element.
 

Protected Attributes

SERIAL< TYPE, ALLOC< TYPE > > serial_
 The underlying container instance.
 
- Protected Attributes inherited from original::container< TYPE, ALLOC< TYPE > >
ALLOC allocator
 The allocator instance used for memory management.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE>
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion.
 
template<typename TYPE>
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting.
 
template<typename TYPE>
static const char * formatCString (const TYPE &t)
 C-string cache for temporary usage.
 
template<typename TYPE>
static std::string formatEnum (const TYPE &t)
 Enum formatting utility.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 

Detailed Description

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
class original::containerAdapter< TYPE, SERIAL, ALLOC >

Adapter class that provides unified interface for various container types.

Template Parameters
TYPEThe type of elements stored in the container
SERIALThe underlying serial container type
ALLOCThe allocator template to use for memory management

This class template adapts different serial container types (like vectors, lists) to provide consistent interfaces including size checking, element existence verification, and formatted string output. Inherits both printable interface and container interface.

The allocator template is propagated to both the base container class and the underlying serial container for consistent memory management. The adapter provides full comparison support through the comparable interface, with lexicographical ordering based on the underlying container's elements. All comparison operations (==, !=, <, >, <=, >=) are available.

Note
The SERIAL template parameter is constrained by C++20 requires clause to ensure it derives from baseList<TYPE>. This guarantees the availability of required container interfaces like size(), clear(), and contains() methods.
Template Parameters
SERIALMust satisfy:
ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
Checks derivation or type identity.
Definition types.h:157
Which enforces SERIAL to be a subclass of baseList<TYPE, ALLOC<TYPE>>.

Constructor & Destructor Documentation

◆ containerAdapter()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
original::containerAdapter< TYPE, SERIAL, ALLOC >::containerAdapter ( const SERIAL< TYPE, ALLOC< TYPE > > & serial)
explicitprotected

Constructs a container adapter with specified underlying container.

Parameters
serialThe underlying container instance to adapt

The constructor initializes the adapter with the provided serial container. The allocator from the serial container will be used for all memory operations.

Note
The allocator is propagated from the serial container to ensure consistent memory management throughout the adapter's lifetime.

Member Function Documentation

◆ className()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::className ( ) const
nodiscardoverridevirtual

Gets class name identifier for type information.

Returns
std::string Fixed identifier "containerAdapter"
Note
Derived classes should override this with specific names (e.g. "stack")

Reimplemented from original::printable.

Reimplemented in original::deque< TYPE, SERIAL, ALLOC >, original::prique< TYPE, Callback, SERIAL, ALLOC >, original::queue< TYPE, SERIAL, ALLOC >, and original::stack< TYPE, SERIAL, ALLOC >.

◆ clear()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::clear ( )

Removes all elements from the adapter.

Clears content through underlying container's clear() method. All elements are properly destroyed using the container's allocator.

◆ compareTo()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::compareTo ( const containerAdapter< TYPE, SERIAL, ALLOC > & other) const
overridevirtual

Compares two container adapters lexicographically.

Parameters
otherThe container adapter to compare against
Returns
integer
  • Negative value if this adapter is "less than" other
  • Zero if both adapters are equivalent
  • Positive value if this adapter is "greater than" other

The comparison is performed by delegating to the underlying serial container's compareTo method. This provides lexicographical comparison of elements in the containers, similar to standard container comparison semantics.

The comparison follows these rules:

  1. If sizes differ, the adapter with fewer elements is considered "less"
  2. For adapters of equal size, elements are compared pairwise until a mismatch is found
  3. If all elements are equal, the adapters are considered equivalent

Implements original::comparable< containerAdapter< TYPE, SERIAL, ALLOC > >.

◆ contains()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::contains ( const TYPE & e) const
overridevirtual

Checks for element existence in the adapter.

Parameters
eElement to search for
Returns
bool True if element exists, false otherwise

Uses underlying container's contains() method for verification. The search operation respects the memory layout determined by the allocator.

Implements original::container< TYPE, ALLOC< TYPE > >.

◆ size()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::size ( ) const
nodiscardoverridevirtual

Returns the number of elements in the adapter.

Returns
u_integer Current number of stored elements

Directly delegates to underlying container's size() method. Memory usage depends on the underlying container's allocator.

Implements original::container< TYPE, ALLOC< TYPE > >.

◆ toString()

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
auto original::containerAdapter< TYPE, SERIAL, ALLOC >::toString ( bool enter) const
nodiscardoverridevirtual

Generates formatted string representation.

Parameters
enterAdd newline at end when true
Returns
std::string Formatted elements in "containerAdapter(e1, e2,...)" format

Provides uniform formatting across all container adapters

Reimplemented from original::printable.

Member Data Documentation

◆ serial_

template<typename TYPE, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
SERIAL<TYPE, ALLOC<TYPE> > original::containerAdapter< TYPE, SERIAL, ALLOC >::serial_
protected

The underlying container instance.

Holds the actual container elements and manages memory using the provided allocator. All operations are delegated to this container instance.


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