3 #ifndef SYNCHRONIZED_HEAP_HOST_H
4 #define SYNCHRONIZED_HEAP_HOST_H
9 #include "synchronized_heap_base.h"
12 #include <boost/shared_ptr.hpp>
13 #include <boost/shared_array.hpp>
18 namespace Synchronized {
31 template<
typename t_Type >
38 template<
typename t_Type >
39 inline Pointer< t_Type > Allocate()
const;
41 template<
typename t_Type >
42 inline Pointer< t_Type[] > Allocate(
size_t const count )
const;
45 inline void Synchronize()
const;
48 template<
typename t_Type >
49 struct Pointer :
public boost::shared_ptr< t_Type const > {
51 typedef typename boost::shared_ptr< t_Type const >::element_type element_type;
55 inline Pointer( Pointer
const& other );
58 inline void Assign( element_type
const& data )
const;
63 inline Pointer( t_Type* pointer );
70 template<
typename t_Type >
71 struct Pointer< t_Type[] > :
public boost::shared_array< t_Type const > {
73 typedef typename boost::shared_ptr< t_Type const >::element_type element_type;
77 inline Pointer( Pointer
const& other );
80 inline void Assign(
size_t const index, element_type
const& data )
const;
85 inline Pointer( t_Type* array );
100 template<
typename t_Type >
101 Heap< PLATFORM_HOST >::Pointer< t_Type >::Pointer() {
105 template<
typename t_Type >
106 Heap< PLATFORM_HOST >::Pointer< t_Type >::Pointer( Pointer
const& other ) : boost::shared_ptr< t_Type const >( other ) {
110 template<
typename t_Type >
111 void Heap< PLATFORM_HOST >::Pointer< t_Type >::Assign( element_type
const& data )
const {
113 *
const_cast< t_Type*
>( boost::shared_ptr< t_Type const >::get() ) = data;
117 template<
typename t_Type >
118 Heap< PLATFORM_HOST >::Pointer< t_Type >::Pointer( t_Type* pointer ) : boost::shared_ptr< t_Type const >( pointer ) {
122 template<
typename t_Type >
123 Heap< PLATFORM_HOST >::Pointer< t_Type[] >::Pointer() {
127 template<
typename t_Type >
128 Heap< PLATFORM_HOST >::Pointer< t_Type[] >::Pointer( Pointer
const& other ) : boost::shared_array< t_Type const >( other ) {
132 template<
typename t_Type >
133 void Heap< PLATFORM_HOST >::Pointer< t_Type[] >::Assign(
size_t const index, element_type
const& data )
const {
135 *
const_cast< t_Type*
>( boost::shared_array< t_Type const >::get() + index ) = data;
139 template<
typename t_Type >
140 Heap< PLATFORM_HOST >::Pointer< t_Type[] >::Pointer( t_Type* array ) : boost::shared_array< t_Type const >( array ) {
151 Heap< PLATFORM_HOST >::Heap() {
155 template<
typename t_Type >
156 Heap< PLATFORM_HOST >::Pointer< t_Type > Heap< PLATFORM_HOST >::Allocate()
const {
158 return Pointer< t_Type >(
new t_Type );
162 template<
typename t_Type >
163 Heap< PLATFORM_HOST >::Pointer< t_Type[] > Heap< PLATFORM_HOST >::Allocate(
size_t const size )
const {
165 return Pointer< t_Type[] >(
new t_Type[ size ] );
169 void Heap< PLATFORM_HOST >::Synchronize()
const {
180 #endif // SYNCHRONIZED_HEAP_HOST_H