Fire Core  8.0.0.alpha
GIS framework per tutti gli usi
 Tutto Classi Namespace Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Friend
Connection.hpp
1 // Copyright © 2015 GEOSYSTEMS SRL
2 // All Rights Reserved.
3 
4 #ifndef FIRE_DATA_CONNECTION_HPP_INCLUDED
5 #define FIRE_DATA_CONNECTION_HPP_INCLUDED
6 
7 #include <fire/Object.hpp>
8 #include <fire/logging/Logger.hpp>
9 #include <boost/thread/mutex.hpp>
10 
11 #include <exception>
12 #include <string>
13 #include <vector>
14 #include <map>
15 
16 #include "fire/gis/export.hpp"
17 #include "fire/source/Features.hpp"
18 #include "fire/source/ConnectionType.hpp"
19 #include "fire/source/vector/shared/VectorLayerInfoSh.hpp"
20 
21 namespace fire {
22 namespace source {
23 
24 namespace shared {
25 class ConnectionSh;
26 } // namespace shared
27 
31 class FIRE_GIS_DLL Connection : public fire::Object {
32  public:
33  typedef std::map< int, std::string > ConnectionParams;
34  typedef std::vector< std::string > LayerList;
36 
37  friend class shared::ConnectionSh;
38 
39  enum paramName {
43  HOST = 1,
47  DATASOURCE = 2,
51  USER = 3,
55  PASSWORD = 4,
59  PORT = 5
60  };
61 
67  static std::string idFromParams(Connection::ConnectionParams const & params);
68 
72  Connection();
73 
77  virtual ~Connection();
78 
79  protected:
84  ConnectionParams const & getConnectionString() const;
85 
90  void open();
91 
97  void open(ConnectionParams const & cnnStr);
98 
103  bool isOpen() const;
104 
109  virtual bool isValid() const = 0;
110 
114  void close();
115 
120  virtual ConnectionType::ConnectionType getType() const;
121 
126  virtual Features const getFeatures() const = 0;
127 
132  virtual LayerList getLayers() const = 0;
133 
138  virtual std::string getNamespace() const = 0;
139 
145  void setId(const std::string& pool, const std::string& id);
146 
151  std::string getId() const;
152 
157  std::string getInstanceId() const;
158 
163  std::string getPoolId() const;
164 
169  void setConnectionString(const Connection::ConnectionParams& val);
170 
171 // protected:
172  virtual void _openNoWait() = 0;
173  virtual void _closeNoWait() = 0;
174 
175  const ConnectionParams& _getConnectionStringNoWait() const;
176 
183  const std::string _readParam(ConnectionParams const & pars, unsigned int const & name) const;
184 
191  const int _readIntParam(ConnectionParams const & pars, unsigned int const & name) const;
192 
193  std::string _getPoolIdNoWait() const;
194 
195  std::string _getInstanceIdNoWait() const;
196 
197  virtual bool _isOpenNoWait() const;
198 
199  bool _isOpen;
200  fire::logging::Logger * _log;
201  mutable boost::mutex _mtx;
202 
203  private:
204  Connection(Connection const & c) {}
205  Connection & operator=(Connection const &) { return *this; }
206 
207  std::string _poolId;
208  std::string _instanceId;
209  Connection::ConnectionParams _cnnStr;
210 };
211 
212 } // namespace source
213 } // namespace fire
214 
215 #endif
Oggetto che consente di verificare la presenza di specifiche funzionalità sull'implementazione di una...
Definition: Features.hpp:21
Classe astratta che implementa l'interfaccia di base di una sorgente dati sia vettoriale che raster...
Definition: Connection.hpp:31
Classe per la gestione di un oggetto.
Definition: Object.hpp:29
Classe per la gestione di un logger.
Definition: Logger.hpp:29
paramName
Definition: Connection.hpp:39
Definition: ConnectionSh.hpp:21