1#ifndef _DRAMA2_BULKDATA_INC
2#define _DRAMA2_BULKDATA_INC
29#if defined(BULK_DEBUG1) || defined(BULK_DEBUG2)
100 std::weak_ptr<Task> _theTask;
104 bool _releaseOnDestruct =
true;
107 bool _deleteOnDestruct =
false;
111 void * _memAddress =
nullptr;
113 unsigned long _size = 0;
144 fprintf(
stderr,
"BulkData::Constructed empty item at address %p\n",
145 static_cast<void *
>(
this));
191 const std::string &
Name=
"",
230 fprintf(
stderr,
"BulkData:Destructor for item at address %p\n",
231 static_cast<void *
>(
this));
257 if (
this == &
rhs)
return (*
this);
259 fprintf(
stderr,
"BulkData:Move assignment item at address %p to %p\n",
260 static_cast<void *
>(&
rhs),
static_cast<void *
>(
this));
264 _theTask =
rhs._theTask;
265 _releaseOnDestruct =
rhs._releaseOnDestruct;
266 _deleteOnDestruct =
rhs._deleteOnDestruct;
267 _memInfo =
rhs._memInfo;
268 _memAddress =
rhs._memAddress;
270 rhs._memAddress =
nullptr;
280 _theTask(std::move(
source._theTask)),
281 _releaseOnDestruct(std::move(
source._releaseOnDestruct)),
282 _deleteOnDestruct(std::move(
source._deleteOnDestruct)),
284 _memAddress(std::move(
source._memAddress)),
285 _size(std::move(
source._size)) {
286 source._memAddress =
nullptr;
289 fprintf(
stderr,
"BulkData:Move copy item at address %p to %p\n",
290 static_cast<void *
>(&
source),
static_cast<void *
>(
this));
311 template <
typename T>
319 (std::is_standard_layout<T>::value && std::is_trivial<T>::value) ,
320 "The type T must be a standard layout and trivial (POD) type");
323 if (_memAddress ==
nullptr)
326 "Failed to create shared memory segement");
332 *
nitems = _size /
sizeof(T);
335 fprintf(
stderr,
"BulkData:Accessing %p, data %p, size %lu, item size %u\n",
336 static_cast<void *
>(
this),
342 return static_cast<T *
>(_memAddress);
357 if (_memAddress ==
nullptr)
360 "Failed to create shared memory segement");
407 class BulkDataSds :
public BulkData,
public sds::Id {
418 fprintf(
stderr,
"BulkDataSds::Constructed empty item at address %p\n",
419 static_cast<void *
>(
this));
473 const std::string &
Name=
"",
486 class BulkDataArg :
public BulkData {
488 std::weak_ptr<Task> _theTask;
489 bool _release =
false;
490 unsigned long _notifyBytes = 0;
504 fprintf(
stderr,
"BulkDataArg::Constructed empty item at address %p\n",
505 static_cast<void *
>(
this));
535 "BulkDataArg:Move assignment item at address %p to %p\n",
536 static_cast<void *
>(&
rhs),
static_cast<void *
>(
this));
538 if (
this == &
rhs)
return (*
this);
543 _theTask =
rhs._theTask;
544 _release =
rhs._release;
556 _theTask(std::move(
source._theTask)),
557 _release(std::move(
source._release)) {
560 "BulkDataArg:Move copy item at address %p to %p\n",
561 static_cast<void *
>(&
source),
static_cast<void *
>(
this));
605 class BulkDataArgSds :
public BulkDataArg,
public sds::Id {
615 fprintf(
stderr,
"BulkDataArgSds::Constructed empty item at address %p\n",
616 static_cast<void *
>(
this));
BulkDataArgSds(std::weak_ptr< Task > theTask)
Constructor - creates a BulkDataArgSds item by calling DitsBulkArgInfo() and then access the item wit...
BulkDataArgSds()
Default constructor.
Definition bulkdata.hh:640
Class used to access SDS structure in bulk data arguments.
Definition bulkdata.hh:632
BulkDataArg(BulkDataArg &&source) noexcept
Move copy constructor.
Definition bulkdata.hh:581
BulkDataArg(std::weak_ptr< Task > theTask)
Constructor - creates a BulkDataArg item by calling DitsBulkArgInfo().
void Report(unsigned bytes)
Notify DRAMA of the number of bulk data bytes used/processed.
BulkDataArg()
Default constructor.
Definition bulkdata.hh:529
BulkDataArg & operator=(BulkDataArg &&rhs) noexcept
Move assignment operator.
Definition bulkdata.hh:559
unsigned long GetNotifyBytes() const
Returns the notification size.
Definition bulkdata.hh:599
A class used to manage a bulk data argument to an action.
Definition bulkdata.hh:513
BulkDataSds()
Default constructor.
Definition bulkdata.hh:443
BulkDataSds(std::weak_ptr< Task > theTask, const sds::Id &SdsTemplate, ShareType type=ShareType::Create, bool Create=true, bool DeleteOnDestruct=true, void *Address=nullptr, const std::string &Name="", int Key=0)
Define a bulk data shared memory segment of the specified type for use with DRAMA 2 methods which can...
Defines and optionally creates a shared memory section containing an SDS structure.
Definition bulkdata.hh:434
BulkData & operator=(const BulkData &rhs)=delete
Assignment operator - deleted.
BulkData(std::weak_ptr< Task > theTask, long Size, ShareType type=ShareType::Create, bool Create=true, bool DeleteOnDestruct=true, void *Address=nullptr, const std::string &Name="", int Key=0)
Define a bulk data shared memory segment of the specified type for use with DRAMA 2 methods which can...
BulkData(const BulkData &source)=delete
Copy constructor - deleted.
void * RawDataAddr() const
Returns the raw address of the data.
Definition bulkdata.hh:150
T * Data(unsigned long *nitems=nullptr)
Return a pointer to the actual data.
Definition bulkdata.hh:339
virtual ~BulkData()
Destructor.
Definition bulkdata.hh:255
BulkData & operator=(BulkData &&rhs) noexcept
Move assignment operator.
Definition bulkdata.hh:283
BulkData(BulkData &&source) noexcept
Move copy constructor.
Definition bulkdata.hh:306
BulkData(std::weak_ptr< Task > theTask, const DitsBulkReportInfoType &info)
Define a bulk data shared memory segment based on a DitsBulkReportInfoType item.
unsigned long SizeBytes() const
Return the size of the data in bytes.
Definition bulkdata.hh:157
BulkData()
Default constructor.
Definition bulkdata.hh:169
DitsSharedMemInfoType & GetDitsSharedMemInfo()
Return a reference to the DitsSharedMemInfoType object managed by this.
Definition bulkdata.hh:382
Defines and optionally creates a shared memory section.
Definition bulkdata.hh:121
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
ShareType
Share memory type codes.
Definition bulkdata.hh:72
@ Create
Create any temporary memory section.
@ Default
System default type.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93