openModeller  Version 1.5.0
TapirOccurrences.hh
Go to the documentation of this file.
1 
27 #ifndef _TAPIR_OCCURRENCESHH_
28 #define _TAPIR_OCCURRENCESHH_
29 
31 
32 #include <openmodeller/om_defs.hh>
34 
35 #include <string>
36 using std::string;
37 
38 #include <expat.h>
39 
40 // Data structure to store relevant information about a TAPIR capabilities response
42 
44 
45  XML_Parser _parser;
46  bool _is_tapir; // indicates if it's a TAPIR response
47  bool _has_guid; // indicates if provider mapped the DarwinCore global unique identifier concept
48  bool _has_name; // indicates if provider mapped the DarwinCore scientific name concept
49  bool _has_long; // indicates if provider mapped the DarwinCore longitude concept
50  bool _has_lat; // indicates if provider mapped the DarwinCore latitude concept
51  bool _accepts_any_model; // indicates if provider accepts any output model
52  bool _accepts_om_model; // indicates if provider accepts the openModeller output model
53  bool _accepts_om_template; // indicates if provider accepts the openModeller query template
54  std::string _max_records; // maximum number of records that can be returned by the provider
55 };
56 
57 // Data structure to be used by the expat handlers during searches
59 
61  int _next; // index of next record to be retrieved
62 };
63 
69 class dllexp TapirOccurrences : public OccurrencesReader
70 {
71 public:
72 
76  static OccurrencesReader * CreateOccurrencesReaderCallback( const char * source, const char * coordSystem );
77 
83  TapirOccurrences( const char * url, const char * coordSystem );
84 
88 
92  bool load();
93 
99  OccurrencesPtr getPresences( const char *groupId );
100 
106  OccurrencesPtr getAbsences( const char *groupId ) { return new OccurrencesImpl( 0 ); }
107 
108 private:
109 
110  // Indicates if occurrences were already loaded.
111  bool _loaded;
112 
113  // Default record limit to be retrieved from the provider
115 
116  // Maximum number of records that can be returned by the provider
118 
119  // callback function that will be called by CURL when retrieving header content
120  static size_t _curl_header_writer( void * ptr, size_t size, size_t nmemb, void * stream );
121 
122  // callback function that will be called by CURL when retrieving body content
123  static size_t _curl_body_writer( void * ptr, size_t size, size_t nmemb, void * stream );
124 
125  // Parse capabilities response
126  bool _parseCapabilities( const std::string * xml, CapabilitiesInfo * info );
127 
128  // Start element handler for capabilities parser
129  static void _startCapabilitiesElement( void *data, const char *el, const char **attr );
130 
131  // Character data handler for maxElementRepetitions element
132  static void _maxRecordsDataHandler( void *data, const char *value, int len );
133 
134  // End element handler for capabilities parser
135  static void _endCapabilitiesElement( void *data, const char *el );
136 
137  // Retrieve records
138  bool _retrieveRecords( TapirRecordData *data, int limit );
139 
140  // Start element handler for search parser
141  static void _startSearchElement( void *data, const char *el, const char **attr );
142 
143 };
144 
145 #endif
146 
OccurrencesPtr _occurrences
std::string _max_records
virtual OccurrencesPtr getPresences(const char *groupId)
virtual bool load()=0
OccurrencesPtr getAbsences(const char *groupId)