diff --git a/src/libsrc++/BankHeader.cpp b/src/libsrc++/BankHeader.cpp
index 758784cf..b5fcc8bd 100644
--- a/src/libsrc++/BankHeader.cpp
+++ b/src/libsrc++/BankHeader.cpp
@@ -24,30 +24,10 @@ namespace evio {
BaseStructureHeader(tag, dataType, num) {length = 1;}
- /**
- * Get the length of the structure's data in 32 bit ints (not counting the header words).
- * @return Get the length of the structure's data in 32 bit ints (not counting the header words).
- */
uint32_t BankHeader::getDataLength() {return length - 1;}
-
- /**
- * Get the length of the structure's header in ints. This includes the first header word itself
- * (which contains the length) and in the case of banks, it also includes the second header word.
- * @return Get the length of the structure's header in ints.
- */
uint32_t BankHeader::getHeaderLength() {return 2;}
-
- /**
- * Write myself out as evio format data
- * into the given byte array in the specified byte order.
- *
- * @param dest array into which evio data is written (destination).
- * @param order byte order in which to write the data.
- * @return the number of bytes written, which for a BankHeader is 8.
- * @throws EvioException if destination array too small to hold data.
- */
size_t BankHeader::write(uint8_t *dest, ByteOrder const & order) {
// length first
Util::toBytes(length, order, dest);
@@ -57,26 +37,10 @@ namespace evio {
return 8;
}
-
- /**
- * Write myself out a byte buffer.
- * This write is relative - i.e., it uses the current position of the buffer.
- *
- * @param byteBuffer the byteBuffer to write to.
- * @return the number of bytes written, which for a BankHeader is 8.
- */
size_t BankHeader::write(std::shared_ptr The content of the returned buffer will be that of this buffer. Changes
* to this buffer's content will be visible in the returned buffer, and vice
* versa; the two buffers' position, limit, and mark values will be
- * independent.
+ * independent. The returned buffer's capacity, limit, position, and mark values will
* initially be identical to those of this buffer.
A cleaner way to do this is for the caller to create their own, new ByteBuffer * object and pass it in as an argument. This method then makes it identical to this * buffer and the data (implemented as a shared pointer) is shared between - * the objects. The buffer passed in as an argument is also the one returned. + * the objects. The buffer passed in as an argument is also the one returned.
* * @param destBuf byte buffer to be made a duplicate of this one. * @return the same byte buffer as passed in as the argument. @@ -683,21 +682,21 @@ namespace evio { *The content of the returned buffer will be that of this buffer. Changes * to this buffer's content will be visible in the returned buffer, and vice * versa; the two buffers' position, limit, and mark values will be - * independent. + * independent.
* *The returned buffer's capacity, limit, position, and mark values will - * initially be identical to those of this buffer.
+ * initially be identical to those of this buffer. * *The C++ version of this method departs from the Java which has no argument. * To implement this method, one could return a unique pointer to a locally created * ByteBuffer object which would eliminate the need for an argument. However, handling * the new buffer would be different from handling those created by the constructor - * since the caller would have a unique pointer instead of a ByteBuffer reference. + * since the caller would have a unique pointer instead of a ByteBuffer reference.
* *A cleaner way to do this is for the caller to create their own, new ByteBuffer * object and pass it in as an argument. This method then makes it identical to this * buffer and the data (implemented as a shared pointer) is shared between - * the objects. The buffer passed in as an argument is also the one returned. + * the objects. The buffer passed in as an argument is also the one returned.
* * @param destBuf byte buffer to be made a duplicate of this one. * @return the same byte buffer as passed in as the argument. @@ -715,23 +714,22 @@ namespace evio { *The content of the returned buffer will be that of this buffer. Changes * to this buffer's content will be visible in the returned buffer, and vice * versa; the two buffers' position, limit, and mark values will be - * independent. + * independent.
* *The returned buffer's capacity, limit, position, and mark values will - * initially be identical to those of this buffer.
+ * initially be identical to those of this buffer. * *The C++ version of this method departs from the Java which has no argument. * To implement this method, one could return a unique pointer to a locally created * ByteBuffer object which would eliminate the need for an argument. However, handling * the new buffer would be different from handling those created by the constructor - * since the caller would have a unique pointer instead of a ByteBuffer reference. + * since the caller would have a unique pointer instead of a ByteBuffer reference.
* *A cleaner way to do this is for the caller to create their own, new ByteBuffer * object and pass it in as an argument. This method then makes it identical to this * buffer and the data (implemented as a shared pointer) is shared between - * the objects. The buffer passed in as an argument is also the one returned. + * the objects. The buffer passed in as an argument is also the one returned.
* - * @param destBuf byte buffer to be made a duplicate of this one. * @return the same byte buffer as passed in as the argument. */ std::shared_ptrThe content of the new buffer will start at this buffer's current * position. Changes to this buffer's content will be visible in the new * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. + * values will be independent.
* *The new buffer's position will be zero, its capacity and its limit * will be the number of bytes remaining in this buffer, and its mark - * will be undefined. + * will be undefined.
* * @return The new byte buffer. */ @@ -796,11 +794,11 @@ namespace evio { *The content of the given buffer will start at this buffer's current * position. Changes to this buffer's content will be visible in the given * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. + * values will be independent.
* *The given buffer's position will be zero, its capacity and its limit * will be the number of bytes remaining in this buffer, and its mark - * will be undefined. + * will be undefined.
* * @param destBuf byte buffer to be made a slice of this one. * @return the same byte buffer as passed in as the argument. @@ -827,21 +825,21 @@ namespace evio { /** - * The given (and returned) byte buffer is one whose content is a shared subsequence of - * this buffer's content. - * - *The content of the given buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the given - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *
The given buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer, and its mark - * will be undefined. - * + * The given (and returned) byte buffer is one whose content is a shared subsequence of + * this buffer's content. + * + *
The content of the given buffer will start at this buffer's current + * position. Changes to this buffer's content will be visible in the given + * buffer, and vice versa; the two buffers' position, limit, and mark + * values will be independent.
+ * + *The given buffer's position will be zero, its capacity and its limit + * will be the number of bytes remaining in this buffer, and its mark + * will be undefined.
+ * * @param destBuf byte buffer to be made a slice of this one. * @return the same byte buffer as passed in as the argument. - */ + */ std::shared_ptrThis method transfers bytes from this buffer into the given * destination array. If there are fewer bytes remaining in the * buffer than are required to satisfy the request, then no - * bytes are transferred and an underflow_error is thrown.
+ * bytes are transferred and an underflow_error is thrown.
* - * Otherwise, this method copies length bytes from this + *Otherwise, this method copies length bytes from this * buffer into the given array, starting at the current position of this * buffer and at the given pointer. The position of this - * buffer is then incremented by length. + * buffer is then incremented by length.
* * @param dst array into which bytes are to be written. * @param length number of bytes to be written to the given @@ -888,15 +886,15 @@ namespace evio { /** * Relative bulk get method. * - * This method transfers bytes from this buffer into the given + *This method transfers bytes from this buffer into the given * destination vector. If there are fewer bytes remaining in the * buffer than are required to satisfy the request, then no - * bytes are transferred and an underflow_error is thrown.
+ * bytes are transferred and an underflow_error is thrown.
* - * Otherwise, this method copies length bytes from this + *Otherwise, this method copies length bytes from this * buffer into the given array, starting at the current position of this * buffer and at the given offset in the array. The position of this - * buffer is then incremented by length. + * buffer is then incremented by length.
* * @param dst vector into which bytes are to be written. * @param offset offset (bytes) within the vector of the first byte to be written. @@ -951,7 +949,7 @@ namespace evio { * which is by nature unsigned. * Keeping the name as "getChar" makes it compatible with Java, but be aware * it does NOT get a 8-bit "char" type. - * This method reads the next two bytes at this buffer's current position, + *This method reads the next two bytes at this buffer's current position, * composing them into a wchar_t value according to the current byte order, * and then increments the position by two.
* @@ -966,7 +964,7 @@ namespace evio { * which is by nature unsigned. Reads at the given index. * Keeping the name as "getChar" makes it compatible with Java, but be aware * it does NOT get a 8-bit "char" type. - * This method reads the next two bytes at the given index, + *This method reads the next two bytes at the given index, * composing them into a wchar_t value according to the current byte order, * and then increments the position by two.
* @@ -981,7 +979,7 @@ namespace evio { * Relative get method for reading a short value. * Reads the next two bytes at this buffer's current position, * composing them into a short value according to the current - * byte order, and then increments the position by two. + * byte order, and then increments the position by two. * * @return short value at buffer's current position. * @throws underflow_error if fewer than two bytes remaining in buffer. @@ -1001,7 +999,7 @@ namespace evio { /** * Absolute get method for reading a short value. * Reads two bytes at the given index, composing them into a - * short value according to the current byte order. + * short value according to the current byte order. * * @param index index from which the bytes will be read. * @return short value at the given index. @@ -1020,7 +1018,7 @@ namespace evio { /** - * Relative get method for reading an unsigned short value. + *Relative get method for reading an unsigned short value. * Reads the next two bytes at this buffer's current position, * composing them into an unsigned short value according to the current * byte order, and then increments the position by two.
@@ -1041,7 +1039,7 @@ namespace evio { /** - * Absolute get method for reading an unsigned short value. + *Absolute get method for reading an unsigned short value. * Reads two bytes at the given index, composing them into an * unsigned short value according to the current byte order.
* This method is not defined in the Java version. @@ -1066,7 +1064,7 @@ namespace evio { * Relative get method for reading an int value. * Reads the next four bytes at this buffer's current position, * composing them into an int value according to the current - * byte order, and then increments the position by four. + * byte order, and then increments the position by four. * * @return int value at buffer's current position. * @throws underflow_error if fewer than four bytes remaining in buffer. @@ -1085,7 +1083,7 @@ namespace evio { /** * Absolute get method for reading an int value. * Reads four bytes at the given index, composing them into an - * int value according to the current byte order. + * int value according to the current byte order. * * @param index index from which the bytes will be read. * @return int value at the given index. @@ -1107,7 +1105,7 @@ namespace evio { * Relative get method for reading an unsigned int value. * Reads the next four bytes at this buffer's current position, * composing them into an unsigned int value according to the current - * byte order, and then increments the position by four. + * byte order, and then increments the position by four. * * @return unsigned int value at buffer's current position. * @throws underflow_error if fewer than four bytes remaining in buffer. @@ -1126,7 +1124,7 @@ namespace evio { /** * Absolute get method for reading an unsigned int value. * Reads four bytes at the given index, composing them into an - * unsigned int value according to the current byte order. + * unsigned int value according to the current byte order. * * @param index index from which the bytes will be read. * @return unsigned int value at the given index. @@ -1148,7 +1146,7 @@ namespace evio { * Relative get method for reading a long long value. * Reads the next eight bytes at this buffer's current position, * composing them into a long long value according to the current - * byte order, and then increments the position by eight. + * byte order, and then increments the position by eight. * * @return long long value at buffer's current position. * @throws underflow_error if fewer than eight bytes remaining in buffer. @@ -1167,7 +1165,7 @@ namespace evio { /** * Absolute get method for reading a long long value. * Reads eight bytes at the given index, composing them into a - * long long value according to the current byte order. + * long long value according to the current byte order. * * @param index index from which the bytes will be read. * @return long long value at the given index. @@ -1189,7 +1187,7 @@ namespace evio { * Relative get method for reading an unsigned long long value. * Reads the next eight bytes at this buffer's current position, * composing them into an unsigned long long value according to the current - * byte order, and then increments the position by eight. + * byte order, and then increments the position by eight. * * @return unsigned long long value at buffer's current position. * @throws underflow_error if fewer than eight bytes remaining in buffer. @@ -1208,7 +1206,7 @@ namespace evio { /** * Absolute get method for reading an unsigned long long value. * Reads eight bytes at the given index, composing them into an - * unsigned long long value according to the current byte order. + * unsigned long long value according to the current byte order. * * @param index index from which the bytes will be read. * @return unsigned long long value at the given index. @@ -1230,7 +1228,7 @@ namespace evio { * Relative get method for reading a float value. * Reads the next four bytes at this buffer's current position, * composing them into a float value according to the current - * byte order, and then increments the position by four. + * byte order, and then increments the position by four. * * @return float value at buffer's current position. * @throws underflow_error if fewer than four bytes remaining in buffer. @@ -1246,7 +1244,7 @@ namespace evio { /** * Absolute get method for reading a float value. * Reads four bytes at the given index, composing them into a - * float value according to the current byte order. + * float value according to the current byte order. * * @param index index from which the bytes will be read. * @return float value at the given index. @@ -1265,7 +1263,7 @@ namespace evio { * Relative get method for reading a double value. * Reads the next eight bytes at this buffer's current position, * composing them into a double value according to the current - * byte order, and then increments the position by eight. + * byte order, and then increments the position by eight. * * @return double value at buffer's current position. * @throws underflow_error if fewer than eight bytes remaining in buffer. @@ -1281,7 +1279,7 @@ namespace evio { /** * Absolute get method for reading a double value. * Reads eight bytes at the given index, composing them into a - * double value according to the current byte order. + * double value according to the current byte order. * * @param index index from which the bytes will be read. * @return double value at the given index. @@ -1302,18 +1300,18 @@ namespace evio { /** - * Relative bulk put method.+ * Relative bulk put method. * - * This method transfers the bytes remaining in the given source + *
This method transfers the bytes remaining in the given source * buffer into this buffer. If there are more bytes remaining in the * source buffer than in this buffer, that is, if * src.remaining() > remaining(), - * then no bytes are transferred and a {@link EvioException} is thrown.
+ * then no bytes are transferred and a {@link EvioException} is thrown.
* - * Otherwise, this method copies + *Otherwise, this method copies * n = src.remaining() bytes from the given * buffer into this buffer, starting at each buffer's current position. - * The positions of both buffers are then incremented by n. + * The positions of both buffers are then incremented by n.
* * @param src source buffer from which bytes are to be read; * must not be this buffer. @@ -1341,18 +1339,18 @@ namespace evio { /** - * Relative bulk put method.+ * Relative bulk put method. * - * This method transfers the bytes remaining in the given source + *
This method transfers the bytes remaining in the given source * buffer into this buffer. If there are more bytes remaining in the * source buffer than in this buffer, that is, if * src.remaining() > remaining(), - * then no bytes are transferred and a {@link EvioException} is thrown.
+ * then no bytes are transferred and a {@link EvioException} is thrown.
* - * Otherwise, this method copies + *Otherwise, this method copies * n = src.remaining() bytes from the given * buffer into this buffer, starting at each buffer's current position. - * The positions of both buffers are then incremented by n. + * The positions of both buffers are then incremented by n.
* * @param src source buffer from which bytes are to be read; * must not be this buffer. @@ -1370,19 +1368,19 @@ namespace evio { /** - * Relative bulk put method.+ * Relative bulk put method. * - * This method transfers bytes into this buffer from the given + *
This method transfers bytes into this buffer from the given * source array. If there are more bytes to be copied from the array * than remain in this buffer, that is, if * length > remaining(), then no * bytes are transferred and a {@link EvioException} is - * thrown.
+ * thrown.
* - * Otherwise, this method copies length bytes from the + *Otherwise, this method copies length bytes from the * given array into this buffer, starting at the given pointer * and at the current position of this buffer. The position of this buffer - * is then incremented by length. + * is then incremented by length.
* * @param src array from which bytes are to be read * @param length number of bytes to be read from the given array; @@ -1402,19 +1400,19 @@ namespace evio { } /** - * Relative bulk put method.+ * Relative bulk put method. * - * This method transfers bytes into this buffer from the given + *
This method transfers bytes into this buffer from the given * vector. If there are more bytes to be copied from the vector * than remain in this buffer, that is, if * length > remaining(), then no * bytes are transferred and a {@link EvioException} is - * thrown.
+ * thrown.
* - * Otherwise, this method copies length bytes from the + *Otherwise, this method copies length bytes from the * given array into this buffer, starting at the given offset in the array * and at the current position of this buffer. The position of this buffer - * is then incremented by length. + * is then incremented by length.
* * @param src array from which bytes are to be read * @param offset offset (bytes) within the array of the first byte to be read; @@ -1439,7 +1437,7 @@ namespace evio { /** * Relative put method. * Writes the given byte into this buffer at the current - * position, and then increments the position by one. + * position, and then increments the position by one. * * @param val byte value to be written. * @return this buffer. diff --git a/src/libsrc++/ByteOrder.h b/src/libsrc++/ByteOrder.h index 12d2eb47..46ba48fc 100644 --- a/src/libsrc++/ByteOrder.h +++ b/src/libsrc++/ByteOrder.h @@ -109,12 +109,12 @@ namespace evio { return isBigEndian() ? ENDIAN_LITTLE : ENDIAN_BIG; } - + /** Defines equal operator. */ bool operator==(const ByteOrder &rhs) const; + /** Defines not-equal operator. */ bool operator!=(const ByteOrder &rhs) const; - /** * Get the byte order of the local host. * @return byte order of the local host. diff --git a/src/libsrc++/CompositeData.cpp b/src/libsrc++/CompositeData.cpp index 6819bf8c..d7fe5e3e 100644 --- a/src/libsrc++/CompositeData.cpp +++ b/src/libsrc++/CompositeData.cpp @@ -2182,319 +2182,319 @@ namespace evio { swapData(iarr, iarr, nwrd, ifmt, padding, false); } - - // Following is Sergui's original function (eviofmtswap) which is now implemented immediately above. - - ///** - // * This method converts (swaps) an array of EVIO composite type data - // * between IEEE (big endian) and DECS (little endian) in place. This - // * data does NOT include the composite type's beginning tagsegment and - // * the format string it contains. It also does NOT include the data's - // * bank header words. - // * - // * Converts the data of array (iarr[i], i=0...nwrd-1) - // * using the format code (ifmt[j], j=0...nfmt-1) . - // * - // *- // * Algorithm description:
- // * Data processed inside while (ib < nwrd)
- // * loop, where 'ib' is iarr[] index;
- // * loop breaks when 'ib' reaches the number of elements in iarr[]
- // *
- // *
- // * @param iarr pointer to data to be swapped
- // * @param nwrd number of data words (32-bit ints) to be swapped
- // * @param ifmt unsigned short vector holding translated format
- // * @param padding number of bytes to ignore in last data word (starting from data end)
- // *
- // * @return 0 if success
- // * @return -1 if nwrd < 0, or ifmt vector empty.
- // */
- //int CompositeData::swapData(int32_t *iarr, int nwrd, const std::vector
+ // // * Algorithm description:
+ // // * Data processed inside while (ib < nwrd)
+ // // * loop, where 'ib' is iarr[] index;
+ // // * loop breaks when 'ib' reaches the number of elements in iarr[]
+ // // *
+ // // *
+ // // * @param iarr pointer to data to be swapped
+ // // * @param nwrd number of data words (32-bit ints) to be swapped
+ // // * @param ifmt unsigned short vector holding translated format
+ // // * @param padding number of bytes to ignore in last data word (starting from data end)
+ // // *
+ // // * @return 0 if success
+ // // * @return -1 if nwrd < 0, or ifmt vector empty.
+ // // */
+ // int CompositeData::swapData(int32_t *iarr, int nwrd, const std::vector
*
- * @param bb ByteBuffer representing the event.
+ * @param bank the bank (as an EvioBank object) to write.
* @param force if writing to disk, force it to write event to the disk.
- * @param duplicate if true, duplicate bb so its position and limit
- * can be changed without issue.
* @param ownRecord if true, write event in its own record regardless
* of event count and record size limits.
*
diff --git a/src/libsrc++/EventWriterV4.cpp b/src/libsrc++/EventWriterV4.cpp
index d1e9eacc..6f90fb98 100644
--- a/src/libsrc++/EventWriterV4.cpp
+++ b/src/libsrc++/EventWriterV4.cpp
@@ -109,12 +109,12 @@ namespace evio {
* @param split if < 1, do not split file, write to only one file of unlimited size.
* Else this is max size in bytes to make a file
* before closing it and starting writing another.
- * @param maxBlockSize the max blocksize in bytes to use which must be >= {@link #MIN_BLOCK_SIZE}
- * and <= {@link #MAX_BLOCK_SIZE}.
+ * @param maxBlockSize the max blocksize in bytes to use which must be >= #MIN_BLOCK_SIZE
+ * and <= #MAX_BLOCK_SIZE.
* The size of the block will not be larger than this size
* unless a single event itself is larger.
* @param maxEventCount the max number of events (including dictionary) in a single block
- * which must be >= {@link #MIN_BLOCK_COUNT} and <= {@link #MAX_BLOCK_COUNT}.
+ * which must be >= #MIN_BLOCK_COUNT and <= #MAX_BLOCK_COUNT.
* @param byteOrder the byte order in which to write the file. This is ignored
* if appending to existing file.
* @param xmlDictionary dictionary in xml format or empty if none.
@@ -131,6 +131,7 @@ namespace evio {
* @param bufferSize number of bytes to make the internal buffer which will
* be storing events before writing them to a file. Must be at least
* a max block size + 1kB (add a little extra). If not, it is set to that.
+ * @param bitInfo set of bits to include in first block header.
*
* @throws EvioException if defined dictionary or first event while appending;
* if splitting file while appending;
@@ -407,12 +408,12 @@ namespace evio {
* Create an EventWriterV4
for writing events to a ByteBuffer.
*
* @param buf the buffer to write to.
- * @param maxBlockSize the max blocksize to use which must be >= {@link #MIN_BLOCK_SIZE}
- * and <= {@link #MAX_BLOCK_SIZE} ints.
+ * @param maxBlockSize the max blocksize to use which must be >= #MIN_BLOCK_SIZE
+ * and <= #MAX_BLOCK_SIZE ints.
* The size of the block will not be larger than this size
* unless a single event itself is larger.
* @param maxEventCount the max number of events (including dictionary) in a single block
- * which must be >= {@link #MIN_BLOCK_COUNT} and <= {@link #MAX_BLOCK_COUNT}.
+ * which must be >= #MIN_BLOCK_COUNT and <= #MAX_BLOCK_COUNT.
* @param xmlDictionary dictionary in xml format or null if none.
* @param bitInfo set of bits to include in first block header.
* @param reserved1 set the value of the first "reserved" int in first block header.
@@ -444,12 +445,12 @@ namespace evio {
* The buffer's position is set to 0 before writing.
*
* @param buf the buffer to write to.
- * @param maxBlockSize the max blocksize to use which must be >= {@link #MIN_BLOCK_SIZE}
- * and <= {@link #MAX_BLOCK_SIZE} ints.
+ * @param maxBlockSize the max blocksize to use which must be >= #MIN_BLOCK_SIZE
+ * and <= #MAX_BLOCK_SIZE ints.
* The size of the block will not be larger than this size
* unless a single event itself is larger.
* @param maxEventCount the max number of events (including dictionary) in a single block
- * which must be >= {@link #MIN_BLOCK_COUNT} and <= {@link #MAX_BLOCK_COUNT}.
+ * which must be >= #MIN_BLOCK_COUNT and <= #MAX_BLOCK_COUNT.
* @param xmlDictionary dictionary in xml format or null if none.
* @param bitInfo set of bits to include in first block header.
* @param reserved1 set the value of the first "reserved" int in first block header.
diff --git a/src/libsrc++/EventWriterV4.h b/src/libsrc++/EventWriterV4.h
index 9d74538c..f95139e5 100644
--- a/src/libsrc++/EventWriterV4.h
+++ b/src/libsrc++/EventWriterV4.h
@@ -76,6 +76,11 @@ namespace evio {
boost::thread_group threadPool;
public:
+
+ /**
+ * Constructor.
+ * @param poolSize size of pool of threads to close files.
+ */
FileCloserV4(int poolSize) {
// Create a work object to keep the io_context busy
boost::asio::io_context::work work(ioContext);
@@ -88,10 +93,16 @@ namespace evio {
}
}
+ /** Close this object by ending all threads in pool. */
void close() {
threadPool.join_all();
}
+ /**
+ * Close file given by filestream after pending write is finished.
+ * @param afc file stream to close.
+ * @param future object representing a write that is in progress.
+ */
void closeAsyncFile(std::shared_ptr