1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2009 Oracle. All rights reserved. 5 * 6 */ 7using System; 8using System.Collections.Generic; 9 10namespace 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> 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> 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> 46 BTreeDecompressDelegate(DatabaseEntry prevKey, 47 DatabaseEntry prevData, byte[] compressed, out uint bytesRead); 48 /// <summary> 49 /// The application-specified feedback function called to report Berkeley DB 50 /// operation progress. 51 /// </summary> 52 /// <param name="opcode"> 53 /// An operation code specifying the Berkley DB operation 54 /// </param> 55 /// <param name="percent"> 56 /// The percent of the operation that has been completed, specified as an 57 /// integer value between 0 and 100. 58 /// </param> 59 public delegate void DatabaseFeedbackDelegate( 60 DatabaseFeedbackEvent opcode, int percent); 61 /// <summary> 62 /// An application-specified comparison function. 63 /// </summary> 64 /// <param name="dbt1">The application supplied key.</param> 65 /// <param name="dbt2">The current tree's key.</param> 66 /// <returns> 67 /// An integer value less than, equal to, or greater than zero if the first 68 /// key parameter is considered to be respectively less than, equal to, or 69 /// greater than the second key parameter. 70 /// </returns> 71 public delegate int EntryComparisonDelegate( 72 DatabaseEntry dbt1, DatabaseEntry dbt2); 73 /// <summary> 74 /// The application-specified feedback function called to report Berkeley DB 75 /// operation progress. 76 /// </summary> 77 /// <param name="opcode"> 78 /// An operation code specifying the Berkley DB operation 79 /// </param> 80 /// <param name="percent"> 81 /// The percent of the operation that has been completed, specified as an 82 /// integer value between 0 and 100. 83 /// </param> 84 public delegate void EnvironmentFeedbackDelegate( 85 EnvironmentFeedbackEvent opcode, int percent); 86 /// <summary> 87 /// The application-specified error reporting function. 88 /// </summary> 89 /// <param name="errPrefix">The prefix string</param> 90 /// <param name="errMessage">The error message string</param> 91 public delegate void ErrorFeedbackDelegate( 92 string errPrefix, string errMessage); 93 /// <summary> 94 /// The application's event notification function. 95 /// </summary> 96 /// <param name="eventcode"> 97 /// An even code specifying the Berkeley DB event 98 /// </param> 99 /// <param name="event_info"> 100 /// Additional information describing an event. By default, event_info is 101 /// null; specific events may pass non-null values, in which case the event 102 /// will also describe the information's structure. 103 /// </param> 104 public delegate void EventNotifyDelegate( 105 NotificationEvent eventcode, byte[] event_info); 106 /// <summary> 107 /// 108 /// </summary> 109 /// <param name="key"></param> 110 /// <param name="data"></param> 111 /// <param name="foreignkey"></param> 112 /// <returns></returns> 113 public delegate DatabaseEntry ForeignKeyNullifyDelegate( 114 DatabaseEntry key, DatabaseEntry data, DatabaseEntry foreignkey); 115 /// <summary> 116 /// The application-specified hash function. 117 /// </summary> 118 /// <param name="data"> 119 /// A byte string representing a key in the database 120 /// </param> 121 /// <returns>The hashed value of <paramref name="data"/></returns> 122 public delegate uint HashFunctionDelegate(byte[] data); 123 /// <summary> 124 /// The function used to transmit data using the replication application's 125 /// communication infrastructure. 126 /// </summary> 127 /// <param name="control"> 128 /// The first of the two data elements to be transmitted by the send 129 /// function. 130 /// </param> 131 /// <param name="rec"> 132 /// The second of the two data elements to be transmitted by the send 133 /// function. 134 /// </param> 135 /// <param name="lsn"> 136 /// If the type of message to be sent has an LSN associated with it, then 137 /// this is the LSN of the record being sent. This LSN can be used to 138 /// determine that certain records have been processed successfully by 139 /// clients. 140 /// </param> 141 /// <param name="envid"> 142 /// <para> 143 /// A positive integer identifier that specifies the replication environment 144 /// to which the message should be sent. 145 /// </para> 146 /// <para> 147 /// The special identifier DB_EID_BROADCAST indicates that a message should 148 /// be broadcast to every environment in the replication group. The 149 /// application may use a true broadcast protocol or may send the message 150 /// in sequence to each machine with which it is in communication. In both 151 /// cases, the sending site should not be asked to process the message. 152 /// </para> 153 /// <para> 154 /// The special identifier DB_EID_INVALID indicates an invalid environment 155 /// ID. This may be used to initialize values that are subsequently checked 156 /// for validity. 157 /// </para> 158 /// </param> 159 /// <param name="flags">XXX: TBD</param> 160 /// <returns>0 on success and non-zero on failure</returns> 161 public delegate int ReplicationTransportDelegate(DatabaseEntry control, 162 DatabaseEntry rec, LSN lsn, int envid, uint flags); 163 /// <summary> 164 /// The function that creates the set of secondary keys corresponding to a 165 /// given primary key and data pair. 166 /// </summary> 167 /// <param name="key">The primary key</param> 168 /// <param name="data">The primary data item</param> 169 /// <returns>The secondary key(s)</returns> 170 public delegate DatabaseEntry SecondaryKeyGenDelegate( 171 DatabaseEntry key, DatabaseEntry data); 172 /// <summary> 173 /// A function which returns a unique identifier pair for a thread of 174 /// control in a Berkeley DB application. 175 /// </summary> 176 /// <returns> 177 /// A DbThreadID object describing the current thread of control 178 /// </returns> 179 public delegate DbThreadID SetThreadIDDelegate(); 180 /// <summary> 181 /// A function which returns an identifier pair for a thread of control 182 /// formatted for display. 183 /// </summary> 184 /// <param name="info">The thread of control to format</param> 185 /// <returns>The formatted identifier pair</returns> 186 public delegate string SetThreadNameDelegate(DbThreadID info); 187 /// <summary> 188 /// A function which returns whether the thread of control, identified by 189 /// <paramref name="info"/>, is still running. 190 /// </summary> 191 /// <param name="info">The thread of control to check</param> 192 /// <param name="procOnly"> 193 /// If true, return only if the process is alive, and the 194 /// <see cref="DbThreadID.threadID"/> portion of <paramref name="info"/> 195 /// should be ignored. 196 /// </param> 197 /// <returns>True if the tread is alive, false otherwise.</returns> 198 public delegate bool ThreadIsAliveDelegate(DbThreadID info, bool procOnly); 199} 200