1 #ifndef ANNOT_NAME__HPP
2 #define ANNOT_NAME__HPP
3 
4 /*  $Id: annot_name.hpp 103491 2007-05-04 17:18:18Z kazimird $
5 * ===========================================================================
6 *
7 *                            PUBLIC DOMAIN NOTICE
8 *               National Center for Biotechnology Information
9 *
10 *  This software/database is a "United States Government Work" under the
11 *  terms of the United States Copyright Act.  It was written as part of
12 *  the author's official duties as a United States Government employee and
13 *  thus cannot be copyrighted.  This software/database is freely available
14 *  to the public for use. The National Library of Medicine and the U.S.
15 *  Government have not placed any restriction on its use or reproduction.
16 *
17 *  Although all reasonable efforts have been taken to ensure the accuracy
18 *  and reliability of the software and data, the NLM and the U.S.
19 *  Government do not and cannot warrant the performance or results that
20 *  may be obtained by using this software or data. The NLM and the U.S.
21 *  Government disclaim all warranties, express or implied, including
22 *  warranties of performance, merchantability or fitness for any particular
23 *  purpose.
24 *
25 *  Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aleksey Grichenko, Michael Kimelman, Eugene Vasilchenko
30 *
31 * File Description:
32 *   Annotations selector structure.
33 *
34 */
35 
36 
37 #include <corelib/ncbistd.hpp>
38 
39 BEGIN_NCBI_SCOPE
40 BEGIN_SCOPE(objects)
41 
42 class CAnnotName
43 {
44 public:
CAnnotName(void)45     CAnnotName(void)
46         : m_Named(false)
47         {
48         }
CAnnotName(const string & name)49     CAnnotName(const string& name)
50         : m_Named(true), m_Name(name)
51         {
52         }
CAnnotName(const char * name)53     CAnnotName(const char* name)
54         : m_Named(true), m_Name(name)
55         {
56         }
57 
IsNamed(void) const58     bool IsNamed(void) const
59         {
60             return m_Named;
61         }
GetName(void) const62     const string& GetName(void) const
63         {
64             _ASSERT(m_Named);
65             return m_Name;
66         }
67 
SetUnnamed(void)68     void SetUnnamed(void)
69         {
70             m_Named = false;
71             m_Name.erase();
72         }
SetNamed(const string & name)73     void SetNamed(const string& name)
74         {
75             m_Name = name;
76             m_Named = true;
77         }
78 
operator <(const CAnnotName & name) const79     bool operator<(const CAnnotName& name) const
80         {
81             return name.m_Named && (!m_Named || name.m_Name > m_Name);
82         }
operator ==(const CAnnotName & name) const83     bool operator==(const CAnnotName& name) const
84         {
85             return name.m_Named == m_Named && name.m_Name == m_Name;
86         }
operator !=(const CAnnotName & name) const87     bool operator!=(const CAnnotName& name) const
88         {
89             return name.m_Named != m_Named || name.m_Name != m_Name;
90         }
91 
92 private:
93     bool   m_Named;
94     string m_Name;
95 };
96 
97 
98 END_SCOPE(objects)
99 END_NCBI_SCOPE
100 
101 #endif  // ANNOT_NAME__HPP
102