1 /*  $Id: heap_scope.cpp 103491 2007-05-04 17:18:18Z kazimird $
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *               National Center for Biotechnology Information
6 *
7 *  This software/database is a "United States Government Work" under the
8 *  terms of the United States Copyright Act.  It was written as part of
9 *  the author's official duties as a United States Government employee and
10 *  thus cannot be copyrighted.  This software/database is freely available
11 *  to the public for use. The National Library of Medicine and the U.S.
12 *  Government have not placed any restriction on its use or reproduction.
13 *
14 *  Although all reasonable efforts have been taken to ensure the accuracy
15 *  and reliability of the software and data, the NLM and the U.S.
16 *  Government do not and cannot warrant the performance or results that
17 *  may be obtained by using this software or data. The NLM and the U.S.
18 *  Government disclaim all warranties, express or implied, including
19 *  warranties of performance, merchantability or fitness for any particular
20 *  purpose.
21 *
22 *  Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors:
27 *           Andrei Gourianov
28 *           Aleksey Grichenko
29 *           Michael Kimelman
30 *           Denis Vakatov
31 *           Eugene Vasilchenko
32 *
33 * File Description:
34 *           Scope is top-level object available to a client.
35 *           Its purpose is to define a scope of visibility and reference
36 *           resolution and provide access to the bio sequence data
37 *
38 */
39 
40 #include <ncbi_pch.hpp>
41 #include <objmgr/impl/heap_scope.hpp>
42 #include <objmgr/impl/scope_impl.hpp>
43 #include <objmgr/scope.hpp>
44 
45 BEGIN_NCBI_SCOPE
BEGIN_SCOPE(objects)46 BEGIN_SCOPE(objects)
47 
48 
49 /////////////////////////////////////////////////////////////////////////////
50 //
51 // CHeapScope
52 //
53 /////////////////////////////////////////////////////////////////////////////
54 
55 
56 void CHeapScope::Set(CScope* scope)
57 {
58     if ( scope ) {
59         m_Scope.Reset(scope->m_Impl->m_HeapScope);
60         _ASSERT(m_Scope);
61     }
62     else {
63         m_Scope.Reset();
64     }
65 }
66 
67 
GetScope(void) const68 CScope& CHeapScope::GetScope(void) const
69 {
70     return static_cast<CScope&>(m_Scope.GetNCObject());
71 }
72 
73 
GetScopeOrNull(void) const74 CScope* CHeapScope::GetScopeOrNull(void) const
75 {
76     return static_cast<CScope*>(m_Scope.GetNCPointerOrNull());
77 }
78 
79 
GetImpl(void) const80 CScope_Impl* CHeapScope::GetImpl(void) const
81 {
82     return GetScope().m_Impl.GetPointer();
83 }
84 
85 
86 END_SCOPE(objects)
87 END_NCBI_SCOPE
88