Yate: yatengine.h Source File

Yate

yatengine.h
1
22#ifndef __YATENGINE_H
23#define __YATENGINE_H
24
25#ifndef __cplusplus
26#error C++ is required
27#endif
28
29#include <yateclass.h>
30
34namespace TelEngine {
35
40 class YATE_API Configuration : public String
41{
42 friend class Engine;
43 YNOCOPY(Configuration); // no automatic copies please
44public:
48 Configuration();
49
55 explicit Configuration(const char* filename, bool warn = true);
56
60 inline Configuration& operator=(const String& value)
61 { String::operator=(value); return *this; }
62
67 inline unsigned int sections() const
68 { return m_sections.length(); }
69
74 inline unsigned int count() const
75 { return m_sections.count(); }
76
82 NamedList* getSection(unsigned int index) const;
83
89 NamedList* getSection(const String& sect) const;
90
97 NamedString* getKey(const String& sect, const String& key) const;
98
106 const char* getValue(const String& sect, const String& key, const char* defvalue = 0) const;
107
119 int getIntValue(const String& sect, const String& key, int defvalue = 0,
120 int minvalue = INT_MIN, int maxvalue = INT_MAX, bool clamp = true) const;
121
130 int getIntValue(const String& sect, const String& key, const TokenDict* tokens, int defvalue = 0) const;
131
143 int64_t getInt64Value(const String& sect, const String& key, int64_t defvalue = 0,
144 int64_t minvalue = LLONG_MIN, int64_t maxvalue = LLONG_MAX, bool clamp = true) const;
145
153 double getDoubleValue(const String& sect, const String& key, double defvalue = 0.0) const;
154
162 bool getBoolValue(const String& sect, const String& key, bool defvalue = false) const;
163
168 void clearSection(const char* sect = 0);
169
175 NamedList* createSection(const String& sect);
176
182 void clearKey(const String& sect, const String& key);
183
190 void addValue(const String& sect, const char* key, const char* value = 0);
191
198 void setValue(const String& sect, const char* key, const char* value = 0);
199
206 void setValue(const String& sect, const char* key, int value);
207
214 void setValue(const String& sect, const char* key, bool value);
215
221 bool load(bool warn = true);
222
227 bool save() const;
228
229private:
235 inline bool loadMain(bool warn = true) {
236 m_main = true;
237 return load(warn);
238 }
239
240 ObjList *getSectHolder(const String& sect) const;
241 ObjList *makeSectHolder(const String& sect);
242 bool loadFile(const char* file, String sect, unsigned int depth, bool warn, void* priv);
243 ObjList m_sections;
244 bool m_main;
245};
246
251 class YATE_API SharedVars : public Mutex, public RefObject
252{
253public:
258 inline SharedVars(const char* name = 0)
259 : Mutex(false,"SharedVars"), m_vars(name)
260 { }
261
267 void get(const String& name, String& rval);
268
274 void set(const String& name, const char* val);
275
282 bool create(const String& name, const char* val = 0);
283
288 void clear(const String& name);
289
293 void clearAll();
294
300 bool exists(const String& name);
301
308 uint64_t inc(const String& name, uint64_t wrap = 0);
309
316 uint64_t dec(const String& name, uint64_t wrap = 0);
317
325 uint64_t add(const String& name, uint64_t val, uint64_t wrap = 0);
326
334 uint64_t sub(const String& name, uint64_t val, uint64_t wrap = 0);
335
343 inline void copy(NamedList& dest, const String& prefix = String::empty(),
344 bool skipPrefix = true, bool replace = false) {
345 Lock lck(this);
346 if (prefix)
347 dest.copySubParams(m_vars,prefix,skipPrefix,replace);
348 else
349 dest.copyParams(m_vars);
350 }
351
356 virtual const String& toString() const
357 { return m_vars; }
358
365 static bool getList(RefPointer<SharedVars>& dest, const String& name);
366
367private:
368 NamedList m_vars;
369};
370
371class MessageDispatcher;
372class MessageRelay;
373class Engine;
374
379 class YATE_API Message : public NamedList
380{
381 friend class MessageDispatcher;
382public:
390 explicit Message(const char* name, const char* retval = 0, bool broadcast = false);
391
397 Message(const Message& original);
398
405 Message(const Message& original, bool broadcast);
406
410 ~Message();
411
417 virtual void* getObject(const String& name) const;
418
423 inline String& retValue()
424 { return m_return; }
425
430 inline const String& retValue() const
431 { return m_return; }
432
437 inline RefObject* userData() const
438 { return m_data; }
439
446 void userData(RefObject* data);
447
453 inline void* userObject(const String& name) const
454 { return m_data ? m_data->getObject(name) : 0; }
455
456
462 inline void setNotify(bool notify = true)
463 { m_notify = notify; }
464
469 inline bool broadcast() const
470 { return m_broadcast; }
471
477 void resetMsg(Time tm = Time::now());
478
483 inline Time& msgTime()
484 { return m_time; }
485
490 inline const Time& msgTime() const
491 { return m_time; }
492
498 inline Time& msgTimeEnqueue()
499 { return m_timeEnqueue; }
500
506 inline const Time& msgTimeEnqueue() const
507 { return m_timeEnqueue; }
508
514 inline Time& msgTimeDispatch()
515 { return m_timeDispatch; }
516
522 inline const Time& msgTimeDispatch() const
523 { return m_timeDispatch; }
524
528 inline Message& operator=(const char* value)
529 { String::operator=(value); return *this; }
530
536 String encode(const char* id) const;
537
544 String encode(bool received, const char* id) const;
545
554 int decode(const char* str, String& id);
555
565 int decode(const char* str, bool& received, const char* id);
566
567protected:
574 virtual void dispatched(bool accepted);
575
576private:
577 Message(); // no default constructor please
578 Message& operator=(const Message& value); // no assignment please
579 String m_return;
580 Time m_time;
581 Time m_timeEnqueue;
582 Time m_timeDispatch;
583 RefObject* m_data;
584 bool m_notify;
585 bool m_broadcast;
586 void commonEncode(String& str) const;
587 int commonDecode(const char* str, int offs);
588};
589
594 class YATE_API MessageFilter
595{
596public:
600 inline MessageFilter()
601 : m_filter(0), m_msgFilter(0)
602 {}
603
607 inline ~MessageFilter()
608 { set(m_filter); set(m_msgFilter); }
609
614 inline bool matchesMsg(const Message& msg) const {
615 return (!m_msgFilter || m_msgFilter->matchString(msg))
616 && (!m_filter || m_filter->matchListParam(msg));
617 }
618
623 inline const MatchingItemBase* getFilter() const
624 { return m_filter; }
625
630 inline const MatchingItemBase* getMsgFilter() const
631 { return m_msgFilter; }
632
638 inline void setFilter(MatchingItemBase* filter)
639 { set(m_filter,filter); }
640
646 inline void setMsgFilter(MatchingItemBase* filter)
647 { set(m_msgFilter,filter); }
648
652 inline void clearFilter()
653 { set(m_filter); }
654
658 inline void clearMsgFilter()
659 { set(m_msgFilter); }
660
666 void setFilter(NamedString* filter);
667
673 inline void setFilter(const char* name, const char* value)
674 { setFilter(new MatchingItemString(name,value)); }
675
676private:
677 void set(MatchingItemBase*& dest, MatchingItemBase* src = 0);
678
679 MatchingItemBase* m_filter;
680 MatchingItemBase* m_msgFilter;
681};
682
689 class YATE_API MessageHandler : public String, public MessageFilter
690{
691 friend class MessageDispatcher;
692 YNOCOPY(MessageHandler); // no automatic copies please
693public:
701 explicit MessageHandler(const char* name, unsigned priority = 100,
702 const char* trackName = 0, bool addPriority = true);
703
707 virtual ~MessageHandler();
708
712 virtual void destruct();
713
719 virtual bool received(Message& msg) = 0;
720
725 inline unsigned priority() const
726 { return m_priority; }
727
732 inline const String& trackName() const
733 { return m_trackName; }
734
739 inline const String& trackNameOnly() const
740 { return m_trackNameOnly; }
741
747 inline void trackName(const char* name) {
748 if (m_dispatcher)
749 return;
750 m_trackName = name;
751 String tmp;
752 tmp << ':' << priority();
753 if (m_trackName.endsWith(tmp))
754 m_trackNameOnly = m_trackName.substr(0,m_trackName.length() - tmp.length());
755 else
756 m_trackNameOnly = m_trackName;
757 }
758
763 inline NamedCounter* objectsCounter() const
764 { return m_counter; }
765
770 inline const MatchingItemBase* filter() const
771 { return getFilter(); }
772
773protected:
778 void cleanup();
779
785 virtual bool receivedInternal(Message& msg);
786
790 void safeNowInternal();
791
792private:
793 String m_trackName;
794 String m_trackNameOnly;
795 unsigned m_priority;
796 AtomicInt m_unsafe;
797 MessageDispatcher* m_dispatcher;
798 NamedCounter* m_counter;
799};
800
805 class YATE_API MessageReceiver : public GenObject
806{
807public:
814 virtual bool received(Message& msg, int id) = 0;
815};
816
821 class YATE_API MessageRelay : public MessageHandler
822{
823 YNOCOPY(MessageRelay); // no automatic copies please
824public:
834 inline MessageRelay(const char* name, MessageReceiver* receiver, int id,
835 int priority = 100, const char* trackName = 0, bool addPriority = true)
836 : MessageHandler(name,priority,trackName,addPriority),
837 m_receiver(receiver), m_id(id)
838 { }
839
846 virtual bool received(Message& msg)
847 { return m_receiver && m_receiver->received(msg,m_id); }
848
853 inline int id() const
854 { return m_id; }
855
861 virtual bool receivedInternal(Message& msg);
862
863private:
864 MessageReceiver* m_receiver;
865 int m_id;
866};
867
874 class YATE_API MessageNotifier
875{
876public:
880 virtual ~MessageNotifier();
881
887 virtual void dispatched(const Message& msg, bool handled) = 0;
888};
889
896 class YATE_API MessagePostHook : public RefObject, public MessageNotifier, public MessageFilter
897{
898};
899
906 class YATE_API MessageDispatcher : public GenObject
907{
908 friend class Engine;
909 YNOCOPY(MessageDispatcher); // no automatic copies please
910public:
915 MessageDispatcher(const char* trackParam = 0);
916
920 ~MessageDispatcher();
921
926 inline const String& trackParam() const
927 { return m_trackParam; }
928
937 bool install(MessageHandler* handler);
938
944 bool uninstall(MessageHandler* handler);
945
957 bool dispatch(Message& msg);
958
964 bool enqueue(Message* msg);
965
969 void dequeue();
970
975 bool dequeueOne();
976
981 inline void warnTime(u_int64_t usec)
982 { m_warnTime = usec; }
983
988 inline void traceTime(bool on = false)
989 { m_traceTime = on; }
990
995 inline void traceHandlerTime(bool on = false)
996 { m_traceHandlerTime = on; }
997
1001 void clear();
1002
1007 inline bool hasMessages() const
1008 { return m_messages.get() || m_messages.next(); }
1009
1014 inline bool hasHandlers() const
1015 { return m_handlers.get() || m_handlers.next(); }
1016
1021 inline bool hasHooks() const
1022 { return m_hooks.get() || m_hooks.next(); }
1023
1028 unsigned int messageCount();
1029
1034 unsigned int handlerCount();
1035
1040 unsigned int postHookCount();
1041
1046 u_int64_t enqueueCount() const
1047 { return m_enqueueCount; }
1048
1053 u_int64_t dequeueCount() const
1054 { return m_dequeueCount; }
1055
1060 u_int64_t dispatchCount() const
1061 { return m_dispatchCount; }
1062
1067 u_int64_t queuedMax() const
1068 { return m_queuedMax; }
1069
1075 u_int64_t messageAge(bool usec = false) const
1076 { return usec ? m_msgAvgAge : ((m_msgAvgAge + 500) / 1000); }
1077
1082 inline RWLock& handlersLock()
1083 { return m_handlersLock; }
1084
1092 void getStats(u_int64_t& enqueued, u_int64_t& dequeued, u_int64_t& dispatched, u_int64_t& queueMax);
1093
1100 bool setHook(MessagePostHook* hook, bool remove = false);
1101
1110 unsigned int fillHandlersInfo(bool matchName, const String& match, String* details = 0,
1111 unsigned int* total = 0);
1112
1113protected:
1118 inline void trackParam(const char* paramName)
1119 { m_trackParam = paramName; }
1120
1121private:
1122 ObjList m_handlers;
1123 ObjList m_messages;
1124 ObjList m_hooks;
1125 RWLock m_handlersLock;
1126 RWLock m_messagesLock;
1127 RWLock m_hooksLock;
1128 ObjList* m_msgAppend;
1129 ObjList* m_hookAppend;
1130 String m_trackParam;
1131 unsigned int m_changes;
1132 u_int64_t m_warnTime;
1133 u_int64_t m_enqueueCount;
1134 u_int64_t m_dequeueCount;
1135 u_int64_t m_dispatchCount;
1136 u_int64_t m_queuedMax;
1137 u_int64_t m_msgAvgAge;
1138 bool m_traceTime;
1139 bool m_traceHandlerTime;
1140 int m_hookCount;
1141 bool m_hookHole;
1142};
1143
1148 class YATE_API MessageHook : public RefObject
1149{
1150public:
1156 virtual bool enqueue(Message* msg) = 0;
1157
1161 virtual void clear() = 0;
1162
1168 virtual bool matchesFilter(const Message& msg) = 0;
1169};
1170
1171
1177 class YATE_API MessageQueue : public MessageHook, public Mutex
1178{
1179 friend class Engine;
1180public:
1186 MessageQueue(const char* hookName, int numWorkers = 0);
1187
1191 ~MessageQueue();
1192
1198 virtual bool enqueue(Message* msg);
1199
1204 bool dequeue();
1205
1211 void addFilter(const char* name, const char* value);
1212
1217 void removeFilter(const String& name);
1218
1222 virtual void clear();
1223
1228 void removeThread(Thread* thread);
1229
1234 inline unsigned int count() const
1235 { return m_count; }
1236
1241 inline const NamedList& getFilters() const
1242 { return m_filters; }
1243
1249 virtual bool matchesFilter(const Message& msg);
1250protected:
1251
1257 virtual void received(Message& msg);
1258
1259private:
1260 NamedList m_filters;
1261 ObjList m_messages;
1262 ObjList m_workers;
1263 ObjList* m_append;
1264 unsigned int m_count;
1265};
1266
1267
1278 class YATE_API Plugin : public GenObject, public DebugEnabler
1279{
1280public:
1286 explicit Plugin(const char* name, bool earlyInit = false);
1287
1293 virtual ~Plugin();
1294
1299 virtual const String& toString() const
1300 { return m_name; }
1301
1307 virtual void* getObject(const String& name) const;
1308
1312 virtual void initialize() = 0;
1313
1318 virtual bool isBusy() const
1319 { return false; }
1320
1325 inline const String& name() const
1326 { return m_name; }
1327
1332 inline NamedCounter* objectsCounter() const
1333 { return m_counter; }
1334
1339 bool earlyInit() const
1340 { return m_early; }
1341
1342private:
1343 Plugin(); // no default constructor please
1344 String m_name;
1345 NamedCounter* m_counter;
1346 bool m_early;
1347};
1348
1349#if 0 /* for documentation generator */
1354 void INIT_PLUGIN(class pclass);
1355
1361 bool UNLOAD_PLUGIN(bool unloadNow);
1362#endif
1363
1364#define INIT_PLUGIN(pclass) static pclass __plugin
1365#ifdef DISABLE_UNLOAD
1366#define UNLOAD_PLUGIN(arg) static bool _unused_unload(bool arg)
1367#else
1368#ifdef _WINDOWS
1369#define UNLOAD_PLUGIN(arg) extern "C" __declspec(dllexport) bool _unload(bool arg)
1370#else
1371#define UNLOAD_PLUGIN(arg) extern "C" bool _unload(bool arg)
1372#endif
1373#endif
1374
1381 class YATE_API EngineCheck
1382{
1383public:
1387 virtual ~EngineCheck()
1388 { }
1389
1396 virtual bool check(const ObjList* cmds) = 0;
1397
1402 static void setChecker(EngineCheck* ptr = 0);
1403};
1404
1408 typedef int (*EngineLoop)();
1409
1416 class YATE_API Engine
1417{
1418 friend class EnginePrivate;
1419 friend class EngineCommand;
1420 YNOCOPY(Engine); // no automatic copies please
1421public:
1425 enum RunMode {
1426 Stopped = 0,
1427 Console = 1,
1428 Server = 2,
1429 Client = 3,
1430 ClientProxy = 4,
1431 };
1432
1433 enum CallAccept {
1434 Accept = 0,
1435 Partial = 1,
1436 Congestion = 2,
1437 Reject = 3,
1438 };
1439
1446 enum PluginMode {
1447 LoadFail = 0,
1448 LoadLate,
1449 LoadEarly
1450 };
1451
1462 static int main(int argc, const char** argv, const char** env,
1463 RunMode mode = Console, EngineLoop loop = 0, bool fail = false);
1464
1470 static void help(bool client, bool errout = false);
1471
1476 int engineInit();
1477
1482 int engineCleanup();
1483
1488 int run();
1489
1494 static Engine* self();
1495
1500 static RunMode mode()
1501 { return s_mode; }
1502
1507 inline static CallAccept accept() {
1508 return (s_congestion && (s_accept < Congestion)) ? Congestion : s_accept;
1509 }
1510
1515 inline static void setAccept(CallAccept ca) {
1516 s_accept = ca;
1517 }
1518
1523 inline static const TokenDict* getCallAcceptStates() {
1524 return s_callAccept;
1525 }
1526
1531 static void setCongestion(const char* reason = 0);
1532
1537 static unsigned int getCongestion()
1538 { return s_congestion; }
1539
1544 inline static bool clientMode()
1545 { return (s_mode == Client) || (s_mode == ClientProxy); }
1546
1553 static bool Register(const Plugin* plugin, bool reg = true);
1554
1559 inline static const String& nodeName()
1560 { return s_node; }
1561
1566 inline static const String& sharedPath()
1567 { return s_shrpath; }
1568
1575 static String configFile(const char* name, bool user = false);
1576
1582 static const String& configPath(bool user = false);
1583
1588 inline static const String& configSuffix()
1589 { return s_cfgsuffix; }
1590
1594 inline static const String& modulePath()
1595 { return s_modpath; }
1596
1602 static void extraPath(const String& path);
1603
1610 static void userPath(const String& path);
1611
1616 inline static const String& moduleSuffix()
1617 { return s_modsuffix; }
1618
1623 static const char* pathSeparator();
1624
1632 static const Configuration& config();
1633
1638 static unsigned int runId();
1639
1644 inline static const NamedList& runParams()
1645 { return s_params; }
1646
1650 static void init();
1651
1657 static bool init(const String& name);
1658
1663 static void halt(unsigned int code);
1664
1671 static bool restart(unsigned int code, bool gracefull = false);
1672
1677 static bool started()
1678 { return s_started; }
1679
1684 static bool exiting()
1685 { return (s_haltcode != -1); }
1686
1692 static bool install(MessageHandler* handler);
1693
1699 static bool uninstall(MessageHandler* handler);
1700
1707 static bool enqueue(Message* msg, bool skipHooks = false);
1708
1716 inline static bool enqueue(const char* name, bool broadcast = false)
1717 { return name && *name && enqueue(new Message(name,0,broadcast)); }
1718
1724 static bool dispatch(Message* msg);
1725
1731 static bool dispatch(Message& msg);
1732
1740 static bool dispatch(const char* name, bool broadcast = false);
1741
1748 inline bool setHook(MessagePostHook* hook, bool remove = false)
1749 { return m_dispatcher.setHook(hook,remove); }
1750
1755 inline static const String& trackParam()
1756 { return s_self ? s_self->m_dispatcher.trackParam() : String::empty(); }
1757
1763 static bool installHook(MessageHook* hook);
1764
1769 static void uninstallHook(MessageHook* hook);
1770
1775 int usedPlugins();
1776
1781 inline unsigned int messageCount()
1782 { return m_dispatcher.messageCount(); }
1783
1788 inline unsigned int handlerCount()
1789 { return m_dispatcher.handlerCount(); }
1790
1795 inline unsigned int postHookCount()
1796 { return m_dispatcher.postHookCount(); }
1797
1802 inline unsigned int messageRate() const
1803 { return m_messageRate; }
1804
1809 inline unsigned int messageMaxRate() const
1810 { return m_maxMsgRate; }
1811
1817 unsigned int messageAge(bool usec = false) const
1818 { return (unsigned int)m_dispatcher.messageAge(usec); }
1819
1827 inline void getStats(u_int64_t& enqueued, u_int64_t& dequeued, u_int64_t& dispatched, u_int64_t& queueMax)
1828 { m_dispatcher.getStats(enqueued,dequeued,dispatched,queueMax); }
1829
1833 inline void resetMax()
1834 { m_maxMsgRate = m_messageRate; m_dispatcher.m_queuedMax = m_dispatcher.messageCount(); }
1835
1841 inline bool pluginLoaded(const String& name) const
1842 { return !!m_libs[name]; }
1843
1849 bool loadPluginDir(const String& relPath);
1850
1855 static void pluginMode(PluginMode mode);
1856
1862 static const ObjList* events(const String& type);
1863
1868 static void clearEvents(const String& type);
1869
1874 static SharedVars& sharedVars();
1875
1882 static void buildCmdLine(String& line);
1883
1892 static void initLibrary(const String& line, String* output = 0);
1893
1899 static int cleanupLibrary();
1900
1905 static inline MessageDispatcher* dispatcher()
1906 { return s_self ? &(s_self->m_dispatcher) : 0; }
1907
1908protected:
1913 ~Engine();
1914
1922 bool loadPlugin(const char* file, bool local = false, bool nounload = false);
1923
1927 void loadPlugins();
1928
1932 void initPlugins();
1933
1934private:
1935 Engine();
1936 void internalStatisticsStart();
1937 void tryPluginFile(const String& name, const String& path, bool defload);
1938 ObjList m_libs;
1939 MessageDispatcher m_dispatcher;
1940 uint64_t m_dispatchedLast;
1941 unsigned int m_messageRate;
1942 unsigned int m_maxMsgRate;
1943 bool m_rateCongested;
1944 bool m_queueCongested;
1945 bool m_ageCongested;
1946 static Engine* s_self;
1947 static String s_node;
1948 static String s_shrpath;
1949 static String s_cfgsuffix;
1950 static String s_modpath;
1951 static String s_modsuffix;
1952 static ObjList s_extramod;
1953 static NamedList s_params;
1954 static int s_haltcode;
1955 static RunMode s_mode;
1956 static bool s_started;
1957 static unsigned int s_congestion;
1958 static CallAccept s_accept;
1959 static const TokenDict s_callAccept[];
1960};
1961
1962}; // namespace TelEngine
1963
1964#endif /* __YATENGINE_H */
1965
1966/* vi: set ts=8 sw=4 sts=4 noet: */
DebugEnabler
A holder for a debug level.
Definition yateclass.h:329
GenObject
Definition yateclass.h:1627
Lock
Ephemeral mutex, semaphore or rw-lock locking object.
Definition yateclass.h:10000
MatchingItemBase
Matching item common interface.
Definition yateclass.h:8704
MatchingItemBase::matchListParam
bool matchListParam(const NamedList &list, MatchingParams *params=0) const
Definition yateclass.h:8747
MatchingItemBase::matchString
bool matchString(const String &str, MatchingParams *params=0) const
Definition yateclass.h:8738
MatchingItemString
String comparison matching item.
Definition yateclass.h:8864
Mutex
Mutex support.
Definition yateclass.h:9403
NamedCounter
Atomic counter with name.
Definition yateclass.h:5428
NamedList
A named string container class.
Definition yateclass.h:7690
NamedList::copySubParams
NamedList & copySubParams(const NamedList &original, const String &prefix, bool skipPrefix=true, bool replace=false)
NamedList::copyParams
NamedList & copyParams(bool replace, const NamedList &original, bool copyUserData=false)
NamedString
A named string class.
Definition yateclass.h:5304
ObjList
An object list class.
Definition yateclass.h:2032
ObjList::next
ObjList * next() const
Definition yateclass.h:2083
ObjList::get
GenObject * get() const
Definition yateclass.h:2068
ObjList::count
unsigned int count() const
ObjList::length
unsigned int length() const
RWLock
Read/write lock support.
Definition yateclass.h:9720
RefObject
Definition yateclass.h:1752
RefObject::getObject
virtual void * getObject(const String &name) const
RefPointer
Templated smart pointer class.
Definition yateclass.h:1884
String
A C-style string handling class.
Definition yateclass.h:3055
String::endsWith
bool endsWith(const char *what, bool wordBreak=false, bool caseInsensitive=false) const
String::operator=
String & operator=(const String &value)
Definition yateclass.h:3518
String::empty
static const String & empty()
String::length
unsigned int length() const
Definition yateclass.h:3182
String::substr
String substr(int offs, int len=-1) const
TelEngine::Client
Class that runs the User Interface.
Definition yatecbase.h:994
TelEngine::Configuration
Configuration file handling.
Definition yatengine.h:41
TelEngine::Configuration::load
bool load(bool warn=true)
TelEngine::Configuration::getKey
NamedString * getKey(const String &sect, const String &key) const
TelEngine::Configuration::clearSection
void clearSection(const char *sect=0)
TelEngine::Configuration::Configuration
Configuration()
TelEngine::Configuration::getIntValue
int getIntValue(const String &sect, const String &key, int defvalue=0, int minvalue=INT_MIN, int maxvalue=INT_MAX, bool clamp=true) const
TelEngine::Configuration::getDoubleValue
double getDoubleValue(const String &sect, const String &key, double defvalue=0.0) const
TelEngine::Configuration::getInt64Value
int64_t getInt64Value(const String &sect, const String &key, int64_t defvalue=0, int64_t minvalue=LLONG_MIN, int64_t maxvalue=LLONG_MAX, bool clamp=true) const
TelEngine::Configuration::getIntValue
int getIntValue(const String &sect, const String &key, const TokenDict *tokens, int defvalue=0) const
TelEngine::Configuration::getSection
NamedList * getSection(unsigned int index) const
TelEngine::Configuration::getSection
NamedList * getSection(const String &sect) const
TelEngine::Configuration::save
bool save() const
TelEngine::Configuration::clearKey
void clearKey(const String &sect, const String &key)
TelEngine::Configuration::addValue
void addValue(const String &sect, const char *key, const char *value=0)
TelEngine::Configuration::getBoolValue
bool getBoolValue(const String &sect, const String &key, bool defvalue=false) const
TelEngine::Configuration::operator=
Configuration & operator=(const String &value)
Definition yatengine.h:60
TelEngine::Configuration::setValue
void setValue(const String &sect, const char *key, int value)
TelEngine::Configuration::createSection
NamedList * createSection(const String &sect)
TelEngine::Configuration::setValue
void setValue(const String &sect, const char *key, const char *value=0)
TelEngine::Configuration::sections
unsigned int sections() const
Definition yatengine.h:67
TelEngine::Configuration::Configuration
Configuration(const char *filename, bool warn=true)
TelEngine::Configuration::setValue
void setValue(const String &sect, const char *key, bool value)
TelEngine::Configuration::count
unsigned int count() const
Definition yatengine.h:74
TelEngine::Configuration::getValue
const char * getValue(const String &sect, const String &key, const char *defvalue=0) const
TelEngine::EngineCheck
Engine checker interface.
Definition yatengine.h:1382
TelEngine::EngineCheck::check
virtual bool check(const ObjList *cmds)=0
TelEngine::EngineCheck::~EngineCheck
virtual ~EngineCheck()
Definition yatengine.h:1387
TelEngine::EngineCheck::setChecker
static void setChecker(EngineCheck *ptr=0)
TelEngine::Engine
Engine globals.
Definition yatengine.h:1417
TelEngine::Engine::clientMode
static bool clientMode()
Definition yatengine.h:1544
TelEngine::Engine::mode
static RunMode mode()
Definition yatengine.h:1500
TelEngine::Engine::halt
static void halt(unsigned int code)
TelEngine::Engine::loadPluginDir
bool loadPluginDir(const String &relPath)
TelEngine::Engine::config
static const Configuration & config()
TelEngine::Engine::clearEvents
static void clearEvents(const String &type)
TelEngine::Engine::resetMax
void resetMax()
Definition yatengine.h:1833
TelEngine::Engine::nodeName
static const String & nodeName()
Definition yatengine.h:1559
TelEngine::Engine::sharedPath
static const String & sharedPath()
Definition yatengine.h:1566
TelEngine::Engine::loadPlugin
bool loadPlugin(const char *file, bool local=false, bool nounload=false)
TelEngine::Engine::RunMode
RunMode
Definition yatengine.h:1425
TelEngine::Engine::usedPlugins
int usedPlugins()
TelEngine::Engine::~Engine
~Engine()
TelEngine::Engine::help
static void help(bool client, bool errout=false)
TelEngine::Engine::moduleSuffix
static const String & moduleSuffix()
Definition yatengine.h:1616
TelEngine::Engine::pathSeparator
static const char * pathSeparator()
TelEngine::Engine::handlerCount
unsigned int handlerCount()
Definition yatengine.h:1788
TelEngine::Engine::getCallAcceptStates
static const TokenDict * getCallAcceptStates()
Definition yatengine.h:1523
TelEngine::Engine::uninstall
static bool uninstall(MessageHandler *handler)
TelEngine::Engine::messageRate
unsigned int messageRate() const
Definition yatengine.h:1802
TelEngine::Engine::run
int run()
TelEngine::Engine::uninstallHook
static void uninstallHook(MessageHook *hook)
TelEngine::Engine::events
static const ObjList * events(const String &type)
TelEngine::Engine::engineCleanup
int engineCleanup()
TelEngine::Engine::main
static int main(int argc, const char **argv, const char **env, RunMode mode=Console, EngineLoop loop=0, bool fail=false)
TelEngine::Engine::restart
static bool restart(unsigned int code, bool gracefull=false)
TelEngine::Engine::pluginMode
static void pluginMode(PluginMode mode)
TelEngine::Engine::init
static bool init(const String &name)
TelEngine::Engine::install
static bool install(MessageHandler *handler)
TelEngine::Engine::installHook
static bool installHook(MessageHook *hook)
TelEngine::Engine::PluginMode
PluginMode
Definition yatengine.h:1446
TelEngine::Engine::accept
static CallAccept accept()
Definition yatengine.h:1507
TelEngine::Engine::extraPath
static void extraPath(const String &path)
TelEngine::Engine::dispatch
static bool dispatch(const char *name, bool broadcast=false)
TelEngine::Engine::userPath
static void userPath(const String &path)
TelEngine::Engine::getStats
void getStats(u_int64_t &enqueued, u_int64_t &dequeued, u_int64_t &dispatched, u_int64_t &queueMax)
Definition yatengine.h:1827
TelEngine::Engine::pluginLoaded
bool pluginLoaded(const String &name) const
Definition yatengine.h:1841
TelEngine::Engine::setHook
bool setHook(MessagePostHook *hook, bool remove=false)
Definition yatengine.h:1748
TelEngine::Engine::dispatch
static bool dispatch(Message &msg)
TelEngine::Engine::dispatcher
static MessageDispatcher * dispatcher()
Definition yatengine.h:1905
TelEngine::Engine::trackParam
static const String & trackParam()
Definition yatengine.h:1755
TelEngine::Engine::postHookCount
unsigned int postHookCount()
Definition yatengine.h:1795
TelEngine::Engine::loadPlugins
void loadPlugins()
TelEngine::Engine::messageAge
unsigned int messageAge(bool usec=false) const
Definition yatengine.h:1817
TelEngine::Engine::buildCmdLine
static void buildCmdLine(String &line)
TelEngine::Engine::dispatch
static bool dispatch(Message *msg)
TelEngine::Engine::configSuffix
static const String & configSuffix()
Definition yatengine.h:1588
TelEngine::Engine::initLibrary
static void initLibrary(const String &line, String *output=0)
TelEngine::Engine::messageMaxRate
unsigned int messageMaxRate() const
Definition yatengine.h:1809
TelEngine::Engine::configPath
static const String & configPath(bool user=false)
TelEngine::Engine::modulePath
static const String & modulePath()
Definition yatengine.h:1594
TelEngine::Engine::getCongestion
static unsigned int getCongestion()
Definition yatengine.h:1537
TelEngine::Engine::cleanupLibrary
static int cleanupLibrary()
TelEngine::Engine::messageCount
unsigned int messageCount()
Definition yatengine.h:1781
TelEngine::Engine::sharedVars
static SharedVars & sharedVars()
TelEngine::Engine::configFile
static String configFile(const char *name, bool user=false)
TelEngine::Engine::setAccept
static void setAccept(CallAccept ca)
Definition yatengine.h:1515
TelEngine::Engine::initPlugins
void initPlugins()
TelEngine::Engine::enqueue
static bool enqueue(const char *name, bool broadcast=false)
Definition yatengine.h:1716
TelEngine::Engine::init
static void init()
TelEngine::Engine::started
static bool started()
Definition yatengine.h:1677
TelEngine::Engine::setCongestion
static void setCongestion(const char *reason=0)
TelEngine::Engine::exiting
static bool exiting()
Definition yatengine.h:1684
TelEngine::Engine::engineInit
int engineInit()
TelEngine::Engine::Register
static bool Register(const Plugin *plugin, bool reg=true)
TelEngine::Engine::self
static Engine * self()
TelEngine::Engine::runId
static unsigned int runId()
TelEngine::Engine::enqueue
static bool enqueue(Message *msg, bool skipHooks=false)
TelEngine::Engine::runParams
static const NamedList & runParams()
Definition yatengine.h:1644
TelEngine::MessageDispatcher
A message dispatching hub.
Definition yatengine.h:907
TelEngine::MessageDispatcher::~MessageDispatcher
~MessageDispatcher()
TelEngine::MessageDispatcher::hasMessages
bool hasMessages() const
Definition yatengine.h:1007
TelEngine::MessageDispatcher::warnTime
void warnTime(u_int64_t usec)
Definition yatengine.h:981
TelEngine::MessageDispatcher::trackParam
const String & trackParam() const
Definition yatengine.h:926
TelEngine::MessageDispatcher::enqueue
bool enqueue(Message *msg)
TelEngine::MessageDispatcher::messageAge
u_int64_t messageAge(bool usec=false) const
Definition yatengine.h:1075
TelEngine::MessageDispatcher::install
bool install(MessageHandler *handler)
TelEngine::MessageDispatcher::queuedMax
u_int64_t queuedMax() const
Definition yatengine.h:1067
TelEngine::MessageDispatcher::handlerCount
unsigned int handlerCount()
TelEngine::MessageDispatcher::handlersLock
RWLock & handlersLock()
Definition yatengine.h:1082
TelEngine::MessageDispatcher::dequeueCount
u_int64_t dequeueCount() const
Definition yatengine.h:1053
TelEngine::MessageDispatcher::traceHandlerTime
void traceHandlerTime(bool on=false)
Definition yatengine.h:995
TelEngine::MessageDispatcher::enqueueCount
u_int64_t enqueueCount() const
Definition yatengine.h:1046
TelEngine::MessageDispatcher::trackParam
void trackParam(const char *paramName)
Definition yatengine.h:1118
TelEngine::MessageDispatcher::MessageDispatcher
MessageDispatcher(const char *trackParam=0)
TelEngine::MessageDispatcher::dequeue
void dequeue()
TelEngine::MessageDispatcher::dequeueOne
bool dequeueOne()
TelEngine::MessageDispatcher::uninstall
bool uninstall(MessageHandler *handler)
TelEngine::MessageDispatcher::getStats
void getStats(u_int64_t &enqueued, u_int64_t &dequeued, u_int64_t &dispatched, u_int64_t &queueMax)
TelEngine::MessageDispatcher::setHook
bool setHook(MessagePostHook *hook, bool remove=false)
TelEngine::MessageDispatcher::hasHooks
bool hasHooks() const
Definition yatengine.h:1021
TelEngine::MessageDispatcher::postHookCount
unsigned int postHookCount()
TelEngine::MessageDispatcher::hasHandlers
bool hasHandlers() const
Definition yatengine.h:1014
TelEngine::MessageDispatcher::dispatch
bool dispatch(Message &msg)
TelEngine::MessageDispatcher::fillHandlersInfo
unsigned int fillHandlersInfo(bool matchName, const String &match, String *details=0, unsigned int *total=0)
TelEngine::MessageDispatcher::clear
void clear()
TelEngine::MessageDispatcher::dispatchCount
u_int64_t dispatchCount() const
Definition yatengine.h:1060
TelEngine::MessageDispatcher::messageCount
unsigned int messageCount()
TelEngine::MessageDispatcher::traceTime
void traceTime(bool on=false)
Definition yatengine.h:988
TelEngine::MessageFilter
A message filter.
Definition yatengine.h:595
TelEngine::MessageFilter::matchesMsg
bool matchesMsg(const Message &msg) const
Definition yatengine.h:614
TelEngine::MessageFilter::setFilter
void setFilter(NamedString *filter)
TelEngine::MessageFilter::MessageFilter
MessageFilter()
Definition yatengine.h:600
TelEngine::MessageFilter::getMsgFilter
const MatchingItemBase * getMsgFilter() const
Definition yatengine.h:630
TelEngine::MessageFilter::clearFilter
void clearFilter()
Definition yatengine.h:652
TelEngine::MessageFilter::setFilter
void setFilter(const char *name, const char *value)
Definition yatengine.h:673
TelEngine::MessageFilter::setFilter
void setFilter(MatchingItemBase *filter)
Definition yatengine.h:638
TelEngine::MessageFilter::setMsgFilter
void setMsgFilter(MatchingItemBase *filter)
Definition yatengine.h:646
TelEngine::MessageFilter::~MessageFilter
~MessageFilter()
Definition yatengine.h:607
TelEngine::MessageFilter::clearMsgFilter
void clearMsgFilter()
Definition yatengine.h:658
TelEngine::MessageFilter::getFilter
const MatchingItemBase * getFilter() const
Definition yatengine.h:623
TelEngine::MessageHandler
A message handler.
Definition yatengine.h:690
TelEngine::MessageHandler::safeNowInternal
void safeNowInternal()
TelEngine::MessageHandler::trackNameOnly
const String & trackNameOnly() const
Definition yatengine.h:739
TelEngine::MessageHandler::filter
const MatchingItemBase * filter() const
Definition yatengine.h:770
TelEngine::MessageHandler::~MessageHandler
virtual ~MessageHandler()
TelEngine::MessageHandler::received
virtual bool received(Message &msg)=0
TelEngine::MessageHandler::trackName
const String & trackName() const
Definition yatengine.h:732
TelEngine::MessageHandler::cleanup
void cleanup()
TelEngine::MessageHandler::priority
unsigned priority() const
Definition yatengine.h:725
TelEngine::MessageHandler::trackName
void trackName(const char *name)
Definition yatengine.h:747
TelEngine::MessageHandler::destruct
virtual void destruct()
TelEngine::MessageHandler::MessageHandler
MessageHandler(const char *name, unsigned priority=100, const char *trackName=0, bool addPriority=true)
TelEngine::MessageHandler::receivedInternal
virtual bool receivedInternal(Message &msg)
TelEngine::MessageHandler::objectsCounter
NamedCounter * objectsCounter() const
Definition yatengine.h:763
TelEngine::MessageHook
Abstract message hook.
Definition yatengine.h:1149
TelEngine::MessageHook::enqueue
virtual bool enqueue(Message *msg)=0
TelEngine::MessageHook::clear
virtual void clear()=0
TelEngine::MessageHook::matchesFilter
virtual bool matchesFilter(const Message &msg)=0
TelEngine::MessageNotifier
Post-dispatching message hook.
Definition yatengine.h:875
TelEngine::MessageNotifier::~MessageNotifier
virtual ~MessageNotifier()
TelEngine::MessageNotifier::dispatched
virtual void dispatched(const Message &msg, bool handled)=0
TelEngine::MessagePostHook
Post-dispatching message hook that can be added to a list.
Definition yatengine.h:897
TelEngine::MessageQueue
A message queue.
Definition yatengine.h:1178
TelEngine::MessageQueue::received
virtual void received(Message &msg)
TelEngine::MessageQueue::addFilter
void addFilter(const char *name, const char *value)
TelEngine::MessageQueue::removeFilter
void removeFilter(const String &name)
TelEngine::MessageQueue::~MessageQueue
~MessageQueue()
TelEngine::MessageQueue::enqueue
virtual bool enqueue(Message *msg)
TelEngine::MessageQueue::dequeue
bool dequeue()
TelEngine::MessageQueue::MessageQueue
MessageQueue(const char *hookName, int numWorkers=0)
TelEngine::MessageQueue::removeThread
void removeThread(Thread *thread)
TelEngine::MessageQueue::matchesFilter
virtual bool matchesFilter(const Message &msg)
TelEngine::MessageQueue::getFilters
const NamedList & getFilters() const
Definition yatengine.h:1241
TelEngine::MessageQueue::clear
virtual void clear()
TelEngine::MessageQueue::count
unsigned int count() const
Definition yatengine.h:1234
TelEngine::MessageReceiver
A multiple message receiver.
Definition yatengine.h:806
TelEngine::MessageReceiver::received
virtual bool received(Message &msg, int id)=0
TelEngine::MessageRelay
A message handler relay.
Definition yatengine.h:822
TelEngine::MessageRelay::received
virtual bool received(Message &msg)
Definition yatengine.h:846
TelEngine::MessageRelay::id
int id() const
Definition yatengine.h:853
TelEngine::MessageRelay::receivedInternal
virtual bool receivedInternal(Message &msg)
TelEngine::MessageRelay::MessageRelay
MessageRelay(const char *name, MessageReceiver *receiver, int id, int priority=100, const char *trackName=0, bool addPriority=true)
Definition yatengine.h:834
TelEngine::Message
A message container class.
Definition yatengine.h:380
TelEngine::Message::getObject
virtual void * getObject(const String &name) const
TelEngine::Message::msgTime
Time & msgTime()
Definition yatengine.h:483
TelEngine::Message::decode
int decode(const char *str, bool &received, const char *id)
TelEngine::Message::setNotify
void setNotify(bool notify=true)
Definition yatengine.h:462
TelEngine::Message::userData
RefObject * userData() const
Definition yatengine.h:437
TelEngine::Message::resetMsg
void resetMsg(Time tm=Time::now())
TelEngine::Message::msgTime
const Time & msgTime() const
Definition yatengine.h:490
TelEngine::Message::dispatched
virtual void dispatched(bool accepted)
TelEngine::Message::msgTimeEnqueue
const Time & msgTimeEnqueue() const
Definition yatengine.h:506
TelEngine::Message::operator=
Message & operator=(const char *value)
Definition yatengine.h:528
TelEngine::Message::~Message
~Message()
TelEngine::Message::userData
void userData(RefObject *data)
TelEngine::Message::Message
Message(const Message &original)
TelEngine::Message::msgTimeDispatch
Time & msgTimeDispatch()
Definition yatengine.h:514
TelEngine::Message::broadcast
bool broadcast() const
Definition yatengine.h:469
TelEngine::Message::retValue
String & retValue()
Definition yatengine.h:423
TelEngine::Message::msgTimeEnqueue
Time & msgTimeEnqueue()
Definition yatengine.h:498
TelEngine::Message::retValue
const String & retValue() const
Definition yatengine.h:430
TelEngine::Message::userObject
void * userObject(const String &name) const
Definition yatengine.h:453
TelEngine::Message::decode
int decode(const char *str, String &id)
TelEngine::Message::msgTimeDispatch
const Time & msgTimeDispatch() const
Definition yatengine.h:522
TelEngine::Message::encode
String encode(const char *id) const
TelEngine::Message::Message
Message(const char *name, const char *retval=0, bool broadcast=false)
TelEngine::Message::encode
String encode(bool received, const char *id) const
TelEngine::Message::Message
Message(const Message &original, bool broadcast)
TelEngine::Plugin
Plugin support.
Definition yatengine.h:1279
TelEngine::Plugin::getObject
virtual void * getObject(const String &name) const
TelEngine::Plugin::toString
virtual const String & toString() const
Definition yatengine.h:1299
TelEngine::Plugin::~Plugin
virtual ~Plugin()
TelEngine::Plugin::earlyInit
bool earlyInit() const
Definition yatengine.h:1339
TelEngine::Plugin::initialize
virtual void initialize()=0
TelEngine::Plugin::name
const String & name() const
Definition yatengine.h:1325
TelEngine::Plugin::Plugin
Plugin(const char *name, bool earlyInit=false)
TelEngine::Plugin::isBusy
virtual bool isBusy() const
Definition yatengine.h:1318
TelEngine::Plugin::objectsCounter
NamedCounter * objectsCounter() const
Definition yatengine.h:1332
TelEngine::SharedVars
Atomic access and operations to shared variables.
Definition yatengine.h:252
TelEngine::SharedVars::clear
void clear(const String &name)
TelEngine::SharedVars::dec
uint64_t dec(const String &name, uint64_t wrap=0)
TelEngine::SharedVars::SharedVars
SharedVars(const char *name=0)
Definition yatengine.h:258
TelEngine::SharedVars::create
bool create(const String &name, const char *val=0)
TelEngine::SharedVars::set
void set(const String &name, const char *val)
TelEngine::SharedVars::clearAll
void clearAll()
TelEngine::SharedVars::getList
static bool getList(RefPointer< SharedVars > &dest, const String &name)
TelEngine::SharedVars::add
uint64_t add(const String &name, uint64_t val, uint64_t wrap=0)
TelEngine::SharedVars::get
void get(const String &name, String &rval)
TelEngine::SharedVars::exists
bool exists(const String &name)
TelEngine::SharedVars::toString
virtual const String & toString() const
Definition yatengine.h:356
TelEngine::SharedVars::inc
uint64_t inc(const String &name, uint64_t wrap=0)
TelEngine::SharedVars::copy
void copy(NamedList &dest, const String &prefix=String::empty(), bool skipPrefix=true, bool replace=false)
Definition yatengine.h:343
TelEngine::SharedVars::sub
uint64_t sub(const String &name, uint64_t val, uint64_t wrap=0)
Thread
Thread support class.
Definition yateclass.h:10192
Time
A time holding class.
Definition yateclass.h:5764
Time::now
static u_int64_t now()
YAtomicNumber< int >
TelEngine
Definition yatemime.h:34
TelEngine::EngineLoop
int(* EngineLoop)()
Definition yatengine.h:1408
TelEngine::UNLOAD_PLUGIN
bool UNLOAD_PLUGIN(bool unloadNow)
TelEngine::INIT_PLUGIN
void INIT_PLUGIN(class pclass)
TokenDict
Definition yateclass.h:891