1 /*- 2 * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. 3 * 4 * See the file LICENSE for license information. 5 * 6 */ 7 using System; 8 using System.Collections.Generic; 9 10 namespace BerkeleyDB { 11 12 /// <summary> 13 /// A function to call after the record number has been selected but before 14 /// the data has been stored into the database. 15 /// </summary> 16 /// <param name="data">The data to be stored.</param> 17 /// <param name="recno">The generated record number.</param> AppendRecordDelegate(DatabaseEntry data, uint recno)18 public delegate void AppendRecordDelegate(DatabaseEntry data, uint recno); 19 /// <summary> 20 /// A function to store a compressed key/data pair into a supplied buffer. 21 /// </summary> 22 /// <param name="prevKey">The key immediately preceding the application supplied key.</param> 23 /// <param name="prevData">The data associated with prevKey.</param> 24 /// <param name="key">The application supplied key.</param> 25 /// <param name="data">The application supplied data. </param> 26 /// <param name="dest">The compressed data to be stored in the 27 /// database.</param> 28 /// <param name="size">The number of compressed bytes written to 29 /// <paramref name="dest"/>, or the required size of 30 /// <paramref name="dest"/>, if too small.</param> 31 /// <returns>True on success, false if dest is too small to contain the 32 /// compressed data. All other errors should throw an exception.</returns> BTreeCompressDelegate(DatabaseEntry prevKey, DatabaseEntry prevData, DatabaseEntry key, DatabaseEntry data, ref byte[] dest, out int size)33 public delegate bool BTreeCompressDelegate(DatabaseEntry prevKey, 34 DatabaseEntry prevData, DatabaseEntry key, 35 DatabaseEntry data, ref byte[] dest, out int size); 36 /// <summary> 37 /// A function to decompress a key/data pair from a supplied buffer. 38 /// </summary> 39 /// <param name="prevKey">The key immediately preceding the key being decompressed.</param> 40 /// <param name="prevData">The data associated with prevKey.</param> 41 /// <param name="compressed">The data stored in the tree, that is, the compressed data.</param> 42 /// <param name="bytesRead">The number of bytes read from <paramref name="compressed"/>.</param> 43 /// <returns>Two new DatabaseEntry objects representing the decompressed 44 /// key/data pair.</returns> 45 public delegate KeyValuePair<DatabaseEntry, DatabaseEntry> BTreeDecompressDelegate(DatabaseEntry prevKey, DatabaseEntry prevData, byte[] compressed, out uint bytesRead)46 BTreeDecompressDelegate(DatabaseEntry prevKey, 47 DatabaseEntry prevData, byte[] compressed, out uint bytesRead); 48 /// <summary> 49 /// An application-specified partitioning function. 50 /// </summary> 51 /// <param name="key"> 52 /// The value used to determine which partition number should be returned. 53 /// </param> PartitionDelegate(DatabaseEntry key)54 public delegate uint PartitionDelegate(DatabaseEntry key); 55 /// <summary> 56 /// The application-specified feedback function called to report the operation 57 /// progress of Berkeley DB. 58 /// </summary> 59 /// <param name="opcode"> 60 /// An operation code specifying the Berkley DB operation 61 /// </param> 62 /// <param name="percent"> 63 /// The percent of the operation that has been completed, specified as an 64 /// integer value between 0 and 100. 65 /// </param> DatabaseFeedbackDelegate( DatabaseFeedbackEvent opcode, int percent)66 public delegate void DatabaseFeedbackDelegate( 67 DatabaseFeedbackEvent opcode, int percent); 68 /// <summary> 69 /// An application-specified comparison function. 70 /// </summary> 71 /// <param name="dbt1">The application supplied key.</param> 72 /// <param name="dbt2">The current tree's key.</param> 73 /// <returns> 74 /// An integer value less than, equal to, or greater than zero if the first 75 /// key parameter is considered to be respectively less than, equal to, or 76 /// greater than the second key parameter. 77 /// </returns> EntryComparisonDelegate( DatabaseEntry dbt1, DatabaseEntry dbt2)78 public delegate int EntryComparisonDelegate( 79 DatabaseEntry dbt1, DatabaseEntry dbt2); 80 /// <summary> 81 /// An application-specified prefix comparison function. 82 /// </summary> 83 /// <param name="dbt1">The application supplied key.</param> 84 /// <param name="dbt2">The current tree's key.</param> 85 /// <returns> 86 /// An unsigned integer value less than, equal to, or greater than zero 87 /// if the firstkey parameter is considered to be respectively less than, 88 /// equal to, or greater than the second key parameter. 89 /// </returns> EntryPrefixComparisonDelegate( DatabaseEntry dbt1, DatabaseEntry dbt2)90 public delegate uint EntryPrefixComparisonDelegate( 91 DatabaseEntry dbt1, DatabaseEntry dbt2); 92 /// <summary> 93 /// The application-specified feedback function called to report Berkeley DB 94 /// operation progress. 95 /// </summary> 96 /// <param name="opcode"> 97 /// An operation code specifying the Berkley DB operation 98 /// </param> 99 /// <param name="percent"> 100 /// The percent of the operation that has been completed, specified as an 101 /// integer value between 0 and 100. 102 /// </param> EnvironmentFeedbackDelegate( EnvironmentFeedbackEvent opcode, int percent)103 public delegate void EnvironmentFeedbackDelegate( 104 EnvironmentFeedbackEvent opcode, int percent); 105 /// <summary> 106 /// The application-specified error reporting function. 107 /// </summary> 108 /// <param name="errPrefix">The prefix string</param> 109 /// <param name="errMessage">The error message string</param> ErrorFeedbackDelegate( string errPrefix, string errMessage)110 public delegate void ErrorFeedbackDelegate( 111 string errPrefix, string errMessage); 112 /// <summary> 113 /// The application's event notification function. 114 /// </summary> 115 /// <param name="eventcode"> 116 /// An even code specifying the Berkeley DB event 117 /// </param> 118 /// <param name="event_info"> 119 /// Additional information describing an event. By default, event_info is 120 /// null; specific events may pass non-null values, in which case the event 121 /// also describes the information's structure. 122 /// </param> EventNotifyDelegate( NotificationEvent eventcode, byte[] event_info)123 public delegate void EventNotifyDelegate( 124 NotificationEvent eventcode, byte[] event_info); 125 /// <summary> 126 /// 127 /// </summary> 128 /// <param name="key"></param> 129 /// <param name="data"></param> 130 /// <param name="foreignkey"></param> 131 /// <returns></returns> ForeignKeyNullifyDelegate( DatabaseEntry key, DatabaseEntry data, DatabaseEntry foreignkey)132 public delegate DatabaseEntry ForeignKeyNullifyDelegate( 133 DatabaseEntry key, DatabaseEntry data, DatabaseEntry foreignkey); 134 /// <summary> 135 /// The application-specified hash function. 136 /// </summary> 137 /// <param name="data"> 138 /// A byte string representing a key in the database 139 /// </param> 140 /// <returns>The hashed value of <paramref name="data"/></returns> HashFunctionDelegate(byte[] data)141 public delegate uint HashFunctionDelegate(byte[] data); 142 /// <summary> 143 /// Application-specific function used to handle messages sent over 144 /// Replication Manager message channels. 145 /// </summary> 146 /// <param name="channel"> 147 /// Channel used to send a reply back to the originator of the message. 148 /// </param> 149 /// <param name="requests"> 150 /// DatabaseEntry array containing the message received from the remote site. 151 /// </param> 152 /// <param name="size"> 153 /// The number of elements in the request array. 154 /// </param> 155 /// <param name="need_response"> 156 /// Whether the message requires a response. 157 /// </param> MessageDispatchDelegate(DbChannel channel, ref DatabaseEntry[] requests, out uint size, bool need_response)158 public delegate void MessageDispatchDelegate(DbChannel channel, 159 ref DatabaseEntry[] requests, out uint size, bool need_response); 160 /// <summary> 161 /// The application-specified reporting function. 162 /// </summary> 163 /// <param name="msgPrefix">The prefix string</param> 164 /// <param name="Message">The message string</param> MessageFeedbackDelegate( string msgPrefix, string Message)165 public delegate void MessageFeedbackDelegate( 166 string msgPrefix, string Message); 167 /// <summary> 168 /// Application-specific function used by a replication view to determine 169 /// whether a database file is replicated to the local site. 170 /// </summary> 171 /// <param name="name"> 172 /// The name of the database file. 173 /// </param> 174 /// <param name="result"> 175 /// Indicates whether or not the database file should be replicated. 176 /// If non-zero, the database file is replicated; otherwise the database 177 /// file is not replicated. 178 /// </param> 179 /// <param name="flags"> 180 /// Currently unused. 181 /// </param> ReplicationViewDelegate(string name, ref int result, uint flags)182 public delegate int ReplicationViewDelegate(string name, 183 ref int result, uint flags); 184 /// <summary> 185 /// The function used to transmit data using the replication application's 186 /// communication infrastructure. 187 /// </summary> 188 /// <param name="control"> 189 /// The first of the two data elements to be transmitted by the send 190 /// function. 191 /// </param> 192 /// <param name="rec"> 193 /// The second of the two data elements to be transmitted by the send 194 /// function. 195 /// </param> 196 /// <param name="lsn"> 197 /// If the type of message to be sent has an LSN associated with it, then 198 /// this is the LSN of the record being sent. This LSN can be used to 199 /// determine that certain records have been processed successfully by 200 /// clients. 201 /// </param> 202 /// <param name="envid"> 203 /// <para> 204 /// A positive integer identifier that specifies the replication environment 205 /// to which the message should be sent. 206 /// </para> 207 /// <para> 208 /// The special identifier <see cref="EnvironmentID.EID_BROADCAST"/> 209 /// indicates that a message should be broadcast to every environment in 210 /// the replication group. The application may use a true broadcast protocol 211 /// or may send the message in sequence to each machine with which it is in 212 /// communication. In both cases, the sending site should not be asked to 213 /// process the message. 214 /// </para> 215 /// <para> 216 /// The special identifier <see cref="EnvironmentID.EID_INVALID"/> indicates 217 /// an invalid environment ID. This may be used to initialize values that 218 /// are subsequently checked for validity. 219 /// </para> 220 /// </param> 221 /// <param name="flags">XXX: TBD</param> 222 /// <returns>0 on success and non-zero on failure</returns> ReplicationTransportDelegate(DatabaseEntry control, DatabaseEntry rec, LSN lsn, int envid, uint flags)223 public delegate int ReplicationTransportDelegate(DatabaseEntry control, 224 DatabaseEntry rec, LSN lsn, int envid, uint flags); 225 /// <summary> 226 /// The function that creates the set of secondary keys corresponding to a 227 /// given primary key and data pair. To create multiple secondary keys, 228 /// return a <see cref="MultipleDatabaseEntry"/>. 229 /// </summary> 230 /// <param name="key">The primary key</param> 231 /// <param name="data">The primary data item</param> 232 /// <returns>The secondary key(s)</returns> SecondaryKeyGenDelegate( DatabaseEntry key, DatabaseEntry data)233 public delegate DatabaseEntry SecondaryKeyGenDelegate( 234 DatabaseEntry key, DatabaseEntry data); 235 /// <summary> 236 /// A function which returns a unique identifier pair for a thread of 237 /// control in a Berkeley DB application. 238 /// </summary> 239 /// <returns> 240 /// A DbThreadID object describing the current thread of control 241 /// </returns> SetThreadIDDelegate()242 public delegate DbThreadID SetThreadIDDelegate(); 243 /// <summary> 244 /// A function which returns an identifier pair for a thread of control 245 /// formatted for display. 246 /// </summary> 247 /// <param name="info">The thread of control to format</param> 248 /// <returns>The formatted identifier pair</returns> SetThreadNameDelegate(DbThreadID info)249 public delegate string SetThreadNameDelegate(DbThreadID info); 250 /// <summary> 251 /// A function which returns whether the thread of control, identified by 252 /// <paramref name="info"/>, is still running. 253 /// </summary> 254 /// <param name="info">The thread of control to check</param> 255 /// <param name="procOnly"> 256 /// If true, return only if the process is alive, and the 257 /// <see cref="DbThreadID.threadID"/> portion of <paramref name="info"/> 258 /// should be ignored. 259 /// </param> 260 /// <returns>True if the tread is alive, false otherwise.</returns> ThreadIsAliveDelegate(DbThreadID info, bool procOnly)261 public delegate bool ThreadIsAliveDelegate(DbThreadID info, bool procOnly); 262 } 263