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 : PCIDSKBuffer &GetHeader();
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 : std::string GetMetadataValue( std::string key );
75 : void SetMetadataValue( std::string key, std::string value );
76 : std::vector<std::string> GetMetadataKeys();
77 :
78 : protected:
79 : PCIDSKFile *file;
80 :
81 : int segment;
82 :
83 : eSegType segment_type;
84 : char segment_flag;
85 : std::string segment_name;
86 :
87 : uint64 data_offset; // includes 1024 byte segment header.
88 : uint64 data_size;
89 :
90 : PCIDSKBuffer header;
91 :
92 : MetadataSet *metadata;
93 : };
94 :
95 : } // end namespace PCIDSK
96 : #endif // _INCLUDE_SEGMENT_PCIDSKSEGMENT_H
|