summaryrefslogtreecommitdiff
path: root/gpr/source/lib/dng_sdk/dng_opcode_list.h
blob: 84813fbd66717d041ce7ba0efd14bed8eb4d59e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*****************************************************************************/
// Copyright 2008-2009 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_opcode_list.h#2 $ */ 
/* $DateTime: 2012/07/31 22:04:34 $ */
/* $Change: 840853 $ */
/* $Author: tknoll $ */

/** \file
 * List of opcodes.
 */

/*****************************************************************************/

#ifndef __dng_opcode_list__
#define __dng_opcode_list__

/*****************************************************************************/

#include "dng_auto_ptr.h"
#include "dng_classes.h"
#include "dng_opcodes.h"

#include <vector>

/*****************************************************************************/

/// A list of opcodes.

class dng_opcode_list
	{
	
	private:
	
		std::vector<dng_opcode *> fList;
		
		bool fAlwaysApply;
		
		uint32 fStage;
		
	public:

		/// Create an empty opcode list for the specific image stage (1, 2, or 3).
	
		dng_opcode_list (uint32 stage);
		
		~dng_opcode_list ();

		/// Is the opcode list empty?
		
		bool IsEmpty () const
			{
			return fList.size () == 0;
			}

		/// Does the list contain at least 1 opcode?
			
		bool NotEmpty () const
			{
			return !IsEmpty ();
			}

		/// Should the opcode list always be applied to the image?
			
		bool AlwaysApply () const
			{
			return fAlwaysApply && NotEmpty ();
			}

		/// Set internal flag to indicate this opcode list should always be
		/// applied.
			
		void SetAlwaysApply ()
			{
			fAlwaysApply = true;
			}

		/// The number of opcodes in this list.
			
		uint32 Count () const
			{
			return (uint32) fList.size ();
			}

		/// Retrieve read/write opcode by index (must be in the range 0 to Count
		/// () - 1).
			
		dng_opcode & Entry (uint32 index)
			{
			return *fList [index];
			}

		/// Retrieve read-only opcode by index (must be in the range 0 to Count
		/// () - 1).
			
		const dng_opcode & Entry (uint32 index) const
			{
			return *fList [index];
			}

		/// Remove all opcodes from the list.

		void Clear ();

		/// Swap two opcode lists.
		
		void Swap (dng_opcode_list &otherList);

		/// Return minimum DNG version required to support all opcodes in this
		/// list. If includeOptional is set to true, then this calculation will
		/// include optional opcodes.
		
		uint32 MinVersion (bool includeOptional) const;
		
		/// Apply this opcode list to the specified image with corresponding
		/// negative.

		void Apply (dng_host &host,
					dng_negative &negative,
					AutoPtr<dng_image> &image);

		/// Append the specified opcode to this list.
					
		void Append (AutoPtr<dng_opcode> &opcode);

		/// Serialize this opcode list to a block of memory. The caller is
		/// responsible for deleting this block.
		
		dng_memory_block * Spool (dng_host &host) const;

		/// Write a fingerprint of this opcode list to the specified stream.
		
		void FingerprintToStream (dng_stream &stream) const;

		/// Read an opcode list from the specified stream, starting at the
		/// specified offset (streamOffset, in bytes). byteCount is provided for
		/// error checking purposes. A bad format exception
		/// will be thrown if the length of the opcode stream does not exactly
		/// match byteCount.

		void Parse (dng_host &host,
					dng_stream &stream,
					uint32 byteCount,
					uint64 streamOffset);
		
	private:
	
		// Hidden copy constructor and assignment operator.
		
		dng_opcode_list (const dng_opcode_list &list);
		
		dng_opcode_list & operator= (const dng_opcode_list &list);
	
	};

/*****************************************************************************/

#endif
	
/*****************************************************************************/