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_Ring.h,v 1.4 2002/11/27 00:21:33 mcoletti Exp $
13 //
14 #ifndef INCLUDED_SB_RING_H
15 #define INCLUDED_SB_RING_H
16 
17 #ifdef _MSC_VER
18 #pragma warning( disable : 4786 )
19 #endif
20 
21 #include <list>
22 #include <string>
23 
24 #ifndef SB_MODULE_H
25 #include <sdts++/builder/sb_Module.h>
26 #endif
27 
28 #ifndef INCLUDED_SB_SPATIAL_H
29 #include <sdts++/builder/sb_Spatial.h>
30 #endif
31 
32 #ifndef INCLUDED_SB_FOREIGNID_H
33 #include <sdts++/builder/sb_ForeignID.h>
34 #endif
35 
36 #ifndef INCLUDED_SIO8211FIELDFORMAT_H
37 #include <sdts++/io/sio_8211FieldFormat.h>
38 #endif
39 
40 
41 class  sc_Record;
42 
43 
44 // This class provides a convenient access to RING records.  It provides
45 // members to access or set various module field and subfield values.
46 // It also provides a mechanism for populating an object of this class with
47 // values found in a valid sc_Record of this module, and for filling a
48 // sc_Record with the contents of a sb_Ring object.
49 
50 
51 struct sb_Ring_Imp;
52 
53 class sb_Ring : public sb_Module
54 {
55  public:
56 
57   sb_Ring();
58 
59   ~sb_Ring();
60 
61 
62   //@{
63   /**
64      Use these members to get subfield/field values.  Pass in an appropriate
65      type to receive the value.  These members will return false if the
66      corresponding value is not set.  (It may not be set because a value
67      was not assigned to it, or because you previously tried to assign
68      an invalid value.)  Otherwise they will return true.
69   */
70   bool getObjectRepresentation( std::string& val ) const;
getOBRP(std::string & val)71   bool getOBRP( std::string& val ) const { return getObjectRepresentation( val ); }
72 
73   bool getLineorArcForeignID( sb_ForeignID& val ) const;
74   bool getLineorArcForeignID( std::string& val ) const;
getLAID(sb_ForeignID & val)75   bool getLAID( sb_ForeignID& val ) const { return getLineorArcForeignID( val ); }
76 
77   bool getPolyID( sb_ForeignID& val ) const;
78   bool getPolyID( std::string& val ) const;
getPLID(sb_ForeignID & val)79   bool getPLID( sb_ForeignID& val ) const { return getPolyID( val ); }
80 
81   //@}
82 
83   /**
84      fill the given record based on the builder's object field/subfield
85      values -- return false if in a wedged state. (E.g., a mandatory
86      field isn't set or was assigned a value outside its proper
87      domain.
88   */
89   bool getRecord( sc_Record& val ) const;
90 
91 
92   /** fills the given schema with one appropriate for RING
93       modules; returns false if unable to create the schema for some
94       bizarre reason.  (Like maybe running out of memory.)  Note that
95       an sio_Writer instance will need a schema generated from this
96       member.
97   */
98   bool getSchema( sio_8211Schema& schema ) const;
99 
100 
101   /** set the object with values found in the record; if not a valid
102       RING record, this will return false
103   */
104   bool setRecord( sc_Record const& val );
105 
106 
107   //@{
108   /**
109      Use these members to set subfield/field values.  Pass in an appropriate
110      value for the particular subfield/field to be set to.  They will return
111      false if you try to assign a value outside the domain of the given
112      subfield/field.  (Note that this is not too pedantic; for example, we
113      do not check to see if a conditionally mandatory or optional field has
114      been set.)
115   */
116   bool setObjectRepresentation( std::string const& val );
setOBRP(std::string const & val)117   bool setOBRP( std::string const& val ) { return setObjectRepresentation( val ); }
118 
119   bool setLineorArcForeignID( sb_ForeignID const& val );
setLAID(sb_ForeignID const & val)120   bool setLAID( sb_ForeignID const& val ) { return setLineorArcForeignID( val ); }
121 
122   bool setPolyID( sb_ForeignID const& val );
setPLID(sb_ForeignID const & val)123   bool setPLID( sb_ForeignID const& val ) { return setPolyID( val ); }
124 
125   //@}
126 
127   //@{
128   /**
129      Since builder objects will be frequently 'recycled' (i.e., used for
130      more than one record), it might be convenient to 'unset' a previously
131      assigned value.  So:
132   */
133 
134   void unDefineObjectRepresentation( );
unDefineOBRP()135   void unDefineOBRP( ) { unDefineObjectRepresentation( ); }
136 
137   void unDefineLineorArcForeignID( );
unDefineLAID()138   void unDefineLAID( ) { unDefineLineorArcForeignID( ); }
139 
140   void unDefinePolyID( );
unDefinePLID()141   void unDefinePLID( ) { unDefinePolyID( ); }
142 
143   //@}
144 
145  private:
146 
147   // Returns reference to schema
148   virtual sio_8211Schema& schema_();
149 
150   virtual void buildSpecificSchema_();
151 
152   sb_Ring(sb_Ring const& right); // NOT NEEDED
153   sb_Ring const& operator=(sb_Ring const& right); // NOT NEEDED
154 
155 
156   sb_Ring_Imp* _imp;
157 
158 }; // sb_Ring
159 
160 
161 #endif // INCLUDED_SB_RING_H
162 
163