Skip to content

Commit

Permalink
Update for C++11 standard library
Browse files Browse the repository at this point in the history
This commit represents the collective efforts of the BDE team
to significantly advance the C++11 conformance of the 'bsl'
library, initially on the shared 'cpp11/baseline' branch, and
now squashed as a single (revertible) commit for the master
branch.
  • Loading branch information
Alisdair Meredith committed Jun 15, 2016
1 parent 9ce87db commit 8f501dd
Show file tree
Hide file tree
Showing 397 changed files with 186,747 additions and 57,734 deletions.
14 changes: 8 additions & 6 deletions groups/bal/balb/balb_controlmanager.cpp
Expand Up @@ -167,17 +167,18 @@ void ControlManager::printUsage(bsl::ostream& stream,

// CREATORS

ControlManager_Entry::ControlManager_Entry(bslma::Allocator *basicAllocator)
ControlManager::ControlManager_Entry::ControlManager_Entry(
bslma::Allocator *basicAllocator)
: d_callback(bsl::allocator_arg_t(),
bsl::allocator<ControlManager::ControlHandler>(basicAllocator))
, d_arguments(basicAllocator)
, d_description(basicAllocator)
{}

ControlManager_Entry::~ControlManager_Entry()
ControlManager::ControlManager_Entry::~ControlManager_Entry()
{}

ControlManager_Entry::ControlManager_Entry(
ControlManager::ControlManager_Entry::ControlManager_Entry(
const ControlManager::ControlHandler& callback,
const bsl::string& arguments,
const bsl::string& description,
Expand All @@ -189,7 +190,7 @@ ControlManager_Entry::ControlManager_Entry(
, d_description(description, basicAllocator)
{}

ControlManager_Entry::ControlManager_Entry(
ControlManager::ControlManager_Entry::ControlManager_Entry(
const ControlManager_Entry& original,
bslma::Allocator *basicAllocator)
: d_callback(bsl::allocator_arg_t(),
Expand All @@ -201,8 +202,9 @@ ControlManager_Entry::ControlManager_Entry(

// MANIPULATORS

ControlManager_Entry&
ControlManager_Entry::operator=(const ControlManager_Entry& rhs)
ControlManager::ControlManager_Entry&
ControlManager::ControlManager_Entry::operator=(
const ControlManager_Entry& rhs)
{
if (&rhs != this) {
d_callback = rhs.d_callback;
Expand Down
178 changes: 94 additions & 84 deletions groups/bal/balb/balb_controlmanager.h
Expand Up @@ -117,7 +117,7 @@ namespace BloombergLP {

namespace balb {

class ControlManager_Entry;
//class ControlManager_Entry;

// ====================
// class ControlManager
Expand All @@ -126,22 +126,6 @@ class ControlManager_Entry;
class ControlManager {
// Dispatch control messages to callbacks by name.

// PRIVATE TYPES
typedef bsl::map<bsl::string,
ControlManager_Entry,
bool(*)(const bsl::string&, const bsl::string&)> Registry;
// Defines a type alias for the ordered associative data structure
// that maps a message prefix to a 'StringComparator' functor.

// INSTANCE DATA
bslma::Allocator *d_allocator_p; // memory allocator (held)
Registry d_registry; // registry
mutable bslmt::RWMutex d_registryMutex; // registry mutex

// NOT IMPLEMENTED
ControlManager(const ControlManager&); // = deleted
ControlManager& operator=(const ControlManager&); // = deletd

public:
// TYPES
typedef bsl::function<void(const bsl::string& prefix,
Expand All @@ -151,70 +135,19 @@ class ControlManager {
// read from the message, and the 'stream' argument is the
// 'bsl::istream' containing the remainder of the message.

// TRAITS
BSLALG_DECLARE_NESTED_TRAITS(ControlManager,
bslalg::TypeTraitUsesBslmaAllocator);

// CREATORS
explicit
ControlManager(bslma::Allocator *basicAllocator = 0);
// Create a control manager object. Optionally specify a
// 'basicAllocator' used to supply memory. If 'basicAllocator' is 0,
// the currently installed default allocator is used.

~ControlManager();
// Destroy this object.

// MANIPULATORS
int registerHandler(const bsl::string& prefix,
const bsl::string& arguments,
const bsl::string& description,
const ControlHandler& handler);
// Register the specified 'handler' to be invoked whenever a control
// message having the specified case-insensitive 'prefix' is received
// for this control manager. Also register the specified 'arguments'
// string to describe the arguments accepted by the message, and the
// specified 'description' to describe its operation; these are
// printed by 'printUsage'. Return a positive value if an existing
// callback was replaced, return 0 if no replacement occurred, and
// return a negative value otherwise.

int deregisterHandler(const bsl::string& prefix);
// Deregister the callback function previously registered to handle the
// specified 'prefix'. Return 0 on success or a non-zero value
// otherwise.

// ACCESSOR
int dispatchMessage(const bsl::string& message) const;
// Parse the specified complete 'message' and dispatch it. Return
// 0 on success, and a non-zero value otherwise; in particular return
// non-zero if no registered callback could be found for the
// case-insensitive prefix in 'message'.

int dispatchMessage(const bsl::string& prefix, bsl::istream& stream) const;
// Dispatch the message contained in the specified 'stream' to the
// callback associated with the specified 'prefix'. Return 0 on
// success, and a non-zero value otherwise; in particular return
// non-zero if no registered callback could be found for the
// case-insensitive 'prefix'.

void printUsage(bsl::ostream& stream, const bsl::string& preamble) const;
// Print to the specified 'stream' the specified 'preamble' text,
// followed by the registered commands and documentation for this
// control manager. Note that a newline is appended to 'preamble' in
// the output.

void printUsageHelper(bsl::ostream *stream,
const bsl::string& preamble) const;
// Invoke 'printUsage' passing the specified '*stream' and 'preamble'.
// Suitable for binding using the bdlf::BindUtil package.

};

// PRIVATE TYPES
// ==========================
// class ControlManager_Entry
// ==========================

// IMPLEMENTATION NOTE: The Sun Studio 12.3 compiler does not support 'map's
// holding types that are incomplete at the point of declaration of a data
// member. Other compilers allow us to complete 'CalendarChache_Entry' at a
// later point in the code, but before any operation (such as 'insert') that
// would require the type to be complete. If we did not have to support this
// compiler, this whole class could be defined in the .cpp file; as it stands,
// it *must* be defined before class 'CalendarCache'.

class ControlManager_Entry {
// This component-private class represents a function with documentation.

Expand Down Expand Up @@ -283,49 +216,126 @@ class ControlManager_Entry {
// object.
};

typedef bsl::map<bsl::string,
ControlManager_Entry,
bool(*)(const bsl::string&, const bsl::string&)> Registry;
// Defines a type alias for the ordered associative data structure
// that maps a message prefix to a 'StringComparator' functor.

// INSTANCE DATA
bslma::Allocator *d_allocator_p; // memory allocator (held)
Registry d_registry; // registry
mutable bslmt::RWMutex d_registryMutex; // registry mutex

// NOT IMPLEMENTED
ControlManager(const ControlManager&); // = deleted
ControlManager& operator=(const ControlManager&); // = deletd

public:
// TRAITS
BSLALG_DECLARE_NESTED_TRAITS(ControlManager,
bslalg::TypeTraitUsesBslmaAllocator);

// CREATORS
explicit
ControlManager(bslma::Allocator *basicAllocator = 0);
// Create a control manager object. Optionally specify a
// 'basicAllocator' used to supply memory. If 'basicAllocator' is 0,
// the currently installed default allocator is used.

~ControlManager();
// Destroy this object.

// MANIPULATORS
int registerHandler(const bsl::string& prefix,
const bsl::string& arguments,
const bsl::string& description,
const ControlHandler& handler);
// Register the specified 'handler' to be invoked whenever a control
// message having the specified case-insensitive 'prefix' is received
// for this control manager. Also register the specified 'arguments'
// string to describe the arguments accepted by the message, and the
// specified 'description' to describe its operation; these are
// printed by 'printUsage'. Return a positive value if an existing
// callback was replaced, return 0 if no replacement occurred, and
// return a negative value otherwise.

int deregisterHandler(const bsl::string& prefix);
// Deregister the callback function previously registered to handle the
// specified 'prefix'. Return 0 on success or a non-zero value
// otherwise.

// ACCESSOR
int dispatchMessage(const bsl::string& message) const;
// Parse the specified complete 'message' and dispatch it. Return
// 0 on success, and a non-zero value otherwise; in particular return
// non-zero if no registered callback could be found for the
// case-insensitive prefix in 'message'.

int dispatchMessage(const bsl::string& prefix, bsl::istream& stream) const;
// Dispatch the message contained in the specified 'stream' to the
// callback associated with the specified 'prefix'. Return 0 on
// success, and a non-zero value otherwise; in particular return
// non-zero if no registered callback could be found for the
// case-insensitive 'prefix'.

void printUsage(bsl::ostream& stream, const bsl::string& preamble) const;
// Print to the specified 'stream' the specified 'preamble' text,
// followed by the registered commands and documentation for this
// control manager. Note that a newline is appended to 'preamble' in
// the output.

void printUsageHelper(bsl::ostream *stream,
const bsl::string& preamble) const;
// Invoke 'printUsage' passing the specified '*stream' and 'preamble'.
// Suitable for binding using the bdlf::BindUtil package.

};

// ============================================================================
// INLINE DEFINITIONS
// ============================================================================

// --------------------------
// class ControlManager_Entry
// class ControlManager::ControlManager_Entry
// --------------------------

// MANIPULATORS
inline
void ControlManager_Entry::setCallback(
void ControlManager::ControlManager_Entry::setCallback(
const ControlManager::ControlHandler& callback)
{
d_callback = callback;
}

inline
bsl::string& ControlManager_Entry::arguments()
bsl::string& ControlManager::ControlManager_Entry::arguments()
{
return d_arguments;
}

inline
bsl::string& ControlManager_Entry::description()
bsl::string& ControlManager::ControlManager_Entry::description()
{
return d_description;
}

// ACCESSORS
inline
const ControlManager::ControlHandler& ControlManager_Entry::callback() const
const ControlManager::ControlHandler&
ControlManager::ControlManager_Entry::callback() const
{
return d_callback;
}

inline
const bsl::string& ControlManager_Entry::arguments() const
const bsl::string& ControlManager::ControlManager_Entry::arguments() const
{
return d_arguments;
}

inline
const bsl::string& ControlManager_Entry::description() const
const bsl::string& ControlManager::ControlManager_Entry::description() const
{
return d_description;
}
Expand Down
54 changes: 0 additions & 54 deletions groups/bdl/bdlt/bdlt_calendarcache.cpp
Expand Up @@ -19,60 +19,6 @@ BSLS_IDENT_RCSID(bdlt_calendarcache_cpp,"$Id$ $CSID$")
namespace BloombergLP {
namespace bdlt {

// =========================
// class CalendarCache_Entry
// =========================

class CalendarCache_Entry {
// This class defines the type of objects that are inserted into the
// calendar cache. Each entry contains a shared pointer to a read-only
// calendar and the time at which that calendar was loaded. Note that an
// explicit allocator is *required* to create a entry object.

// DATA
bsl::shared_ptr<const Calendar> d_ptr; // shared pointer to
// out-of-place instance

Datetime d_loadTime; // time when calendar was
// loaded

public:
// CREATORS
CalendarCache_Entry();
// Create an empty cache entry object. Note that an empty cache entry
// is never actually inserted into the cache.

CalendarCache_Entry(Calendar *calendar,
Datetime loadTime,
bslma::Allocator *allocator);
// Create a cache entry object for managing the specified 'calendar'
// that was loaded at the specified 'loadTime' using the specified
// 'allocator'. The behavior is undefined unless 'calendar' uses
// 'allocator' to obtain memory.

CalendarCache_Entry(const CalendarCache_Entry& original);
// Create a cache entry object having the value of the specified
// 'original' object.

~CalendarCache_Entry();
// Destroy this cache entry object.

// MANIPULATORS
CalendarCache_Entry& operator=(const CalendarCache_Entry&);
// Assign to this cache entry object the value of the specified 'rhs'
// object, and return a reference providing modifiable access to this
// object.

// ACCESSORS
bsl::shared_ptr<const Calendar> get() const;
// Return a shared pointer providing non-modifiable access to the
// calendar referred to by this cache entry object.

Datetime loadTime() const;
// Return the time at which the calendar referred to by this cache
// entry object was loaded.
};

// -------------------------
// class CalendarCache_Entry
// -------------------------
Expand Down

0 comments on commit 8f501dd

Please sign in to comment.