mapnik/include/datasource.hpp

110 lines
3.1 KiB
C++
Raw Normal View History

2006-03-31 12:32:02 +02:00
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
* Copyright (C) 2006 Artem Pavlenko
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
2005-06-14 17:06:59 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2006-03-31 12:32:02 +02:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
*****************************************************************************/
2005-06-14 17:06:59 +02:00
//$Id: datasource.hpp 43 2005-04-22 18:52:47Z pavlenko $
#ifndef DATASOURCE_HPP
#define DATASOURCE_HPP
#include <map>
#include <string>
#include "ctrans.hpp"
#include "params.hpp"
#include "feature.hpp"
#include "query.hpp"
#include "feature_layer_desc.hpp"
#include <boost/shared_ptr.hpp>
2005-06-14 17:06:59 +02:00
namespace mapnik
{
2006-03-22 16:52:29 +01:00
typedef MAPNIK_DECL shared_ptr<Feature> feature_ptr;
struct MAPNIK_DECL Featureset
2005-06-14 17:06:59 +02:00
{
virtual feature_ptr next()=0;
2005-06-14 17:06:59 +02:00
virtual ~Featureset() {};
};
typedef shared_ptr<Featureset> featureset_ptr;
2006-03-22 16:52:29 +01:00
class MAPNIK_DECL datasource_exception : public std::exception
2005-06-14 17:06:59 +02:00
{
private:
const std::string message_;
public:
datasource_exception(const std::string& message=std::string())
:message_(message) {}
~datasource_exception() throw() {}
virtual const char* what() const throw()
{
return message_.c_str();
}
};
2006-03-22 16:52:29 +01:00
class MAPNIK_DECL datasource
2005-06-14 17:06:59 +02:00
{
public:
enum {
Vector,
Raster
};
virtual int type() const=0;
virtual featureset_ptr features(const query& q) const=0;
virtual Envelope<double> const& envelope() const=0;
virtual layer_descriptor const& get_descriptor() const=0;
virtual ~datasource() {};
};
typedef std::string datasource_name();
typedef datasource* create_ds(const parameters& params);
2005-06-14 17:06:59 +02:00
typedef void destroy_ds(datasource *ds);
class datasource_deleter
2005-06-14 17:06:59 +02:00
{
public:
void operator() (datasource* ds)
{
delete ds;
}
2005-06-14 17:06:59 +02:00
};
typedef boost::shared_ptr<datasource> datasource_p;
2005-06-14 17:06:59 +02:00
///////////////////////////////////////////
#define DATASOURCE_PLUGIN(classname) \
2006-03-22 16:52:29 +01:00
extern "C" MAPNIK_DECL std::string datasource_name() \
2005-06-14 17:06:59 +02:00
{ \
return classname::name();\
}\
2006-03-22 16:52:29 +01:00
extern "C" MAPNIK_DECL datasource* create(const parameters &params) \
2005-06-14 17:06:59 +02:00
{ \
return new classname(params); \
2005-06-14 17:06:59 +02:00
}\
2006-03-22 16:52:29 +01:00
extern "C" MAPNIK_DECL void destroy(datasource *ds) \
2005-06-14 17:06:59 +02:00
{ \
delete ds;\
}\
///////////////////////////////////////////
}
#endif //DATASOURCE_HPP