/usr/include/tango/devapi.h is in libtango8-dev 8.1.2c+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 | //////////////////////////////////////////////////////////////////
//
// devapi.h - include file for TANGO device api
//
//
// Copyright (C) : 2004,2005,2006,2007,2008,2009,2010,2011,2012,2013
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This file is part of Tango.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Revision: 22213 $
//
///////////////////////////////////////////////////////////////
#ifndef _DEVAPI_H
#define _DEVAPI_H
#include <tango.h>
#include <tango_const.h>
#include <apiexcept.h>
#include <cbthread.h>
#include <lockthread.h>
#include <readers_writers_lock.h>
#include <bitset>
using namespace std;
namespace Tango {
//
// forward declarations
//
class DeviceData;
class DeviceAttribute;
class DbDevice;
class DbAttribute;
class DbDatum;
class DbDevImportInfo;
class Database;
class AsynReq;
class NotifdEventConsumer;
class ZmqEventConsumer;
class CallBack;
class AttributeProxy;
class TangoMonitor;
//
// Some typedef
//
typedef vector<DbDatum> DbData;
typedef union
{
TangoSys_Pid LockerPid;
unsigned long UUID[4];
}LockerId;
struct LockerInfo
{
LockerLanguage ll;
LockerId li;
string locker_host;
string locker_class;
};
struct LockingThread
{
TangoMonitor *mon;
LockThCmd *shared;
LockThread *l_thread;
};
struct _DevCommandInfo
{
string cmd_name;
long cmd_tag;
long in_type;
long out_type;
string in_type_desc;
string out_type_desc;
bool operator==(const _DevCommandInfo &);
};
struct AttributeDimension
{
long dim_x;
long dim_y;
};
typedef struct _DevCommandInfo DevCommandInfo;
struct _CommandInfo : public DevCommandInfo
{
Tango::DispLevel disp_level;
bool operator==(const _CommandInfo &);
};
typedef _CommandInfo CommandInfo;
typedef vector<CommandInfo> CommandInfoList;
struct _DeviceInfo
{
string dev_class;
string server_id;
string server_host;
long server_version;
string doc_url;
string dev_type;
};
typedef _DeviceInfo DeviceInfo;
struct _DeviceAttributeConfig
{
string name;
AttrWriteType writable;
AttrDataFormat data_format;
int data_type;
int max_dim_x;
int max_dim_y;
string description;
string label;
string unit;
string standard_unit;
string display_unit;
string format;
string min_value;
string max_value;
string min_alarm;
string max_alarm;
string writable_attr_name;
vector<string> extensions;
bool operator==(const _DeviceAttributeConfig &);
};
typedef struct _DeviceAttributeConfig DeviceAttributeConfig;
struct _AttributeInfo : public DeviceAttributeConfig
{
Tango::DispLevel disp_level;
friend ostream &operator<<(ostream &,_AttributeInfo &);
bool operator==(const _AttributeInfo &);
};
typedef _AttributeInfo AttributeInfo;
typedef vector<AttributeInfo> AttributeInfoList;
struct _AttributeAlarmInfo
{
string min_alarm;
string max_alarm;
string min_warning;
string max_warning;
string delta_t;
string delta_val;
vector<string> extensions;
};
struct _ChangeEventInfo
{
string rel_change;
string abs_change;
vector<string> extensions;
};
struct _PeriodicEventInfo
{
string period;
vector<string> extensions;
};
struct _ArchiveEventInfo
{
string archive_rel_change;
string archive_abs_change;
string archive_period;
vector<string> extensions;
};
typedef _ChangeEventInfo ChangeEventInfo;
typedef _PeriodicEventInfo PeriodicEventInfo;
typedef _ArchiveEventInfo ArchiveEventInfo;
struct _AttributeEventInfo
{
ChangeEventInfo ch_event;
PeriodicEventInfo per_event;
ArchiveEventInfo arch_event;
};
typedef _AttributeAlarmInfo AttributeAlarmInfo;
typedef _AttributeEventInfo AttributeEventInfo;
struct _AttributeInfoEx : public AttributeInfo
{
AttributeAlarmInfo alarms;
AttributeEventInfo events;
vector<string> sys_extensions;
_AttributeInfoEx & operator=(AttributeConfig_2 *);
_AttributeInfoEx & operator=(AttributeConfig_3 *);
friend ostream &operator<<(ostream &,_AttributeInfoEx &);
bool operator==(const _AttributeInfoEx &);
};
typedef _AttributeInfoEx AttributeInfoEx;
typedef vector<AttributeInfoEx> AttributeInfoListEx;
//
// Can't use CALLBACK (without _) in the following enum because it's a
// pre-defined type on Windows....
//
enum asyn_req_type
{
POLLING,
CALL_BACK,
ALL_ASYNCH
};
enum cb_sub_model
{
PUSH_CALLBACK,
PULL_CALLBACK
};
//
// Some define
//
#define CONNECTION_OK 1
#define CONNECTION_NOTOK 0
#define PROT_SEP "://"
#define TACO_PROTOCOL "taco"
#define TANGO_PROTOCOL "tango"
#define MODIFIER '#'
#define DBASE_YES "dbase=yes"
#define DBASE_NO "dbase=no"
#define MODIFIER_DBASE_NO "#dbase=no"
#define HOST_SEP ':'
#define PORT_SEP '/'
#define DEV_NAME_FIELD_SEP '/'
#define RES_SEP "->"
#define DEVICE_SEP '/'
#define FROM_IOR "IOR"
#define NOT_USED "Unused"
/****************************************************************************************
* *
* The ApiUtil class *
* ----------------- *
* *
***************************************************************************************/
class ApiUtil
{
public:
TANGO_IMP_EXP static ApiUtil *instance();
CORBA::ORB_ptr get_orb() {return CORBA::ORB::_duplicate(_orb);}
void set_orb(CORBA::ORB_ptr orb_in) {_orb = orb_in;}
void create_orb();
int get_db_ind();
int get_db_ind(string &host,int port);
vector<Database *> &get_db_vect() {return db_vect;}
bool in_server() {return in_serv;}
void in_server(bool serv) {in_serv = serv;}
TangoSys_Pid get_client_pid() {return ext->cl_pid;}
void clean_locking_threads(bool clean=true);
bool is_lock_exit_installed() {omni_mutex_lock guard(lock_th_map);return exit_lock_installed;}
void set_lock_exit_installed(bool in) {omni_mutex_lock guard(lock_th_map);exit_lock_installed = in;}
bool need_reset_already_flag() {return reset_already_executed_flag;}
void need_reset_already_flag(bool in) {reset_already_executed_flag = in;}
TANGO_IMP_EXP static inline void cleanup()
{if (_instance != NULL){delete _instance;_instance=NULL;}}
TANGO_IMP_EXP static inline bool _is_instance_null()
{return _instance == NULL;}
//
// Utilities methods
//
TANGO_IMP_EXP static int get_env_var(const char *,string &);
int get_user_connect_timeout() {return ext->user_connect_timeout;}
DevLong get_user_sub_hwm() {return ext->user_sub_hwm;}
void set_event_buffer_hwm(DevLong val) {if (ext->user_sub_hwm == -1)ext->user_sub_hwm=val;}
void get_ip_from_if(vector<string> &);
void print_error_message(const char *);
//
// EventConsumer related methods
//
void create_notifd_event_consumer();
void create_zmq_event_consumer();
bool is_notifd_event_consumer_created() {return ext->notifd_event_consumer != NULL;}
NotifdEventConsumer *get_notifd_event_consumer();
bool is_zmq_event_consumer_created() {return ext->zmq_event_consumer != NULL;}
ZmqEventConsumer *get_zmq_event_consumer();
//
// Asynchronous methods
//
void get_asynch_replies();
void get_asynch_replies(long);
AsynReq *get_pasyn_table() {return asyn_p_table;}
void set_asynch_cb_sub_model(cb_sub_model);
cb_sub_model get_asynch_cb_sub_model() {return auto_cb;}
size_t pending_asynch_call(asyn_req_type ty)
{if (ty==POLLING)return asyn_p_table->get_request_nb();
else if (ty==CALL_BACK)return asyn_p_table->get_cb_request_nb();
else return (asyn_p_table->get_request_nb()+asyn_p_table->get_cb_request_nb());}
//
// Conv, between AttributeValuexxx and DeviceAttribute
//
static void attr_to_device(const AttributeValue *,const AttributeValue_3 *,long,DeviceAttribute *);
static void attr_to_device(const AttributeValue_4 *,long,DeviceAttribute *);
static void device_to_attr(const DeviceAttribute &,AttributeValue_4 &);
static void device_to_attr(const DeviceAttribute &,AttributeValue &,string &);
protected:
ApiUtil();
virtual ~ApiUtil();
vector<Database *> db_vect;
omni_mutex the_mutex;
CORBA::ORB_ptr _orb;
bool in_serv;
cb_sub_model auto_cb;
CbThreadCmd cb_thread_cmd;
CallBackThread *cb_thread_ptr;
AsynReq *asyn_p_table;
public:
omni_mutex lock_th_map;
map<string,LockingThread> lock_threads;
private:
class ApiUtilExt
{
public:
ApiUtilExt():notifd_event_consumer(NULL),cl_pid(0),user_connect_timeout(-1),
zmq_event_consumer(NULL),user_sub_hwm(-1) {};
NotifdEventConsumer *notifd_event_consumer;
TangoSys_Pid cl_pid;
int user_connect_timeout;
ZmqEventConsumer *zmq_event_consumer;
vector<string> host_ip_adrs;
DevLong user_sub_hwm;
};
TANGO_IMP static ApiUtil *_instance;
static omni_mutex inst_mutex;
bool exit_lock_installed;
bool reset_already_executed_flag;
#ifdef HAS_UNIQUE_PTR
unique_ptr<ApiUtilExt> ext;
#else
ApiUtilExt *ext; // Class extension
#endif
};
/****************************************************************************************
* *
* The DeviceData class *
* -------------------- *
* *
***************************************************************************************/
class DeviceData
{
public :
//
// constructor methods
//
enum except_flags
{
isempty_flag,
wrongtype_flag,
numFlags
};
DeviceData();
DeviceData(const DeviceData &);
DeviceData & operator=(const DeviceData &);
#ifdef HAS_RVALUE
DeviceData(DeviceData &&);
DeviceData & operator=(DeviceData &&);
#endif
~DeviceData();
bool is_empty() {return any_is_null();}
void exceptions(bitset<numFlags> fl) {exceptions_flags = fl;}
bitset<numFlags> exceptions() {return exceptions_flags;}
void reset_exceptions(except_flags fl) {exceptions_flags.reset((size_t)fl);}
void set_exceptions(except_flags fl) {exceptions_flags.set((size_t)fl);}
int get_type();
CORBA::Any_var any;
//
// insert methods for native C++ types
//
void operator << (bool datum) {any <<= CORBA::Any::from_boolean(datum);}
void operator << (short datum) {any <<= datum;}
void operator << (unsigned short datum) {any <<= datum;}
void operator << (DevLong datum) {any <<= datum;}
void operator << (DevULong datum) {any <<= datum;}
void operator << (DevLong64 datum) {any <<= datum;}
void operator << (DevULong64 datum) {any <<= datum;}
void operator << (float datum) {any <<= datum;}
void operator << (double datum) {any <<= datum;}
void operator << (char *&datum) {any <<= datum;}
void operator << (const char *&datum) {any <<= datum;}
void operator << (string &datum) {any <<= datum.c_str();}
void operator << (vector<unsigned char>&);
void operator << (vector<string>&);
void operator << (vector<short>&);
void operator << (vector<unsigned short>&);
void operator << (vector<DevLong> &);
void operator << (vector<DevULong> &);
void operator << (vector<DevLong64> &);
void operator << (vector<DevULong64> &);
void operator << (vector<float>&);
void operator << (vector<double>&);
void operator << (DevState datum) {(any.inout()) <<= datum;}
void operator << (DevEncoded &datum) {(any.inout()) <<= datum;}
void insert(vector<DevLong>&, vector<string>&);
void insert(vector<double>&, vector<string>&);
void insert(const string &,vector<unsigned char>&);
void insert(const char *,DevVarCharArray *);
void insert(const char *,unsigned char *,unsigned int);
//
// insert methods for TANGO CORBA sequence types
//
inline void operator << (DevVarCharArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarShortArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarUShortArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarLongArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarLong64Array *datum) { any.inout() <<= datum;}
inline void operator << (DevVarULongArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarULong64Array* datum) { any.inout() <<= datum;}
inline void operator << (DevVarFloatArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarDoubleArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarStringArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarLongStringArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarDoubleStringArray* datum) { any.inout() <<= datum;}
inline void operator << (DevVarCharArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarShortArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarUShortArray datum) { any.inout() <<= datum;}
inline void operator << (DevVarLongArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarLong64Array &datum) { any.inout() <<= datum;}
inline void operator << (DevVarULongArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarULong64Array &datum) { any.inout() <<= datum;}
inline void operator << (DevVarFloatArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarDoubleArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarStringArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarLongStringArray &datum) { any.inout() <<= datum;}
inline void operator << (DevVarDoubleStringArray &datum) { any.inout() <<= datum;}
//
// extract methods for native C++ types
//
bool operator >> (bool&);
bool operator >> (short&);
bool operator >> (unsigned short&);
bool operator >> (DevLong&);
bool operator >> (DevULong&);
bool operator >> (DevLong64&);
bool operator >> (DevULong64&);
bool operator >> (float&);
bool operator >> (double&);
bool operator >> (const char*&);
bool operator >> (string&);
bool operator >> (vector<unsigned char>&);
bool operator >> (vector<string>&);
bool operator >> (vector<short>&);
bool operator >> (vector<unsigned short>&);
bool operator >> (vector<DevLong>&);
bool operator >> (vector<DevULong>&);
bool operator >> (vector<DevLong64>&);
bool operator >> (vector<DevULong64>&);
bool operator >> (vector<float>&);
bool operator >> (vector<double>&);
bool operator >> (DevState&);
bool extract(vector<DevLong>&, vector<string>&);
bool extract(vector<double>&, vector<string>&);
bool extract(const char *&,const unsigned char *&,unsigned int &);
bool extract(string &,vector<unsigned char> &);
//
// extract methods for TANGO CORBA sequence types
//
bool operator >> (const DevVarCharArray* &datum);
bool operator >> (const DevVarShortArray* &datum);
bool operator >> (const DevVarUShortArray* &datum);
bool operator >> (const DevVarLongArray* &datum);
bool operator >> (const DevVarLong64Array* &datum);
bool operator >> (const DevVarULongArray* &datum);
bool operator >> (const DevVarULong64Array* &datum);
bool operator >> (const DevVarFloatArray* &datum);
bool operator >> (const DevVarDoubleArray* &datum);
bool operator >> (const DevVarStringArray* &datum);
bool operator >> (const DevVarLongStringArray* &datum);
bool operator >> (const DevVarDoubleStringArray* &datum);
bool operator >> (const DevEncoded* &datum);
bool operator >> (DevEncoded &datum);
friend ostream &operator<<(ostream &,DeviceData &);
protected :
bool any_is_null();
bitset<numFlags> exceptions_flags;
private:
class DeviceDataExt
{
public:
DeviceDataExt() {};
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<DeviceDataExt> ext;
#else
DeviceDataExt *ext; // Class extension
#endif
};
/****************************************************************************************
* *
* The DeviceAttribute class *
* ------------------------- *
* *
***************************************************************************************/
class DeviceAttribute
{
public :
//
// constructor methods
//
enum except_flags
{
isempty_flag = 0,
wrongtype_flag,
failed_flag,
unknown_format_flag,
numFlags
};
DeviceAttribute();
DeviceAttribute(const DeviceAttribute&);
DeviceAttribute & operator=(const DeviceAttribute &);
#ifdef HAS_RVALUE
DeviceAttribute(DeviceAttribute &&);
DeviceAttribute & operator=(DeviceAttribute &&);
#endif
void deep_copy(const DeviceAttribute &);
DeviceAttribute(AttributeValue);
DeviceAttribute(string&, short);
DeviceAttribute(string&, DevLong);
DeviceAttribute(string&, double);
DeviceAttribute(string&, string&);
DeviceAttribute(string&, const char *);
DeviceAttribute(string&, float);
DeviceAttribute(string&, bool);
DeviceAttribute(string&, unsigned short);
DeviceAttribute(string&, unsigned char);
DeviceAttribute(string&, DevLong64);
DeviceAttribute(string&, DevULong);
DeviceAttribute(string&, DevULong64);
DeviceAttribute(string&, DevState);
DeviceAttribute(string&, DevEncoded &);
DeviceAttribute(string&, vector<short> &);
DeviceAttribute(string&, vector<DevLong> &);
DeviceAttribute(string&, vector<double> &);
DeviceAttribute(string&, vector<string> &);
DeviceAttribute(string&, vector<float> &);
DeviceAttribute(string&, vector<bool> &);
DeviceAttribute(string&, vector<unsigned short> &);
DeviceAttribute(string&, vector<unsigned char> &);
DeviceAttribute(string&, vector<DevLong64> &);
DeviceAttribute(string&, vector<DevULong> &);
DeviceAttribute(string&, vector<DevULong64> &);
DeviceAttribute(string&, vector<DevState> &);
DeviceAttribute(string&, vector<short> &,int,int);
DeviceAttribute(string&, vector<DevLong> &,int,int);
DeviceAttribute(string&, vector<double> &,int,int);
DeviceAttribute(string&, vector<string> &,int,int);
DeviceAttribute(string&, vector<float> &,int,int);
DeviceAttribute(string&, vector<bool> &,int,int);
DeviceAttribute(string&, vector<unsigned short> &,int,int);
DeviceAttribute(string&, vector<unsigned char> &,int,int);
DeviceAttribute(string&, vector<DevLong64> &,int,int);
DeviceAttribute(string&, vector<DevULong> &,int,int);
DeviceAttribute(string&, vector<DevULong64> &,int,int);
DeviceAttribute(string&, vector<DevState> &,int,int);
DeviceAttribute(const char *, short);
DeviceAttribute(const char *, DevLong);
DeviceAttribute(const char *, double);
DeviceAttribute(const char *, string&);
DeviceAttribute(const char *, const char *);
DeviceAttribute(const char *, float);
DeviceAttribute(const char *, bool);
DeviceAttribute(const char *, unsigned short);
DeviceAttribute(const char *, unsigned char);
DeviceAttribute(const char *, DevLong64);
DeviceAttribute(const char *, DevULong);
DeviceAttribute(const char *, DevULong64);
DeviceAttribute(const char *, DevState);
DeviceAttribute(const char *, DevEncoded &);
DeviceAttribute(const char *, vector<short> &);
DeviceAttribute(const char *, vector<DevLong> &);
DeviceAttribute(const char *, vector<double> &);
DeviceAttribute(const char *, vector<string> &);
DeviceAttribute(const char *, vector<float> &);
DeviceAttribute(const char *, vector<bool> &);
DeviceAttribute(const char *, vector<unsigned short> &);
DeviceAttribute(const char *, vector<unsigned char> &);
DeviceAttribute(const char *, vector<DevLong64> &);
DeviceAttribute(const char *, vector<DevULong> &);
DeviceAttribute(const char *, vector<DevULong64> &);
DeviceAttribute(const char *, vector<DevState> &);
DeviceAttribute(const char *, vector<short> &,int,int);
DeviceAttribute(const char *, vector<DevLong> &,int,int);
DeviceAttribute(const char *, vector<double> &,int,int);
DeviceAttribute(const char *, vector<string> &,int,int);
DeviceAttribute(const char *, vector<float> &,int,int);
DeviceAttribute(const char *, vector<bool> &,int,int);
DeviceAttribute(const char *, vector<unsigned short> &,int,int);
DeviceAttribute(const char *, vector<unsigned char> &,int,int);
DeviceAttribute(const char *, vector<DevLong64> &,int,int);
DeviceAttribute(const char *, vector<DevULong> &,int,int);
DeviceAttribute(const char *, vector<DevULong64> &,int,int);
DeviceAttribute(const char *, vector<DevState> &,int,int);
~DeviceAttribute();
AttrQuality quality;
AttrDataFormat data_format;
string name;
int dim_x;
int dim_y;
TimeVal time;
string &get_name() {return name;}
AttrQuality &get_quality() {return quality;}
int get_dim_x() {return dim_x;}
int get_dim_y() {return dim_y;}
int get_written_dim_x() {return ext->w_dim_x;}
int get_written_dim_y() {return ext->w_dim_y;}
AttributeDimension get_r_dimension();
AttributeDimension get_w_dimension();
long get_nb_read();
long get_nb_written();
int get_type();
AttrDataFormat get_data_format();
TimeVal &get_date() {return time;}
void set_name(string &na) {name = na;}
void set_name(const char *na) {string str(na);name = str;}
bool is_empty();
bool has_failed() {DevErrorList *tmp;if ((tmp=ext->err_list.operator->())==NULL)return false;
else{if (tmp->length() != 0)return true;else return false;}}
const DevErrorList &get_err_stack() {return ext->err_list.in();}
DevVarEncodedArray_var &get_Encoded_data() const {return ext->EncodedSeq;}
DevVarLong64Array_var &get_Long64_data() const {return ext->Long64Seq;}
DevVarULongArray_var &get_ULong_data() const {return ext->ULongSeq;}
DevVarULong64Array_var &get_ULong64_data() const {return ext->ULong64Seq;}
DevVarStateArray_var &get_State_data() const {return ext->StateSeq;}
DevErrorList_var &get_error_list() {return ext->err_list;}
void set_w_dim_x(int val) {ext->w_dim_x = val;}
void set_w_dim_y(int val) {ext->w_dim_y = val;}
void set_err_list(DevErrorList *ptr) {ext->err_list = ptr;}
void set_error_list(DevErrorList *ptr) {ext->err_list = ptr;}
void set_Encoded_data(DevVarEncodedArray *ptr) {ext->EncodedSeq = ptr;}
void set_Long64_data(DevVarLong64Array *ptr) {ext->Long64Seq = ptr;}
void set_ULong_data(DevVarULongArray *ptr) {ext->ULongSeq = ptr;}
void set_ULong64_data(DevVarULong64Array *ptr) {ext->ULong64Seq = ptr;}
void set_State_data(DevVarStateArray *ptr) {ext->StateSeq = ptr;}
void exceptions(bitset<numFlags> fl) {exceptions_flags = fl;}
bitset<numFlags> exceptions() {return exceptions_flags;}
void reset_exceptions(except_flags fl) {exceptions_flags.reset((size_t)fl);}
void set_exceptions(except_flags fl) {exceptions_flags.set((size_t)fl);}
DevVarLongArray_var LongSeq;
DevVarShortArray_var ShortSeq;
DevVarDoubleArray_var DoubleSeq;
DevVarStringArray_var StringSeq;
DevVarFloatArray_var FloatSeq;
DevVarBooleanArray_var BooleanSeq;
DevVarUShortArray_var UShortSeq;
DevVarCharArray_var UCharSeq;
//
// For the state attribute
//
DevState d_state;
bool d_state_filled;
//
// Insert operators for C++ types
//
void operator << (short);
void operator << (DevLong);
void operator << (double);
void operator << (string &);
void operator << (float);
void operator << (bool);
void operator << (unsigned short);
void operator << (unsigned char);
void operator << (DevLong64);
void operator << (DevULong);
void operator << (DevULong64);
void operator << (DevState);
void operator << (DevEncoded &);
void operator << (DevString);
void operator << (const char *);
void operator << (vector<short> &);
void operator << (vector<DevLong> &);
void operator << (vector<double> &);
void operator << (vector<string> &);
void operator << (vector<float> &);
void operator << (vector<bool> &);
void operator << (vector<unsigned short> &);
void operator << (vector<unsigned char> &);
void operator << (vector<DevLong64> &);
void operator << (vector<DevULong> &);
void operator << (vector<DevULong64> &);
void operator << (vector<DevState> &);
void operator << (const DevVarShortArray &datum);
void operator << (const DevVarLongArray &datum);
void operator << (const DevVarDoubleArray &datum);
void operator << (const DevVarStringArray &datum);
void operator << (const DevVarFloatArray &datum);
void operator << (const DevVarBooleanArray &datum);
void operator << (const DevVarUShortArray &datum);
void operator << (const DevVarCharArray &datum);
void operator << (const DevVarLong64Array &datum);
void operator << (const DevVarULongArray &datum);
void operator << (const DevVarULong64Array &datum);
void operator << (const DevVarStateArray &datum);
void operator << (DevVarShortArray *datum);
void operator << (DevVarLongArray *datum);
void operator << (DevVarDoubleArray *datum);
void operator << (DevVarStringArray *datum);
void operator << (DevVarFloatArray *datum);
void operator << (DevVarBooleanArray *datum);
void operator << (DevVarUShortArray *datum);
void operator << (DevVarCharArray *datum);
void operator << (DevVarLong64Array *datum);
void operator << (DevVarULongArray *datum);
void operator << (DevVarULong64Array *datum);
void operator << (DevVarStateArray *datum);
//
// Insert methods
//
void insert(vector<short> &,int,int);
void insert(vector<DevLong> &,int,int);
void insert(vector<double> &,int,int);
void insert(vector<string> &,int,int);
void insert(vector<float> &,int,int);
void insert(vector<bool> &,int,int);
void insert(vector<unsigned short> &,int,int);
void insert(vector<unsigned char> &,int,int);
void insert(vector<DevLong64> &,int,int);
void insert(vector<DevULong> &,int,int);
void insert(vector<DevULong64> &,int,int);
void insert(vector<DevState> &,int,int);
void insert(const DevVarShortArray &datum,int,int);
void insert(const DevVarLongArray &datum,int,int);
void insert(const DevVarDoubleArray &datum,int,int);
void insert(const DevVarStringArray &datum,int,int);
void insert(const DevVarFloatArray &datum,int,int);
void insert(const DevVarBooleanArray &datum,int,int);
void insert(const DevVarUShortArray &datum,int,int);
void insert(const DevVarCharArray &datum,int,int);
void insert(const DevVarLong64Array &datum,int,int);
void insert(const DevVarULongArray &datum,int,int);
void insert(const DevVarULong64Array &datum,int,int);
void insert(const DevVarStateArray &datum,int,int);
void insert(DevVarShortArray *datum,int,int);
void insert(DevVarLongArray *datum,int,int);
void insert(DevVarDoubleArray *datum,int,int);
void insert(DevVarStringArray *datum,int,int);
void insert(DevVarFloatArray *datum,int,int);
void insert(DevVarBooleanArray *datum,int,int);
void insert(DevVarUShortArray *datum,int,int);
void insert(DevVarCharArray *datum,int,int);
void insert(DevVarLong64Array *datum,int,int);
void insert(DevVarULongArray *datum,int,int);
void insert(DevVarULong64Array *datum,int,int);
void insert(DevVarStateArray *datum,int,int);
void insert(char *&,unsigned char *&,unsigned int); // Deprecated. For compatibility purpose
void insert(const char *,unsigned char *,unsigned int);
void insert(const string &,vector<unsigned char> &);
void insert(string &,vector<unsigned char> &); // Deprecated. For compatibility purpose
void insert(const char *,DevVarCharArray *);
//
// Extract operators for C++ types
//
bool operator >> (short &);
bool operator >> (DevLong &);
bool operator >> (double &);
bool operator >> (string&);
bool operator >> (float &);
bool operator >> (bool &);
bool operator >> (unsigned short &);
bool operator >> (unsigned char &);
bool operator >> (DevLong64 &);
bool operator >> (DevULong &);
bool operator >> (DevULong64 &);
bool operator >> (DevState &);
bool operator >> (DevEncoded &);
bool operator >> (vector<string>&);
bool operator >> (vector<short>&);
bool operator >> (vector<DevLong>&);
bool operator >> (vector<double>&);
bool operator >> (vector<float>&);
bool operator >> (vector<bool>&);
bool operator >> (vector<unsigned short>&);
bool operator >> (vector<unsigned char>&);
bool operator >> (vector<DevLong64>&);
bool operator >> (vector<DevULong>&);
bool operator >> (vector<DevULong64>&);
bool operator >> (vector<DevState>&);
bool operator >> (DevVarShortArray* &datum);
bool operator >> (DevVarLongArray* &datum);
bool operator >> (DevVarDoubleArray* &datum);
bool operator >> (DevVarStringArray* &datum);
bool operator >> (DevVarFloatArray* &datum);
bool operator >> (DevVarBooleanArray* &datum);
bool operator >> (DevVarUShortArray* &datum);
bool operator >> (DevVarCharArray* &datum);
bool operator >> (DevVarLong64Array * &datum);
bool operator >> (DevVarULongArray * &datum);
bool operator >> (DevVarULong64Array * &datum);
bool operator >> (DevVarStateArray * &datum);
bool operator >> (DevVarEncodedArray *&datum);
//
// Extract_xxx methods
//
bool extract_read (vector<string>&);
bool extract_read (vector<short>&);
bool extract_read (vector<DevLong>&);
bool extract_read (vector<double>&);
bool extract_read (vector<float>&);
bool extract_read (vector<bool>&);
bool extract_read (vector<unsigned short>&);
bool extract_read (vector<unsigned char>&);
bool extract_read (vector<DevLong64>&);
bool extract_read (vector<DevULong>&);
bool extract_read (vector<DevULong64>&);
bool extract_read (vector<DevState>&);
bool extract_read (string &,vector<unsigned char> &);
bool extract_set (vector<string>&);
bool extract_set (vector<short>&);
bool extract_set (vector<DevLong>&);
bool extract_set (vector<double>&);
bool extract_set (vector<float>&);
bool extract_set (vector<bool>&);
bool extract_set (vector<unsigned short>&);
bool extract_set (vector<unsigned char>&);
bool extract_set (vector<DevLong64>&);
bool extract_set (vector<DevULong>&);
bool extract_set (vector<DevULong64>&);
bool extract_set (vector<DevState>&);
bool extract_set (string &,vector<unsigned char> &);
bool extract(char *&,unsigned char *&,unsigned int &); // Deprecated, for compatibility purpose
bool extract(const char *&,unsigned char *&,unsigned int &);
bool extract(string &,vector<unsigned char> &);
friend ostream &operator<<(ostream &,DeviceAttribute &);
protected :
bitset<numFlags> exceptions_flags;
void del_mem(int);
bool check_for_data();
bool check_wrong_type_exception();
int check_set_value_size(int seq_length);
protected:
class DeviceAttributeExt
{
public:
DeviceAttributeExt():w_dim_x(0),w_dim_y(0) {};
DeviceAttributeExt & operator=(const DeviceAttributeExt &);
void deep_copy(const DeviceAttributeExt &);
DevErrorList_var err_list;
long w_dim_x;
long w_dim_y;
DevVarLong64Array_var Long64Seq;
DevVarULongArray_var ULongSeq;
DevVarULong64Array_var ULong64Seq;
DevVarStateArray_var StateSeq;
DevVarEncodedArray_var EncodedSeq;
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<DeviceAttributeExt> ext;
#else
DeviceAttributeExt *ext; // Class extension
#endif
};
/****************************************************************************************
* *
* The xxxDataHistory classes *
* -------------------------- *
* *
***************************************************************************************/
class DeviceDataHistory: public DeviceData
{
public :
//
// constructor methods
//
DeviceDataHistory();
DeviceDataHistory(int, int *,DevCmdHistoryList *);
DeviceDataHistory(const DeviceDataHistory &);
DeviceDataHistory & operator=(const DeviceDataHistory &);
#ifdef HAS_RVALUE
DeviceDataHistory(DeviceDataHistory &&);
DeviceDataHistory &operator=(DeviceDataHistory &&);
#endif
~DeviceDataHistory();
bool has_failed() {return fail;}
TimeVal &get_date() {return time;}
const DevErrorList &get_err_stack() {return err.in();}
friend ostream &operator<<(ostream &,DeviceDataHistory &);
// Three following methods for compatibility with older release
bool failed() {return fail;}
void failed(bool val) {fail = val;}
void set_date(TimeVal &tv) {time = tv;}
TimeVal &date() {return time;}
const DevErrorList &errors() {return err.in();}
void errors(DevErrorList_var &del) {err = del;}
protected:
bool fail;
TimeVal time;
DevErrorList_var err;
DevCmdHistoryList *seq_ptr;
int *ref_ctr_ptr;
private:
class DeviceDataHistoryExt
{
public:
DeviceDataHistoryExt() {};
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<DeviceDataHistoryExt> ext_hist;
#else
DeviceDataHistoryExt *ext_hist; // Class extension
#endif
};
typedef vector<DeviceDataHistory> DeviceDataHistoryList;
class DeviceAttributeHistory: public DeviceAttribute
{
public :
//
// constructor methods
//
DeviceAttributeHistory();
DeviceAttributeHistory(int, DevAttrHistoryList_var &);
DeviceAttributeHistory(int, DevAttrHistoryList_3_var &);
DeviceAttributeHistory(const DeviceAttributeHistory &);
DeviceAttributeHistory & operator=(const DeviceAttributeHistory &);
#ifdef HAS_RVALUE
DeviceAttributeHistory(DeviceAttributeHistory &&);
DeviceAttributeHistory &operator=(DeviceAttributeHistory &&);
#endif
~DeviceAttributeHistory();
bool has_failed() {return fail;}
// Three following methods for compatibility with older release
bool failed() {return fail;}
void failed(bool val) {fail = val;}
TimeVal &date() {return time;}
// const DevErrorList &errors() {return err;}
friend ostream &operator<<(ostream &,DeviceAttributeHistory &);
protected:
bool fail;
char compatibility_padding[16];
private:
class DeviceAttributeHistoryExt
{
public:
DeviceAttributeHistoryExt() {};
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<DeviceAttributeHistoryExt> ext_hist;
#else
DeviceAttributeHistoryExt *ext_hist; // Class extension
#endif
};
/****************************************************************************************
* *
* The Connection class *
* -------------------- *
* *
***************************************************************************************/
class Connection
{
protected :
bool dbase_used; // Dev. with database
bool from_env_var; // DB from TANGO_HOST
string host; // DS host (if dbase_used=false)
string port; // DS port (if dbase_used=false)
int port_num; // DS port (as number)
string db_host; // DB host
string db_port; // DB port
int db_port_num; // DB port (as number)
string ior;
long pasyn_ctr;
long pasyn_cb_ctr;
Tango::Device_var device;
Tango::Device_2_var device_2;
int timeout;
int connection_state;
int version;
Tango::DevSource source;
bool check_acc;
AccessControlType access;
virtual string get_corba_name(bool)=0;
virtual string build_corba_name()=0;
virtual int get_lock_ctr()=0;
virtual void set_lock_ctr(int)=0;
DeviceData redo_synch_cmd(TgRequest &);
int get_env_var(const char *,string &);
int get_env_var_from_file(string &,const char *,string &);
void set_connection_state(int);
void check_and_reconnect();
void check_and_reconnect(Tango::DevSource &);
void check_and_reconnect(Tango::AccessControlType &);
void check_and_reconnect(Tango::DevSource &,Tango::AccessControlType &);
long add_asyn_request(CORBA::Request_ptr,TgRequest::ReqType);
void remove_asyn_request(long);
void add_asyn_cb_request(CORBA::Request_ptr,CallBack *,Connection *,TgRequest::ReqType);
void remove_asyn_cb_request(Connection *,CORBA::Request_ptr);
long get_pasyn_cb_ctr();
class ConnectionExt
{
public:
ConnectionExt():tr_reco(true),prev_failed(false),prev_failed_t0(0.0),user_connect_timeout(-1),tango_host_localhost(false) {}
~ConnectionExt() {}
ConnectionExt & operator=(const ConnectionExt &);
bool tr_reco;
Tango::Device_3_var device_3;
bool prev_failed;
double prev_failed_t0;
Tango::Device_4_var device_4;
omni_mutex adm_dev_mutex;
omni_mutex asyn_mutex;
ReadersWritersLock con_to_mon;
int user_connect_timeout;
bool tango_host_localhost;
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<ConnectionExt> ext;
#else
ConnectionExt *ext; // Class extension
#endif
public :
virtual string dev_name()=0;
Connection(CORBA::ORB *orb = NULL);
Connection(bool dummy);
virtual ~Connection();
Connection(const Connection &);
Connection & operator=(const Connection &);
string &get_db_host() {return db_host;}
string &get_db_port() {return db_port;}
int get_db_port_num() {return db_port_num;}
bool get_from_env_var() {return from_env_var;}
static void get_fqdn(string &);
bool is_dbase_used() {return dbase_used;}
string &get_dev_host() {return host;}
string &get_dev_port() {return port;}
void connect(string &name);
virtual void reconnect(bool);
int get_idl_version() {return version;}
Tango::Device_var &get_device() {return device;} // For CORBA expert !!
virtual void set_timeout_millis(int timeout);
virtual int get_timeout_millis();
virtual Tango::DevSource get_source();
virtual void set_source(Tango::DevSource sou);
virtual void set_transparency_reconnection(bool val) {ext->tr_reco = val;}
virtual bool get_transparency_reconnection() {return ext->tr_reco;}
virtual DeviceData command_inout(string &);
virtual DeviceData command_inout(const char *co) {string str(co);return command_inout(str);}
virtual DeviceData command_inout(string &, DeviceData &);
virtual DeviceData command_inout(const char *co,DeviceData &d) {string str(co);return command_inout(str,d);}
virtual CORBA::Any_var command_inout(string &, CORBA::Any&);
virtual CORBA::Any_var command_inout(const char *co, CORBA::Any &d) {string str(co);return command_inout(str,d);}
//
// Asynchronous methods
//
void Cb_Cmd_Request(CORBA::Request_ptr,Tango::CallBack *);
void Cb_ReadAttr_Request(CORBA::Request_ptr,Tango::CallBack *);
void Cb_WriteAttr_Request(CORBA::Request_ptr req,Tango::CallBack *cb_ptr);
void dec_asynch_counter(asyn_req_type ty);
virtual long command_inout_asynch(const char *,DeviceData &argin,bool forget=false);
virtual long command_inout_asynch(string &,DeviceData &argin,bool forget=false);
virtual long command_inout_asynch(const char *,bool forget=false);
virtual long command_inout_asynch(string &,bool forget=false);
virtual DeviceData command_inout_reply(long);
virtual DeviceData command_inout_reply(long,long);
virtual void command_inout_asynch(const char *,DeviceData &argin,CallBack &cb);
virtual void command_inout_asynch(string &,DeviceData &argin,CallBack &cb);
virtual void command_inout_asynch(const char *,CallBack &cb);
virtual void command_inout_asynch(string &,CallBack &cb);
virtual void get_asynch_replies();
virtual void get_asynch_replies(long);
virtual void cancel_asynch_request(long);
virtual void cancel_all_polling_asynch_request();
//
// Control access related methods
//
AccessControlType get_access_control() {return access;}
void set_access_control(AccessControlType acc) {access=acc;}
AccessControlType get_access_right() {return get_access_control();}
};
/****************************************************************************************
* *
* The DeviceProxy class *
* -------------------- *
* *
***************************************************************************************/
class DeviceProxy: public Tango::Connection
{
private :
void real_constructor(string &,bool ch_acc=true);
Tango::DbDevice *db_dev;
string device_name;
string alias_name;
DeviceInfo _info;
bool is_alias;
DeviceProxy *adm_device;
string adm_dev_name;
omni_mutex netcalls_mutex;
int lock_ctr;
int lock_valid;
void connect_to_adm_device();
void retrieve_read_args(TgRequest &,vector<string> &);
DeviceAttribute *redo_synch_read_call(TgRequest &);
vector<DeviceAttribute> *redo_synch_reads_call(TgRequest &);
void redo_synch_write_call(TgRequest &);
void write_attribute(const AttributeValueList &);
void write_attribute(const AttributeValueList_4 &);
void create_locking_thread(ApiUtil *,DevLong);
void local_import(string &);
enum read_attr_type
{
SIMPLE,
MULTIPLE
};
void read_attr_except(CORBA::Request_ptr,long,read_attr_type);
void write_attr_except(CORBA::Request_ptr,long,TgRequest::ReqType);
void check_connect_adm_device();
friend class AttributeProxy;
protected :
virtual string get_corba_name(bool);
virtual string build_corba_name();
virtual int get_lock_ctr() {return lock_ctr;}
virtual void set_lock_ctr(int lo) {lock_ctr=lo;}
enum polled_object
{
Cmd,
Attr
};
bool is_polled(polled_object,string &, string &);
virtual void reconnect(bool);
void get_remaining_param(AttributeInfoListEx *);
void from_hist4_2_AttHistory(DevAttrHistory_4_var &,vector<DeviceAttributeHistory> *);
void from_hist4_2_DataHistory(DevCmdHistory_4_var &,vector<DeviceDataHistory> *);
void ask_locking_status(vector<string> &,vector<DevLong> &);
void get_locker_host(string &,string &);
void same_att_name(vector<string> &,const char *);
private:
class DeviceProxyExt
{
public:
DeviceProxyExt() {};
omni_mutex lock_mutex;
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<DeviceProxyExt> ext_proxy;
#else
DeviceProxyExt *ext_proxy; // Class extension
#endif
public :
DeviceProxy(string &name, CORBA::ORB *orb=NULL);
DeviceProxy(string &name, bool ch_access, CORBA::ORB *orb=NULL);
DeviceProxy(const char *, bool ch_access, CORBA::ORB *orb=NULL);
DeviceProxy(const char *, CORBA::ORB *orb=NULL);
DeviceProxy(const DeviceProxy &);
DeviceProxy & operator=(const DeviceProxy &);
virtual ~DeviceProxy();
DeviceProxy():Connection((CORBA::ORB *)NULL),db_dev(NULL),adm_device(NULL),ext_proxy(Tango_NullPtr)
{dbase_used = false;}
//
// general methods
//
virtual DeviceInfo const &info();
virtual inline string dev_name() { return device_name; }
virtual void parse_name(string &);
virtual Database *get_device_db();
virtual string status();
virtual DevState state();
virtual string adm_name();
virtual string description();
virtual string name();
virtual string alias();
int get_tango_lib_version();
virtual int ping();
virtual vector<string> *black_box(int);
//
// device methods
//
virtual CommandInfo command_query(string);
virtual CommandInfoList *command_list_query();
virtual DbDevImportInfo import_info();
//
// property methods
//
virtual void get_property(string&, DbData&);
virtual void get_property(vector<string>&, DbData&);
virtual void get_property(DbData&);
virtual void put_property(DbData&);
virtual void delete_property(string&);
virtual void delete_property(vector<string>&);
virtual void delete_property(DbData&);
virtual void get_property_list(const string &,vector<string> &);
//
// attribute methods
//
virtual vector<string> *get_attribute_list();
virtual AttributeInfoList *get_attribute_config(vector<string>&);
virtual AttributeInfoListEx *get_attribute_config_ex(vector<string>&);
virtual AttributeInfoEx get_attribute_config(const string &);
virtual AttributeInfoEx attribute_query(string name) {return get_attribute_config(name);}
virtual AttributeInfoList *attribute_list_query();
virtual AttributeInfoListEx *attribute_list_query_ex();
virtual void set_attribute_config(AttributeInfoList &);
virtual void set_attribute_config(AttributeInfoListEx &);
virtual DeviceAttribute read_attribute(string&);
virtual DeviceAttribute read_attribute(const char *at) {string str(at);return read_attribute(str);}
void read_attribute(const char *,DeviceAttribute &);
void read_attribute(string &at,DeviceAttribute &da) {read_attribute(at.c_str(),da);}
virtual vector<DeviceAttribute> *read_attributes(vector<string>&);
virtual void write_attribute(DeviceAttribute&);
virtual void write_attributes(vector<DeviceAttribute>&);
virtual DeviceAttribute write_read_attribute(DeviceAttribute &);
//
// history methods
//
virtual vector<DeviceDataHistory> *command_history(string &,int);
virtual vector<DeviceDataHistory> *command_history(const char *na,int n)
{string str(na);return command_history(str,n);}
virtual vector<DeviceAttributeHistory> *attribute_history(string &,int);
virtual vector<DeviceAttributeHistory> *attribute_history(const char *na,int n)
{string str(na);return attribute_history(str,n);}
//
// Polling administration methods
//
virtual vector<string> *polling_status();
virtual void poll_command(string &, int);
virtual void poll_command(const char *na, int per) {string tmp(na);poll_command(tmp,per);}
virtual void poll_attribute(string &, int);
virtual void poll_attribute(const char *na, int per) {string tmp(na);poll_attribute(tmp,per);}
virtual int get_command_poll_period(string &);
virtual int get_command_poll_period(const char *na)
{string tmp(na);return get_command_poll_period(tmp);}
virtual int get_attribute_poll_period(string &);
virtual int get_attribute_poll_period(const char *na)
{string tmp(na);return get_attribute_poll_period(tmp);}
virtual bool is_command_polled(string &);
virtual bool is_command_polled(const char *na) {string tmp(na);return is_command_polled(tmp);}
virtual bool is_attribute_polled(string &);
virtual bool is_attribute_polled(const char *na) {string tmp(na);return is_attribute_polled(tmp);}
virtual void stop_poll_command(string &);
virtual void stop_poll_command(const char *na) {string tmp(na);stop_poll_command(tmp);}
virtual void stop_poll_attribute(string &);
virtual void stop_poll_attribute(const char *na) {string tmp(na);stop_poll_attribute(tmp);}
//
// Asynchronous methods
//
virtual long read_attribute_asynch(const char *na) {string tmp(na);return read_attribute_asynch(tmp);}
virtual long read_attribute_asynch(string &att_name);
virtual long read_attributes_asynch(vector <string> &);
virtual vector<DeviceAttribute> *read_attributes_reply(long);
virtual vector<DeviceAttribute> *read_attributes_reply(long,long);
virtual DeviceAttribute *read_attribute_reply(long);
virtual DeviceAttribute *read_attribute_reply(long,long);
virtual long write_attribute_asynch(DeviceAttribute &);
virtual long write_attributes_asynch(vector<DeviceAttribute> &);
virtual void write_attributes_reply(long);
virtual void write_attributes_reply(long,long);
virtual void write_attribute_reply(long id) {write_attributes_reply(id);}
virtual void write_attribute_reply(long to,long id) {write_attributes_reply(to,id);}
virtual long pending_asynch_call(asyn_req_type req)
{if (req == POLLING)return pasyn_ctr;
else if (req==CALL_BACK) return pasyn_cb_ctr;
else return (pasyn_ctr + pasyn_cb_ctr);}
virtual void read_attributes_asynch(vector<string> &,CallBack &);
virtual void read_attribute_asynch(const char *na,CallBack &cb) {string tmp(na);read_attribute_asynch(tmp,cb);}
virtual void read_attribute_asynch(string &,CallBack &);
virtual void write_attribute_asynch(DeviceAttribute &,CallBack &);
virtual void write_attributes_asynch(vector<DeviceAttribute> &,CallBack &);
//
// Logging administration methods
//
#ifdef TANGO_HAS_LOG4TANGO
virtual void add_logging_target(const string &target_type_name);
virtual void add_logging_target(const char *target_type_name)
{add_logging_target(string(target_type_name));}
virtual void remove_logging_target(const string &target_type_name);
virtual void remove_logging_target(const char *target_type_name)
{remove_logging_target(string(target_type_name));}
virtual vector<string> get_logging_target (void);
virtual int get_logging_level (void);
virtual void set_logging_level (int level);
#endif // TANGO_HAS_LOG4TANGO
//
// Event methods
//
virtual int subscribe_event(const string &attr_name, EventType event, CallBack *,
const vector<string> &filters); // For compatibility with Tango < 8
virtual int subscribe_event(const string &attr_name, EventType event, CallBack *,
const vector<string> &filters, bool stateless); // For compatibility with Tango < 8
virtual int subscribe_event(const string &attr_name, EventType event, int event_queue_size,
const vector<string> &filters, bool stateless = false); // For compatibility with Tango < 8
virtual int subscribe_event(const string &attr_name, EventType event, CallBack *);
virtual int subscribe_event(const string &attr_name, EventType event, CallBack *,bool stateless);
virtual int subscribe_event(const string &attr_name, EventType event, int event_queue_size,bool stateless = false);
virtual void unsubscribe_event(int event_id);
//
// Methods to access data in event queues
//
virtual void get_events (int event_id, EventDataList &event_list);
virtual void get_events (int event_id, AttrConfEventDataList &event_list);
virtual void get_events (int event_id, DataReadyEventDataList &event_list);
virtual void get_events (int event_id, CallBack *cb);
virtual int event_queue_size(int event_id);
virtual TimeVal get_last_event_date(int event_id);
virtual bool is_event_queue_empty(int event_id);
//
// Locking methods
//
virtual void lock(int lock_validity=DEFAULT_LOCK_VALIDITY);
virtual void unlock(bool force=false);
virtual string locking_status();
virtual bool is_locked();
virtual bool is_locked_by_me();
virtual bool get_locker(LockerInfo &);
};
/****************************************************************************************
* *
* The AttributeProxy class *
* -------------------- *
* *
***************************************************************************************/
class AttributeProxy
{
private :
string attr_name;
string device_name;
Tango::DeviceProxy *dev_proxy;
Tango::DbAttribute *db_attr;
bool dbase_used; // Dev. with database
bool from_env_var; // DB from TANGO_HOST
string host; // DS host (if dbase_used=false)
string port; // DS port (if dbase_used=false)
int port_num; // DS port (as number)
string db_host; // DB host
string db_port; // DB port
int db_port_num; // DB port (as number)
void real_constructor(string &);
void ctor_from_dp(const DeviceProxy *,string &);
class AttributeProxyExt
{
public:
AttributeProxyExt() {};
};
#ifdef HAS_UNIQUE_PTR
unique_ptr<AttributeProxyExt> ext;
#else
AttributeProxyExt *ext; // Class extension
#endif
public :
AttributeProxy(string &name);
AttributeProxy(const char *);
AttributeProxy(const DeviceProxy *,string &);
AttributeProxy(const DeviceProxy *,const char *);
AttributeProxy(const AttributeProxy &);
AttributeProxy & operator=(const AttributeProxy &);
virtual ~AttributeProxy();
//
// general methods
//
virtual inline string name() { return attr_name; }
virtual inline DeviceProxy* get_device_proxy() { return dev_proxy; }
virtual void parse_name(string &);
virtual string status();
virtual DevState state();
virtual int ping();
virtual void set_transparency_reconnection(bool);
virtual bool get_transparency_reconnection();
//
// property methods
//
virtual void get_property(string&, DbData&);
virtual void get_property(vector<string>&, DbData&);
virtual void get_property(DbData&);
virtual void put_property(DbData&);
virtual void delete_property(string&);
virtual void delete_property(vector<string>&);
virtual void delete_property(DbData&);
//
// attribute methods
//
virtual AttributeInfoEx get_config();
virtual void set_config(AttributeInfo &);
virtual void set_config(AttributeInfoEx &);
virtual DeviceAttribute read();
virtual void write(DeviceAttribute&);
virtual DeviceAttribute write_read(DeviceAttribute &);
//
// history methods
//
virtual vector<DeviceAttributeHistory> *history(int);
//
// Polling administration methods
//
virtual void poll(int);
virtual int get_poll_period();
virtual bool is_polled();
virtual void stop_poll();
//
// Asynchronous methods
//
virtual long read_asynch() {return dev_proxy->read_attribute_asynch(attr_name);}
virtual DeviceAttribute *read_reply(long id) {return dev_proxy->read_attribute_reply(id);}
virtual DeviceAttribute *read_reply(long id,long to) {return dev_proxy->read_attribute_reply(id,to);}
virtual long write_asynch(DeviceAttribute &da) {return dev_proxy->write_attribute_asynch(da);}
virtual void write_reply(long id) {dev_proxy->write_attribute_reply(id);}
virtual void write_reply(long id,long to) {dev_proxy->write_attribute_reply(id,to);}
virtual void read_asynch(CallBack &cb) {dev_proxy->read_attribute_asynch(attr_name,cb);}
virtual void write_asynch(DeviceAttribute &da,CallBack &cb) {dev_proxy->write_attribute_asynch(da,cb);}
//
// Event methods
//
virtual int subscribe_event (EventType event, CallBack *,const vector<string> &filters); // For compatibility
virtual int subscribe_event (EventType event, CallBack *,const vector<string> &filters, bool stateless); // For compatibility
virtual int subscribe_event (EventType event, int event_queue_size,const vector<string> &filters, bool stateless = false); // For compatibility
virtual int subscribe_event (EventType event, CallBack *);
virtual int subscribe_event (EventType event, CallBack *,bool stateless);
virtual int subscribe_event (EventType event, int event_queue_size, bool stateless = false);
virtual void unsubscribe_event (int ev_id) {dev_proxy->unsubscribe_event(ev_id);}
//
// Methods to access data in event queues
//
virtual void get_events (int event_id, EventDataList &event_list)
{dev_proxy->get_events (event_id, event_list);}
virtual void get_events (int event_id, AttrConfEventDataList &event_list)
{dev_proxy->get_events (event_id, event_list);}
virtual void get_events (int event_id, CallBack *cb)
{dev_proxy->get_events (event_id, cb);}
virtual int event_queue_size(int event_id)
{return dev_proxy->event_queue_size(event_id);}
virtual TimeVal get_last_event_date(int event_id)
{return dev_proxy->get_last_event_date(event_id);}
virtual bool is_event_queue_empty(int event_id)
{return dev_proxy->is_event_queue_empty(event_id);}
};
/****************************************************************************************
* *
* The DummyDeviceProxy class *
* -------------------- *
* *
***************************************************************************************/
class DummyDeviceProxy: public Tango::Connection
{
public:
DummyDeviceProxy():Tango::Connection(true) {};
virtual string get_corba_name(bool) {string str;return str;}
virtual string build_corba_name() {string str;return str;}
virtual int get_lock_ctr() {return 0;}
virtual void set_lock_ctr(int) {};
virtual string dev_name() {string str;return str;}
int get_env_var(const char *cc,string &str_ref) {return Tango::Connection::get_env_var(cc,str_ref);}
};
///
/// Some inline methods
/// -------------------
///
inline ApiUtil *ApiUtil::instance()
{
omni_mutex_lock lo(inst_mutex);
if (_instance == NULL)
_instance = new ApiUtil();
return _instance;
}
inline long Connection::add_asyn_request(CORBA::Request_ptr req,TgRequest::ReqType req_type)
{
omni_mutex_lock guard(ext->asyn_mutex);
long id = ApiUtil::instance()->get_pasyn_table()->store_request(req,req_type);
pasyn_ctr++;
return id;
}
inline void Connection::remove_asyn_request(long id)
{
omni_mutex_lock guard(ext->asyn_mutex);
ApiUtil::instance()->get_pasyn_table()->remove_request(id);
pasyn_ctr--;
}
inline void Connection::add_asyn_cb_request(CORBA::Request_ptr req,CallBack *cb,Connection *con,TgRequest::ReqType req_type)
{
omni_mutex_lock guard(ext->asyn_mutex);
ApiUtil::instance()->get_pasyn_table()->store_request(req,cb,con,req_type);
pasyn_cb_ctr++;
}
inline void Connection::remove_asyn_cb_request(Connection *con,CORBA::Request_ptr req)
{
omni_mutex_lock guard(ext->asyn_mutex);
ApiUtil::instance()->get_pasyn_table()->remove_request(con,req);
pasyn_cb_ctr--;
}
inline long Connection::get_pasyn_cb_ctr()
{
long ret;
ext->asyn_mutex.lock();
ret = pasyn_cb_ctr;
ext->asyn_mutex.unlock();
return ret;
}
inline void Connection::dec_asynch_counter(asyn_req_type ty)
{
omni_mutex_lock guard(ext->asyn_mutex);
if (ty==POLLING)
pasyn_ctr--;
else if (ty==CALL_BACK)
pasyn_cb_ctr--;
}
inline void DeviceProxy::check_connect_adm_device()
{
omni_mutex_lock guard(ext->adm_dev_mutex);
if (adm_device == NULL)
connect_to_adm_device();
}
//
// For Tango 8 ZMQ event system
//
inline int DeviceProxy::subscribe_event (const string &attr_name, EventType event, CallBack *callback)
{
vector<string> filt;
return subscribe_event (attr_name,event,callback,filt,false);
}
inline int DeviceProxy::subscribe_event (const string &attr_name, EventType event,
CallBack *callback,bool stateless)
{
vector<string> filt;
return subscribe_event(attr_name,event,callback,filt,stateless);
}
inline int DeviceProxy::subscribe_event (const string &attr_name, EventType event,
int event_queue_size,bool stateless)
{
vector<string> filt;
return subscribe_event(attr_name,event,event_queue_size,filt,stateless);
}
///
/// Some macros
/// -----------
///
#define READ_ATT_EXCEPT(NAME_CHAR) \
catch (Tango::ConnectionFailed &e) \
{ \
TangoSys_OMemStream desc; \
desc << "Failed to read_attribute on device " << device_name; \
desc << ", attribute " << NAME_CHAR << ends; \
ApiConnExcept::re_throw_exception(e,(const char*)"API_AttributeFailed", \
desc.str(), (const char*)"DeviceProxy::read_attribute()"); \
} \
catch (Tango::DevFailed &e) \
{ \
TangoSys_OMemStream desc; \
desc << "Failed to read_attribute on device " << device_name; \
desc << ", attribute " << NAME_CHAR << ends; \
Except::re_throw_exception(e,(const char*)"API_AttributeFailed", \
desc.str(), (const char*)"DeviceProxy::read_attribute()"); \
} \
catch (CORBA::TRANSIENT &trans) \
{ \
TRANSIENT_NOT_EXIST_EXCEPT(trans,"DeviceProxy","read_attribute"); \
} \
catch (CORBA::OBJECT_NOT_EXIST &one) \
{ \
if (one.minor() == omni::OBJECT_NOT_EXIST_NoMatch || one.minor() == 0) \
{ \
TRANSIENT_NOT_EXIST_EXCEPT(one,"DeviceProxy","read_attribute"); \
} \
else \
{ \
set_connection_state(CONNECTION_NOTOK); \
TangoSys_OMemStream desc; \
desc << "Failed to read_attribute on device " << device_name << ends; \
ApiCommExcept::re_throw_exception(one, \
(const char*)"API_CommunicationFailed", \
desc.str(), \
(const char*)"DeviceProxy::read_attribute()"); \
} \
} \
catch (CORBA::COMM_FAILURE &comm) \
{ \
if (comm.minor() == omni::COMM_FAILURE_WaitingForReply) \
{ \
TRANSIENT_NOT_EXIST_EXCEPT(comm,"DeviceProxy","read_attribute"); \
} \
else \
{ \
set_connection_state(CONNECTION_NOTOK); \
TangoSys_OMemStream desc; \
desc << "Failed to read_attribute on device " << device_name << ends; \
ApiCommExcept::re_throw_exception(comm, \
(const char*)"API_CommunicationFailed", \
desc.str(), \
(const char*)"DeviceProxy::read_attribute()"); \
} \
} \
catch (CORBA::SystemException &ce) \
{ \
set_connection_state(CONNECTION_NOTOK); \
TangoSys_OMemStream desc; \
desc << "Failed to read_attribute on device " << device_name << ends; \
ApiCommExcept::re_throw_exception(ce, \
(const char*)"API_CommunicationFailed", \
desc.str(), \
(const char*)"DeviceProxy::read_attribute()"); \
}
///
/// Small utility classes
/// ---------------------
class AutoConnectTimeout
{
public:
AutoConnectTimeout(unsigned int to) {omniORB::setClientConnectTimeout((CORBA::ULong)to);}
~AutoConnectTimeout() {omniORB::setClientConnectTimeout(0);}
};
} // End of Tango namespace
#endif /* _DEVAPI_H */
|