[Liblas-commits] hg: add WriterFactory
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Dec 17 14:04:50 EST 2010
changeset d44837072a6a in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d44837072a6a
summary: add WriterFactory
diffstat:
include/liblas/factory.hpp | 23 +++++++++++++++++++++--
include/liblas/laswriter.hpp | 5 +++--
src/detail/writer/writer.cpp | 16 ----------------
src/factory.cpp | 20 +++++++++++++++++++-
src/laswriter.cpp | 9 ++++++++-
5 files changed, 51 insertions(+), 22 deletions(-)
diffs (163 lines):
diff -r d4128e8b5ece -r d44837072a6a include/liblas/factory.hpp
--- a/include/liblas/factory.hpp Fri Dec 17 11:42:54 2010 -0600
+++ b/include/liblas/factory.hpp Fri Dec 17 13:04:42 2010 -0600
@@ -67,7 +67,7 @@
Reader CreateWithImpl(ReaderIPtr r);
Reader CreateCached(std::istream& stream, boost::uint32_t cache_size);
- Reader Create(std::istream& stream);
+ Reader CreateWithStream(std::istream& stream);
/// Destructor.
/// @exception nothrow
@@ -76,10 +76,29 @@
private:
+};
+class LAS_DLL WriterFactory
+{
+public:
+
+
+ WriterFactory() {};
+
+ WriterFactory(WriterFactory const& other);
+ WriterFactory& operator=(WriterFactory const& rhs);
+
+ Writer CreateWithImpl(WriterIPtr w);
+ Writer CreateWithStream(std::ostream& stream);
+
+ /// Destructor.
+ /// @exception nothrow
+ ~WriterFactory() {};
+
+
+private:
};
-
} // namespace liblas
#endif // ndef LIBLAS_LASREADER_HPP_INCLUDED
diff -r d4128e8b5ece -r d44837072a6a include/liblas/laswriter.hpp
--- a/include/liblas/laswriter.hpp Fri Dec 17 11:42:54 2010 -0600
+++ b/include/liblas/laswriter.hpp Fri Dec 17 13:04:42 2010 -0600
@@ -71,6 +71,8 @@
Writer(std::ostream& ofs, Header const& header);
Writer(Writer const& other);
+ Writer(WriterIPtr ptr);
+
Writer& operator=(Writer const& rhs);
/// Destructor does not close file attached to the output stream
@@ -104,8 +106,7 @@
void SetTransforms(std::vector<liblas::TransformPtr> const& transforms);
private:
-
- typedef boost::shared_ptr<WriterI> WriterIPtr;
+
WriterIPtr m_pimpl;
};
diff -r d4128e8b5ece -r d44837072a6a src/detail/writer/writer.cpp
--- a/src/detail/writer/writer.cpp Fri Dec 17 11:42:54 2010 -0600
+++ b/src/detail/writer/writer.cpp Fri Dec 17 13:04:42 2010 -0600
@@ -129,21 +129,5 @@
m_header = HeaderPtr(new liblas::Header(header));
}
-WriterImpl* WriterFactory::Create(std::ostream& ofs)
-{
- if (!ofs)
- {
- throw std::runtime_error("output stream state is invalid");
- }
-
- return new detail::WriterImpl(ofs);
-
-}
-
-void WriterFactory::Destroy(detail::WriterImpl* p)
-{
- delete p;
- p = 0;
-}
}} // namespace liblas::detail
diff -r d4128e8b5ece -r d44837072a6a src/factory.cpp
--- a/src/factory.cpp Fri Dec 17 11:42:54 2010 -0600
+++ b/src/factory.cpp Fri Dec 17 13:04:42 2010 -0600
@@ -43,6 +43,7 @@
#include <liblas/factory.hpp>
#include <liblas/detail/reader/reader.hpp>
#include <liblas/detail/reader/cachedreader.hpp>
+#include <liblas/detail/writer/writer.hpp>
#include <liblas/utility.hpp>
// boost
@@ -73,10 +74,27 @@
return liblas::Reader(r);
}
-Reader ReaderFactory::Create(std::istream& stream)
+Reader ReaderFactory::CreateWithStream(std::istream& stream)
{
ReaderIPtr r = ReaderIPtr(new detail::ReaderImpl(stream) );
return liblas::Reader(r);
}
+
+
+Writer WriterFactory::CreateWithImpl(WriterIPtr w)
+{
+ liblas::Writer writer(w);
+ return writer;
+}
+
+
+Writer WriterFactory::CreateWithStream(std::ostream& stream)
+{
+
+ WriterIPtr w = WriterIPtr(new detail::WriterImpl(stream));
+ return liblas::Writer(w);
+}
+
+
} // namespace liblas
diff -r d4128e8b5ece -r d44837072a6a src/laswriter.cpp
--- a/src/laswriter.cpp Fri Dec 17 11:42:54 2010 -0600
+++ b/src/laswriter.cpp Fri Dec 17 13:04:42 2010 -0600
@@ -42,6 +42,7 @@
#include <liblas/lasversion.hpp>
#include <liblas/laswriter.hpp>
#include <liblas/detail/writer/writer.hpp>
+#include <liblas/factory.hpp>
// std
#include <stdexcept>
@@ -54,7 +55,7 @@
{
Writer::Writer(std::ostream& ofs, Header const& header) :
- m_pimpl(detail::WriterFactory::Create(ofs))
+ m_pimpl(WriterIPtr(new detail::WriterImpl(ofs)))
{
m_pimpl->SetHeader(header);
@@ -76,6 +77,12 @@
return *this;
}
+Writer::Writer(WriterIPtr ptr) :
+ m_pimpl(ptr)
+
+{
+}
+
Writer::~Writer()
{
More information about the Liblas-commits
mailing list