ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SourceDestBufferImpl.h
Go to the documentation of this file.
1 /*
2  * Original work Copyright 2009 - 2010 Kevin Ackley (kackley@gwi.net)
3  * Modified work Copyright 2018 - 2020 Andy Maloney <asmaloney@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person or organization
6  * obtaining a copy of the software and accompanying documentation covered by
7  * this license (the "Software") to use, reproduce, display, distribute,
8  * execute, and transmit the Software, and to prepare derivative works of the
9  * Software, and to permit third-parties to whom the Software is furnished to
10  * do so, all subject to the following:
11  *
12  * The copyright notices in the Software and this entire statement, including
13  * the above license grant, this restriction and the following disclaimer,
14  * must be included in all copies of the Software, in whole or in part, and
15  * all derivative works of the Software, unless such copies or derivative
16  * works are solely in the form of machine-executable object code generated by
17  * a source language processor.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  */
27 
28 #pragma once
29 
30 #include "Common.h"
31 
32 namespace e57
33 {
34  class ImageFileImpl;
35 
36  class SourceDestBufferImpl : public std::enable_shared_from_this<SourceDestBufferImpl>
37  {
38  public:
40  bool doConversion = false, bool doScaling = false );
41 
42  template <typename T> void setTypeInfo( T *base, size_t stride = sizeof( T ) );
43 
45 
47  {
48  return destImageFile_;
49  }
50 
51  ustring pathName() const
52  {
53  return pathName_;
54  }
56  {
57  return memoryRepresentation_;
58  }
59  void *base() const
60  {
61  return base_;
62  }
64  {
65  return ustrings_;
66  }
67  bool doConversion() const
68  {
69  return doConversion_;
70  }
71  bool doScaling() const
72  {
73  return doScaling_;
74  }
75  size_t stride() const
76  {
77  return stride_;
78  }
79  size_t capacity() const
80  {
81  return capacity_;
82  }
83  unsigned nextIndex() const
84  {
85  return nextIndex_;
86  }
87  void rewind()
88  {
89  nextIndex_ = 0;
90  }
91 
92  int64_t getNextInt64();
93  int64_t getNextInt64( double scale, double offset );
94  float getNextFloat();
95  double getNextDouble();
97  void setNextInt64( int64_t value );
98  void setNextInt64( int64_t value, double scale, double offset );
99  void setNextFloat( float value );
100  void setNextDouble( double value );
101  void setNextString( const ustring &value );
102 
103  void checkCompatible( const std::shared_ptr<SourceDestBufferImpl> &newBuf ) const;
104 
105 #ifdef E57_DEBUG
106  void dump( int indent = 0, std::ostream &os = std::cout );
107 #endif
108 
109  private:
110  template <typename T> void _setNextReal( T inValue );
111 
112  void checkState_() const;
114 
115  //??? verify alignment
116  ImageFileImplWeakPtr destImageFile_;
117  ustring pathName_;
119  MemoryRepresentation memoryRepresentation_;
121  char *base_ = nullptr;
122  size_t capacity_ = 0;
123  bool doConversion_ = false;
124  bool doScaling_ = false;
125  size_t stride_ = 0;
127  unsigned nextIndex_ = 0;
129  StringList *ustrings_ = nullptr;
131  };
132 }
int offset
void setNextString(const ustring &value)
void setTypeInfo(T *base, size_t stride=sizeof(T))
void dump(int indent=0, std::ostream &os=std::cout)
MemoryRepresentation memoryRepresentation() const
SourceDestBufferImpl(ImageFileImplWeakPtr destImageFile, const ustring &pathName, const size_t capacity, bool doConversion=false, bool doScaling=false)
void checkCompatible(const std::shared_ptr< SourceDestBufferImpl > &newBuf) const
StringList * ustrings() const
ImageFileImplWeakPtr destImageFile() const
std::weak_ptr< class ImageFileImpl > ImageFileImplWeakPtr
Definition: Common.h:189
std::string ustring
UTF-8 encodeded Unicode string.
Definition: E57Format.h:54
MemoryRepresentation
Identifies the representations of memory elements API can transfer data to/from.
Definition: E57Format.h:79
std::vector< std::string > StringList
Definition: Common.h:193