Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bdld::ManagedDatum Class Reference

#include <bdld_manageddatum.h>

List of all members.

Public Types

typedef bsl::allocator< char > allocator_type

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (ManagedDatum, bslma::UsesBslmaAllocator)
 BSLMF_NESTED_TRAIT_DECLARATION (ManagedDatum, bslmf::IsBitwiseMoveable)
 ManagedDatum ()
 ManagedDatum (const allocator_type &allocator)
 ManagedDatum (const Datum &datum, const allocator_type &allocator=allocator_type())
 ManagedDatum (const ManagedDatum &original, const allocator_type &allocator=allocator_type())
 ~ManagedDatum ()
ManagedDatumoperator= (const ManagedDatum &rhs)
void adopt (const Datum &obj)
void clone (const Datum &value)
void makeNull ()
Datum release ()
void swap (ManagedDatum &other)
const Datumoperator-> () const
const Datumoperator* () const
const Datumdatum () const
bslma::Allocatorallocator () const
allocator_type get_allocator () const
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const

Detailed Description

This class implements a smart-pointer-like resource manager for a Datum object.

See Component bdld_manageddatum


Member Typedef Documentation


Constructor & Destructor Documentation

bdld::ManagedDatum::ManagedDatum (  ) 
bdld::ManagedDatum::ManagedDatum ( const allocator_type allocator  )  [explicit]

Create a ManagedDatum object having the default (null) value. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. Calling isNull on the resulting managed Datum object returns true.

bdld::ManagedDatum::ManagedDatum ( const Datum datum,
const allocator_type allocator = allocator_type() 
) [explicit]

Create a ManagedDatum object that assumes ownership of the specified datum. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used. The behavior is undefined unless datum was allocated using the indicated allocator and is not subsequently destroyed externally using Datum::destroy.

bdld::ManagedDatum::ManagedDatum ( const ManagedDatum original,
const allocator_type allocator = allocator_type() 
)

Create a ManagedDatum object having the same value as the specified original object. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) used to supply memory; otherwise, the default allocator is used. This operation performs a clone of the underlying Datum, see Value Semantics for more detail.

bdld::ManagedDatum::~ManagedDatum (  ) 

Destroy this object and release all dynamically allocated memory managed by this object.


Member Function Documentation

bdld::ManagedDatum::BSLMF_NESTED_TRAIT_DECLARATION ( ManagedDatum  ,
bslma::UsesBslmaAllocator   
)
bdld::ManagedDatum::BSLMF_NESTED_TRAIT_DECLARATION ( ManagedDatum  ,
bslmf::IsBitwiseMoveable   
)

ManagedDatum objects are allocator-aware and bitwise movable.

ManagedDatum& bdld::ManagedDatum::operator= ( const ManagedDatum rhs  ) 

Assign to this object the value of the specified rhs object, and return a non-'const' reference to this object. This operation performs a clone of the underlying Datum, see Value Semantics for more detail.

void bdld::ManagedDatum::adopt ( const Datum obj  ) 

Take ownership of the specified obj and destroy the Datum object previously managed by this object. The behavior is undefined unless obj was allocated using the same allocator used by this object and is not subsequently destroyed externally using Datum::destroy.

void bdld::ManagedDatum::clone ( const Datum value  ) 

Assign to this object the specified value by making a "deep copy" of value, so that any dynamically allocated memory managed by value is cloned and not shared with value.

void bdld::ManagedDatum::makeNull (  ) 

Make the Datum object managed by this object null and release all dynamically allocated memory managed by this object.

Datum bdld::ManagedDatum::release (  ) 

Return, by value, the Datum object managed by this object and set the managed object to null. Ownership of the previously managed Datum object is transferred to the caller.

void bdld::ManagedDatum::swap ( ManagedDatum other  ) 

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless this object was created with the same allocator as other.

const Datum* bdld::ManagedDatum::operator-> (  )  const

Return an address providing non-modifiable access to the Datum object managed by this object.

const Datum& bdld::ManagedDatum::operator* (  )  const

Return a const reference to the Datum object managed by this object.

const Datum& bdld::ManagedDatum::datum (  )  const

Return a const reference to the Datum object managed by this object.

bslma::Allocator* bdld::ManagedDatum::allocator (  )  const

DEPRECATED: Use get_allocator() instead.

Return get_allocator().mechanism().

allocator_type bdld::ManagedDatum::get_allocator (  )  const

Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.

bsl::ostream& bdld::ManagedDatum::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.


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