1 : /******************************************************************************
2 : *
3 : * Purpose: Declaration of the CPCIDSKChannel Abstract 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 : #ifndef __INCLUDE_CHANNEL_CPCIDSKCHANNEL_H
28 : #define __INCLUDE_CHANNEL_CPCIDSKCHANNEL_H
29 :
30 : #include "pcidsk_config.h"
31 : #include "pcidsk_buffer.h"
32 : #include "pcidsk_channel.h"
33 : #include "core/metadataset.h"
34 : #include "core/mutexholder.h"
35 : #include <vector>
36 : #include <string>
37 :
38 : namespace PCIDSK
39 : {
40 : class CPCIDSKFile;
41 : class CTiledChannel;
42 : /************************************************************************/
43 : /* CPCIDSKChannel */
44 : /* */
45 : /* Abstract class that helps implement some of the more mundane details */
46 : /* required for when implementing an imagery channel I/O strategy. If */
47 : /* you are using this to implement those details, use virtual */
48 : /* inheritance to attempt to avoid the fragile base class problem and */
49 : /* then implement the Imagery I/O functions. */
50 : /************************************************************************/
51 : class CPCIDSKChannel : public PCIDSKChannel
52 : {
53 : friend class PCIDSKFile;
54 :
55 : public:
56 : CPCIDSKChannel( PCIDSKBuffer &image_header, uint64 ih_offset,
57 : CPCIDSKFile *file, eChanType pixel_type,
58 : int channel_number );
59 : virtual ~CPCIDSKChannel();
60 :
61 322 : virtual int GetBlockWidth() const { return block_width; }
62 322 : virtual int GetBlockHeight() const { return block_height; }
63 : virtual int GetBlockCount() const;
64 :
65 3 : virtual int GetWidth() const { return width; }
66 3 : virtual int GetHeight() const { return height; }
67 482 : virtual eChanType GetType() const { return pixel_type; }
68 :
69 : int GetOverviewCount();
70 : PCIDSKChannel *GetOverview( int i );
71 : bool IsOverviewValid( int i );
72 : void SetOverviewValidity( int i, bool validity );
73 : std::string GetOverviewResampling( int i );
74 : std::vector<int> GetOverviewLevelMapping() const;
75 :
76 : int GetChannelNumber() { return channel_number; }
77 :
78 29 : std::string GetMetadataValue( const std::string &key ) const
79 29 : { return metadata.GetMetadataValue(key); }
80 5 : void SetMetadataValue( const std::string &key, const std::string &value )
81 5 : { metadata.SetMetadataValue(key,value); }
82 156 : std::vector<std::string> GetMetadataKeys() const
83 156 : { return metadata.GetMetadataKeys(); }
84 :
85 261 : virtual void Synchronize() {}
86 :
87 : std::string GetDescription();
88 : void SetDescription( const std::string &description );
89 :
90 : virtual std::vector<std::string> GetHistoryEntries() const;
91 : virtual void SetHistoryEntries( const std::vector<std::string> &entries );
92 : virtual void PushHistory(const std::string &app,
93 : const std::string &message);
94 :
95 : // Just for CPCIDSKFile.
96 : void InvalidateOverviewInfo();
97 :
98 : protected:
99 : CPCIDSKFile *file;
100 : mutable MetadataSet metadata;
101 :
102 : void LoadHistory( const PCIDSKBuffer &image_header );
103 : std::vector<std::string> history_;
104 :
105 : int channel_number;
106 : uint64 ih_offset;
107 : mutable eChanType pixel_type;
108 : char byte_order; // 'S': littleendian, 'N': bigendian
109 : mutable int needs_swap;
110 :
111 : // width/height, and block size.
112 : mutable int width;
113 : mutable int height;
114 : mutable int block_width;
115 : mutable int block_height;
116 :
117 : // info about overviews;
118 : void EstablishOverviewInfo() const;
119 :
120 : mutable bool overviews_initialized;
121 : mutable std::vector<std::string> overview_infos;
122 : mutable std::vector<CTiledChannel *> overview_bands;
123 : mutable std::vector<int> overview_decimations;
124 :
125 : void InvalidateOverviews();
126 : };
127 : } // end namespace PCIDSK
128 :
129 : #endif // __INCLUDE_CHANNEL_CPCIDSKCHANNEL_H
|