16 #ifndef DABC_Publisher
17 #define DABC_Publisher
36 CmdGetBinary(
const std::string &path,
const std::string &kind,
const std::string &query) :
61 CmdGetNamesList(
const std::string &kind,
const std::string &path,
const std::string &query) :
69 void AddHeader(
const std::string &name,
const std::string &value,
bool withquotes =
true)
71 int num =
GetInt(
"NumHdrs");
73 SetStr(
dabc::format(
"OptHdrValue%d", num), withquotes ? std::string(
"\"") + value +
"\"" : value);
207 bool IdentifyItem(
bool asproducer,
const std::string &itemname,
bool &islocal, std::string &producer_name, std::string &request_name);
216 virtual const char*
ClassName()
const {
return "Publisher"; }
224 bool
Register(const std::
string &path, const std::
string &workername,
void* hierarchy)
225 {
return OwnCommand(1, path, workername, hierarchy); }
227 bool Unregister(
const std::string &path,
const std::string &workername,
void* hierarchy)
228 {
return OwnCommand(2, path, workername, hierarchy); }
230 bool Subscribe(
const std::string &path,
const std::string &workername)
233 bool Unsubscribe(
const std::string &path,
const std::string &workername)
237 {
return OwnCommand(sync ? 5 : -5,
"", workername); }
239 bool AddRemote(
const std::string &remnode,
const std::string &workername)
240 {
return OwnCommand(6, remnode, workername); }
246 std::string
UserInterfaceKind(
const char *uri, std::string &path, std::string &fname);
249 int NeedAuth(
const std::string &path);
252 Buffer GetBinary(
const std::string &fullname,
const std::string &kind,
const std::string &query,
double tmout = 5.);
254 Hierarchy GetItem(
const std::string &fullname,
const std::string &query =
"",
double tmout = 5.);
257 Command ExeCmd(
const std::string &fullname,
const std::string &query);
260 bool OwnCommand(
int id,
const std::string &path,
const std::string &workername,
void *hier =
nullptr);
#define DABC_REFERENCE(RefClass, ParentClass, T)
Reference on memory from memory pool.
Command used to produce custom binary data for published in hierarchy entries.
DABC_COMMAND(CmdGetBinary, "CmdGetBinary")
CmdGetBinary(const std::string &path, const std::string &kind, const std::string &query)
Command to request names list.
static void SetResNamesList(dabc::Command &cmd, Hierarchy &res)
DABC_COMMAND(CmdGetNamesList, "CmdGetNamesList")
static Hierarchy GetResNamesList(dabc::Command &cmd)
CmdGetNamesList(const std::string &kind, const std::string &path, const std::string &query)
void AddHeader(const std::string &name, const std::string &value, bool withquotes=true)
Command submitted to worker when item in hierarchy defined as DABC.Command and used to produce custom...
DABC_COMMAND(CmdHierarchyExec, "CmdHierarchyExec")
CmdHierarchyExec(const std::string &path)
DABC_COMMAND(CmdPublisher, "CmdPublisher")
void SetEntry(const Hierarchy &e)
DABC_COMMAND(CmdSubscriber, "CmdSubscriber")
Represents command with its arguments.
bool SetStr(const std::string &name, const char *value)
bool SetInt(const std::string &name, int v)
Reference GetRef(const std::string &name)
Returns reference from the command, can be called only once.
int GetInt(const std::string &name, int dflt=0) const
bool SetRef(const std::string &name, Reference ref)
Set reference to the command.
Represents objects hierarchy of remote (or local) DABC process.
int NeedAuth(const std::string &path)
Returns 1 - need auth, 0 - no need auth, -1 - undefined.
Buffer GetBinary(const std::string &fullname, const std::string &kind, const std::string &query, double tmout=5.)
Return different kinds of binary data, depends from kind.
bool Unregister(const std::string &path, const std::string &workername, void *hierarchy)
bool RemoveWorker(const std::string &workername, bool sync=true)
Command ExeCmd(const std::string &fullname, const std::string &query)
Execute item is command, providing parameters in query.
bool Unsubscribe(const std::string &path, const std::string &workername)
std::string UserInterfaceKind(const char *uri, std::string &path, std::string &fname)
Returns "" - undefined, "__tree__" – tree hierarchy "__single__" – single element "__file__" – just a...
Hierarchy GetItem(const std::string &fullname, const std::string &query="", double tmout=5.)
bool AddRemote(const std::string &remnode, const std::string &workername)
bool Subscribe(const std::string &path, const std::string &workername)
bool OwnCommand(int id, const std::string &path, const std::string &workername, void *hier=nullptr)
bool Register(const std::string &path, const std::string &workername, void *hierarchy)
Module manages published hierarchies and provide optimize access to them
uint64_t fLastLocalVers
! this is hierarchy only for entries from local modules
virtual bool ReplyCommand(Command cmd)
Reimplement this method to react on command reply Return true if command can be destroyed by framewor...
std::list< SubscriberEntry > SubscribersList
Hierarchy GetWorkItem(const std::string &path, bool *islocal=nullptr)
Return hierarchy item selected for work.
int fFileLimit
! selected hierarchy path for storage like 'MBS' or 'FESA/server'
std::string fMgrPath
! counter for new records
dabc::Command CreateExeCmd(const std::string &path, const std::string &query, dabc::Command tgt=nullptr)
virtual double ProcessTimeout(double last_diff)
virtual const char * ClassName() const
Returns class name of the object instance.
bool IdentifyItem(bool asproducer, const std::string &itemname, bool &islocal, std::string &producer_name, std::string &request_name)
Try to find producer which potentially could deliver item It could happen that item is not exists in ...
std::string fStoreSel
! directory to store data
bool RedirectCommand(dabc::Command cmd, const std::string &itemname)
Command redirected to local modules or remote publisher, where it should be processed Primary usage -...
Publisher(const std::string &name, dabc::Command cmd=nullptr)
PublishersList fPublishers
void CheckDnsSubscribers()
bool ApplyEntryDiff(unsigned recid, dabc::Buffer &buf, uint64_t version, bool witherror=false)
Hierarchy fLocal
! this is hierarchy of all known items, including remote, used only when any global hierarchies are e...
std::string fStoreDir
! this is manager hierarchy, published by ourselfs
double fStorePeriod
! maximum time of store file, in seconds
virtual void OnThreadAssigned()
! how often storage is triggered
static const char * DfltName()
SubscribersList fSubscribers
void InvalidateGlobal()
Method marks that global version is out of date and should be rebuild.
int fTimeLimit
! maximum size of store file, in MB
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
std::list< PublisherEntry > PublishersList
! last local version, used to build global list
Hierarchy fMgrHiearchy
! path for manager
Reference on dabc::Worker
Active object, which is working inside dabc::Thread.
std::string format(const char *fmt,...)
PublisherEntry & operator=(const PublisherEntry &src)
PublisherEntry(const PublisherEntry &src)