1 /*****************************************************************************/ 2 // Copyright 2008-2009 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_opcode_list.h#2 $ */ 10 /* $DateTime: 2012/07/31 22:04:34 $ */ 11 /* $Change: 840853 $ */ 12 /* $Author: tknoll $ */ 13 14 /** \file 15 * List of opcodes. 16 */ 17 18 /*****************************************************************************/ 19 20 #ifndef __dng_opcode_list__ 21 #define __dng_opcode_list__ 22 23 /*****************************************************************************/ 24 25 #include "dng_auto_ptr.h" 26 #include "dng_classes.h" 27 #include "dng_memory.h" 28 #include "dng_opcodes.h" 29 30 #include <vector> 31 32 /*****************************************************************************/ 33 34 /// A list of opcodes. 35 36 class dng_opcode_list 37 { 38 39 private: 40 41 dng_std_vector<dng_opcode *> fList; 42 43 bool fAlwaysApply; 44 45 uint32 fStage; 46 47 public: 48 49 /// Create an empty opcode list for the specific image stage (1, 2, or 3). 50 51 dng_opcode_list (uint32 stage); 52 53 ~dng_opcode_list (); 54 55 /// Is the opcode list empty? 56 57 bool IsEmpty () const 58 { 59 return fList.size () == 0; 60 } 61 62 /// Does the list contain at least 1 opcode? 63 64 bool NotEmpty () const 65 { 66 return !IsEmpty (); 67 } 68 69 /// Should the opcode list always be applied to the image? 70 71 bool AlwaysApply () const 72 { 73 return fAlwaysApply && NotEmpty (); 74 } 75 76 /// Set internal flag to indicate this opcode list should always be 77 /// applied. 78 79 void SetAlwaysApply () 80 { 81 fAlwaysApply = true; 82 } 83 84 /// The number of opcodes in this list. 85 86 uint32 Count () const 87 { 88 return (uint32) fList.size (); 89 } 90 91 /// Retrieve read/write opcode by index (must be in the range 0 to Count 92 /// () - 1). 93 94 dng_opcode & Entry (uint32 index) 95 { 96 return *fList [index]; 97 } 98 99 /// Retrieve read-only opcode by index (must be in the range 0 to Count 100 /// () - 1). 101 102 const dng_opcode & Entry (uint32 index) const 103 { 104 return *fList [index]; 105 } 106 107 /// Remove all opcodes from the list. 108 109 void Clear (); 110 111 /// Swap two opcode lists. 112 113 void Swap (dng_opcode_list &otherList); 114 115 /// Return minimum DNG version required to support all opcodes in this 116 /// list. If includeOptional is set to true, then this calculation will 117 /// include optional opcodes. 118 119 uint32 MinVersion (bool includeOptional) const; 120 121 /// Apply this opcode list to the specified image with corresponding 122 /// negative. 123 124 void Apply (dng_host &host, 125 dng_negative &negative, 126 AutoPtr<dng_image> &image); 127 128 /// Append the specified opcode to this list. 129 130 void Append (AutoPtr<dng_opcode> &opcode); 131 132 /// Serialize this opcode list to a block of memory. The caller is 133 /// responsible for deleting this block. 134 135 dng_memory_block * Spool (dng_host &host) const; 136 137 /// Write a fingerprint of this opcode list to the specified stream. 138 139 void FingerprintToStream (dng_stream &stream) const; 140 141 /// Read an opcode list from the specified stream, starting at the 142 /// specified offset (streamOffset, in bytes). byteCount is provided for 143 /// error checking purposes. A bad format exception 144 /// will be thrown if the length of the opcode stream does not exactly 145 /// match byteCount. 146 147 void Parse (dng_host &host, 148 dng_stream &stream, 149 uint32 byteCount, 150 uint64 streamOffset); 151 152 private: 153 154 // Hidden copy constructor and assignment operator. 155 156 dng_opcode_list (const dng_opcode_list &list); 157 158 dng_opcode_list & operator= (const dng_opcode_list &list); 159 160 }; 161 162 /*****************************************************************************/ 163 164 #endif 165 166 /*****************************************************************************/ 167