1 : /******************************************************************************
2 : *
3 : * Purpose: Declaration of the CPCIDSKSegment class.
4 : *
5 : ******************************************************************************
6 : * Copyright (c) 2009
7 : * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
8 : *
9 : * Permission is hereby granted, free of charge, to any person obtaining a
10 : * copy of this software and associated documentation files (the "Software"),
11 : * to deal in the Software without restriction, including without limitation
12 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 : * and/or sell copies of the Software, and to permit persons to whom the
14 : * Software is furnished to do so, subject to the following conditions:
15 : *
16 : * The above copyright notice and this permission notice shall be included
17 : * in all copies or substantial portions of the Software.
18 : *
19 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 : * DEALINGS IN THE SOFTWARE.
26 : ****************************************************************************/
27 :
28 : #ifndef _INCLUDE_SEGMENT_PCIDSKSEGMENT_H
29 : #define _INCLUDE_SEGMENT_PCIDSKSEGMENT_H
30 :
31 : #include "pcidsk_config.h"
32 : #include "pcidsk_types.h"
33 : #include "pcidsk_buffer.h"
34 : #include "pcidsk_segment.h"
35 :
36 : #include <string>
37 : #include <vector>
38 :
39 : namespace PCIDSK
40 : {
41 : class PCIDSKFile;
42 : class MetadataSet;
43 :
44 : /************************************************************************/
45 : /* CPCIDSKSegment */
46 : /* */
47 : /* Base class for accessing all segments. Provides core */
48 : /* PCIDSKObject implementation for segments with raw segment io */
49 : /* options. */
50 : /************************************************************************/
51 :
52 : class CPCIDSKSegment : virtual public PCIDSKSegment
53 : {
54 : public:
55 : CPCIDSKSegment( PCIDSKFile *file, int segment,
56 : const char *segment_pointer );
57 : virtual ~CPCIDSKSegment();
58 :
59 : void LoadSegmentPointer( const char *segment_pointer );
60 : void LoadSegmentHeader();
61 :
62 0 : PCIDSKBuffer &GetHeader() { return header; }
63 :
64 : void WriteToFile( const void *buffer, uint64 offset, uint64 size );
65 : void ReadFromFile( void *buffer, uint64 offset, uint64 size );
66 :
67 0 : eSegType GetSegmentType() { return segment_type; }
68 0 : std::string GetName() { return segment_name; }
69 : std::string GetDescription();
70 1 : int GetSegmentNumber() { return segment; }
71 0 : uint64 GetContentSize() { return data_size - 1024; }
72 : bool IsAtEOF();
73 :
74 : void SetDescription( const std::string &description);
75 :
76 : std::string GetMetadataValue( const std::string &key ) const;
77 : void SetMetadataValue( const std::string &key, const std::string &value );
78 : std::vector<std::string> GetMetadataKeys() const;
79 :
80 130 : virtual void Synchronize() {}
81 :
82 : std::vector<std::string> GetHistoryEntries() const;
83 : void SetHistoryEntries( const std::vector<std::string> &entries );
84 : void PushHistory(const std::string &app,
85 : const std::string &message);
86 :
87 : protected:
88 : PCIDSKFile *file;
89 :
90 : int segment;
91 :
92 : eSegType segment_type;
93 : char segment_flag;
94 : std::string segment_name;
95 :
96 : uint64 data_offset; // includes 1024 byte segment header.
97 : uint64 data_size;
98 :
99 : PCIDSKBuffer header;
100 :
101 : mutable MetadataSet *metadata;
102 :
103 : std::vector<std::string> history_;
104 : };
105 :
106 : } // end namespace PCIDSK
107 : #endif // _INCLUDE_SEGMENT_PCIDSKSEGMENT_H
|