1#ifndef _DRAMA2_PARSYS_INC
2#define _DRAMA2_PARSYS_INC
57 std::weak_ptr<Task> _theTask;
94 "Failed to create new structured parameter");
112 template <
typename T>
135 void Create (
const std::string &name,
const std::string &
value) {
186 bool Exists(
const std::string &name)
const {
210 template <
typename T>
static void SdpPut(
211 const std::string &name,
228 template <
typename T>
static void SdpGet(
229 const std::string &name,
253 template <
typename T>
254 void Get (
const std::string &name, T *
value)
const {
269 "SdpGet of parameter % failed",
292 template <
typename T>
293 void Put (
const std::string &name, T
value) {
301 (std::is_standard_layout<T>::value && std::is_trivial<T>::value ) ,
302 "The type T must be a standard layout and trivial (POD) type");
305 (std::is_integral<T>::value
or std::is_floating_point<T>::value),
306 "The type T must be integral or floating point");
321 "SdpPut of parameter % failed",
333 void Put(
const std::string &name,
const char *
value);
344 void Put (
const std::string &name,
const std::string &
value);
351 int GetInt(
const std::string &name)
const;
358 unsigned int GetUInt(
const std::string &name)
const;
365 long GetLong(
const std::string &name)
const;
372 unsigned long GetULong(
const std::string &name)
const;
386 std::string
GetString(
const std::string &name)
const;
483 void Update(
const std::string &name);
498 template <>
void ParSys::SdpPut<bool>(
499 const std::string &name,
501 template <>
void ParSys::SdpPut<char>(
502 const std::string &name,
504 template <>
void ParSys::SdpPut<short>(
505 const std::string &name,
507 template <>
void ParSys::SdpPut<unsigned short>(
508 const std::string &name,
510 template <>
void ParSys::SdpPut<INT32>(
511 const std::string &name,
513 template <>
void ParSys::SdpPut<UINT32>(
514 const std::string &name,
516 template <>
void ParSys::SdpPut<INT64>(
517 const std::string &name,
519 template <>
void ParSys::SdpPut<UINT64>(
520 const std::string &name,
522 template <>
void ParSys::SdpPut<float>(
523 const std::string &name,
525 template <>
void ParSys::SdpPut<double>(
526 const std::string &name,
530 template <>
void ParSys::SdpPut<const char *>(
531 const std::string &name,
534 template <>
void ParSys::SdpPut<const std::string&>(
535 const std::string &name,
553 template <>
void ParSys::SdpGet<bool>(
554 const std::string &name,
556 template <>
void ParSys::SdpGet<char>(
557 const std::string &name,
559 template <>
void ParSys::SdpGet<short>(
560 const std::string &name,
562 template <>
void ParSys::SdpGet<unsigned short>(
563 const std::string &name,
565 template <>
void ParSys::SdpGet<INT32>(
566 const std::string &name,
568 template <>
void ParSys::SdpGet<UINT32>(
569 const std::string &name,
571 template <>
void ParSys::SdpGet<INT64>(
572 const std::string &name,
574 template <>
void ParSys::SdpGet<UINT64>(
575 const std::string &name,
577 template <>
void ParSys::SdpGet<float>(
578 const std::string &name,
580 template <>
void ParSys::SdpGet<double>(
581 const std::string &name,
583 template <>
void ParSys::SdpGet<std::string>(
584 const std::string &name,
587 template <>
void ParSys::SdpGet<sds::Id>(
588 const std::string &name,
608 std::weak_ptr<Task> _theTask;
610 void InvalidCall(
const std::string &
fromWhere);
623 InvalidCall(
"SetFree()");
628 InvalidCall(
"SetDelete()");
633 InvalidCall(
"ClearDelete()");
638 InvalidCall(
"Outlive()");
642 InvalidCall(
"Delete()");
646 InvalidCall(
"Extract()");
649 void Rename(
const std::string &)
override final {
650 InvalidCall(
"Rename()");
658 InvalidCall(
"COut()");
662 void ShallowCopy (
Id * ,
664 InvalidCall(
"ShallowCopy()");
667 void ShallowCopy (
const Id & )
override final {
668 InvalidCall(
"ShallowCopy()");
674 InvalidCall(
"ShallowCopy()");
ParId(ParSys *parSys, const std::string &name)
Access a parameter of a given name.
void Update() const
Indicate to DRAMA that the parameter has been updated.
virtual ~ParId()
Destroy this object.
ParId(std::weak_ptr< Task > dramaTask, const std::string &name)
Access a parameter of a given name.
A class used to access a DRAMA Parameter via an SDS Id.
Definition parsys.hh:630
void CreateItem(sds::Id &item)
Create a new parameter by inserting an SDS item.
Definition parsys.hh:111
void Create(const std::string &name, const std::string &value)
Create a string parameter.
Definition parsys.hh:162
void PutSdsCvt(const std::string &name, const sds::Id &value)
Put an SDS item a named parameter.
unsigned long GetULong(const std::string &name) const
If the Parameter contains scalar value, convert it to an unsigned long integer.
void Update(const std::string &name)
Indicate a parameter value has been updated by other means.
unsigned int GetUInt(const std::string &name) const
If the Parameter contains scalar value, convert it to an unsigned integer.
bool Exists(const std::string &name) const
Does a parameter of a given name exist?
Definition parsys.hh:213
std::string GetString(const std::string &name) const
If the Parameter contains scalar value or a character string convert it to a string.
void Put(const std::string &name, const std::string &value)
Insert a string value into the parameter.
void Get(const std::string &name, T *value) const
Fetch primitive value from parameter.
Definition parsys.hh:281
void Create(const std::string &name, T value)
Create primitive parameter.
Definition parsys.hh:140
ParSys(std::weak_ptr< Task > dramaTask)
Create an object to access the parameter system.
Definition parsys.hh:94
void Put(const std::string &name, T value)
Update parameter from primitive value.
Definition parsys.hh:320
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.
sds::Id CreateSds(const std::string &name, SdsCodeType code, const std::string &extra="")
Create a parameters as an raw SDS item.
Definition parsys.hh:194
long GetLong(const std::string &name) const
If the Parameter contains scalar value, convert it to long integer.
void Put(const std::string &name, const char *value)
Insert a char * (string) value into the parameter.
int GetInt(const std::string &name) const
If the Parameter contains scalar value, convert it to integer.
void PutSdsReplaceByInsert(const std::string &name, sds::Id *value, const bool create=true)
Put a SDS item a named parameter - replacing the existing value.
double GetDouble(const std::string &name) const
If the Parameter contains scalar value, convert it to a double.
A DRAMA 2 C++ Interface to the DRAMA Simple DITS Parameter System (SDP).
Definition parsys.hh:78
std::lock_guard< mutexType > guardType
Defines the type of a lock guard using our mutex type.
Definition task.hh:460
static Id CreateFromSdsId(const SdsId &item)
Factory constructor method that constructs an sds::Id item from an existing old C++ interface SdsId i...
Id()
Default constructor.
Definition sds.hh:611
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
#define DramaTHROW_S(status_, format_,...)
Throw a Drama exception with safe string formatting.
Definition exception.hh:110
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:93
@ Create
Create any temporary memory section.
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
DRAMA 2 include file - Sds class definition.
DRAMA 2 include file - Task class definition.