Commit da3cb122 authored by Matthieu Dorier's avatar Matthieu Dorier

added subsegment selection and selection from remote_bulk

parent 0f1eb55f
......@@ -91,6 +91,16 @@ private:
*/
bulk_segment(bulk_segment&&) = default;
/**
* @brief Copy assignment operator is default.
*/
bulk_segment& operator=(const bulk_segment&) = default;
/**
* @brief Move assignment operator is default.
*/
bulk_segment& operator=(bulk_segment&&) = default;
/**
* @brief Destructor is default.
*/
......@@ -127,6 +137,27 @@ private:
* @return the size of data transfered.
*/
std::size_t operator<<(const remote_bulk& b) const;
/**
* @brief Selects a subsegment from this segment. If the size is too large,
* the maximum possible size is chosen.
*
* @param offset Offset of the subsegment relative to the current segment.
* @param size Size of the subsegment.
*
* @return a new bulk_segment object.
*/
bulk_segment select(std::size_t offset, std::size_t size) const {
std::size_t effective_size = offset+size > m_size ? m_size - offset : size;
return bulk_segment(m_bulk, m_offset+offset, effective_size);
}
/**
* @see bulk_segment::select.
*/
inline bulk_segment operator()(std::size_t offset, std::size_t size) const {
return select(offset, size);
}
};
public:
......
......@@ -41,6 +41,26 @@ private:
public:
/**
* @brief Default copy constructor.
*/
remote_bulk(const remote_bulk&) = default;
/**
* @brief Default move constructor.
*/
remote_bulk(remote_bulk&&) = default;
/**
* @brief Default copy-assignment operator.
*/
remote_bulk& operator=(const remote_bulk&) = default;
/**
* @brief Default move-assignment operator.
*/
remote_bulk& operator=(remote_bulk&&) = default;
/**
* @brief Performs a pull operation from the remote_bulk
* (left operand) to the destination bulk (right operand).
......@@ -64,6 +84,26 @@ public:
* @return the size of data transfered.
*/
std::size_t operator<<(const bulk::bulk_segment& src) const;
/**
* @brief Creates a bulk_segment object by selecting a given portion
* of the bulk object given an offset and a size.
*
* @param offset Offset at which the segment starts.
* @param size Size of the segment.
*
* @return a bulk_segment object.
*/
remote_bulk select(std::size_t offset, std::size_t size) const {
return remote_bulk(m_segment.select(offset, size), m_endpoint);
}
/**
* @see remote_bulk::select
*/
inline remote_bulk operator()(std::size_t offset, std::size_t size) const {
return select(offset, size);
}
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment