DNA Calib 1.1
Project brief
Namespaces | Classes | Typedefs | Functions
pma Namespace Reference

Namespaces

namespace  impl
 

Classes

class  AlignedMemoryResource
 A MemoryResource that honors alignment requirements. More...
 
class  ArenaMemoryResource
 Serves allocations from a preallocated memory region. More...
 
struct  DefaultInstanceCreator
 
struct  DefaultInstanceCreator< dna::BinaryStreamReader >
 
struct  DefaultInstanceCreator< dna::BinaryStreamWriter >
 
struct  DefaultInstanceCreator< dna::JSONStreamReader >
 
struct  DefaultInstanceCreator< dna::JSONStreamWriter >
 
struct  DefaultInstanceCreator< dnac::DNACalibDNAReader >
 
struct  DefaultInstanceCreator< trio::FileStream >
 
struct  DefaultInstanceCreator< trio::MemoryMappedFileStream >
 
struct  DefaultInstanceCreator< trio::MemoryStream >
 
struct  DefaultInstanceDestroyer
 
struct  DefaultInstanceDestroyer< dna::BinaryStreamReader >
 
struct  DefaultInstanceDestroyer< dna::BinaryStreamWriter >
 
struct  DefaultInstanceDestroyer< dna::JSONStreamReader >
 
struct  DefaultInstanceDestroyer< dna::JSONStreamWriter >
 
struct  DefaultInstanceDestroyer< dnac::DNACalibDNAReader >
 
struct  DefaultInstanceDestroyer< trio::FileStream >
 
struct  DefaultInstanceDestroyer< trio::MemoryMappedFileStream >
 
struct  DefaultInstanceDestroyer< trio::MemoryStream >
 
class  DefaultMemoryResource
 A MemoryResource that delegates to malloc / free. More...
 
struct  Delete
 
struct  Delete< T[]>
 
struct  FactoryCreate
 
struct  FactoryDestroy
 
class  MemoryResource
 MemoryResource is an abstract class that allows the implementation of polymorphic allocators. More...
 
struct  New
 
struct  New< T[]>
 
class  PolyAllocator
 
class  ScopedPtr
 Takes ownership over the given pointer and handles it's lifetime. More...
 

Typedefs

template<typename T , typename Allocator = PolyAllocator<T>>
using String = std::basic_string< T, std::char_traits< T >, Allocator >
 
template<typename T , typename Allocator = PolyAllocator<T>>
using Vector = std::vector< T, Allocator >
 
template<typename T , typename Allocator = PolyAllocator<Vector<T> >>
using Matrix = Vector< Vector< T >, Allocator >
 
template<typename T , typename Allocator = PolyAllocator<T>>
using List = std::list< T, Allocator >
 
template<typename T , typename Allocator = PolyAllocator<T>>
using Set = std::set< T, std::less< T >, Allocator >
 
template<typename T , typename Allocator = PolyAllocator<T>>
using UnorderedSet = std::unordered_set< T, std::hash< T >, std::equal_to< T >, Allocator >
 
template<typename K , typename V , typename Allocator = PolyAllocator<std::pair<const K, V> >>
using Map = std::map< K, V, std::less< K >, Allocator >
 
template<typename K , typename V , typename Allocator = PolyAllocator<std::pair<const K, V> >>
using UnorderedMap = std::unordered_map< K, V, std::hash< K >, std::equal_to< K >, Allocator >
 
template<class TTarget , class TBase = TTarget>
using UniqueInstance = impl::ManagedInstance< std::unique_ptr< TBase, std::function< void(TBase *)> >, TTarget, TBase >
 
template<class TTarget , class TBase = TTarget>
using SharedInstance = impl::ManagedInstance< std::shared_ptr< TBase >, TTarget, TBase >
 

Functions

template<typename T , std::size_t TAlignment, class TDefaultMemoryResource , typename U , std::size_t UAlignment, class UDefaultMemoryResource >
bool operator== (const PolyAllocator< T, TAlignment, TDefaultMemoryResource > &lhs, const PolyAllocator< U, UAlignment, UDefaultMemoryResource > &rhs)
 
template<typename T , std::size_t TAlignment, class TDefaultMemoryResource , typename U , std::size_t UAlignment, class UDefaultMemoryResource >
bool operator!= (const PolyAllocator< T, TAlignment, TDefaultMemoryResource > &lhs, const PolyAllocator< U, UAlignment, UDefaultMemoryResource > &rhs)
 
template<class T , class TCreator , class TDestroyer , typename ... Args, typename Base = typename std::remove_pointer < decltype(TCreator{} (std::declval<Args>()...)) > ::type>
ScopedPtr< Base, TDestroyer > makeScoped (Args &&... args)
 Syntactic sugar for creating instances wrapped in a ScopedPtr. More...
 
template<class T , template< class ... > class TCreatorTemplate, template< class ... > class TDestroyerTemplate, typename ... Args>
ScopedPtr< T, TDestroyerTemplate< T > > makeScoped (Args &&... args)
 
template<class T , typename ... Args>
ScopedPtr< T, typename DefaultInstanceDestroyer< T >::type > makeScoped (Args &&... args)
 
std::uintptr_t alignAddress (std::uintptr_t address, std::size_t alignment)
 
template<typename T >
T * alignPointer (T *ptr, std::size_t alignment)
 

Typedef Documentation

◆ List

template<typename T , typename Allocator = PolyAllocator<T>>
using pma::List = typedef std::list<T, Allocator>

◆ Map

template<typename K , typename V , typename Allocator = PolyAllocator<std::pair<const K, V> >>
using pma::Map = typedef std::map<K, V, std::less<K>, Allocator>

◆ Matrix

