ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
NodeImpl.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 
35  class CheckedFile;
36 
37  class NodeImpl : public std::enable_shared_from_this<NodeImpl>
38  {
39  public:
40  virtual NodeType type() const = 0;
41  void checkImageFileOpen( const char *srcFileName, int srcLineNumber, const char *srcFunctionName ) const;
42  virtual bool isTypeEquivalent( NodeImplSharedPtr ni ) = 0;
43  bool isRoot() const;
45  ustring pathName() const;
46  ustring relativePathName( const NodeImplSharedPtr &origin, ustring childPathName = ustring() ) const;
47  ustring elementName() const;
49 
50  ustring imageFileName() const;
51  virtual bool isDefined( const ustring &pathName ) = 0;
52  bool isAttached() const;
53  virtual void setAttachedRecursive();
54 
56  bool isTypeConstrained();
57 
58  virtual NodeImplSharedPtr get( const ustring &pathName );
59  virtual void set( const ustring &pathName, NodeImplSharedPtr ni, bool autoPathCreate = false );
60  virtual void set( const StringList &fields, unsigned level, NodeImplSharedPtr ni, bool autoPathCreate = false );
61 
62  virtual void checkLeavesInSet( const StringSet &pathNames, NodeImplSharedPtr origin ) = 0;
63  void checkBuffers( const std::vector<SourceDestBuffer> &sdbufs, bool allowMissing );
64  bool findTerminalPosition( const NodeImplSharedPtr &target, uint64_t &countFromLeft );
65 
66  virtual void writeXml( ImageFileImplSharedPtr imf, CheckedFile &cf, int indent,
67  const char *forcedFieldName = nullptr ) = 0;
68 
69  virtual ~NodeImpl() = default;
70 
71 #ifdef E57_DEBUG
72  virtual void dump( int indent = 0, std::ostream &os = std::cout ) const;
73 #endif
74 
75  private:
76  bool _verifyPathNameAbsolute( const ustring &inPathName );
77 
78  NodeImplSharedPtr _verifyAndGetRoot();
79 
80  protected:
81  friend class StructureNodeImpl;
83  friend class Decoder;
84  friend class Encoder;
85 
88  virtual NodeImplSharedPtr lookup( const ustring & /*pathName*/ )
89  {
90  return NodeImplSharedPtr();
91  }
93 
98  };
99 }
std::vector< PCLPointField > fields
ustring imageFileName() const
Definition: NodeImpl.cpp:147
ImageFileImplWeakPtr destImageFile_
Definition: NodeImpl.h:94
virtual ~NodeImpl()=default
ustring elementName_
Definition: NodeImpl.h:96
virtual NodeImplSharedPtr lookup(const ustring &)
Definition: NodeImpl.h:88
ImageFileImplSharedPtr destImageFile()
Definition: NodeImpl.cpp:126
virtual NodeType type() const =0
NodeImpl(ImageFileImplWeakPtr destImageFile)
Definition: NodeImpl.cpp:35
ustring relativePathName(const NodeImplSharedPtr &origin, ustring childPathName=ustring()) const
Definition: NodeImpl.cpp:93
bool findTerminalPosition(const NodeImplSharedPtr &target, uint64_t &countFromLeft)
Definition: NodeImpl.cpp:313
void checkBuffers(const std::vector< SourceDestBuffer > &sdbufs, bool allowMissing)
Definition: NodeImpl.cpp:271
virtual void setAttachedRecursive()
Definition: NodeImpl.cpp:139
bool isAttached_
Definition: NodeImpl.h:97
bool isAttached() const
Definition: NodeImpl.cpp:132
virtual void set(const ustring &pathName, NodeImplSharedPtr ni, bool autoPathCreate=false)
Definition: NodeImpl.cpp:248
void checkImageFileOpen(const char *srcFileName, int srcLineNumber, const char *srcFunctionName) const
Definition: NodeImpl.cpp:41
NodeImplSharedPtr getRoot()
Definition: NodeImpl.cpp:182
virtual bool isDefined(const ustring &pathName)=0
ustring elementName() const
Definition: NodeImpl.cpp:119
NodeImpl & operator=(NodeImpl &n)
virtual void checkLeavesInSet(const StringSet &pathNames, NodeImplSharedPtr origin)=0
NodeImplSharedPtr parent()
Definition: NodeImpl.cpp:59
virtual NodeImplSharedPtr get(const ustring &pathName)
Definition: NodeImpl.cpp:233
virtual bool isTypeEquivalent(NodeImplSharedPtr ni)=0
void setParent(NodeImplSharedPtr parent, const ustring &elementName)
Definition: NodeImpl.cpp:155
virtual void dump(int indent=0, std::ostream &os=std::cout) const
Definition: NodeImpl.cpp:372
bool isRoot() const
Definition: NodeImpl.cpp:52
ustring pathName() const
Definition: NodeImpl.cpp:74
bool isTypeConstrained()
Definition: NodeImpl.cpp:195
NodeImplWeakPtr parent_
Definition: NodeImpl.h:95
virtual void writeXml(ImageFileImplSharedPtr imf, CheckedFile &cf, int indent, const char *forcedFieldName=nullptr)=0
std::shared_ptr< class NodeImpl > NodeImplSharedPtr
Definition: Common.h:190
std::weak_ptr< class ImageFileImpl > ImageFileImplWeakPtr
Definition: Common.h:189
std::shared_ptr< class ImageFileImpl > ImageFileImplSharedPtr
Definition: Common.h:188
std::weak_ptr< class NodeImpl > NodeImplWeakPtr
Definition: Common.h:191
std::string ustring
UTF-8 encodeded Unicode string.
Definition: E57Format.h:54
std::set< std::string > StringSet
Definition: Common.h:194
NodeType
Identifiers for types of E57 elements.
Definition: E57Format.h:58
std::vector< std::string > StringList
Definition: Common.h:193