move singleton to util/singleton.hpp

move windows UTF conversion routines to util/utf_conv_win.hpp
This commit is contained in:
artemp 2015-06-02 11:10:41 +01:00
parent 9a93b21159
commit 2eaa90033a
28 changed files with 102 additions and 75 deletions

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/util/noncopyable.hpp>
// stl

View file

@ -25,7 +25,7 @@
// mapnik (should not depend on anything that need to use this)
#include <mapnik/config.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/util/noncopyable.hpp>
// std

View file

@ -24,7 +24,7 @@
#define MAPNIK_FACTORY_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
// stl
#include <stdexcept>

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/util/noncopyable.hpp>
// boost

View file

@ -24,7 +24,7 @@
#define MAPNIK_MARKER_CACHE_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/config.hpp>
#include <mapnik/util/noncopyable.hpp>

View file

@ -24,7 +24,7 @@
#define MAPNIK_POOL_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/util/noncopyable.hpp>
// boost

View file

@ -23,7 +23,7 @@
#define FORMATTING_REGISTRY_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/text/formatting/base.hpp>
#include <mapnik/text/text_properties.hpp>
#include <mapnik/util/noncopyable.hpp>

View file

@ -23,7 +23,7 @@
#define PLACEMENTS_REGISTRY_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/text/placements/base.hpp>
#include <mapnik/util/noncopyable.hpp>

View file

@ -24,7 +24,7 @@
#define MAPNIK_FILE_IO_HPP
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/make_unique.hpp>
#include <mapnik/util/noncopyable.hpp>
//#include <mapnik/config.hpp>

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2014 Artem Pavlenko
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,8 +20,8 @@
*
*****************************************************************************/
#ifndef MAPNIK_UTILS_HPP
#define MAPNIK_UTILS_HPP
#ifndef MAPNIK_UTIL_SINGLETON_HPP
#define MAPNIK_UTIL_SINGLETON_HPP
#include <mapnik/config.hpp>
@ -128,24 +128,12 @@ template <typename T,
}
};
template <typename T,
template <typename U> class CreatePolicy> std::mutex singleton<T,CreatePolicy>::mutex_;
template <typename T,
template <typename U> class CreatePolicy> std::atomic<T*> singleton<T,CreatePolicy>::pInstance_;
template <typename T,
template <typename U> class CreatePolicy> bool singleton<T,CreatePolicy>::destroyed_=false;
#ifdef _WINDOWS
// UTF8 <--> UTF16 conversion routines
MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr);
MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str);
#endif // _WINDOWS
template <typename U> class CreatePolicy> bool singleton<T,CreatePolicy>::destroyed_ = false;
}
#endif // MAPNIK_UTILS_HPP
#endif // MAPNIK_UTIL_SINGLETON_HPP

View file

@ -0,0 +1,43 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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
*
*****************************************************************************/
#ifndef MAPNIK_UTIL_UTF_CONV_WIN_HPP
#define MAPNIK_UTIL_UTF_CONV_WIN_HPP
#ifdef _WINDOWS
// mapnik
#include <mapnik/config.hpp>
// stl
#include <string>
namespace mapnik
{
// UTF8 <--> UTF16 conversion routines
MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr);
MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str);
}
#endif // _WINDOWS
#endif // MAPNIK_UTIL_UTF_CONV_WIN_HPP

View file

@ -29,7 +29,7 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/feature_factory.hpp>

View file

@ -37,7 +37,7 @@
// mapnik
#include <mapnik/boolean.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/feature_kv_iterator.hpp>

View file

@ -25,7 +25,7 @@
#include <mapnik/feature_factory.hpp>
#include <mapnik/json/geometry_grammar.hpp>
#include <mapnik/json/feature_grammar.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
// stl
#include <string>
#include <vector>

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
// occi
#include <occi.h>

View file

@ -31,7 +31,7 @@
#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/timer.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/util/trim.hpp>
// boost

View file

@ -27,7 +27,7 @@
// mapnik
#include <mapnik/pool.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
// boost
#include <memory>

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/global.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/util/trim.hpp>

View file

@ -37,7 +37,7 @@
#include <mapnik/make_unique.hpp>
#include <mapnik/util/fs.hpp>
#include <mapnik/global.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/util/conversions.hpp>
#include <mapnik/geom_util.hpp>

View file

@ -31,7 +31,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/box2d.hpp>
#ifdef SHAPE_MEMORY_MAPPED_FILE
#include <boost/interprocess/mapped_region.hpp>

View file

@ -31,7 +31,6 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/params.hpp>
#include <mapnik/sql_utils.hpp>

View file

@ -28,7 +28,7 @@
#include <mapnik/params.hpp>
#include <mapnik/plugin.hpp>
#include <mapnik/util/fs.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
// boost
#pragma GCC diagnostic push

View file

@ -27,7 +27,7 @@
#include <mapnik/text/face.hpp>
#include <mapnik/util/fs.hpp>
#include <mapnik/util/file_io.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/make_unique.hpp>
// boost

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// mapnik
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/util/fs.hpp>
// boost

View file

