1 #ifndef _DRAMA2_PARSYS_INC
2 #define _DRAMA2_PARSYS_INC
35 #include "DitsParam.h"
54 std::weak_ptr<Task> _theTask;
64 ParSys(std::weak_ptr<Task> dramaTask) : _theTask(dramaTask) {}
86 StatusType status = STATUS__OK;
88 SdpCreateItem((SdsIdType)(DitsGetParId()),(SdsIdType)item,&status);
89 if (status != STATUS__OK)
91 "Failed to create new structured parameter");
111 template <
typename T>
static void SdpPut(
112 const std::string &name,
113 T value, StatusType *status);
129 template <
typename T>
static void SdpGet(
130 const std::string &name,
131 T *value, StatusType *status);
154 template <
typename T>
155 void Get (
const std::string &name, T *value) {
160 StatusType status = STATUS__OK;
167 SdpGet(name, value, &status);
168 if (status != STATUS__OK)
170 "SdpGet of parameter % failed",
193 template <
typename T>
194 void Put (
const std::string &name, T value) {
199 StatusType status = STATUS__OK;
206 SdpPut(name, value, &status);
207 if (status != STATUS__OK)
209 "SdpPut of parameter % failed",
221 void Put (
const std::string &name,
const std::string &value) {
226 StatusType status = STATUS__OK;
227 SdpPutString(name.c_str(), value.c_str(), &status);
228 if (status != STATUS__OK)
231 "SdpPutString of parameter % failed",
241 int GetInt(
const std::string &name);
248 unsigned int GetUInt(
const std::string &name);
255 long GetLong(
const std::string &name);
262 unsigned long GetULong(
const std::string &name);
268 double GetDouble(
const std::string &name);
276 std::string
GetString(
const std::string &name);
327 const bool create=
true );
353 const bool create=
true );
373 void Update(
const std::string &name);
388 template <>
void ParSys::SdpPut<bool>(
389 const std::string &name,
390 bool value, StatusType *status);
391 template <>
void ParSys::SdpPut<char>(
392 const std::string &name,
393 char value, StatusType *status);
394 template <>
void ParSys::SdpPut<short>(
395 const std::string &name,
396 short value, StatusType *status);
397 template <>
void ParSys::SdpPut<unsigned short>(
398 const std::string &name,
399 unsigned short value, StatusType *status);
400 template <>
void ParSys::SdpPut<INT32>(
401 const std::string &name,
402 INT32 value, StatusType *status);
403 template <>
void ParSys::SdpPut<UINT32>(
404 const std::string &name,
405 UINT32 value, StatusType *status);
406 template <>
void ParSys::SdpPut<INT64>(
407 const std::string &name,
408 INT64 value, StatusType *status);
409 template <>
void ParSys::SdpPut<UINT64>(
410 const std::string &name,
411 UINT64 value, StatusType *status);
412 template <>
void ParSys::SdpPut<float>(
413 const std::string &name,
414 float value, StatusType *status);
415 template <>
void ParSys::SdpPut<double>(
416 const std::string &name,
417 double value, StatusType *status);
420 template <>
void ParSys::SdpPut<const char *>(
421 const std::string &name,
422 const char *value, StatusType *status);
424 template <>
void ParSys::SdpPut<const std::string&>(
425 const std::string &name,
426 const std::string &value, StatusType *status);
443 template <>
void ParSys::SdpGet<bool>(
444 const std::string &name,
445 bool *value, StatusType *status);
446 template <>
void ParSys::SdpGet<char>(
447 const std::string &name,
448 char *value, StatusType *status);
449 template <>
void ParSys::SdpGet<short>(
450 const std::string &name,
451 short *value, StatusType *status);
452 template <>
void ParSys::SdpGet<unsigned short>(
453 const std::string &name,
454 unsigned short *value, StatusType *status);
455 template <>
void ParSys::SdpGet<INT32>(
456 const std::string &name,
457 INT32 *value, StatusType *status);
458 template <>
void ParSys::SdpGet<UINT32>(
459 const std::string &name,
460 UINT32 *value, StatusType *status);
461 template <>
void ParSys::SdpGet<INT64>(
462 const std::string &name,
463 INT64 *value, StatusType *status);
464 template <>
void ParSys::SdpGet<UINT64>(
465 const std::string &name,
466 UINT64 *value, StatusType *status);
467 template <>
void ParSys::SdpGet<float>(
468 const std::string &name,
469 float *value, StatusType *status);
470 template <>
void ParSys::SdpGet<double>(
471 const std::string &name,
472 double *value, StatusType *status);
473 template <>
void ParSys::SdpGet<std::string>(
474 const std::string &name,
475 std::string *value, StatusType *status);
477 template <>
void ParSys::SdpGet<sds::Id>(
478 const std::string &name,
479 sds::Id *parId, StatusType *status);
498 std::weak_ptr<Task> _theTask;
501 void InvalidCall(
const std::string &fromWhere);
513 void SetFree() override final {
514 InvalidCall(
"SetFree()");
518 void SetDelete() override final {
519 InvalidCall(
"SetDelete()");
523 void ClearDelete() override final {
524 InvalidCall(
"ClearDelete()");
528 void Outlive() override final {
529 InvalidCall(
"Outlive()");
532 void Delete() override final {
533 InvalidCall(
"Delete()");
536 void Extract() override final {
537 InvalidCall(
"Extract()");
540 void Rename(
const std::string &) override final {
541 InvalidCall(
"Rename()");
544 SdsIdType COut(
const bool ,
547 bool *
const = 0) override final {
549 InvalidCall(
"COut()");
553 void ShallowCopy (
Id * ,
554 const bool =
true) override final {
555 InvalidCall(
"ShallowCopy()");
558 void ShallowCopy (
const Id & ) override final {
559 InvalidCall(
"ShallowCopy()");
561 void ShallowCopy (
const SdsIdType ,
564 const bool =
false) override final {
565 InvalidCall(
"ShallowCopy()");
577 ParId(std::weak_ptr<Task> dramaTask,
const std::string& name);
long GetLong(const std::string &name)
If the Parameter contains scalar value, convert it to long integer.
DRAMA 2 include file - Task class definition.
#define DramaTHROW_S(status_, format_,...)
Throw a Drama exception with safe string formatting.
Definition: exception.hh:112
void Get(const std::string &name, T *value)
Fetch primitive value from parameter.
Definition: parsys.hh:182
void PutSdsCvt(const std::string &name, const sds::Id &value)
Put an SDS item a named parameter.
int GetInt(const std::string &name)
If the Parameter contains scalar value, convert it to integer.
DRAMA 2 include file - Sds class definition.
void CreateItem(sds::Id &item)
Create a new parameter by inserting an SDS item.
Definition: parsys.hh:108
void PutSdsReplaceByInsert(const std::string &name, sds::Id *value, const bool create=true)
Put a SDS item a named parameter - replacing the existing value.
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
unsigned int GetUInt(const std::string &name)
If the Parameter contains scalar value, convert it to an unsigned integer.
void Update() const
Indicate to DRAMA that the parameter has been updated.
A class used to access a DRAMA Parameter via an SDS Id.
Definition: parsys.hh:520
virtual ~ParId()
Destroy this object.
std::string GetString(const std::string &name)
If the Parameter contains scalar value or a character string convert it to a string.
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition: exception.hh:82
A DRAMA 2 C++ Interface to the DRAMA Simple DITS Parameter System (SDP).
Definition: parsys.hh:76
ParSys(std::weak_ptr< Task > dramaTask)
Create an object to access the parameter system.
Definition: parsys.hh:91
unsigned long GetULong(const std::string &name)
If the Parameter contains scalar value, convert it to an unsigned long integer.
Id()
Default constructor.
Definition: sds.hh:589
ParId(std::weak_ptr< Task > dramaTask, const std::string &name)
Access a parameter of a given name.
void Put(const std::string &name, T value)
Update parameter from primitive value.
Definition: parsys.hh:221
void Update(const std::string &name)
Indicate a parameter value has been updated by other means.
double GetDouble(const std::string &name)
If the Parameter contains scalar value, convert it to a double.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition: drama.hh:89
void PutSdsReplaceByCopy(const std::string &name, const sds::Id &value, const bool create=true)
Put a SDS item a named parameter - replacing the existing item.