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_Comp.h,v 1.4 2002/11/24 22:07:42 mcoletti Exp $ 13 // 14 #ifndef INCLUDED_SB_COMP_H 15 #define INCLUDED_SB_COMP_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 COMP 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_Comp object. 51 52 53 struct sb_Comp_Imp; 54 55 class sb_Comp : public sb_Module 56 { 57 public: 58 59 sb_Comp(); 60 61 ~sb_Comp(); 62 63 64 //@{ 65 /** 66 Use these members to get subfield/field values. Pass in an 67 appropriate type to receive the value. These members will 68 return false if the corresponding value is not set. (It may 69 not be set because a value was not assigned to it, or because 70 you previously tried to assign an invalid value.) Otherwise 71 they will return true. 72 */ 73 bool getObjectRepresentation( std::string& val ) const; getOBRP(std::string & val)74 bool getOBRP( std::string& val ) const { return getObjectRepresentation( val ); } 75 76 bool getAttributeID( std::list<std::string> & val ) const; 77 bool getAttributeID( sb_AttributeIDs& val ) const; getATID(sb_AttributeIDs & val)78 bool getATID( sb_AttributeIDs& val ) const { return getAttributeID( val ); } 79 80 bool getForeignID( sb_ForeignIDs& val ) const; 81 bool getForeignID( std::list<std::string> & val ) const; getFRID(sb_ForeignIDs & val)82 bool getFRID( sb_ForeignIDs& val ) const { return getForeignID( val ); } 83 84 bool getCompositeID( sb_ForeignIDs& val ) const; 85 bool getCompositeID( std::list<std::string> & val ) const; getCPID(sb_ForeignIDs & val)86 bool getCPID( sb_ForeignIDs& val ) const { return getCompositeID( val ); } 87 88 //@} 89 90 /** 91 fill the given record based on the builder's object 92 field/subfield values -- return false if in a wedged 93 state. (E.g., a mandatory field isn't set or was assigned a 94 value outside its proper domain. 95 */ 96 bool getRecord( sc_Record& val ) const; 97 98 99 /** fills the given schema with one appropriate for COMP 100 modules; returns false if unable to create the schema for 101 some bizarre reason. (Like maybe running out of memory.) 102 Note that an sio_Writer instance will need a schema 103 generated from this member. */ 104 bool getSchema( sio_8211Schema& schema ) const; 105 106 107 /** set the object with values found in the record; if not a 108 valid COMP record, this will return false */ 109 bool setRecord( sc_Record const& val ); 110 111 112 //@{ 113 /** 114 Use these members to set subfield/field values. Pass in an 115 appropriate value for the particular subfield/field to be set 116 to. They will return false if you try to assign a value 117 outside the domain of the given subfield/field. (Note that 118 this is not too pedantic; for example, we do not check to see 119 if a conditionally mandatory or optional field has been set.) */ 120 bool setObjectRepresentation( std::string const& val ); setOBRP(std::string const & val)121 bool setOBRP( std::string const& val ) { return setObjectRepresentation( val ); } 122 123 bool setAttributeID( sb_AttributeIDs const& val ); setATID(sb_AttributeIDs const & val)124 bool setATID( sb_AttributeIDs const& val ) { return setAttributeID( val ); } 125 126 bool setForeignID( sb_ForeignIDs const& val ); setFRID(sb_ForeignIDs const & val)127 bool setFRID( sb_ForeignIDs const& val ) { return setForeignID( val ); } 128 129 bool setCompositeID( sb_ForeignIDs const& val ); setCPID(sb_ForeignIDs const & val)130 bool setCPID( sb_ForeignIDs const& val ) { return setCompositeID( val ); } 131 132 //@} 133 134 //@{ 135 /** 136 Since builder objects will be frequently 'recycled' (i.e., 137 used for more than one record), it might be convenient to 138 'unset' a previously assigned value. So: */ 139 140 void unDefineObjectRepresentation( ); unDefineOBRP()141 void unDefineOBRP( ) { unDefineObjectRepresentation( ); } 142 143 void unDefineAttributeID( ); unDefineATID()144 void unDefineATID( ) { unDefineAttributeID( ); } 145 146 void unDefineForeignID( ); unDefineFRID()147 void unDefineFRID( ) { unDefineForeignID( ); } 148 149 void unDefineCompositeID( ); unDefineCPID()150 void unDefineCPID( ) { unDefineCompositeID( ); } 151 152 //@} 153 154 private: 155 156 // Returns reference to schema 157 virtual sio_8211Schema& schema_(); 158 159 virtual void buildSpecificSchema_(); 160 161 sb_Comp(sb_Comp const& right); // NOT NEEDED 162 sb_Comp const& operator=(sb_Comp const& right); // NOT NEEDED 163 164 165 sb_Comp_Imp* _imp; 166 167 }; // sb_Comp 168 169 170 #endif // INCLUDED_SB_COMP_H 171 172