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,
57 : CPCIDSKFile *file, eChanType pixel_type,
58 : int channel_number );
59 : virtual ~CPCIDSKChannel();
60 :
61 237 : virtual int GetBlockWidth() { return block_width; }
62 237 : virtual int GetBlockHeight() { return block_height; }
63 : virtual int GetBlockCount();
64 :
65 3 : virtual int GetWidth() { return width; }
66 3 : virtual int GetHeight() { return height; }
67 197 : virtual eChanType GetType() { return pixel_type; }
68 :
69 : int GetOverviewCount();
70 : PCIDSKChannel *GetOverview( int i );
71 :
72 : int GetChannelNumber() { return channel_number; }
73 :
74 29 : std::string GetMetadataValue( std::string key )
75 29 : { return metadata.GetMetadataValue(key); }
76 5 : void SetMetadataValue( std::string key, std::string value )
77 5 : { metadata.SetMetadataValue(key,value); }
78 71 : std::vector<std::string> GetMetadataKeys()
79 71 : { return metadata.GetMetadataKeys(); }
80 :
81 : // Just for CPCIDSKFile.
82 : void InvalidateOverviewInfo();
83 :
84 : protected:
85 : CPCIDSKFile *file;
86 : MetadataSet metadata;
87 :
88 : int channel_number;
89 : eChanType pixel_type;
90 : char byte_order; // 'S': littleendian, 'N': bigendian
91 : int needs_swap;
92 :
93 : // width/height, and block size.
94 : int width;
95 : int height;
96 : int block_width;
97 : int block_height;
98 :
99 : // info about overviews;
100 : void EstablishOverviewInfo();
101 :
102 : bool overviews_initialized;
103 : std::vector<std::string> overview_infos;
104 : std::vector<CTiledChannel *> overview_bands;
105 : };
106 : } // end namespace PCIDSK
107 :
108 : #endif // __INCLUDE_CHANNEL_CPCIDSKCHANNEL_H
|