Public Member Functions | Protected Attributes | Related Functions | List of all members
vil_memory_chunk Class Reference

Ref. counted block of data on the heap. More...

#include <vil_memory_chunk.h>

Public Member Functions

 vil_memory_chunk ()
 Dflt ctor. More...
 
 vil_memory_chunk (std::size_t n, vil_pixel_format pixel_format)
 Allocate n bytes of memory. More...
 
 vil_memory_chunk (const vil_memory_chunk &)
 Copy ctor. More...
 
vil_memory_chunkoperator= (const vil_memory_chunk &)
 Copy operator. More...
 
virtual ~vil_memory_chunk ()
 Destructor. More...
 
void ref ()
 Increment reference count. More...
 
void unref ()
 Decrement reference count. More...
 
long ref_count () const
 Number of objects referring to this data. More...
 
virtual void * data ()
 Pointer to first element of data. More...
 
virtual void * const_data () const
 Pointer to first element of data. More...
 
vil_pixel_format pixel_format () const
 Indicate what format data is to be saved as in binary IO. More...
 
std::size_t size () const
 Number of bytes allocated. More...
 
virtual void set_size (unsigned long n, vil_pixel_format pixel_format)
 Create space for n bytes. More...
 

Protected Attributes

void * data_
 Data. More...
 
std::size_t size_
 Number of elements (bytes). More...
 
vil_pixel_format pixel_format_
 Indicate what format data is (used for binary IO). More...
 
vcl_atomic_count ref_count_
 Reference count. More...
 

Related Functions

(Note that these are not member functions.)

void vsl_b_write (vsl_b_ostream &os, const vil_memory_chunk &chunk)
 Binary save vil_memory_chunk to stream. More...
 
void vsl_b_read (vsl_b_istream &is, vil_memory_chunk &chunk)
 Binary load vil_memory_chunk from stream. More...
 
void vsl_b_write (vsl_b_ostream &os, const vil_memory_chunk *chunk)
 Binary save vil_memory_chunk to stream by pointer. More...
 
void vsl_b_read (vsl_b_istream &is, vil_memory_chunk *&chunk)
 Binary load vil_memory_chunk from stream onto the heap. More...
 
void vsl_print_summary (std::ostream &os, const vil_memory_chunk &chunk)
 Print human readable summary of a vil_memory_chunk object to a stream. More...
 
void vsl_print_summary (std::ostream &os, const vil_memory_chunk *chunk)
 Print human readable summary of a vil_memory_chunk object to a stream. More...
 

Detailed Description

Ref. counted block of data on the heap.

Image data block used by vil_image_view<T>.

Definition at line 19 of file vil_memory_chunk.h.

Constructor & Destructor Documentation

◆ vil_memory_chunk() [1/3]

vil_memory_chunk::vil_memory_chunk ( )

Dflt ctor.

Definition at line 14 of file vil_memory_chunk.cxx.

◆ vil_memory_chunk() [2/3]

vil_memory_chunk::vil_memory_chunk ( std::size_t  n,
vil_pixel_format  pixel_format 
)

Allocate n bytes of memory.

Parameters
pixel_formatindicates what format to be used for binary IO, and should always be a scalar type.

Definition at line 20 of file vil_memory_chunk.cxx.

◆ vil_memory_chunk() [3/3]

vil_memory_chunk::vil_memory_chunk ( const vil_memory_chunk d)

Copy ctor.

Definition at line 34 of file vil_memory_chunk.cxx.

◆ ~vil_memory_chunk()

vil_memory_chunk::~vil_memory_chunk ( )
virtual

Destructor.

Definition at line 28 of file vil_memory_chunk.cxx.

Member Function Documentation

◆ const_data()

void * vil_memory_chunk::const_data ( ) const
virtual

Pointer to first element of data.

Definition at line 68 of file vil_memory_chunk.cxx.

◆ data()

void * vil_memory_chunk::data ( )
virtual