@ -26,7 +26,6 @@
#include <mapnik/projection.hpp>
#include <mapnik/proj_transform.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/utils.hpp>
#ifdef MAPNIK_USE_PROJ4
// proj4
@ -233,7 +232,7 @@ unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
{
std::size_t size = ls.size();
if (size == 0) return 0;
if (is_source_equal_dest_)
return 0;
@ -247,7 +246,7 @@ unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
lonlat2merc(ls);
return 0;
}
geometry::point<double> * ptr = ls.data();
double * x = reinterpret_cast<double*>(ptr);
double * y = x + 1;
@ -270,7 +269,7 @@ bool proj_transform::forward (box2d<double> & box) const
double lry = box.miny();
double lrx = box.maxx();
double urx = box.maxx();
double uly = box.maxy();
double uly = box.maxy();
double ury = box.maxy();
double z = 0.0;
if (!forward(llx,lly,z))
@ -304,7 +303,7 @@ bool proj_transform::backward (box2d<double> & box) const
double lry = box.miny();
double lrx = box.maxx();
double urx = box.maxx();
double uly = box.maxy();
double uly = box.maxy();
double ury = box.maxy();
double z = 0.0;
if (!backward(llx,lly,z))
@ -326,8 +325,7 @@ bool proj_transform::backward (box2d<double> & box) const
return true;
}
/* Returns points in clockwise order. This allows us to do anti-meridian checks.
*/
// Returns points in clockwise order. This allows us to do anti-meridian checks.
void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env, int points)
{
double width = env.width();
@ -358,7 +356,7 @@ void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env
}
}
/* determine if an ordered sequence of coordinates is in clockwise order */
// determine if an ordered sequence of coordinates is in clockwise order
bool is_clockwise(const std::vector< coord<double,2> > & coords)
{
int n = coords.size();
@ -385,12 +383,12 @@ box2d<double> calculate_bbox(std::vector<coord<double,2> > & points) {
}
/* More robust, but expensive, bbox transform
* in the face of proj4 out of bounds conditions.
* Can result in 20 -> 10 r/s performance hit.
* Alternative is to provide proper clipping box
* in the target srs by setting map 'maximum-extent'
*/
// More robust, but expensive, bbox transform
// in the face of proj4 out of bounds conditions.
// Can result in 20 -> 10 r/s performance hit.
// Alternative is to provide proper clipping box
// in the target srs by setting map 'maximum-extent'
bool proj_transform::backward(box2d<double>& env, int points) const
{
if (is_source_equal_dest_)
@ -413,15 +411,15 @@ bool proj_transform::backward(box2d<double>& env, int points) const
}
box2d<double> result = calculate_bbox(coords);
if (is_source_longlat_ && !is_clockwise(coords)) {
/* we've gone to a geographic CS, and our clockwise envelope has
* changed into an anticlockwise one. This means we've crossed the antimeridian, and
* need to expand the X direction to +/-180 to include all the data. Once we can deal
* with multiple bboxes in queries we can improve.
*/
double miny = result.miny();
result.expand_to_include(-180.0, miny);
result.expand_to_include(180.0, miny);
if (is_source_longlat_ && !is_clockwise(coords))
{
// we've gone to a geographic CS, and our clockwise envelope has
// changed into an anticlockwise one. This means we've crossed the antimeridian, and
// need to expand the X direction to +/-180 to include all the data. Once we can deal
// with multiple bboxes in queries we can improve.
double miny = result.miny();
result.expand_to_include(-180.0, miny);
result.expand_to_include(180.0, miny);
}
env.re_center(result.center().x, result.center().y);
@ -454,15 +452,15 @@ bool proj_transform::forward(box2d<double>& env, int points) const
box2d<double> result = calculate_bbox(coords);
if (is_dest_longlat_ && !is_clockwise(coords)) {
/* we've gone to a geographic CS, and our clockwise envelope has
* changed into an anticlockwise one. This means we've crossed the antimeridian, and
* need to expand the X direction to +/-180 to include all the data. Once we can deal
* with multiple bboxes in queries we can improve.
*/
double miny = result.miny();
result.expand_to_include(-180.0, miny);
result.expand_to_include(180.0, miny);
if (is_dest_longlat_ && !is_clockwise(coords))
{
// we've gone to a geographic CS, and our clockwise envelope has
// changed into an anticlockwise one. This means we've crossed the antimeridian, and
// need to expand the X direction to +/-180 to include all the data. Once we can deal
// with multiple bboxes in queries we can improve.
double miny = result.miny();
result.expand_to_include(-180.0, miny);
result.expand_to_include(180.0, miny);
}
env.re_center(result.center().x, result.center().y);

View file

@ -22,7 +22,7 @@
// mapnik
#include <mapnik/projection.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/singleton.hpp>
#include <mapnik/util/trim.hpp>
#include <mapnik/well_known_srs.hpp>

View file

@ -26,7 +26,6 @@
// mapnik
#include <mapnik/config_error.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/util/fs.hpp>
#include <mapnik/xml_loader.hpp>
#include <boost/property_tree/detail/xml_parser_read_rapidxml.hpp>

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2014 Artem Pavlenko
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,7 +22,7 @@
#ifdef _WINDOWS
// windows specific methods for UTF8 from/to UTF16
#include <mapnik/utils.hpp>
#include <mapnik/util/utf_conv_win.hpp>
#include <string>
#include <vector>
#define NOMINMAX