42 #ifndef TEUCHOS_CONST_NONCONST_OBJECT_CONTAINER_HPP
43 #define TEUCHOS_CONST_NONCONST_OBJECT_CONTAINER_HPP
274 template<
class ObjType>
279 :constObj_(null),isConst_(true) {}
304 { constObj_=null; isConst_=
true; }
330 <<
"\" was given as a const-only object and non-const access is not allowed."
332 return rcp_const_cast<ObjType>(constObj_);
340 {
return constObj_; }
365 {
return constObj_.count(); }
394 #endif // TEUCHOS_CONST_NONCONST_OBJECT_CONTAINER_HPP
int count() const
Return the internal count.
Null reference error exception class.
ConstNonconstObjectContainer()
. Constructs to uninitialized
bool nonnull(const std::shared_ptr< T > &p)
Returns true if p.get()!=NULL.
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
void initialize(const RCP< ObjType > &obj)
. Initialize using a non-const object. Allows both const and non-const access to the contained object...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
ConstNonconstObjectContainer(const RCP< ObjType > &obj)
. Calls initialize() with a non-const object.
bool isConst() const
Returns true if const-only access to the object is allowed.
T * get() const
Get the raw C++ pointer to the underlying object.
ENull
Used to initialize a RCP object to NULL using an implicit conversion!
ConstNonconstObjectContainer(const RCP< const ObjType > &obj)
. Calls initialize() with a const object.
RCP< const ObjType > getConstObj() const
Get an RCP to the const contained object.
void initialize(const RCP< const ObjType > &obj)
. Initialize using a const object. Allows only const access enforced with a runtime check...
const ObjType * operator->() const
Pointer (->) access to underlying const object.
ConstNonconstObjectContainer< ObjType > & operator=(ENull)
bool nonnull(const ConstNonconstObjectContainer< T > &p)
Returns true if p.get()!=NULL.
bool is_null(const ConstNonconstObjectContainer< T > &p)
Returns true if p.get()==NULL.
Simple class supporting the "runtime protection of const" idiom.
Smart reference counting pointer class for automatic garbage collection.
RCP< ObjType > getNonconstObj() const
Get an RCP to the non-const contained object.
RCP< const ObjType > operator()() const
Perform shorthand for getConstObj().
Reference-counted pointer class and non-member templated function implementations.
const ObjType & operator*() const
Dereference the underlying object.
static std::string name()
Null reference error exception class.