86 virtual const char*
ClassName()
const {
return "Command"; }
123 Command(
const std::string &name)
throw();
130 {
return cmd1() == cmd2(); }
135 bool SetStr(
const std::string &name,
const std::string &value) {
return SetField(name, value); }
136 std::string
GetStr(
const std::string &name,
const std::string &dflt =
"")
const {
return GetField(name).
AsStr(dflt); }
151 void SetPtr(
const std::string &name,
void* p);
153 void*
GetPtr(
const std::string &name,
void* deflt = 0)
const;
219 void Print(
int lvl=0,
const char* from =
nullptr)
const;
282 #define DABC_COMMAND(cmd_class, cmd_name) \
284 static const char* CmdName() { return cmd_name; } \
285 cmd_class() : dabc::Command(CmdName()) {} \
286 cmd_class(const dabc::Command& src) : dabc::Command(src) \
287 { if (!src.IsName(CmdName())) throw dabc::Exception(dabc::ex_Command, "Wrong command name in assignment constructor", src.GetName()); } \
288 cmd_class& operator=(const cmd_class& cmd) { dabc::Command::operator=(cmd); return *this; } \
289 cmd_class& operator=(const dabc::Command& cmd) { \
290 if (!cmd.IsName(CmdName())) throw dabc::Exception(dabc::ex_Command, "Wrong command name in assignment operator", cmd.GetName()); \
291 dabc::Command::operator=(cmd); return *this; \
#define DABC_REFERENCE(RefClass, ParentClass, T)
Reference on memory from memory pool.
Container object for command which should not been seen to normal user.
virtual const char * ClassName() const
Returns class name of the object instance.
bool fCanceled
indicate if command was canceled ant not need to be executed further
std::list< CallerRec > fCallers
list of callers
virtual ~CommandContainer()
TimeStamp fTimeout
absolute time when timeout will be expired
CommandContainer(const std::string &name="Command")
Represents command with its arguments.
double TimeTillTimeout(double extra=0.) const
Returns time which remains until command should be timed out.
virtual void CreateRecord(const std::string &name)
void ReplyBool(bool res)
Reply on the command with true or false value.
static const char * ReceiverParName()
Name of the parameter, used to specified command receiver.
void ResetTimeout()
Disable timeout for the command.
bool ReadFromCmdString(const std::string &str)
Read command from string, which is typed in std output.
void SetPtr(const std::string &name, void *p)
Set pointer argument for the command.
static const char * PriorityParName()
Name of the parameter, used to keep command priority.
unsigned GetUInt(const std::string &name, unsigned dflt=0) const
void AddCaller(Worker *worker, bool *exe_ready=nullptr)
bool SetStr(const std::string &name, const char *value)
bool SetStrRawData(const std::string &str)
Set raw data with string content.
void Cancel()
Call this method to cancel command execution.
void ReplyTimedout()
Reply on the command with timeout value.
bool SetBool(const std::string &name, bool v)
friend int operator==(const Command &cmd1, const Command &cmd2)
Compare operator, returns true when command contains pointer on same object.
double GetDouble(const std::string &name, double dflt=0.) const
bool SetInt(const std::string &name, int v)
bool SetRawData(Buffer rawdata)
Set raw data to the command, which can be transported also between nodes.
std::string GetStr(const std::string &name, const std::string &dflt="") const
Command & SetTimeout(double tm)
Set maximum time which can be used for command execution.
friend class CommandContainer
void ReplyFalse()
Reply on the command with false (cmd_false==0) value.
bool IsTimeoutSet() const
Return true if timeout was specified.
bool SetUInt(const std::string &name, unsigned v)
void Release()
Method used to clean command - all internal data will be cleaned, command container will be released.
void AddValuesFrom(const Command &cmd, bool canoverwrite=true)
Command & SetReceiver(const std::string &itemname)
These methods prepare command so, that one can submit command to the manager like: dabc::mgr....
void ReplyTrue()
Reply on the command with true (cmd_true==1) value.
bool GetBool(const std::string &name, bool dflt=false) const
Reference GetRef(const std::string &name)
Returns reference from the command, can be called only once.
static const char * ResultParName()
Name of the parameter, used to keep command result.
bool SetDouble(const std::string &name, double v)
void Print(int lvl=0, const char *from=nullptr) const
Show on debug output content of command.
bool IsCanceled()
Return true if command was canceled.
bool IsTimedout() const
Returns true if command timeout is expired.
int GetInt(const std::string &name, int dflt=0) const
Buffer GetRawData()
Returns reference on raw data Can be called only once - raw data reference will be cleaned.
void Reply(int res=cmd_noresult)
Replied on the command.
void ChangeName(const std::string &name)
Change command name, should not be used for remote commands.
void SetPriority(int prio)
Set command priority, defines how fast command should be treated In special cases priority allows to ...
bool SetStr(const std::string &name, const std::string &value)
std::string GetReceiver() const
bool SetRef(const std::string &name, Reference ref)
Set reference to the command.
void RemoveCaller(Worker *worker, bool *exe_ready=nullptr)
int GetPriority() const
Returns command priority.
void * GetPtr(const std::string &name, void *deflt=0) const
Get pointer argument from the command.
Container for records fields.
uint64_t AsUInt(uint64_t dflt=0) const
bool AsBool(bool dflt=false) const
std::string AsStr(const std::string &dflt="") const
int64_t AsInt(int64_t dflt=0) const
double AsDouble(double dflt=0.) const
RecordField GetField(const std::string &name) const
bool HasField(const std::string &name) const
bool SetField(const std::string &name, const RecordField &v)
bool RemoveField(const std::string &name)
Reference on the arbitrary object
void SetObject(Object *obj, bool withmutex=true)
Direct set of object to reference.
Represent thread functionality.
Active object, which is working inside dabc::Thread.
CallerRec()=default
pointer on variable, which is used to indicate that execution is done
CallerRec & operator=(CallerRec &src)
CallerRec(const CallerRec &src)
bool * exe_ready
pointer on worker, do not use reference while worker will care about correct cleanup
CallerRec(Worker *w, bool *e)
Class for acquiring and holding timestamps.