1 #ifndef OBJECTS_SUBMIT___SUBMIT_MACROS__HPP
2 #define OBJECTS_SUBMIT___SUBMIT_MACROS__HPP
3 
4 /*  $Id: submit_macros.hpp 394538 2013-04-03 19:01:36Z ucko $
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  * Authors:  Jonathan Kans, Michael Kornbluh, Colleen Bollin
30  *
31  */
32 
33 /// @file submit_macros.hpp
34 /// Utility macros and typedefs for exploring NCBI objects from submit.asn.
35 
36 
37 #include <objects/misc/sequence_util_macros.hpp>
38 #include <objects/submit/submit__.hpp>
39 
40 
41 /// @NAME Convenience macros for NCBI objects
42 /// @{
43 
44 
45 BEGIN_NCBI_SCOPE
46 BEGIN_SCOPE(objects)
47 
48 /////////////////////////////////////////////////////////////////////////////
49 /// Macros and typedefs for object subtypes
50 /////////////////////////////////////////////////////////////////////////////
51 
52 
53 /// CSeq_submit definitions
54 
55 #define NCBI_SEQSUBMIT(Type) CSeq_submit::TData::e_##Type
56 typedef CSeq_submit::TData::E_Choice TSEQSUBMIT_CHOICE;
57 
58 //   Entrys     Annots
59 
60 
61 
62 // "FOR_EACH_XXX_ON_YYY" does a linear const traversal of STL containers
63 // "EDIT_EACH_XXX_ON_YYY" does a linear non-const traversal of STL containers
64 
65 // "SWITCH_ON_XXX_CHOICE" switches on the item subtype
66 
67 // "ADD_XXX_TO_YYY" adds an element to a specified object
68 // "ERASE_XXX_ON_YYY" deletes a specified object within an iterator
69 
70 // Miscellaneous macros for testing objects include
71 // "XXX_IS_YYY" or "XXX_HAS_YYY"
72 // "XXX_CHOICE_IS"
73 
74 
75 ///
76 /// CSeq_submit macros
77 
78 /// SEQSUBMIT_CHOICE macros
79 
80 #define SEQSUBMIT_CHOICE_Test(Var) ((Var).IsSetData() && \
81                                     (Var).GetData().Which() != CSeq_submit::TData::e_not_set)
82 #define SEQSUBMIT_CHOICE_Chs(Var)  (Var).GetData().Which()
83 
84 /// SEQSUBMIT_CHOICE_IS
85 
86 #define SEQSUBMIT_CHOICE_IS(Var, Chs) \
87 CHOICE_IS (SEQSUBMIT_CHOICE, Var, Chs)
88 
89 /// SEQSUBMIT_IS_ENTRYS
90 
91 #define SEQSUBMIT_IS_ENTRYS(Var) \
92 SEQSUBMIT_CHOICE_IS (Var, NCBI_SEQSUBMIT(Entrys))
93 
94 /// SEQSUBMIT_IS_ANNOTS
95 
96 #define SEQSUBMIT_IS_ANNOTS(Var) \
97 SEQSUBMIT_CHOICE_IS (Var, NCBI_SEQSUBMIT(Annots))
98 
99 /// SWITCH_ON_SEQSUBMIT_CHOICE
100 
101 #define SWITCH_ON_SEQSUBMIT_CHOICE(Var) \
102 SWITCH_ON (SEQSUBMIT_CHOICE, Var)
103 
104 /// SEQENTRY_ON_SEQSUBMIT macros
105 
106 #define SEQENTRY_ON_SEQSUBMIT_Type      CSeq_submit::TData::TEntrys
107 #define SEQENTRY_ON_SEQSUBMIT_Test(Var) ((Var).IsSetData() && (Var).GetData().IsEntrys())
108 #define SEQENTRY_ON_SEQSUBMIT_Get(Var)  (Var).GetData().GetEntrys()
109 #define SEQENTRY_ON_SEQSUBMIT_Set(Var)  (Var).SetData().SetEntrys()
110 
111 /// FOR_EACH_SEQENTRY_ON_SEQSUBMIT
112 /// EDIT_EACH_SEQENTRY_ON_SEQSUBMIT
113 // CSeq_submit& as input, dereference with [const] CSeq_entry& se = **itr;
114 
115 #define FOR_EACH_SEQENTRY_ON_SEQSUBMIT(Itr, Var) \
116 FOR_EACH (SEQENTRY_ON_SEQSUBMIT, Itr, Var)
117 
118 #define EDIT_EACH_SEQENTRY_ON_SEQSUBMIT(Itr, Var) \
119 EDIT_EACH (SEQENTRY_ON_SEQSUBMIT, Itr, Var)
120 
121 /// ADD_SEQENTRY_TO_SEQSUBMIT
122 
123 #define ADD_SEQENTRY_TO_SEQSUBMIT(Var, Ref) \
124 ADD_ITEM (SEQENTRY_ON_SEQSUBMIT, Var, Ref)
125 
126 /// ERASE_SEQENTRY_ON_SEQSUBMIT
127 
128 #define ERASE_SEQENTRY_ON_SEQSUBMIT(Itr, Var) \
129 LIST_ERASE_ITEM (SEQENTRY_ON_SEQSUBMIT, Itr, Var)
130 
131 
132 /// SEQANNOT_ON_SEQSUBMIT macros
133 
134 #define SEQANNOT_ON_SEQSUBMIT_Type      CSeq_submit::TData::TAnnots
135 #define SEQANNOT_ON_SEQSUBMIT_Test(Var) ((Var).IsSetData() && (Var).GetData().IsAnnots())
136 #define SEQANNOT_ON_SEQSUBMIT_Get(Var)  (Var).GetData().GetAnnots()
137 #define SEQANNOT_ON_SEQSUBMIT_Set(Var)  (Var).SetData().SetAnnots()
138 
139 /// SEQSUBMIT_HAS_SEQANNOT
140 
141 #define SEQSUBMIT_HAS_SEQANNOT(Var) \
142 ITEM_HAS (SEQANNOT_ON_SEQSUBMIT, Var)
143 
144 /// FOR_EACH_SEQANNOT_ON_SEQSUBMIT
145 /// EDIT_EACH_SEQANNOT_ON_SEQSUBMIT
146 // CBioseq_set& as input, dereference with [const] CSeq_annot& annot = **itr;
147 
148 #define FOR_EACH_SEQANNOT_ON_SEQSUBMIT(Itr, Var) \
149 FOR_EACH (SEQANNOT_ON_SEQSUBMIT, Itr, Var)
150 
151 #define EDIT_EACH_SEQANNOT_ON_SEQSUBMIT(Itr, Var) \
152 EDIT_EACH (SEQANNOT_ON_SEQSUBMIT, Itr, Var)
153 
154 /// ADD_SEQANNOT_TO_SEQSUBMIT
155 
156 #define ADD_SEQANNOT_TO_SEQSUBMIT(Var, Ref) \
157 ADD_ITEM (SEQANNOT_ON_SEQSUBMIT, Var, Ref)
158 
159 /// ERASE_SEQANNOT_ON_SEQSUBMIT
160 
161 #define ERASE_SEQANNOT_ON_SEQSUBMIT(Itr, Var) \
162 LIST_ERASE_ITEM (SEQANNOT_ON_SEQSUBMIT, Itr, Var)
163 
164 
165 END_SCOPE(objects)
166 END_NCBI_SCOPE
167 
168 
169 /* @} */
170 
171 #endif  /* OBJECTS_SUBMIT___SUBMIT_MACROS__HPP */
172