1 #ifndef _DRAMA2_PARAMETER_INC
2 #define _DRAMA2_PARAMETER_INC
32 #include "DitsParam.h"
33 #include "DitsMonitor.h"
73 template<
typename SDS_T>
class Parameter {
80 std::weak_ptr<Task> _theTask;
81 const std::string _name;
96 const std::string &name,
97 const SDS_T &initVal) : _theTask(task), _name(name) {
104 parSys.
Put(name, initVal);
120 StatusType status = STATUS__OK;
121 Sdp::Put(_name, val, &status);
123 if (status != STATUS__OK)
133 operator SDS_T()
const {
135 StatusType status = STATUS__OK;
136 Sdp::Get(_name, &val, &status);
138 if (status != STATUS__OK)
189 template<>
class Parameter<
drama::sds::Id> {
195 std::weak_ptr<Task> _theTask;
196 const std::string _name;
214 const std::string &name,
216 bool copy =
true) : _theTask(task), _name(name),
217 _parSys(sds::Id::CreateFromSdsIdType((long)(DitsGetParId()))) {
218 Set(initVal, copy,
true);
243 bool create =
false) {
255 SdsCodeType code = newVal->GetCode();
257 std::vector<unsigned long> dims;
258 newVal->GetDims(&dims);
260 if ((code != SDS_STRUCT)&&(dims.size() == 0))
268 if (_parSys.Exists(_name))
285 "Error updating parameter %, does not exist",
292 StatusType status = STATUS__OK;
299 sds::Id tid = newVal->Copy();
303 StatusType status = STATUS__OK;
304 DitsMonitor(_name.c_str(),DITS_MON_TRUST,(SdsIdType)(tid),&status);
312 newVal->Rename(_name);
313 _parSys.Insert(*newVal);
314 DitsMonitor(_name.c_str(),DITS_MON_TRUST,(SdsIdType)(*newVal),&status);
316 if (status != STATUS__OK)
319 "Error updating parameter %, DitsMonitor() failed",
338 sds::Id Get()
const {
339 return _parSys.Find(_name);
349 void UpdateMonitors()
const {
359 DitsMonitor(_name.c_str(),DITS_MON_TRUST,(SdsIdType)(_parSys.Find(_name)),&status);
360 if (status != STATUS__OK)
363 "Error updating parameter %, DitsMonitor() failed",
DRAMA 2 include file - Task class definition.
#define DramaTHROW_S(status_, format_,...)
Throw a Drama exception with safe string formatting.
Definition: exception.hh:112
class_type & operator=(SDS_T val)
Set the value of the parameter to the specified value.
Definition: parameter.hh:140
DRAMA 2 include file - Sds class definition.
virtual void Delete()
Delete the SDS item.
Definition: sds.hh:1174
std::lock_guard< mutexType > guardType
Defines the type of a lock guard using our mutex type.
Definition: task.hh:322
A C++ Interface to the handling SDS structures.
Definition: sds.hh:412
static Id CreateFromSdsIdType(const SdsIdType item, const bool free=false, const bool del=false, const bool readfree=false)
Factory constructor method that constructs an sds::Id item from an existing C language SDS id...
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition: sds.hh:2962
Parameter< SDS_T > class_type
The type of this template instantiation.
Definition: parameter.hh:112
virtual Id Find(const std::string &name, bool throwOnNotFound=true) const
Factory constructor method Constructor which returns a reference to a named item. ...
virtual ~Parameter()
Parameter Destructor.
Definition: parameter.hh:177
Parameter(std::weak_ptr< Task > task, const std::string &name, const SDS_T &initVal)
Construct a parameter of a given name.
Definition: parameter.hh:122
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition: drama.hh:89
void Put(const unsigned long length, const T *const data, const unsigned long offset=0)
Put data into an SDS item.
Definition: sds.hh:1737