xo-umbrella2/xo-alloc2/docs/IAllocator_Xfer-reference.rst
Roland Conybeare 6a82040d48 git subrepo clone git@github.com:Rconybea/xo-alloc2.git xo-alloc2
subrepo:
  subdir:   "xo-alloc2"
  merged:   "4039c29f"
upstream:
  origin:   "git@github.com:Rconybea/xo-alloc2.git"
  branch:   "main"
  commit:   "4039c29f"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 22:01:14 -04:00

76 lines
3 KiB
ReStructuredText

.. _IAllocator_Xfer-reference:
IAllocator_Xfer
===============
IAllocator_Xfer provides a type-erased interface to a specific native allocator
implementation.
It supports runtime polymorphism for the cpp:class:`xo::mm::AAllocator` facet.
Application code iis unlikely to directly interact with this class
Context
-------
.. ditaa::
:--scale: 0.99
+----------------------+-------------------------+-----------------------------------+
| RAllocator | RAllocIterator | IAllocator_DArena |
| | | IAllocIterator_DArenaIterator |
+----------------------+-------------------------+-----------------------------------+
|cBLU IAllocator_Xfer | IAllocIterator_Xfer | DArena |
+----------------------+ IAllocIterator_Any | DArenaIterator |
| IAllocator_Any | IAllocIterator_Impltype | |
| IAllocator_Impltype | | |
+----------------------+-------------------------+-----------------------------------+
| AAllocator | AAllocIterator | ArenaConfig |
+----------------------+-------------------------+-----------------------------------+
+-----------------+----------------------------------------------+-------------------+
| | AllocInfo | |
| +----------------------------------------------+ |
| AllocError | AllocHeaderConfig | cmpresult |
| +----------------------------------------------+ |
| | AllocHeader | |
+-----------------+----------------------------------------------+-------------------+
Each method operates by downcasting its first argument to the known target
native interface type, and delegating to native interface method with the same name.
For example (paraphrasing):
.. code-block:: cpp
template <typename DRepr, typename IAllocator_DRepr>
bool IAllocator_Xfer<DRepr, IAllocator_DRepr>::contains(Copaque d,
const void * p) const ...
{
return IAllocator_DRepr::contains(*(DRepr*)(d), p);
};
Code for other methods follows the same pattern;
in fact expect to be able to generate class definition mechanically at some point.
Application code will not normally interact with :cpp:class:`IAllocator_Xfer`.
It will be used once for each specific allocator implementation
(e.g. with :cpp:class:`xo::mm::IAllocator_DArena`).
In any case, can include the transfer template with:
.. code-block:: cpp
#include <xo/alloc2/IAllocator_Xfer.hpp>
Class
-----
.. doxygenclass:: xo::mm::IAllocator_Xfer
Types
-----
.. doxygengroup:: mm-allocator-xfer-types
Methods
-------
.. doxygengroup:: mm-allocator-xfer-methods