template<typename T , typename Allocator = PolyAllocator<Vector<T> >>
using pma::Matrix = typedef Vector<Vector<T>, Allocator>

◆ Set

template<typename T , typename Allocator = PolyAllocator<T>>
using pma::Set = typedef std::set<T, std::less<T>, Allocator>

◆ SharedInstance

template<class TTarget , class TBase = TTarget>
using pma::SharedInstance = typedef impl::ManagedInstance<std::shared_ptr<TBase>, TTarget, TBase>

◆ String

template<typename T , typename Allocator = PolyAllocator<T>>
using pma::String = typedef std::basic_string<T, std::char_traits<T>, Allocator>

◆ UniqueInstance

template<class TTarget , class TBase = TTarget>
using pma::UniqueInstance = typedef impl::ManagedInstance<std::unique_ptr<TBase, std::function<void (TBase*)> >, TTarget, TBase>

◆ UnorderedMap

template<typename K , typename V , typename Allocator = PolyAllocator<std::pair<const K, V> >>
using pma::UnorderedMap = typedef std::unordered_map<K, V, std::hash<K>, std::equal_to<K>, Allocator>

◆ UnorderedSet

template<typename T , typename Allocator = PolyAllocator<T>>
using pma::UnorderedSet = typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, Allocator>

◆ Vector

template<typename T , typename Allocator = PolyAllocator<T>>
using pma::Vector = typedef std::vector<T, Allocator>

Function Documentation

◆ alignAddress()

std::uintptr_t pma::alignAddress ( std::uintptr_t  address,
std::size_t  alignment 
)
inline
15 {
16 const std::size_t mask = alignment - 1ul;
17 assert((alignment & mask) == 0ul);
18 return (address + mask) & ~mask;
19}

Referenced by alignPointer().

◆ alignPointer()

template<typename T >
T * pma::alignPointer ( T *  ptr,
std::size_t  alignment 
)
inline
22 {
23 const std::uintptr_t address = reinterpret_cast<std::uintptr_t>(ptr);
24 const std::uintptr_t aligned = alignAddress(address, alignment);
25 return reinterpret_cast<T*>(aligned);
26}
std::uintptr_t alignAddress(std::uintptr_t address, std::size_t alignment)
Definition: AlignedMemoryResource.cpp:31

References alignAddress().

Referenced by pma::ArenaMemoryResource::Impl::allocate().

◆ makeScoped() [1/3]

template<class T , class TCreator , class TDestroyer , typename ... Args, typename Base = typename std::remove_pointer < decltype(TCreator{} (std::declval<Args>()...)) > ::type>
ScopedPtr< Base, TDestroyer > pma::makeScoped ( Args &&...  args)

Syntactic sugar for creating instances wrapped in a ScopedPtr.

Note
The default behavior is to rely on the New / Delete pair of lifetime managers, because it's sensible to do so. However, because a significant portion of our abstractions follow the convention of exposing a create / destroy pair of factory functions (where create always returns a raw pointer), there also exists a dedicated FactoryCreate / FactoryDestroy pair of lifetime managers. To change the default behavior in order to utilize a specific lifetime manager pair, specialize the DefaultInstanceCreator and DefaultInstanceDestroyer traits for the types that need different handling. Alternately, it's also possible to pass a custom creator / destroyer on each invocation.
252 {
253 static_assert(std::is_same<Base, T>::value ||
254 std::is_base_of<Base, T>::value ||
255 std::is_convertible<T, typename std::add_pointer<Base>::type>::value,
256 "Incompatible types.");
257 return ScopedPtr<Base, TDestroyer>{TCreator{} (std::forward<Args>(args)...)};
258}
Takes ownership over the given pointer and handles it's lifetime.
Definition: ScopedPtr.h:116

◆ makeScoped() [2/3]

template<class T , template< class ... > class TCreatorTemplate, template< class ... > class TDestroyerTemplate, typename ... Args>
ScopedPtr< T, TDestroyerTemplate< T > > pma::makeScoped ( Args &&...  args)
261 {
262 using TCreator = TCreatorTemplate<T>;
263 using TDestroyer = TDestroyerTemplate<T>;
264 return makeScoped<T, TCreator, TDestroyer>(std::forward<Args>(args)...);
265}

◆ makeScoped() [3/3]

template<class T , typename ... Args>
ScopedPtr< T, typename DefaultInstanceDestroyer< T >::type > pma::makeScoped ( Args &&...  args)
268 {
269 using TCreator = typename DefaultInstanceCreator<T>::type;
270 using TDestroyer = typename DefaultInstanceDestroyer<T>::type;
271 return makeScoped<T, TCreator, TDestroyer>(std::forward<Args>(args)...);
272}
Definition: ScopedPtr.h:26
Definition: ScopedPtr.h:17

◆ operator!=()

template<typename T , std::size_t TAlignment, class TDefaultMemoryResource , typename U , std::size_t UAlignment, class UDefaultMemoryResource >
bool pma::operator!= ( const PolyAllocator< T, TAlignment, TDefaultMemoryResource > &  lhs,
const PolyAllocator< U, UAlignment, UDefaultMemoryResource > &  rhs 
)
167{
168 return !(lhs == rhs);
169}

◆ operator==()

template<typename T , std::size_t TAlignment, class TDefaultMemoryResource , typename U , std::size_t UAlignment, class UDefaultMemoryResource >
bool pma::operator== ( const PolyAllocator< T, TAlignment, TDefaultMemoryResource > &  lhs,
const PolyAllocator< U, UAlignment, UDefaultMemoryResource > &  rhs 
)
159{
160 return (TAlignment == UAlignment && lhs.getMemoryResource() == rhs.getMemoryResource());
161}