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_Dddf.h,v 1.3 2002/11/24 22:07:42 mcoletti Exp $ 13 // 14 #ifndef INCLUDED_SB_DDDF_H 15 #define INCLUDED_SB_DDDF_H 16 17 18 #ifdef _MSC_VER 19 #pragma warning( disable : 4786 ) 20 #endif 21 22 23 #include <list> 24 #include <string> 25 26 #ifndef SB_MODULE_H 27 #include <sdts++/builder/sb_Module.h> 28 #endif 29 30 #ifndef INCLUDED_SB_SPATIAL_H 31 #include <sdts++/builder/sb_Spatial.h> 32 #endif 33 34 #ifndef INCLUDED_SB_FOREIGNID_H 35 #include <sdts++/builder/sb_ForeignID.h> 36 #endif 37 38 #ifndef INCLUDED_SIO8211FIELDFORMAT_H 39 #include <sdts++/io/sio_8211FieldFormat.h> 40 #endif 41 42 43 class sc_Record; 44 45 46 // This class provides a convenient access to DDDF records. It provides 47 // members to access or set various module field and subfield values. 48 // It also provides a mechanism for populating an object of this class with 49 // values found in a valid sc_Record of this module, and for filling a 50 // sc_Record with the contents of a sb_Dddf object. 51 52 53 struct sb_Dddf_Imp; 54 55 class sb_Dddf : public sb_Module 56 { 57 public: 58 59 sb_Dddf(); 60 61 ~sb_Dddf(); 62 63 64 //@{ 65 /** 66 Use these members to get subfield/field values. Pass in an appropriate 67 type to receive the value. These members will return false if the 68 corresponding value is not set. (It may not be set because a value 69 was not assigned to it, or because you previously tried to assign 70 an invalid value.) Otherwise they will return true. 71 */ 72 bool getEntityOrAttribute( std::string& val ) const; getEORA(std::string & val)73 bool getEORA( std::string& val ) const { return getEntityOrAttribute( val ); } 74 75 bool getLabel( std::string& val ) const; getEALB(std::string & val)76 bool getEALB( std::string& val ) const { return getLabel( val ); } 77 78 bool getSource( std::string& val ) const; getSRCE(std::string & val)79 bool getSRCE( std::string& val ) const { return getSource( val ); } 80 81 bool getDefinition( std::string& val ) const; getDFIN(std::string & val)82 bool getDFIN( std::string& val ) const { return getDefinition( val ); } 83 84 bool getAttributeAuthority( std::string& val ) const; getAUTH(std::string & val)85 bool getAUTH( std::string& val ) const { return getAttributeAuthority( val ); } 86 87 bool getAttributeAuthorityDescription( std::string& val ) const; getADSC(std::string & val)88 bool getADSC( std::string& val ) const { return getAttributeAuthorityDescription( val ); } 89 90 //@} 91 92 /** 93 fill the given record based on the builder's object field/subfield 94 values -- return false if in a wedged state. (E.g., a mandatory 95 field isn't set or was assigned a value outside its proper 96 domain. 97 */ 98 bool getRecord( sc_Record& val ) const; 99 100 101 /** fills the given schema with one appropriate for DDDF 102 modules; returns false if unable to create the schema for some 103 bizarre reason. (Like maybe running out of memory.) Note that 104 an sio_Writer instance will need a schema generated from this 105 member. 106 */ 107 bool getSchema( sio_8211Schema& schema ) const; 108 109 110 /** set the object with values found in the record; if not a valid 111 DDDF record, this will return false 112 */ 113 bool setRecord( sc_Record const& val ); 114 115 116 //@{ 117 /** 118 Use these members to set subfield/field values. Pass in an appropriate 119 value for the particular subfield/field to be set to. They will return 120 false if you try to assign a value outside the domain of the given 121 subfield/field. (Note that this is not too pedantic; for example, we 122 do not check to see if a conditionally mandatory or optional field has 123 been set.) 124 */ 125 bool setEntityOrAttribute( std::string const& val ); setEORA(std::string const & val)126 bool setEORA( std::string const& val ) { return setEntityOrAttribute( val ); } 127 128 bool setLabel( std::string const& val ); setEALB(std::string const & val)129 bool setEALB( std::string const& val ) { return setLabel( val ); } 130 131 bool setSource( std::string const& val ); setSRCE(std::string const & val)132 bool setSRCE( std::string const& val ) { return setSource( val ); } 133 134 bool setDefinition( std::string const& val ); setDFIN(std::string const & val)135 bool setDFIN( std::string const& val ) { return setDefinition( val ); } 136 137 bool setAttributeAuthority( std::string const& val ); setAUTH(std::string const & val)138 bool setAUTH( std::string const& val ) { return setAttributeAuthority( val ); } 139 140 bool setAttributeAuthorityDescription( std::string const& val ); setADSC(std::string const & val)141 bool setADSC( std::string const& val ) { return setAttributeAuthorityDescription( val ); } 142 143 //@} 144 145 //@{ 146 /** 147 Since builder objects will be frequently 'recycled' (i.e., used for 148 more than one record), it might be convenient to 'unset' a previously 149 assigned value. So: 150 */ 151 152 void unDefineEntityOrAttribute( ); unDefineEORA()153 void unDefineEORA( ) { unDefineEntityOrAttribute( ); } 154 155 void unDefineLabel( ); unDefineEALB()156 void unDefineEALB( ) { unDefineLabel( ); } 157 158 void unDefineSource( ); unDefineSRCE()159 void unDefineSRCE( ) { unDefineSource( ); } 160 161 void unDefineDefinition( ); unDefineDFIN()162 void unDefineDFIN( ) { unDefineDefinition( ); } 163 164 void unDefineAttributeAuthority( ); unDefineAUTH()165 void unDefineAUTH( ) { unDefineAttributeAuthority( ); } 166 167 void unDefineAttributeAuthorityDescription( ); unDefineADSC()168 void unDefineADSC( ) { unDefineAttributeAuthorityDescription( ); } 169 170 //@} 171 172 private: 173 174 // Returns reference to schema 175 virtual sio_8211Schema& schema_(); 176 177 virtual void buildSpecificSchema_(); 178 179 sb_Dddf(sb_Dddf const& right); // NOT NEEDED 180 sb_Dddf const& operator=(sb_Dddf const& right); // NOT NEEDED 181 182 183 sb_Dddf_Imp* _imp; 184 185 }; // sb_Dddf 186 187 188 #endif // INCLUDED_SB_DDDF_H 189 190