HiRISE
 PDS_JP2

JP2_Box.hh
Go to the documentation of this file.
1 /* JP2_Box
2 
3 HiROC CVS ID: JP2_Box.hh,v 1.4 2007/10/20 00:39:47 castalia Exp
4 
5 Copyright (C) 2007 Arizona Board of Regents on behalf of the
6 Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
7 the University of Arizona.
8 
9 This library is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License, version 2.1,
11 as published by the Free Software Foundation.
12 
13 This library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with this library; if not, write to the Free Software Foundation,
20 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 */
22 
23 #ifndef _JP2_Box_
24 #define _JP2_Box_
25 
26 #include <string>
27 #include <vector>
28 
29 
30 namespace UA
31 {
32 namespace HiRISE
33 {
39 class JP2_Box
40 {
41 public:
42 /*==============================================================================
43  Types:
44 */
46 typedef std::vector<JP2_Box*> JP2_Box_List;
47 
48 /*==============================================================================
49  Constants:
50 */
52 static const char* const
53  ID;
54 
56 static const unsigned int
59 static const unsigned int
62 static const unsigned int
65 static const unsigned int
67 
69 static const unsigned int
71 
73 static const unsigned int
75 
77 static const unsigned int
79 
81 static const unsigned int
83 
85 static const unsigned int
87 
88 /*==============================================================================
89  Constructors:
90 */
93 JP2_Box ();
94 
110 explicit JP2_Box (unsigned int box_type,
111  const unsigned char* data = NULL, unsigned int amount = 0);
112 
119 explicit JP2_Box (unsigned int box_type, const std::string& text);
120 
126 virtual ~JP2_Box ();
127 
128 /*==============================================================================
129  Accessors:
130 */
142 std::string type_name () const
143  {return Type ? type_name (Type) : "";}
144 
153 JP2_Box& type_name (const std::string& name);
154 
162 unsigned int type_code () const
163  {return Type;}
164 
172 JP2_Box& type_code (unsigned int box_type);
173 
182 unsigned int content_amount () const
183  {return Content_Amount;}
184 
190 unsigned char* content () const
191  {return Content;}
192 
208 JP2_Box& content (const unsigned char* data, unsigned int amount = 0);
209 
223 JP2_Box& content (const std::string& text);
224 
242  {return Locally_Owned_Content;}
243 
256 JP2_Box& attach_content (unsigned char* data, unsigned int amount = 0);
257 
258 /*==============================================================================
259  Manipulators:
260 */
281 JP2_Box& append_content (const unsigned char* data, unsigned int amount);
282 
295 JP2_Box& append_content (const std::string& text);
296 
297 //------------------------------------------------------------------------------
298 // Sub-boxes
299 
315 JP2_Box& add (JP2_Box* sub_box);
316 
325 JP2_Box& add (JP2_Box& sub_box)
326  {return add (&sub_box);}
327 
343 bool remove (JP2_Box* sub_box);
344 
357  {return Sub_Boxes;}
358 
366  {return Container;}
367 
368 /*==============================================================================
369  Helpers
370 */
382 static std::string type_name (unsigned int box_type);
383 
398 static unsigned int type_code (const std::string& name);
399 
400 /*==============================================================================
401  Data members:
402 */
403 protected:
404 
406 unsigned int
408 
410 unsigned char
412 
414 unsigned int
416 
418 bool
420 
422 JP2_Box
424 
428 
429 }; // class JP2_Box
430 
431 
432 } // namespace HiRISE
433 } // namespace UA
434 #endif
435 
A JP2_Box contains JP2 file format box data.
Definition: JP2_Box.hh:40
bool remove(JP2_Box *sub_box)
Remove a sub-box from this box.
Definition: JP2_Box.cc:389
JP2_Box & add(JP2_Box *sub_box)
Add a sub-box to this box.
Definition: JP2_Box.cc:350
unsigned char * content() const
Get the box data content.
Definition: JP2_Box.hh:190
unsigned int content_amount() const
Get the box data content amount.
Definition: JP2_Box.hh:182
virtual ~JP2_Box()
Destroy this JP2_Box.
Definition: JP2_Box.cc:181
unsigned int type_code() const
Get the type code of the box.
Definition: JP2_Box.hh:162
static const unsigned int LABEL_BOX_TYPE
Label box type.
Definition: JP2_Box.hh:82
static const unsigned int UUID_LIST_BOX_TYPE
UUID List box type.
Definition: JP2_Box.hh:66
JP2_Box & attach_content(unsigned char *data, unsigned int amount=0)
Set the box data content.
Definition: JP2_Box.cc:330
static const unsigned int UUID_BOX_TYPE
UUID box type.
Definition: JP2_Box.hh:57
unsigned int Content_Amount
The amount (bytes) of content data.
Definition: JP2_Box.hh:415
static const unsigned int UUID_SIZE
Size of the UUID data content.
Definition: JP2_Box.hh:60
unsigned char * Content
The data content buffer.
Definition: JP2_Box.hh:411
unsigned int Type
The JP2 box type code.
Definition: JP2_Box.hh:407
static const unsigned int URL_BOX_TYPE
URL box type.
Definition: JP2_Box.hh:70
JP2_Box_List Sub_Boxes
List of boxes contained in this box.
Definition: JP2_Box.hh:427
JP2_Box & add(JP2_Box &sub_box)
Add a sub-box to this box.
Definition: JP2_Box.hh:325
JP2_Box * container() const
Get the container of this box.
Definition: JP2_Box.hh:365
std::string type_name() const
Get the type name of the box.
Definition: JP2_Box.hh:142
bool locally_owned_content() const
Test if the box data content buffer is locally owned.
Definition: JP2_Box.hh:241
static const unsigned int ASSOCIATION_BOX_TYPE
Association box type.
Definition: JP2_Box.hh:78
JP2_Box()
Construct a JP2_Box with no data content.
Definition: JP2_Box.cc:127
static const unsigned int UUID_INFO_BOX_TYPE
UUID Info box type.
Definition: JP2_Box.hh:63
JP2_Box_List & sub_boxes()
Get the list of sub-boxes contained in this box.
Definition: JP2_Box.hh:356
bool Locally_Owned_Content
Flag for a locally owned data content buffer.
Definition: JP2_Box.hh:419
static const unsigned int INTELLECTUAL_PROPERTY_BOX_TYPE
Intellectual Property box type.
Definition: JP2_Box.hh:86
JP2_Box & append_content(const unsigned char *data, unsigned int amount)
Append data to the box data content.
Definition: JP2_Box.cc:268
std::vector< JP2_Box * > JP2_Box_List
List of JP2 boxes.
Definition: JP2_Box.hh:46
JP2_Box * Container
Pointer to the JP2_Box that contains this box.
Definition: JP2_Box.hh:423
static const char *const ID
Class identification name with source code version and date.
Definition: JP2_Box.hh:53
static const unsigned int XML_BOX_TYPE
XML box type.
Definition: JP2_Box.hh:74
Definition: Dimensions.cc:30
kdu_uint32 box_type(const char *box_name)
Definition: relocate_label.cc:813