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