1 //
2 // This file is part of the SDTS++ toolkit, written by the U.S.
3 // Geological Survey.  It is experimental software, written to support
4 // USGS research and cartographic data production.
5 //
6 // SDTS++ is public domain software.  It may be freely copied,
7 // distributed, and modified.  The USGS welcomes user feedback, but makes
8 // no committment to any level of support for this code.  See the SDTS
9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information,
10 // including points of contact.
11 //
12 // $Id: sb_Dq.h,v 1.7 2002/11/24 22:07:42 mcoletti Exp $
13 //
14 #ifndef INCLUDED_SB_DQ_H
15 #define INCLUDED_SB_DQ_H
16 
17 #include <list>
18 #include <string>
19 
20 #ifndef SB_MODULE_H
21 #include <sdts++/builder/sb_Module.h>
22 #endif
23 
24 
25 #ifndef INCLUDED_SIO8211FIELDFORMAT_H
26 #include <sdts++/io/sio_8211FieldFormat.h>
27 #endif
28 
29 class  sc_Record;
30 
31 
32 struct sb_Dq_Imp;
33 
34 /**
35  This class provides a convenient access to DQ records.  It provides
36  members to access or set various module field and subfield values.
37  It also provides a mechanism for populating an object of this class with
38  values found in a valid sc_Record of this module, and for filling a
39  sc_Record with the contents of a sb_dq object.
40 */
41 class sb_Dq : public sb_Module
42 {
43    public:
44 
45       sb_Dq();
46 
47       ~sb_Dq();
48 
49 
50       /**
51        Use these members to get subfield/field values.  Pass in an appropriate
52        type to receive the value.  These members will return false if the
53        corresponding value is not set.  (It may not be set because a value
54        was not assigned to it, or because you previously tried to assign
55        an invalid value.)  Otherwise they will return true.
56       */
57       bool getComment( std::string& val ) const;
getCOMT(std::string & val)58       bool getCOMT( std::string& val ) const { return getComment( val ); }
59 
60       /**
61        fill the given record based on the builder's object field/subfield
62        values -- return false if in a wedged state. (E.g., a mandatory
63        field isn't set or was assigned a value outside its proper
64        domain.
65       */
66       bool getRecord( sc_Record& val ) const = 0;
67 
68 
69       /**
70        set the object with values found in the record; if not a valid
71        DQ record, this will return false
72       */
73       bool setRecord( sc_Record const& val ) = 0;
74 
75 
76       /**
77        Use these members to set subfield/field values.  Pass in an appropriate
78        value for the particular subfield/field to be set to.  They will return
79        false if you try to assign a value outside the domain of the given
80        subfield/field.  (Note that this is not too pedantic; for example, we
81        do not check to see if a conditionally mandatory or optional field has
82        been set.)
83       */
84       bool setComment( std::string const& val );
setCOMT(std::string const & val)85       bool setCOMT( std::string const& val ) { return setComment( val ); }
86 
87 
88       /**
89        Since builder objects will be frequently 'recycled' (i.e., used for
90        more than one record), it might be convenient to 'unset' a previously
91        assigned value.  So:
92       */
93       void unDefineComment( );
unDefineCOMT()94       void unDefineCOMT( ) { unDefineComment( ); }
95 
96    protected:
97 
98       ///
getImp()99       sb_Dq_Imp& getImp() { return *imp_; }
100 
101 
102       /// returns reference to schema
103       virtual sio_8211Schema& schema_() = 0;
104 
105       ///
106       virtual void buildSpecificSchema_() = 0;
107 
108 
109    private:
110 
111 
112       /// NOT NEEDED
113       sb_Dq(sb_Dq const& right);
114 
115       /// NOT NEEDED
116       sb_Dq const& operator=(sb_Dq const& right);
117 
118 
119       /// pointer to hidden, opaque data structure
120       sb_Dq_Imp* imp_;
121 
122 }; // sb_Dq
123 
124 
125 
126 /** */
127 class sb_Dqhl : public sb_Dq
128 {
129    public:
130 
131       sb_Dqhl();
132 
133       /**
134        fill the given record based on the builder's object field/subfield
135        values -- return false if in a wedged state. (E.g., a mandatory
136        field isn't set or was assigned a value outside its proper
137        domain.
138       */
139       bool getRecord( sc_Record& val ) const;
140 
141 
142       /**
143          set the object with values found in the record; if not a valid
144        DQ record, this will return false
145       */
146       bool setRecord( sc_Record const& val );
147 
148    private:
149 
150       /// returns reference to schema
151       sio_8211Schema& schema_();
152 
153       ///
154       void buildSpecificSchema_();
155 
156 }; // sb_Dqhl
157 
158 
159 /** */
160 class sb_Dqpa : public sb_Dq
161 {
162    public:
163 
164       sb_Dqpa();
165 
166 
167       /**
168        fill the given record based on the builder's object field/subfield
169        values -- return false if in a wedged state. (E.g., a mandatory
170        field isn't set or was assigned a value outside its proper
171        domain.
172       */
173       bool getRecord( sc_Record& val ) const;
174 
175 
176       /**
177        set the object with values found in the record; if not a valid
178        DQ record, this will return false
179       */
180       bool setRecord( sc_Record const& val );
181 
182 
183    private:
184 
185       /// returns reference to schema
186       sio_8211Schema& schema_();
187 
188       ///
189       void buildSpecificSchema_();
190 
191 }; // sb_Dqpa
192 
193 
194 
195 /** */
196 class sb_Dqaa : public sb_Dq
197 {
198    public:
199 
200       sb_Dqaa();
201 
202       /**
203        fill the given record based on the builder's object field/subfield
204        values -- return false if in a wedged state. (E.g., a mandatory
205        field isn't set or was assigned a value outside its proper
206        domain.
207       */
208       bool getRecord( sc_Record& val ) const;
209 
210 
211       /**
212        set the object with values found in the record; if not a valid
213        DQ record, this will return false
214       */
215       bool setRecord( sc_Record const& val );
216 
217    private:
218 
219       /// returns reference to schema
220       sio_8211Schema& schema_();
221 
222       ///
223       void buildSpecificSchema_();
224 
225 }; // sb_Dqaa
226 
227 
228 /** */
229 class sb_Dqlc : public sb_Dq
230 {
231    public:
232 
233       sb_Dqlc();
234 
235       /**
236        fill the given record based on the builder's object field/subfield
237        values -- return false if in a wedged state. (E.g., a mandatory
238        field isn't set or was assigned a value outside its proper
239        domain.
240       */
241       bool getRecord( sc_Record& val ) const;
242 
243 
244       /**
245        set the object with values found in the record; if not a valid
246        DQ record, this will return false
247       */
248       bool setRecord( sc_Record const& val );
249 
250    private:
251 
252       /// returns reference to schema
253       sio_8211Schema& schema_();
254 
255       ///
256       void buildSpecificSchema_();
257 
258 }; // sb_Dqlc
259 
260 
261 
262 /** */
263 class sb_Dqcg : public sb_Dq
264 {
265    public:
266 
267       sb_Dqcg();
268 
269       /**
270        fill the given record based on the builder's object field/subfield
271        values -- return false if in a wedged state. (E.g., a mandatory
272        field isn't set or was assigned a value outside its proper
273        domain.
274       */
275       bool getRecord( sc_Record& val ) const;
276 
277 
278       /**
279        set the object with values found in the record; if not a valid
280        DQ record, this will return false
281       */
282       bool setRecord( sc_Record const& val );
283 
284    private:
285 
286       /// returns reference to schema
287       sio_8211Schema& schema_();
288 
289       ///
290       void buildSpecificSchema_();
291 
292 }; // sb_Dqcg
293 
294 
295 #endif // INCLUDED_SB_DQ_H
296 
297