NCBI C++ ToolKit
heap_scope.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

00001 #ifndef OBJMGR_IMPL_HEAP_SCOPE__HPP
00002 #define OBJMGR_IMPL_HEAP_SCOPE__HPP
00003 
00004 /*  $Id: heap_scope.hpp 33815 2007-05-04 17:18:18Z kazimird $
00005 * ===========================================================================
00006 *
00007 *                            PUBLIC DOMAIN NOTICE
00008 *               National Center for Biotechnology Information
00009 *
00010 *  This software/database is a "United States Government Work" under the
00011 *  terms of the United States Copyright Act.  It was written as part of
00012 *  the author's official duties as a United States Government employee and
00013 *  thus cannot be copyrighted.  This software/database is freely available
00014 *  to the public for use. The National Library of Medicine and the U.S.
00015 *  Government have not placed any restriction on its use or reproduction.
00016 *
00017 *  Although all reasonable efforts have been taken to ensure the accuracy
00018 *  and reliability of the software and data, the NLM and the U.S.
00019 *  Government do not and cannot warrant the performance or results that
00020 *  may be obtained by using this software or data. The NLM and the U.S.
00021 *  Government disclaim all warranties, express or implied, including
00022 *  warranties of performance, merchantability or fitness for any particular
00023 *  purpose.
00024 *
00025 *  Please cite the author in any work or product based on this material.
00026 *
00027 * ===========================================================================
00028 *
00029 * Authors:
00030 *           Eugene Vasilchenko
00031 *
00032 * File Description:
00033 *           CHeapScope is internal holder of CScope_Impl object
00034 *
00035 */
00036 
00037 #include <corelib/ncbiobj.hpp>
00038 
00039 BEGIN_NCBI_SCOPE
00040 BEGIN_SCOPE(objects)
00041 
00042 // objmgr
00043 class CScope;
00044 class CHeapScope;
00045 class CScope_Impl;
00046 
00047 /////////////////////////////////////////////////////////////////////////////
00048 // CHeapScope
00049 //    Holds reference on heap scope object
00050 //    used internally in interface classes (iterators, handles etc)
00051 /////////////////////////////////////////////////////////////////////////////
00052 
00053 class CHeapScope
00054 {
00055 public:
00056     CHeapScope(void)
00057         {
00058         }
00059     explicit CHeapScope(CScope& scope)
00060         {
00061             Set(&scope);
00062         }
00063     explicit CHeapScope(CScope* scope)
00064         {
00065             Set(scope);
00066         }
00067 
00068     // check is scope is not null
00069     bool IsSet(void) const
00070         {
00071             return m_Scope.NotEmpty();
00072         }
00073     bool IsNull(void) const
00074         {
00075             return !m_Scope;
00076         }
00077 
00078     DECLARE_OPERATOR_BOOL_REF(m_Scope);
00079 
00080     bool operator==(const CHeapScope& scope) const
00081         {
00082             return m_Scope == scope.m_Scope;
00083         }
00084     bool operator!=(const CHeapScope& scope) const
00085         {
00086             return m_Scope != scope.m_Scope;
00087         }
00088     bool operator<(const CHeapScope& scope) const
00089         {
00090             return m_Scope < scope.m_Scope;
00091         }
00092 
00093     // scope getters
00094     NCBI_XOBJMGR_EXPORT CScope& GetScope(void) const;
00095     NCBI_XOBJMGR_EXPORT CScope* GetScopeOrNull(void) const;
00096     operator CScope&(void) const
00097         {
00098             return GetScope();
00099         }
00100     operator CScope*(void) const
00101         {
00102             return &GetScope();
00103         }
00104     CScope& operator*(void) const
00105         {
00106             return GetScope();
00107         }
00108 
00109     // scope impl getters
00110     NCBI_XOBJMGR_EXPORT CScope_Impl* GetImpl(void) const;
00111 
00112     operator CScope_Impl*(void) const
00113         {
00114             return GetImpl();
00115         }
00116     CScope_Impl* operator->(void) const
00117         {
00118             return GetImpl();
00119         }
00120 
00121 
00122     NCBI_XOBJMGR_EXPORT void Set(CScope* scope);
00123     void Reset(void)
00124         {
00125             m_Scope.Reset();
00126         }
00127 
00128 private:
00129     // the reference has to be CObject* to avoid circular header dep.
00130     CRef<CObject> m_Scope;
00131 };
00132 
00133 
00134 /////////////////////////////////////////////////////////////////////////////
00135 // inline methods
00136 /////////////////////////////////////////////////////////////////////////////
00137 
00138 
00139 END_SCOPE(objects)
00140 END_NCBI_SCOPE
00141 
00142 #endif//OBJMGR_IMPL_HEAP_SCOPE__HPP
Modified on Mon Jul 21 17:22:46 2014 by modify_doxy.py rev. 426318