[Liblas-commits] libpc: convert to std::size_t and friends
liblas-commits at liblas.org
liblas-commits at liblas.org
Sat Feb 12 17:51:26 EST 2011
details: http://hg.liblas.orglibpc/rev/339ecf48937e
changeset: 50:339ecf48937e
user: Michael P. Gerlek <mpg at flaxen.com>
date: Sat Feb 12 13:21:13 2011 -0800
description:
convert to std::size_t and friends
Subject: libpc: fix size_t
details: http://hg.liblas.orglibpc/rev/07d85de87f12
changeset: 51:07d85de87f12
user: Michael P. Gerlek <mpg at flaxen.com>
date: Sat Feb 12 14:42:10 2011 -0800
description:
fix size_t
diffstat:
include/libpc/Color.hpp | 2 -
include/libpc/ColorFilter.hpp | 2 +-
include/libpc/FauxReader.hpp | 5 ++-
include/libpc/Field.hpp | 10 ++--
include/libpc/Filter.hpp | 10 ++++-
include/libpc/Header.hpp | 8 ++-
include/libpc/MosaicFilter.hpp | 4 +-
include/libpc/PointData.hpp | 45 +++++++++-------------
include/libpc/PointLayout.hpp | 38 +++++--------------
include/libpc/Reader.hpp | 10 ++++-
include/libpc/Stage.hpp | 17 ++++++++-
src/ColorFilter.cpp | 26 ++++++++----
src/FauxReader.cpp | 37 +++++++++++++-----
src/Field.cpp | 11 +++--
src/Filter.cpp | 11 +++++
src/Header.cpp | 4 +-
src/MosaicFilter.cpp | 6 +-
src/PointData.cpp | 82 +++++++++++------------------------------
src/PointLayout.cpp | 44 +++++----------------
src/Reader.cpp | 27 ++++++++++++-
src/Writer.cpp | 8 ++--
21 files changed, 209 insertions(+), 198 deletions(-)
diffs (truncated from 978 to 300 lines):
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/Color.hpp
--- a/include/libpc/Color.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/Color.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -47,8 +47,6 @@
#include <boost/array.hpp>
#include <boost/cstdint.hpp>
-// std
-//#include <cstdlib> // std::size_t
namespace libpc
{
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/ColorFilter.hpp
--- a/include/libpc/ColorFilter.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/ColorFilter.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -50,7 +50,7 @@
public:
ColorFilter(Stage& prevStage);
- void readNextPoints(PointData&);
+ void readPoints(PointData&);
private:
void getColor(float value, boost::uint8_t& red, boost::uint8_t& green, boost::uint8_t& blue);
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/FauxReader.hpp
--- a/include/libpc/FauxReader.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/FauxReader.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -46,7 +46,10 @@
// generates N points randomly within the bounds
FauxReader(const Bounds<double>&, int numPoints);
- void readNextPoints(PointData& data);
+ void readPoints(PointData& data);
+
+ // does nothing
+ void seekToPoint(boost::uint64_t&) { }
private:
FauxReader& operator=(const FauxReader&); // not implemented
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/Field.hpp
--- a/include/libpc/Field.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/Field.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -73,7 +73,7 @@
F64
};
static std::string getName(DataType);
- static int getSize(DataType);
+ static std::size_t getSize(DataType);
public:
Field();
@@ -96,24 +96,24 @@
}
// what byte the field starts at, within the raw bytes of the point
- int getOffset() const
+ std::size_t getOffset() const
{
return m_offset;
}
- void setOffset(int offset)
+ void setOffset(std::size_t offset)
{
m_offset = offset;
}
// number of bytes needed for the datatype
- int getNumBytes() const;
+ std::size_t getNumBytes() const;
void dump() const;
private:
DataItem m_item;
DataType m_type;
- int m_offset; // byte offset within a point buffer
+ std::size_t m_offset; // byte offset within a point buffer
};
} // namespace libpc
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/Filter.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -47,7 +47,15 @@
public:
Filter(Stage& prevStage);
- virtual void readNextPoints(PointData&) = 0;
+ virtual void readPoints(PointData&) = 0;
+
+ // advance (or retreat) to the Nth point in the file (absolute,
+ // default behaviour for filters is just to call seek on the previous stage
+ virtual void seekToPoint(boost::uint64_t& pointNum);
+
+ // reset the filter
+ // default behaviour for filters is just to call reset on the previous stage
+ virtual void reset();
protected:
int m_lastPointRead;
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/Header.hpp
--- a/include/libpc/Header.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/Header.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -35,6 +35,8 @@
#ifndef INCLUDED_HEADER_HPP
#define INCLUDED_HEADER_HPP
+#include <boost/cstdint.hpp>
+
#include "libpc/export.hpp"
#include "libpc/PointLayout.hpp"
#include "libpc/Bounds.hpp"
@@ -53,8 +55,8 @@
PointLayout& getLayout();
void setLayout(const PointLayout&);
- int getNumPoints() const;
- void setNumPoints(int);
+ boost::uint64_t getNumPoints() const;
+ void setNumPoints(boost::uint64_t);
const Bounds<double>& getBounds() const;
void setBounds(const Bounds<double>&);
@@ -63,7 +65,7 @@
private:
PointLayout m_pointLayout;
- int m_numPoints;
+ boost::uint64_t m_numPoints;
Bounds<double> m_bounds;
};
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/MosaicFilter.hpp
--- a/include/libpc/MosaicFilter.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/MosaicFilter.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -48,7 +48,9 @@
public:
MosaicFilter(Stage& prevStage, Stage& prevStage2);
- void readNextPoints(PointData&);
+ void readPoints(PointData&);
+
+ // BUG: what does seetToPoint() do for a mosaic filter?
private:
Stage& m_prevStage2;
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/PointData.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -51,7 +51,8 @@
// A PointData object has an associated Layout object.
//
// Many of the methods take a first parameter "index", to specify which point in the
-// collection is to be operated upon.
+// collection is to be operated upon. The point index is a uint32; you can't read
+// more than 4 billion points at a time.
class LIBPC_DLL PointData
{
public:
@@ -59,10 +60,10 @@
// regardless of what the passed-in layout says -- this is because the field object
// represents the state within the owning object, which in this case is a completely
// empty buffer (similarly, all the points in the buffer are marked "invalid")
- PointData(const PointLayout&, int numPoints);
+ PointData(const PointLayout&, boost::uint32_t numPoints);
// number of points in this buffer
- int getNumPoints() const;
+ boost::uint32_t getNumPoints() const;
// layout (number and kinds of fields) for a point in this buffer
const PointLayout& getLayout() const;
@@ -70,46 +71,38 @@
// "valid" means the data for the point can be used; if invalid, the point should
// be ignored or skipped. (This is done for efficiency; we don't want to have to
// modify the buffer's size just to "delete" a point.)
- bool isValid(int pointIndex) const;
- void setValid(int pointIndex, bool value=true);
+ bool isValid(std::size_t pointIndex) const;
+ void setValid(std::size_t pointIndex, bool value=true);
// accessors to a particular field of a particular point in this buffer
- boost::uint8_t getField_U8(int pointIndex, int fieldIndex) const;
- float getField_F32(int pointIndex, int fieldIndex) const;
- double getField_F64(int pointIndex, int fieldIndex) const;
+ boost::uint8_t getField_U8(std::size_t pointIndex, std::size_t fieldIndex) const;
+ float getField_F32(std::size_t pointIndex, std::size_t fieldIndex) const;
+ double getField_F64(std::size_t pointIndex, std::size_t fieldIndex) const;
// accessors to a particular field of a particular point in this buffer
- void setField_U8(int pointIndex, int fieldIndex, boost::uint8_t value);
- void setField_F32(int pointIndex, int fieldIndex, float value);
- void setField_F64(int pointIndex, int fieldIndex, double value);
-
- // handy functions to get at some some well-known fields
- float getX(int pointIndex) const;
- float getY(int pointIndex) const;
- float getZ(int pointIndex) const;
- void setX(int pointIndex, float value);
- void setY(int pointIndex, float value);
- void setZ(int pointIndex, float value);
+ void setField_U8(std::size_t pointIndex, std::size_t fieldIndex, boost::uint8_t value);
+ void setField_F32(std::size_t pointIndex, std::size_t fieldIndex, float value);
+ void setField_F64(std::size_t pointIndex, std::size_t fieldIndex, double value);
// bulk copy all the fields from the given point into this object
// NOTE: this is only legal if the src and dest layouts are exactly the same
// (later, this will be implemented properly, to handle the general cases slowly and the best case quickly)
- void copyFieldsFast(int destPointIndex, int srcPointIndex, const PointData& srcPointData);
+ void copyFieldsFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointData& srcPointData);
void dump(std::string indent="") const;
- void dump(int index, std::string indent="") const;
+ void dump(std::size_t pointIndex, std::string indent="") const;
private:
// access to the raw memory
- boost::uint8_t* getData(int pointIndex) const;
+ boost::uint8_t* getData(std::size_t pointIndex) const;
- template<class T> T getField(int fieldIndex, int itemOffset) const;
- template<class T> void setField(int fieldIndex, int itemOffset, T value);
+ template<class T> T getField(std::size_t fieldIndex, std::size_t itemOffset) const;
+ template<class T> void setField(std::size_t fieldIndex, std::size_t itemOffset, T value);
PointLayout m_layout;
boost::uint8_t* m_data;
- int m_pointSize;
- int m_numPoints;
+ std::size_t m_pointSize;
+ boost::uint32_t m_numPoints;
std::vector<bool> m_isValid; // one bool for each point
PointData(const PointData&); // not implemented
diff -r 163e4dc28532 -r 07d85de87f12 include/libpc/PointLayout.hpp
--- a/include/libpc/PointLayout.hpp Sat Feb 12 12:01:09 2011 -0800
+++ b/include/libpc/PointLayout.hpp Sat Feb 12 14:42:10 2011 -0800
@@ -38,6 +38,8 @@
#include <vector>
#include <string>
+#include <boost/cstdint.hpp>
+
#include "libpc/export.hpp"
#include "libpc/Field.hpp"
@@ -54,54 +56,34 @@
bool operator==(const PointLayout& other) const;
// adds a field to the end of the layout, and returns the index of the field added
- int addField(const Field& field);
+ std::size_t addField(const Field& field);
// returns a given field
- const Field& getField(int fieldIndex) const
+ const Field& getField(std::size_t fieldIndex) const
{
return m_fields[fieldIndex];
}
- Field& getField(int fieldIndex)
+ Field& getField(std::size_t fieldIndex)
{
return m_fields[fieldIndex];
}
// total num bytes for all fields in the point
- int getSizeInBytes() const;
+ std::size_t getSizeInBytes() const;
// number of fields in the point
- int getNumFields() const;
+ std::size_t getNumFields() const;
void dump(std::string indent="") const;
- // returns -1 if not found
- int findFieldIndex(Field::DataItem item) const;
+ // returns false if not found, otherwise sets index
+ bool findFieldIndex(Field::DataItem item, std::size_t& index) const;
bool hasField(Field::DataItem item) const;
- // some well-known field types are always available
- // (is this worth it?)
- int getFieldIndex_X() const
- {
- return m_fieldIndex_X;
- }
- int getFieldIndex_Y() const
- {
- return m_fieldIndex_Y;
- }
- int getFieldIndex_Z() const
- {
- return m_fieldIndex_Z;
- }
-
private:
std::vector<Field> m_fields; // each of the fields
- int m_numBytes; // num bytes required to store all fields
More information about the Liblas-commits
mailing list