Pointer to first element of data.

Definition at line 65 of file vil_memory_chunk.cxx.

◆ operator=()

vil_memory_chunk & vil_memory_chunk::operator= ( const vil_memory_chunk d)

Copy operator.

Assignment operator.

Definition at line 41 of file vil_memory_chunk.cxx.

◆ pixel_format()

vil_pixel_format vil_memory_chunk::pixel_format ( ) const
inline

Indicate what format data is to be saved as in binary IO.

Definition at line 69 of file vil_memory_chunk.h.

◆ ref()

void vil_memory_chunk::ref ( )
inline

Increment reference count.

Definition at line 54 of file vil_memory_chunk.h.

◆ ref_count()

long vil_memory_chunk::ref_count ( ) const
inline

Number of objects referring to this data.

Definition at line 60 of file vil_memory_chunk.h.

◆ set_size()

void vil_memory_chunk::set_size ( unsigned long  n,
vil_pixel_format  pixel_form 
)
virtual

Create space for n bytes.

Create empty space for n elements.

pixel_format indicates what format to be used for binary IO

Leave existing data untouched if the size is already n.

Definition at line 72 of file vil_memory_chunk.cxx.

◆ size()

std::size_t vil_memory_chunk::size ( ) const
inline

Number of bytes allocated.

Definition at line 72 of file vil_memory_chunk.h.

◆ unref()

void vil_memory_chunk::unref ( )

Decrement reference count.

Decrement reference count and call destructor when it becomes zero.

Definition at line 51 of file vil_memory_chunk.cxx.

Friends And Related Function Documentation

◆ vsl_b_read() [1/2]

void vsl_b_read ( vsl_b_istream &  is,
vil_memory_chunk chunk 
)
related

Binary load vil_memory_chunk from stream.

Definition at line 99 of file vil_io_memory_chunk.cxx.

◆ vsl_b_read() [2/2]

void vsl_b_read ( vsl_b_istream &  is,
vil_memory_chunk *&  chunk 
)
related

Binary load vil_memory_chunk from stream onto the heap.

Definition at line 287 of file vil_io_memory_chunk.cxx.

◆ vsl_b_write() [1/2]

void vsl_b_write ( vsl_b_ostream &  os,
const vil_memory_chunk chunk 
)
related

Binary save vil_memory_chunk to stream.

Definition at line 21 of file vil_io_memory_chunk.cxx.

◆ vsl_b_write() [2/2]

void vsl_b_write ( vsl_b_ostream &  os,
const vil_memory_chunk chunk 
)
related

Binary save vil_memory_chunk to stream by pointer.

Definition at line 278 of file vil_io_memory_chunk.cxx.

◆ vsl_print_summary() [1/2]

void vsl_print_summary ( std::ostream &  os,
const vil_memory_chunk chunk 
)
related

Print human readable summary of a vil_memory_chunk object to a stream.

Definition at line 302 of file vil_io_memory_chunk.cxx.

◆ vsl_print_summary() [2/2]

void vsl_print_summary ( std::ostream &  os,
const vil_memory_chunk chunk 
)
related

Print human readable summary of a vil_memory_chunk object to a stream.

Definition at line 34 of file vil_io_memory_chunk.h.

Member Data Documentation

◆ data_

void* vil_memory_chunk::data_
protected

Data.

Definition at line 23 of file vil_memory_chunk.h.

◆ pixel_format_

vil_pixel_format vil_memory_chunk::pixel_format_
protected

Indicate what format data is (used for binary IO).

Should always be a scalar type.

Definition at line 30 of file vil_memory_chunk.h.

◆ ref_count_

vcl_atomic_count vil_memory_chunk::ref_count_
protected

Reference count.

Definition at line 33 of file vil_memory_chunk.h.

◆ size_

std::size_t vil_memory_chunk::size_
protected

Number of elements (bytes).

Definition at line 26 of file vil_memory_chunk.h.


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