This file is indexed.

/usr/include/tango/group.h is in libtango-dev 9.2.5a+dfsg1-2.

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
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
//=============================================================================
//
// file :               group.h
//
// description :        Include for Tango Group impl.
//
// project :            TANGO
//
// author(s) :          N.Leclercq
//
// Copyright (C) :      2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015
//                      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: 27410 $
//
//=============================================================================

#ifndef _GROUP_H_
#define _GROUP_H_

#include <tango.h>

namespace Tango {

/** @defgroup Grp Group Client classes
 * @ingroup Client
 */
//=============================================================================
// THREAD SAFE IMPL OPTION
//=============================================================================
#define TANGO_GROUP_HAS_THREAD_SAFE_IMPL 1

//=============================================================================
// FORWARD DECLARATIONS
//=============================================================================
class Group;
class GroupElement;

//=============================================================================
// Misc. Typedefs
//=============================================================================
//- group content (individual devices and/or sub-groups)
typedef std::vector<GroupElement*> GroupElements;
//- group content iterator
typedef GroupElements::iterator GroupElementsIterator;
//-----------------------------------------------------------------------------
//- define what is a list of token (for name pattern management)
typedef std::vector<std::string> TokenList;
//=============================================================================
// class ExtRequestDesc : an asynch. request holder for groups
//-----------------------------------------------------------------------------
class AsynchRequest
{
  //- An asynch. request repository is maintain by each GroupDeviceElement
  friend class GroupDeviceElement;

  public:
    //- ctor
    AsynchRequest (long _rid, const std::string& _obj_name, bool ge_enabled = true)
      : rq_id(_rid), group_element_enabled_m(ge_enabled)
    {
      obj_names.push_back(_obj_name);
    };
    //- ctor
    AsynchRequest (long _rid, const std::vector<std::string>& _obj_names, bool ge_enabled = true)
      : rq_id(_rid), group_element_enabled_m(ge_enabled)
    {
      obj_names = _obj_names;
    };
    //- ctor
    AsynchRequest (long _rid, const std::string& _obj_name, const DevFailed& _df)
      : rq_id(_rid), rq_ex(_df), group_element_enabled_m(true)
    {
      obj_names.push_back(_obj_name);
    };
    //- ctor
    AsynchRequest (long _rid, const std::vector<std::string>& _obj_names, const DevFailed& _df)
      : rq_id(_rid), rq_ex(_df), group_element_enabled_m(true)
    {
      obj_names = _obj_names;
    };
    //- dtor
    virtual ~AsynchRequest () {
      //-noop impl
    };
    //- group_element_enabled accessor
    inline bool group_element_enabled () const {
      return group_element_enabled_m;
    }
  private:
    //- request ID
    long rq_id;
    //- name of requested objects (command or attribute)
    std::vector<std::string> obj_names;
    //- DevFailed containing potential error
    DevFailed rq_ex;
    //- true is the associated group member is enabled, false otherwise
    bool group_element_enabled_m;
};
//-----------------------------------------------------------------------------
//- asynch. request repository
typedef std::map<long, AsynchRequest> AsynchRequestRep;
//- asynch. request repository iterator
typedef AsynchRequestRep::iterator AsynchRequestRepIterator;
//- asynch. request repository value
typedef AsynchRequestRep::value_type AsynchRequestRepValue;
//=============================================================================

//=============================================================================
// class GroupReply : base class for group reply
//=============================================================================

/**
 * Base class for Group reply
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */

class GroupReply
{
public:

///@privatesection
  //- default ctor
  GroupReply ();
  //- copy ctor
  GroupReply (const GroupReply& src);
  //- ctor
  GroupReply (const std::string& dev_name,
              const std::string& obj_name,
              bool group_element_enabled = true);
  //- ctor
  GroupReply (const std::string& dev_name,
              const std::string& obj_name,
              const DevFailed& exception,
              bool group_element_enabled = true);
  //- dtor
  virtual ~GroupReply ();
  //- group_element_enabled accessor
  inline bool group_element_enabled () const {
    return group_element_enabled_m;
  }
///@publicsection
   //- enable/disable exception - returns the previous mode
/**
 * Enable/Disable exception
 *
 * Set the group exception mode. If set to true, exception will be thrown
 * (when needed) by the library when the user get command  execution result.
 * If set to false (the default), the user has to deal with the has_failed()
 * exception to manage cases of wrong execution command.
 *
 * @param [in] exception_mode The new exception mode
 * @return The previous exception mode
 */
  static bool enable_exception (bool exception_mode = true);
  //- has_failed accessor
/**
 * Check if an error has occured
 *
 * Returns a boolean set to true if the command executed on the group
 * element has failed. Otherwise, returns false
 *
 * @return The error flag
 */
  inline bool has_failed () const {
    return has_failed_m;
  }
  //- device name accessor
/**
 * Get device name
 *
 * Returns the device name for the group element
 *
 * @return The device name
 */
  inline const std::string& dev_name () const {
    return dev_name_m;
  }
//- object (i.e. command or attribute) name accessor
/**
 * Get object name
 *
 * Returns the object name (i.e. command or attribute) for the group element
 *
 * @return The object name
 */
  inline const std::string& obj_name () const {
    return obj_name_m;
  }
  //- error stack accessor
/**
 * Get error stack
 *
 * Returns the error stack for the group element
 *
 * @return The error stack
 */
  inline const DevErrorList& get_err_stack () const {
    return exception_m.errors;
  }
protected:
///@privatesection
  //- exception flag (enable/disable)
  static bool exception_enabled;
  //- the device name
  std::string dev_name_m;
  //- command or attribute name
  std::string obj_name_m;
  //- has_failed_m: true is an error occurred, false otherwise
  bool has_failed_m;
  //- group_element_enabled_m : true is the associated group member is enabled, false otherwise
  bool group_element_enabled_m;
  //- exception: valid if has_failed_m set to true
  DevFailed exception_m;
};

//=============================================================================
// class GroupCmdReply : reply to command executed on a group
//=============================================================================
/**
 * Single element group reply for a command execution
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */
class GroupCmdReply : public GroupReply
{
public:
///@privatesection
  //- default ctor
  GroupCmdReply ();
  //- copy ctor
  GroupCmdReply (const GroupCmdReply& src);
  //-
  GroupCmdReply (const std::string& dev_name,
                 const std::string& obj_name,
                 const DeviceData& data);
  //- ctor
  GroupCmdReply (const std::string& dev_name,
                 const std::string& obj_name,
                 const DevFailed& exception);
  //- ctor
  GroupCmdReply (const std::string& dev_name,
                 const std::string& obj_name,
                 bool group_element_enabled);
  //- dtor
  virtual ~GroupCmdReply ();
///@publicsection
  //- data accessor (may throw Tango::DevFailed)
/**
 * Get command data
 *
 * Get command result for a device member of a group hierarchy
 *
 * @return The command data
 */
  DeviceData& get_data ();
  //- template data exctractor method
/**
 * Get command data and extract them
 *
 * Get command result for a device member of a group hierarchy and extract
 * them in the provided variable
 *
 * @param [out] dest The variable in which the data should be extracted
 * @return Flag set to true if the extraction succeeds
 */
  template <typename T> bool operator>> (T& dest);
  //- data exctractor method for DevVarLongStringArray
/**
 * Get command data and extract them (DevVarLongStringArray)
 *
 * Get command result for a device member of a group hierarchy and extract
 * them in the provided variable in case the command returns a
 * data of the DevVarLongStringArray type
 *
 * @param [out] vl The array of DevLong part of the DevVarLongStringArray
 * @param [out] vs The array of string part of the DevVarLongStringArray data
 * @return Flag set to true if the extraction succeeds
 */
  bool extract (std::vector<DevLong>& vl, std::vector<std::string>& vs);
  //- data exctractor method for DevVarDoubleStringArray
/**
 * Get command data and extract them (DevVarDoubleStringArray)
 *
 * Get command result for a device member of a group hierarchy and extract
 * them in the provided variable in case the command returns a
 * data of the DevVarDoubleStringArray type
 *
 * @param [out] vd The array of DevDouble part of the DevVarDoubleStringArray
 * @param [out] vs The array of string part of the DevVarDoubleStringArray data
 * @return Flag set to true if the extraction succeeds
 */
  bool extract (std::vector<double>& vd, std::vector<std::string>& vs);
private:
  //- data: valid if GroupReply::has_failed_m set to false and
  //- GroupReply::enabled_m set to true
  DeviceData data_m;
};

//=============================================================================
// class GroupAttrReply : reply to an attribute reading executed on a group
//=============================================================================
/**
 * Single element group reply for a read attribute execution
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */
class GroupAttrReply : public GroupReply
{
public:
///@privatesection
  //- ctor
  GroupAttrReply ();
  //- copy ctor
  GroupAttrReply (const GroupAttrReply& src);
  //- ctor
  GroupAttrReply (const std::string& dev_name,
                  const std::string& obj_name,
                  const DeviceAttribute& data);
  //- ctor
  GroupAttrReply (const std::string& dev_name,
                  const std::string& obj_name,
                  const DevFailed& exception);
  //- ctor
  GroupAttrReply (const std::string& dev_name,
                  const std::string& obj_name,
                  bool group_element_enabled);
  //- dtor
  virtual ~GroupAttrReply ();
///@publicsection
  //- data accessor (may throw Tango::DevFailed)
/**
 * Get attribute data
 *
 * Get attribute data for a device member of a group hierarchy
 *
 * @return The attribute data
 */
  DeviceAttribute& get_data ();
  //- template data exctractor method
/**
 * Get attribute data and extract them
 *
 * Get attribute data for a device member of a group hierarchy and extract
 * them in the provided variable
 *
 * @param [out] dest The variable in which the data should be extracted
 * @return Flag set to true if the extraction succeeds
 */
  template <typename T> bool operator>> (T& dest);
private:
  //- data: valid if GroupReply::has_failed_m set to false and
  //- GroupReply::enabled_m set to true
  DeviceAttribute data_m;
};

//=============================================================================
// class GroupReplyList : a simple list of GroupReply
//=============================================================================
/**
 * Group reply for a write_attribute execution
 *
 * This class inherits from @b vector<GroupReply> and therefore, each
 * device in the  group heierarchy has his own GroupReply object
 * which can be retrieved with the classical vector [] operator
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */
class GroupReplyList : public std::vector<GroupReply>
{
///@privatesection
  typedef std::vector<GroupReply> Inherited;

  friend class Group;

public:
///@privatesection
  //- ctor
  GroupReplyList();
  //- dtor
  virtual ~GroupReplyList();
///@publicsection
  //- has_failed accessor
/**
 * Check if an error has occured
 *
 * Returns a boolean set to true if the write_attribute executed on the group has failed
 * for any device member of the hierarchy. Otherwise, returns false
 *
 * @return The error flag
 */
  bool has_failed () const {
    return has_failed_m;
  }
  //- reset the error list
/**
 * Reset the object
 *
 * This methods empty the inherited vector and reset the error flag
 */
  inline void reset () {
    clear();
    has_failed_m = false;
  };
///@privatesection
  //- push_back overload
  void push_back (const GroupReply& r) {
    if (r.has_failed()) {
      has_failed_m = true;
    }
    Inherited::push_back(r);
  }
private:
  //- has_failed_m: true if at least one error occurred, false otherwise
  bool has_failed_m;
};

//=============================================================================
// class GroupCmdReplyList : a simple list of GroupCmdReply
//=============================================================================
/**
 * Group reply for a command execution
 *
 * This class inherits from @b vector<GroupCmdReply> and therefore, each
 * device in the  group heierarchy has his own GroupCmdReply object
 * which can be retrieved with the classical vector [] operator
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */

class GroupCmdReplyList : public std::vector<GroupCmdReply>
{
///@privatesection
  typedef std::vector<GroupCmdReply> Inherited;

  friend class Group;

public:
///@privatesection
  //- ctor
  GroupCmdReplyList();
  //- dtor
  virtual ~GroupCmdReplyList();
///@publicsection
  //- has_failed accessor method
/**
 * Check if an error has occured
 *
 * Returns a boolean set to true if the command executed on the group has failed
 * for any device member of the hierarchy. Otherwise, returns false
 *
 * @return The error flag
 */
  bool has_failed () const {
    return has_failed_m;
  }
  //- reset the error list
/**
 * Reset the object
 *
 * This methods empty the inherited vector and reset the error flag
 */
  inline void reset () {
    clear();
    has_failed_m = false;
  };
///@privatesection
  //- push_back overload
  void push_back (const GroupCmdReply& cr) {
    if (cr.has_failed()) {
      has_failed_m = true;
    }
    Inherited::push_back(cr);
  }
private:
  //- has_failed_m: true if at least one error occurred, false otherwise
  bool has_failed_m;
};

//=============================================================================
// class GroupAttrReplyList : a simple list of GroupAttrReply
//=============================================================================
/**
 * Group reply for a read_attribute execution
 *
 * This class inherits from @b vector<GroupAttrReply> and therefore, each
 * device in the  group heierarchy has his own GroupAttrReply object
 * which can be retrieved with the classical vector [] operator
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */
class GroupAttrReplyList : public std::vector<GroupAttrReply>
{
///@privatesection
  typedef std::vector<GroupAttrReply> Inherited;

  friend class Group;

public:
///@privatesection
  //- ctor
  GroupAttrReplyList();
  //- dtor
  virtual ~GroupAttrReplyList();
///@publicsection
  //- has_failed accessor method
/**
 * Check if an error has occured
 *
 * Returns a boolean set to true if the read_attribute executed on the group has failed
 * for any device member of the hierarchy. Otherwise, returns false
 *
 * @return The error flag
 */
  bool has_failed () const {
    return has_failed_m;
  }
  //- reset the error list
/**
 * Reset the object
 *
 * This methods empty the inherited vector and reset the error flag
 */
  inline void reset () {
    clear();
    has_failed_m = false;
  };
///@privatesection
  //- push_back overload
  void push_back (const GroupAttrReply& ar) {
    if (ar.has_failed()) {
      has_failed_m = true;
    }
    Inherited::push_back(ar);
  }
private:
  //- has_failed_m: true if at least one error occurred, false otherwise
  bool has_failed_m;
};

//=============================================================================
// class GroupElementFactory : a GroupElement factory
//=============================================================================
class GroupElementFactory
{
  friend class Group;

  //- instanciatethe GroupElement which name matches the specified pattern with the specified timeout
  //- timeout = -1 => do not change the timeout
  static GroupElements instanciate (const std::string& p, int tmo = -1);

  static void parse_name (const std::string& p, std::string &db_host, int &db_port, std::string &dev_pattern);

  //- forbidden methods
  GroupElementFactory();
  ~GroupElementFactory();
  GroupElementFactory& operator=(const GroupElementFactory& other);
};

//=============================================================================
// class GroupElement: base class for all tango group element
//=============================================================================
class GroupElement
{
  friend class Group;

public:
  //---------------------------------------------
  //- Group management methods
  //---------------------------------------------
  //-
  virtual bool contains (const std::string& n, bool fwd = true);
  //-
  virtual DeviceProxy* get_device (const std::string& n) = 0;
  //-
  virtual DeviceProxy* get_device (long idx) = 0;
  //-
  virtual DeviceProxy* operator[] (long idx) = 0;

  //---------------------------------------------
  //- a la DeviceProxy interface
  //---------------------------------------------
  //-
  virtual bool ping (bool fwd = true) = 0;
  //-
  virtual void set_timeout_millis (int tmo_ms) = 0;

  //---------------------------------------------
  //- Misc.
  //---------------------------------------------
  //-
  inline const std::string& get_name () const {
    return name;
  };
  //-
  inline const std::string get_fully_qualified_name () const {
    if (parent) {
      return parent->get_fully_qualified_name() + "." + name;
    }
    return name;
  };
  //-
  inline void enable () {
    enabled = true;
  };
  //-
  inline void disable () {
    enabled = false;
  };
  //-
  inline bool is_enabled () const {
    return enabled;
  };
  bool name_equals (const std::string& n);
  //-
  bool name_matches (const std::string& n);
  //-
  virtual void dump (int indent_level = 0) = 0;
  //-
  virtual void dump (TangoSys_OMemStream& oms, int indent_level = 0) = 0;
  //-
  virtual bool is_connected();

protected:
  //- ctor: creates an GroupElement named <name>
  GroupElement (const std::string& name, GroupElement* parent = 0);
  //- dtor
  virtual ~GroupElement();

private:
  //- element name
  std::string name;
  //- parent element
  GroupElement* parent;
  //- enabled: true is this group member is enabled, false otherwise
  bool enabled;

  //- forbidden methods
  GroupElement ();
  GroupElement (const GroupElement&);
  GroupElement& operator=(const GroupElement&);

  //- element name tokenizer
  TokenList tokenize_i (const std::string& p);

  //- element name pattern matching
  bool match_i (const std::string& p, const TokenList& tokens);

  //- element identification
  virtual bool is_device_i () = 0;
  virtual bool is_group_i () = 0;

  //- group interface
  virtual long get_size_i (bool fwd = true) = 0;

  //- element searching
  virtual GroupElement* find_i (const std::string& n, bool fwd = true);

  //- private part of the asynch command exec. impl.
  virtual long command_inout_asynch_i (const std::string& c, bool fgt, bool fwd , long ari) = 0;
  virtual long command_inout_asynch_i (const std::string& c,  const DeviceData& d, bool fgt, bool fwd, long ari) = 0;
  virtual GroupCmdReplyList command_inout_reply_i (long req_id, long tmo_ms) = 0;

  //- private part of the asynch attribute(s) reading impl.
  virtual long read_attribute_asynch_i (const std::string& a, bool fwd, long ari) = 0;
  virtual GroupAttrReplyList read_attribute_reply_i (long req_id, long tmo_ms) = 0;
  virtual long read_attributes_asynch_i (const std::vector<std::string>& al, bool fwd, long ari) = 0;
  virtual GroupAttrReplyList read_attributes_reply_i (long req_id, long tmo_ms) = 0;

  //- private part of the asynch attribute writting impl.
  virtual long write_attribute_asynch_i (const DeviceAttribute& d, bool fwd, long ari) = 0;
  virtual GroupReplyList write_attribute_reply_i (long req_id, long tmo_ms) = 0;

  //- set the parent element, returns previous parent or 0 (null) if none
  GroupElement* set_parent (GroupElement* _parent);
};

//=============================================================================
// class Group: actual tango group implementation
//=============================================================================

/**
 * High level class allowing the user to handle Tango group
 *
 * $Author: taurel $
 * $Revision: 27410 $
 *
 * @headerfile tango.h
 * @ingroup Grp
 */

class Group : public GroupElement
{
  typedef std::map<long, bool> AsynchRequestDesc;
  typedef AsynchRequestDesc::iterator AsynchRequestDescIt;
  typedef AsynchRequestDesc::value_type AsynchRequestDescVal;

public:

  //---------------------------------------------
  //- Ctor & Dtor
  //---------------------------------------------
/**@name Constructor and destructor */
//@{
/**
 * Create a Group instance
 *
 * Instanciate an empty group. The group name allows retrieving a sub-group in the hierarchy.
 *
 * @param name The group name
 */
  Group (const std::string& name);
/**
 * Create a Group instance
 *
 * Delete a group and all its elements.
 * Be aware that a group always gets the ownership of its children and deletes themwhen it is itself deleted.
 * Therefore, never try to delete a Group (respectively a DeviceProxy) returned by a call to @e Tango::Group::get_group()
 * (respectively to @e Tango::Group::get_device()). Use the @e Tango::Group::remove() method instead.
 */
  virtual ~Group();
//@}

  //---------------------------------------------
  //- Group management methods
  //---------------------------------------------
/**@name Group management related methods */
//@{
/**
 * Attaches a (sub) group
 *
 *  Be aware that a group always gets the ownership of its children and deletes them when it is itself
 * deleted. Therefore, never try to delete a Group attached to a Group. Use the Group::remove() method
 * instead.
 * If timeout_ms parameter is different from -1, the client side timeout associated to each device composing
 * the group added is set to timeout_ms milliseconds. If timeout_ms is -1, timeouts are not changed.
 * This method does nothing if the specified group is already attached (i.e. it is silently ignored) and
 * timeout_ms = -1.
 * If the specified group is already attached and timeout_ms is different from -1, the client side timeout of
 * each device composing the group given in parameter is set to timeout_ms milliseconds.
 *
 * @param [in] group The group to be attached
 * @param [in] tmo_ms The timeout value
 */
  virtual void add (Group* group, int tmo_ms = -1);
/**
 * Attaches any device which name matches the specified pattern
 *
 * The pattern parameter can be a simple device name or a device name pattern (e.g. domain_* / family/
 * member_*).
 * This method first asks to the Tango database the list of device names matching the pattern. Devices are
 * then attached to the group in the order in which they are returned by the database.
 * Any device already present in the hierarchy (i.e. a device belonging to the group or to one of its
 * subgroups) is silently ignored but its client side timeout is set to timeout_ms milliseconds if timeout_ms is
 * different from -1.
 * Set the client side timeout of each device matching the specified pattern to timeout_ms milliseconds if
 * timeout_ms is different from -1.
 *
 * @param [in] pattern The device selection pattern
 * @param [in] tmo_ms The timeout value
 */
  virtual void add (const std::string& pattern, int tmo_ms = -1);
/**
 * Attaches any device which name matches one of the specified pattern
 *
 * The patterns parameter can be an array of device names and/or device name patterns.
 * Thismethod first asks to the Tango database the list of device namesmatching one the patterns. Devices
 * are then attached to the group in the order in which they are returned by the database.
 * Any device already present in the hierarchy (i.e. a device belonging to the group or to one of its
 * subgroups), is silently ignored but its client side timeout is set to timeout_ms milliseconds if timeout_ms is
 * different from -1.
 * If timeout_ms is different from -1, the client side timeouts of all devices matching the specified patterns
 * are set to timeout_ms milliseconds.
 *
 * @param [in] patterns The device selection pattern list
 * @param [in] tmo_ms The timeout value
 */
  virtual void add (const std::vector<std::string>& patterns, int tmo_ms = -1);
#ifdef GEN_DOC
/**
 * Removes any group or device which name matches the specified pattern.
 *
 * The pattern parameter can be a group name, a device name or a device name pattern (e.g domain_* /family/member_*).
 * Since we can have groups with the same name in the hierarchy, a group name can be fully qualified to
 * specify which group should be removed. Considering the following group:
 * @verbatim
  -> gauges
     | -> cell-01
     |     | -> penning
     |     |     | -> ...
     |     | -> pirani
     |     |     | -> ...
     | -> cell-02
     |     | -> penning
     |     |     | -> ...
     |     | -> pirani
     |     |     | -> ...
     | -> cell-03
     |     | -> ...

   @endverbatim
 * A call to gauges->remove("penning") will remove any group named "penning" in the hierarchy while
 * gauges->remove("gauges.cell-02.penning") will only remove the specified group.
 * If fwd is set to true (the default), the remove request is also forwarded to subgroups. Otherwise, it is
 * only applied to the local set of elements. For instance, the following code remove any stepper motor in the
 * hierarchy:
 * @code
 * root_group->remove("*/stepper_motor/*");
 * @endcode
 *
 * @param [in] pattern The device selection pattern
 * @param [in] fwd The forward flag
 */
#endif
  virtual void remove (const std::string& pattern, bool fwd = true);
/**
 * Removes any group or device which name matches any of the specified patterns.
 *
 * The patterns parameter can be an array of group names and/or device names and/or device name patterns.
 * Since we can have groups with the same name in the hierarchy, a group name can be fully qualified to
 * specify which group should be removed. See previous method for details.
 * If fwd is set to true (the default), the remove request is also forwarded to subgroups. Otherwise, it is
 * only applied to the local set of elements.
 *
 * @param [in] patterns The device selection patterns
 * @param [in] fwd The forward flag
 */
  virtual void remove (const std::vector<std::string>& patterns, bool fwd = true);
/**
 * Removes all elements in the group
 *
 * Removes all elements in the group. After such a call, the group is empty.
 */
  virtual void remove_all ();
/**
 * Check if the hierarchy contains groups and/or devices which name matches the specified pattern.
 *
 * Returns true if the hierarchy contains groups and/or devices which name matches the specified pattern.
 * Returns false otherwise.
 * The pattern can be a fully qualified or simple group name, a device name or a device name pattern.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of elements.
 *
 * @param [in] pattern The device selection pattern
 * @param [in] fwd The forward flag
 * @return True if the hierarchy contains the element
 */
  virtual bool contains (const std::string& pattern, bool fwd = true);
/**
 * Returns a reference to the specified device
 *
 * Returns a reference to the specified device or NULL if there is no device by that name in the group. This
 * method may throw an exception in case the specified device belongs to the group but can’t be reached (not
 * registered, down...). See example below. See also the Tango::DeviceProxy class documentation for details.
 * @code
 * try
 * {
 *    Tango::DeviceProxy *dp = g->get_device("my/device/01");
 *    if (dp == 0)
 *    {
 *       // my/device/01 does not belongs to the group
 *    }
 * }
 * catch (const Tango::DevFailed &df)
 * {
 *    // my/device/01 belongs to the group but can’t be reached
 * }
 * @endcode
 * The request is systematically forwarded to subgroups (i.e. if no device named device_name could be
 * found in the local set of devices, the request is forwarded to subgroups).
 * Be aware that a group always gets the ownership of its children and deletes them when it is itself
 * deleted. Therefore, never try to delete a DeviceProxy returned by the Group::get_device()method. Use the
 * Tango::Group::remove() method instead.
 *
 * @param [in] device_name The device name
 * @return True if the hierarchy contains the element
 */
  virtual DeviceProxy* get_device (const std::string& device_name);
/**
 * Returns a reference to the "idx-th" device in the hierarchy
 *
 * Returns a reference to the "idx-th" device in the hierarchy or NULL if the hierarchy contains less than
 * "idx" devices. This method may throw an exception in case the specified device belongs to the group but
 * can’t be reached (not registered, down...). See previous example. See also the Tango::DeviceProxy class
 * documentation for details.
 * The request is systematically forwarded to subgroups (i.e. if the local set of devices contains less than
 * "idx" devices, the request is forwarded to subgroups).
 * Be aware that a group always gets the ownership of its children and deletes them when it is itself
 * deleted. Therefore, never try to delete a DeviceProxy returned by the Group::get_device()method. Use the
 * Tango::Group::remove() method instead.
 *
 * @param [in] idx The device name
 * @return device reference
 */
  virtual DeviceProxy* get_device (long idx);
/**
 * Returns a reference to the "idx-th" device in the hierarchy
 *
 * Returns a reference to the "idx-th" device in the hierarchy or NULL if the hierarchy contains less than "idx"
 * devices. See the Tango::DeviceProxy class documentation for details.
 * The request is systematically forwarded to subgroups (i.e. if the local set of devices contains less than
 * "idx" devices, the request is forwarded to subgroups).
 * Be aware that a group always gets the ownership of its children and deletes them when it is itself
 * deleted. Therefore, never try to delete a DeviceProxy returned by the Group::get_device()method. Use the
 * Tango::Group::remove() method instead.
 *
 * @param [in] idx The device name
 * @return device reference
 */
  virtual DeviceProxy* operator[] (long idx);
/**
 * Returns a reference to the specified group
 *
 * Returns a reference to the specified group or NULL if there is no group by that name. The group_name
 * can be a fully qualified name.
 * Considering the following group:
 * @verbatim
  -> gauges
     | -> cell-01
     |     | -> penning
     |     |     | -> ...
     |     | -> pirani
     |     |     | -> ...
     | -> cell-02
     |     | -> penning
     |     |     | -> ...
     |     | -> pirani
     |     |     | -> ...
     | -> cell-03
     |     | -> ...

   @endverbatim
 * A call to gauges->get_group("penning") returns the first group named "penning" in the hierarchy (i.e.
 * gauges.cell-01.penning)while gauges->get_group("gauges.cell-02.penning”) returns the specified group.
 * The request is systematically forwarded to subgroups (i.e. if no group named group_name could be
 * found in the local set of elements, the request is forwarded to subgroups).
 * Be aware that a group always gets the ownership of its children and deletes them when it is itself
 * deleted. Therefore, never try to delete a Group returned by the Group::get_group() method. Use the
 * Tango::Group::remove() method instead.
 *
 * @param [in] group_name The group name
 * @return group pointer
 */
  virtual Group* get_group (const std::string& group_name);
/**
 * Return the number of devices in the hierarchy
 *
 * Return the number of devices in the hierarchy (respectively the number of device in the group) if the
 * forward option is set to true (respectively set to false)
 *
 * @param [in] fwd The forward flag
 * @return group size
 */
  long get_size (bool fwd = true);
/**
 * Returns the list of devices currently in the hierarchy.
 *
 * Returns the list of devices currently in the hierarchy.
 * If fwd is set to true (the default) the request is forwarded to subgroups. Otherwise, it is only applied to
 * the local set of devices.
 * Considering the following hierarchy:
 * @code
 * g2->add("my/device/04"); g2->add("my/device/05");
 *
 * g4->add("my/device/08"); g4->add("my/device/09");
 *
 * g3->add("my/device/06");
 * g3->addg(g4);
 * g3->add("my/device/07");
 *
 * g1->add("my/device/01");
 * g1->add(g2);
 * g1->add("my/device/03");
 * g1->add(g3);
 * g1->add("my/device/02");
 * @endcode
 * The returned vector content depends on the value of the forward option. If set to true, the results will be
 * organized as follows:
 * @code
 * std::vector<std::string> dl = g1->get_device_list(true);
 * @endcode
 * dl[0] contains "my/device/01" which belongs to g1
 * @n dl[1] contains "my/device/04" which belongs to g1.g2
 * @n dl[2] contains "my/device/05" which belongs to g1.g2
 * @n dl[3] contains "my/device/03" which belongs to g1
 * @n dl[4] contains "my/device/06" which belongs to g1.g3
 * @n dl[5] contains "my/device/08" which belongs to g1.g3.g4
 * @n dl[6] contains "my/device/09" which belongs to g1.g3.g4
 * @n dl[7] contains "my/device/07" which belongs to g1.g3
 * @n dl[8] contains "my/device/02" which belongs to g1
 * @n @n If the forward option is set to false, the results are:
 * @code
 * std::vector<std::string> dl = g1->get_device_list(false);
 * @endcode
 * dl[0] contains "my/device/01" which belongs to g1
 * @n dl[1] contains "my/device/03" which belongs to g1
 * @n dl[2] contains "my/device/02" which belongs to g1
 *
 * @param [in] fwd The forward flag
 * @return group size
 */
  std::vector<std::string> get_device_list (bool fwd = true);
  //-

//@}
///@privatesection
  //-
  virtual Group* get_parent () const;
  //-
  void enable (const std::string& device_name, bool fwd = true);
  //-
  void disable (const std::string& device_name, bool fwd = true);
  //-
  bool is_enabled (const std::string& device_name, bool fwd = true) {
    GroupElement * ge = this->find_i(device_name, fwd);
    return ge ? ge->is_enabled() : false;
  };
  //-
  bool is_root_group () const;

  //---------------------------------------------
  //- a la DeviceProxy interface
  //---------------------------------------------
///@publicsection
///@name a la Deviceproxy interface
//@{
  //- misc.
  //---------------------------------------------
/**
 * Ping all devices in a group
 *
 * Ping all devices in a group. This method returns true if all devices in the group are alive, false otherwise.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 *
 * @param [in] fwd The forward flag
 * @return True if all devices are alive
 */
  virtual bool ping (bool fwd = true);
/**
 * Set client side timeout for all devices in the group
 *
 * Set client side timeout for all devices composing the group in milliseconds. Any method which takes longer
 * than this time to execute will throw an exception.
 *
 * @param [in] tmo_ms The timeout value
 */
  virtual void set_timeout_millis (int tmo_ms);

  //- command execution
  //---------------------------------------------
/**
 * Executes a Tango command on a group
 *
 * Executes a Tango command on a group. This method is synchronous and does not return until replies are
 * obtained or timeouts occurred.
 * The parameter c is the name of the command.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * Command results are returned in a GroupCmdReplyList. See Obtaining command result for details
 * (Chapter 4.7.3.1 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>). See also Case 1 of executing a command
 * (Chapter 4.7.3.2 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] c The command name
 * @param [in] fwd The forward flag
 * @return The group command result
 */
  GroupCmdReplyList command_inout (const std::string& c, bool fwd = true);
/**
 * Executes a Tango command with the same input data on a group
 *
 * Executes a Tango command on each device in the group. This method is synchronous and does not return
 * until replies are obtained or timeouts occurred.
 * The parameter c is the name of the command.
 * The second parameter d is a Tango generic container for command carrying the command argument.
 * See the Tango::DeviceData documentation.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * Command results are returned in a GroupCmdReplyList. See Obtaining command results
 * (Chapter 4.7.3.1 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Case 2 of executing a command (Chapter 4.7.3.4 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] c The command name
 * @param [in] d The command data
 * @param [in] fwd The forward flag
 * @return The group command result
 */
  GroupCmdReplyList command_inout (const std::string& c, const DeviceData& d, bool fwd = true);
/**
 * Executes a Tango command with the different input data on a group (Using DeviceData class instances)
 *
 * Executes a Tango command on each device in the group. This method is synchronous and does not return
 * until replies are obtained or timeouts occurred.
 * This implementation of command_inout allows passing a specific input argument to each device in
 * the group. In order to use this form of command_inout, the user must have an "a priori" and "perfect"
 * knowledge of the devices order in the group.
 * @n The parameter c is the name of the command.
 * The std::vector d contains a specific argument value for each device in the group. Its size must equal Group::get_size(fwd).
 * Otherwise, an exception is thrown. The order of the argument values must follows the order of the devices
 * in the group (d[0] => 1st device, d[1] => 2nd device and so on).
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * Command results are returned in a GroupCmdReplyList. See Obtaining command results (Chpater 4.7.3.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>)
 * for details. See also Case 3 of executing a command (Chapter 4.7.3.5 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example of this special form of
 * command_inout.
 *
 * @param [in] c The command name
 * @param [in] d The command data
 * @param [in] fwd The forward flag
 * @return The group command result
 */
  GroupCmdReplyList command_inout (const std::string& c, const std::vector<DeviceData>& d, bool fwd = true);
/**
 * Executes a Tango command with the different input data on a group
 *
 * Executes a Tango command on each device in the group. This method is synchronous and does not return
 * until replies are obtained or timeouts occurred.
 * This implementation of command_inout allows passing a specific input argument to each device in
 * the group. In order to use this form of command_inout, the user must have an "a priori" and "perfect"
 * knowledge of the devices order in the group.
 * @n The parameter c is the name of the command.
 * The std::vector d contains a specific argument value for each device in the group. Since this method is a
 * template, d is able to contain any Tango command argument type. Its size must equal Group::get_size(fwd).
 * Otherwise, an exception is thrown. The order of the argument values must follows the order of the devices
 * in the group (d[0] => 1st device, d[1] => 2nd device and so on).
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * Command results are returned in a GroupCmdReplyList. See Obtaining command results (Chpater 4.7.3.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>)
 * for details. See also Case 3 of executing a command (Chapter 4.7.3.5 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example of this special form of
 * command_inout.
 *
 * @tparam T The command input data type
 * @param [in] c The command name
 * @param [in] d The command data
 * @param [in] fwd The forward flag
 * @return The group command result
 */
  template<typename T> GroupCmdReplyList command_inout (const std::string& c, const std::vector<T>& d, bool fwd = true);
/**
 * Executes a Tango command on each device in the group asynchronously.
 *
 * Executes a Tango command on each device in the group asynchronously. The method sends the request
 * to all devices and returns immediately. Pass the returned request id to Group::command_inout_reply() to
 * obtain the results.
 * The parameter c is the name of the command.
 * The parameter fgt is a fire and forget flag. If set to true, it means that no reply is expected (i.e. the caller
 * does not care about it and will not even try to get it). A false default value is provided.
 * If the parameter fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * See Case 1 of Executing a command (Chapter 4.7.3.2 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] c The command name
 * @param [in] fgt The command data
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long command_inout_asynch (const std::string& c, bool fgt = false, bool fwd = true);
/**
 * Executes a Tango command with same input data on each device in the group asynchronously.
 *
 * Executes a Tango command on each device in the group asynchronously. The method sends the request
 * to all devices and returns immediately. Pass the returned request id to Group::command_inout_reply() to
 * obtain the results.
 * The parameter c is the name of the command.
 * The second parameter d is a Tango generic container for command carrying the command argument.
 * See the Tango::DeviceData documentation for details.
 * The parameter fgt is a fire and forget flag. If set to true, it means that no reply is expected (i.e. the caller
 * does not care about it and will not even try to get it). A false default value is provided.
 * If the parameter fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * See Case 2 of Executing a command (Chapter 4.7.3.4 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] c The command name
 * @param [in] d The command input data
 * @param [in] fgt The command data
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long command_inout_asynch (const std::string& c, const DeviceData& d, bool fgt = false, bool fwd = true);
/**
 * Executes a Tango command with different input data (using DeviceData object) on each device in the group asynchronously.
 *
 * Executes a Tango command on each device in the group asynchronously. The method send the request to
 * all devices and return immediately. Pass the returned request id to Group::command_inout_reply to obtain
 * the results.
 * This implementation of command_inout allows passing a specific input argument to each device in the
 * group. In order to use this form of command_inout_asynch, the user must have an "a priori" and "perfect"
 * knowledge of the devices order in the group.
 * The parameter c is the name of the command.
 * The std::vector d contains a specific argument value for each device in the group. Its size must equal Group::get_size(fwd). Otherwise, an exception is
 * thrown. The order of the argument values must follows the order of the devices in the group (d[0] => 1st
 * device, d[1] => 2nd device and so on).
 * The parameter fgt is a fire and forget flag. If set to true, it means that no reply is expected (i.e. the caller
 * does not care about it and will not even try to get it). A false default value is provided.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * See Case 3 of Executing a command (Chapter 4.7.3.5 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example of this special form of command_inout.
 *
 * @param [in] c The command name
 * @param [in] d The command input data
 * @param [in] fgt The command data
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long command_inout_asynch (const std::string& c, const std::vector<DeviceData>& d, bool fgt = false, bool fwd = true);
/**
 * Executes a Tango command with different input data on each device in the group asynchronously.
 *
 * Executes a Tango command on each device in the group asynchronously. The method send the request to
 * all devices and return immediately. Pass the returned request id to Group::command_inout_reply to obtain
 * the results.
 * This implementation of command_inout allows passing a specific input argument to each device in the
 * group. In order to use this form of command_inout_asynch, the user must have an "a priori" and "perfect"
 * knowledge of the devices order in the group.
 * The parameter c is the name of the command.
 * The std::vector d contains a specific argument value for each device in the group. Since it's a template data type, d is able to contain
 * any Tango command argument type. Its size must equal Group::get_size(fwd). Otherwise, an exception is
 * thrown. The order of the argument values must follows the order of the devices in the group (d[0] => 1st
 * device, d[1] => 2nd device and so on).
 * The parameter fgt is a fire and forget flag. If set to true, it means that no reply is expected (i.e. the caller
 * does not care about it and will not even try to get it). A false default value is provided.
 * If fwd is set to true (the default), the request is also forwarded to subgroups. Otherwise, it is only
 * applied to the local set of devices.
 * See Case 3 of Executing a command (Chapter 4.7.3.5 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example of this special form of command_inout.
 *
 * @tparam T The command input data type
 * @param [in] c The command name
 * @param [in] d The command input data
 * @param [in] fgt The command data
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  template<typename T> long command_inout_asynch (const std::string& c, const std::vector<T>& d, bool fgt = false, bool fwd = true);
/**
 * Returns the results of an asynchronous command.
 *
 * Returns the results of an asynchronous command.
 * The first parameter req_id is a request identifier previously returned by one of the command_inout_asynch
 * methods.
 * For each device in the hierarchy, if the command result is not yet available, command_inout_replywait
 * timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If
 * timeout_ms is set to 0, command_inout_reply waits "indefinitely".
 * Command results are returned in a GroupCmdReplyList. See Obtaining command results (Chapter 4.7.3.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details.
 *
 * @param [in] req_id The request identifier
 * @param [in] tmo_ms The timeout value
 * @return The group command result
 */
  GroupCmdReplyList command_inout_reply (long req_id, long tmo_ms = 0);

  //- attribute(s) reading
  //---------------------------------------------
/**
 * Reads an attribute on each device in the group
 *
 * Reads an attribute on each device in the group. This method is synchronous and does not return until replies
 * are obtained or timeouts occurred.
 * The parameter a is the name of the attribute to read.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * Attribute values are returned in a GroupAttrReplyList. See Obtaining attribute values (Chapter 4.7.4.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Reading an attribute (Chapter 4.7.4 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] a The attribute name
 * @param [in] fwd The forward flag
 * @return The group attribute data
 */
  GroupAttrReplyList read_attribute (const std::string& a, bool fwd = true);
/**
 * Reads several attributes on each device in the group
 *
 * Reads several attributes on each device in the group. This method is synchronous and does not return until replies
 * are obtained or timeouts occurred.
 * The parameter al is the list of attributes to be read.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * Attribute values are returned in a GroupAttrReplyList. See Obtaining attribute values (Chapter 4.7.4.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Reading an attribute (Chapter 4.7.4 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] al The attribute name list
 * @param [in] fwd The forward flag
 * @return The group attribute data
 */
  GroupAttrReplyList read_attributes (const std::vector<std::string>& al, bool fwd = true);
/**
 * Reads an attribute on each device in the group asynchronously
 *
 * Reads an attribute on each device in the group asynchronously. The method sends the request to all devices
 * and returns immediately. Pass the returned request id to Group::read_attribute_reply() to obtain the results.
 * The parameter a is the name of the attribute to read.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * The last parameter (rsv) is reserved for internal purpose and should not be modify. It may disappear in
 * a near future.
 * See Reading an attribute (Chapter 4.7.4 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] a The attribute name
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long read_attribute_asynch (const std::string& a, bool fwd = true);
/**
 * Reads several attributes on each device in the group asynchronously
 *
 * Reads several attribute on each device in the group asynchronously. The method sends the request to all devices
 * and returns immediately. Pass the returned request id to Group::read_attribute_reply() to obtain the results.
 * The parameter a is the name of the attribute to read.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * The last parameter (rsv) is reserved for internal purpose and should not be modify. It may disappear in
 * a near future.
 * See Reading an attribute (Chapter 4.7.4 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] al The attribute name list
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long read_attributes_asynch (const std::vector<std::string>& al, bool fwd = true);
/**
 * Returns the results of an asynchronous attribute reading
 *
 * Returns the results of an asynchronous attribute reading.
 * The first parameter req_id is a request identifier previously returned by read_attribute_asynch.
 * For each device in the hierarchy, if the attribute value is not yet available, read_attribute_reply wait
 * timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If
 * timeout_ms is set to 0, read_attribute_reply waits "indefinitely".
 * Replies are returned in a GroupAttrReplyList. See Obtaining attribute values (Chapter 4.7.4.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for details
 *
 * @param [in] req_id The attribute name list
 * @param [in] tmo_ms The timeout value
 * @return The group attribute data
 */
  GroupAttrReplyList read_attribute_reply (long req_id, long tmo_ms = 0);
/**
 * Returns the results of an asynchronous attributes reading
 *
 * Returns the results of an asynchronous attributes reading.
 * The first parameter req_id is a request identifier previously returned by read_attribute_asynch.
 * For each device in the hierarchy, if the attribute value is not yet available, read_attribute_reply wait
 * timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If
 * timeout_ms is set to 0, read_attribute_reply waits "indefinitely".
 * Replies are returned in a GroupAttrReplyList. See Obtaining attribute values (Chapter 4.7.4.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for details
 *
 * @param [in] req_id The attribute name list
 * @param [in] tmo_ms The timeout value
 * @return The group attribute data
 */
  GroupAttrReplyList read_attributes_reply (long req_id, long tmo_ms = 0);

  //- attribute writting
  //---------------------------------------------
/**
 * Writes an attribute on each device in the group
 *
 * Writes an attribute on each device in the group. This method is synchronous and does not return until
 * acknowledgements are obtained or timeouts occurred.
 * The first parameter d is a Tango generic container for attribute carrying both the attribute name and the
 * value. See the Tango::DeviceAttribute documentation for details.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * Acknowledgements are returned in a GroupReplyList. See Obtaining acknowledgements (Chapter 4.7.5.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Case 1 of Writing an attribute (Chapter 4.7.5.2 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] d The attribute name and value
 * @param [in] fwd The forward flag
 * @return The group reply
 */
  GroupReplyList write_attribute (const DeviceAttribute& d, bool fwd = true);
/**
 * Writes several attributes on each device in the group (using DeviceAttribute)
 *
 * Writes several attributes on each device in the group. This method is synchronous and does not return until
 * acknowledgements are obtained or timeouts occurred.
 * The first parameter d is a vector of Tango generic container for attribute carrying both the attribute name and the
 * value. See the Tango::DeviceAttribute documentation for details.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * Acknowledgements are returned in a GroupReplyList. See Obtaining acknowledgements (Chapter 4.7.5.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Case 2 of Writing an attribute (Chapter 4.7.5.3 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] d The attribute names and values
 * @param [in] fwd The forward flag
 * @return The group reply
 */
  GroupReplyList write_attribute (const std::vector<DeviceAttribute>& d, bool fwd = true);
/**
 * Writes one attributes on each device in the group with specific value per device
 *
 * Writes an attribute on each device in the group. This method is synchronous and does not return until
 * replies are obtained or timeouts occurred.
 * This implementation of write_attribute allows writing a specific value to each device in the group. In
 * order to use this form of write_attribute, the user must have an "a priori" and "perfect" knowledge of the
 * devices order in the group.
 * The parameter a is the name of the attribute.
 * The std::vector d contains a specific value for each device in the group. Since this method is a template,
 * d is able to contain any Tango attribute type. Its size must equal Group::get_size(fwd). Otherwise, an
 * exception is thrown. The order of the attribute values must follows the order of the devices in the group
 * (d[0] => 1st device, d[1] => 2nd device and so on).
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * Acknowledgements are returned in a GroupReplyList. See Obtaining acknowledgements (Chapter 4.7.5.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details. See also Case 2 of Writing an attribute (Chapter 4.7.5.3 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @tparam T The attribute data type
 * @param [in] n The attribute name
 * @param [in] d The attribute names and values
 * @param [in] fwd The forward flag
 * @return The group reply
 */
  template<typename T> GroupReplyList write_attribute (const std::string& n, const std::vector<T>& d, bool fwd = true);
/**
 * Writes an attribute on each device in the group asynchronously.
 *
 * Write an attribute on each device in  the group asynchronously. The method sends the request to all
 * devices and returns immediately. Pass the returned request id to Group::write_attribute_reply() to obtain
 * the acknowledgements.
 * The first parameter d is a Tango generic container for attribute carrying both the attribute name and the
 * value. See the Tango::DeviceAttribute documentation for details.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * See Case 1 of Writing an attribute (Chapter 4.7.5.2 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] d The attribute name and value
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long write_attribute_asynch (const DeviceAttribute& d, bool fwd = true);
/**
 * Writes several attributes on each device in the group asynchronously.
 *
 * Write several attributes on each device in  the group asynchronously. The method sends the request to all
 * devices and returns immediately. Pass the returned request id to Group::write_attribute_reply() to obtain
 * the acknowledgements.
 * The first parameter d is a vector of Tango generic container for attribute carrying both the attribute name and the
 * value. See the Tango::DeviceAttribute documentation for details.
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * See Case 1 of Writing an attribute (Chapter 4.7.5.2 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @param [in] d The attribute name and value
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  long write_attribute_asynch (const std::vector<DeviceAttribute>& d, bool fwd = true);
/**
 * Writes an attribute on each device in the group asynchronously (Without DeviceAttribute data)
 *
 * Writes an attribute on each device in the group asynchronously. The method sends the request to all
 * devices and returns immediately. Pass the returned request id to Group::write_attribute_reply() to obtain
 * the acknowledgements.
 * This implementation of write_attribute_asynch allows writing a specific value to each device in the
 * group. In order to use this form of write_attribute_asynch, the user must have an "a priori" and "perfect"
 * knowledge of the devices order in the group.
 * The parameter a is the name of the attribute.
 * The std::vector d contains a specific value for each device in the group. Since this method is a template,
 * d is able to contain any Tango attribute type. Its size must equal Group::get_size(fwd). Otherwise, an
 * exception is thrown. The order of the attribute values must follows the order of the devices in the group
 * (d[0] => 1st device, d[1] => 2nd device and so on).
 * If fwd is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the
 * local set of devices.
 * See Case2 of Writing an attribute (Chapter 4.7.5.3 in <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for an example.
 *
 * @tparam T The attribute data type
 * @param [in] a The attribute name
 * @param [in] d The attribute value(s)
 * @param [in] fwd The forward flag
 * @return The call identifier
 */
  template<typename T> long write_attribute_asynch (const std::string &a, const std::vector<T> &d, bool fwd = true);
/**
 * Returns the acknowledgements of an asynchronous attribute writing.
 *
 * Returns the acknowledgements of an asynchronous attribute writing.
 * The first parameter req_id is a request identifier previously returned by one of the write_attribute_asynch
 * implementation.
 * For each device in the hierarchy, if the acknowledgement is not yet available, write_attribute_replywait
 * timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If
 * timeout_ms is set to 0, write_attribute_reply waits "indefinitely".
 * Acknowledgements are returned in a GroupReplyList. See Obtaining acknowledgements (Chapter 4.7.5.1 in
 * <a href=http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/ds_prog/index.html target=new>Tango book</a>) for
 * details.
 *
 * @param [in] req_id The request identifier
 * @param [in] tmo_ms The timeout value
 * @return The attribute writing acknowledgements
 */
  GroupReplyList write_attribute_reply (long req_id, long tmo_ms = 0);

///@privatesection
  //---------------------------------------------
  //- Misc.
  //---------------------------------------------
  //-
  virtual void dump (int indent_level = 0);
  //-
  virtual void dump (TangoSys_OMemStream& oms, int indent_level = 0);
//@}

private:
  //-
  long next_asynch_request_id ();
  //-
  bool add_i (GroupElement* e, bool fwd = true);
  //-
  void remove_i (const std::string& p, bool fwd = true);
  //-
  GroupElement* find_i (const std::string& n, bool fwd = true);
  //-
  GroupElements get_hiearchy ();
  //-
  Group* get_group_i (const std::string& n);
  //-
  long get_size_i (bool fwd);
  //-
  void push_async_request (long rid, bool fwded);
  //-
  void pop_async_request (long rid);
  //-
  virtual bool is_device_i ();
  //-
  virtual bool is_group_i ();

#ifdef TANGO_GROUP_HAS_THREAD_SAFE_IMPL
  omni_mutex elements_mutex;
#endif
  //- elements
  GroupElements elements;
  //- asynch request repository
  AsynchRequestDesc arp;
  //- pseudo asynch. req. id generator
  long asynch_req_id;

  //- forbidden methods
  Group ();
  Group (const Group&);
  Group& operator=(const Group&);

  //- private part of the asynch impl
  virtual long command_inout_asynch_i (const std::string& c, bool fgt, bool fwd, long ari);
  virtual long command_inout_asynch_i (const std::string& c, const DeviceData& d, bool fgt, bool fwd, long ari);
  virtual long command_inout_asynch_i (const std::string& c, const std::vector<DeviceData>& d, bool fgt, bool fwd, long ari);
  template<typename T> long command_inout_asynch_i (const std::string& c, /*const*/ std::vector<T>& d, bool fgt, bool fwd, long ari);
  virtual GroupCmdReplyList command_inout_reply_i (long req_id, long tmo_ms);

  virtual long read_attribute_asynch_i (const std::string& a, bool fwd, long ari);
  virtual GroupAttrReplyList read_attribute_reply_i (long req_id, long tmo_ms);

  virtual long read_attributes_asynch_i (const std::vector<std::string>& al, bool fwd, long ari);
  virtual GroupAttrReplyList read_attributes_reply_i (long req_id, long tmo_ms);

  virtual long write_attribute_asynch_i (const DeviceAttribute& d, bool fwd, long ari);
  virtual long write_attribute_asynch_i (const std::vector<DeviceAttribute>& d, bool fwd, long ari);
  template<typename T> long write_attribute_asynch_i (const std::string& a, /*const*/ std::vector<T>& d, bool fwd, long ari);
  virtual GroupReplyList write_attribute_reply_i (long req_id, long tmo_ms);
};

//=============================================================================
// class GroupDeviceElement: a device element
//=============================================================================
class GroupDeviceElement : public GroupElement
{
  friend class Group;
  friend class GroupElementFactory;

public:

  //---------------------------------------------
  //- Group management
  //---------------------------------------------
  //-
  virtual DeviceProxy* get_device (const std::string& n);
  //-
  virtual DeviceProxy* get_device (long idx);
  //-
  virtual DeviceProxy* operator[] (long idx);

  //---------------------------------------------
  //- a la DeviceProxy interface
  //---------------------------------------------
  //-
  virtual bool ping (bool fwd = true);
  //-
  virtual void set_timeout_millis (int tmo_ms);

  //---------------------------------------------
  //- Misc
  //---------------------------------------------
  //-
  virtual void dump (int indent_level = 0);
  //-
  virtual void dump (TangoSys_OMemStream& oms, int indent_level = 0);
  //-
  virtual bool is_connected();

private:
  //- the device proxy
  DeviceProxy *dp;
  //- asynch request repository
  AsynchRequestRep arp;

  //- forbidden methods
  GroupDeviceElement ();
  GroupDeviceElement (const GroupDeviceElement&);
  GroupDeviceElement& operator=(const GroupDeviceElement&);

  //- ctor: creates an GroupDeviceElement named <name>
  GroupDeviceElement (const std::string& name);
  //- ctor: creates a GroupDeviceElement named <name> with timeout set to tmo_ms milliseconds
  GroupDeviceElement (const std::string& name, int tmo_ms);
  //- dtor: release resources
  virtual ~GroupDeviceElement();

  //- build connection to the device (may throw DevFailed)
  DeviceProxy * connect ();
  //- close connection
  void disconnect ();

  //- a trick to get a valid device proxy or an exception
  inline DeviceProxy* dev_proxy () {
    return dp ? dp : connect();
  }

  //- element identification
  virtual bool is_device_i ();
  virtual bool is_group_i ();

  //- size (group interface)
  virtual long get_size_i (bool fwd = true);

  //- private part of the asynch impl
  virtual long command_inout_asynch_i (const std::string& c, bool fgt, bool fwd, long ari);
  virtual long command_inout_asynch_i (const std::string& c,  const DeviceData& d, bool fgt, bool fwd, long ari);
  virtual GroupCmdReplyList command_inout_reply_i (long req_id, long tmo_ms);

  virtual long read_attribute_asynch_i (const std::string& a, bool fwd, long ari);
  virtual GroupAttrReplyList read_attribute_reply_i (long req_id, long tmo_ms);

  virtual long read_attributes_asynch_i (const std::vector<std::string>& al, bool fwd, long ari);
  virtual GroupAttrReplyList read_attributes_reply_i (long req_id, long tmo_ms);

  virtual long write_attribute_asynch_i (const DeviceAttribute& d, bool fwd, long ari);
  virtual GroupReplyList write_attribute_reply_i (long req_id, long tmo_ms);
};

//=============================================================================
// GroupCmdReply::operator>> template impl.
//=============================================================================
template <typename T>
bool GroupCmdReply::operator>> (T& dest)
{
  bool result = true;
  if (GroupReply::group_element_enabled_m == false)
  {
    if (exception_enabled)
    {
      Tango::DevErrorList errors(1);
      errors.length(1);
      errors[0].severity = Tango::ERR;
      errors[0].desc = CORBA::string_dup("no available data");
      errors[0].reason = CORBA::string_dup("no data - group member is disabled");
      errors[0].origin = CORBA::string_dup("GroupCmdReply::operator>>");
      DevFailed df(errors);
      throw df;
    }
    result = false;
  }
  else if (GroupReply::has_failed_m == true)
  {
    if (exception_enabled)
      throw GroupReply::exception_m;
    result = false;
  }
  else
  {
    std::bitset<DeviceData::numFlags> bs;
    data_m.exceptions(exception_enabled ? bs.set() : bs.reset());
    try
    {
      result = data_m >> dest;
    }
    catch (const DevFailed& df)
    {
      GroupReply::exception_m = df;
      if (exception_enabled)
        throw GroupReply::exception_m;
      result = false;
    }
    catch (...) {
      if (exception_enabled)
      {
        Tango::DevErrorList errors(1);
        errors.length(1);
        errors[0].severity = Tango::ERR;
        errors[0].desc = CORBA::string_dup("unknown exception caught");
        errors[0].reason = CORBA::string_dup("an error occured while trying to extract data");
        errors[0].origin = CORBA::string_dup("GroupCmdReply::operator>>");
        DevFailed df(errors);
        GroupReply::exception_m = df;
        throw GroupReply::exception_m;
      }
      result = false;
    }
  }
  return result;
}

//=============================================================================
// GroupAttrReply::operator>> template impl.
//=============================================================================
template <typename T>
bool GroupAttrReply::operator>> (T& dest)
{
  bool result = true;
  if (GroupReply::group_element_enabled_m == false)
  {
    if (exception_enabled)
    {
      Tango::DevErrorList errors(1);
	    errors.length(1);
	    errors[0].severity = Tango::ERR;
	    errors[0].desc = CORBA::string_dup("no available data");
	    errors[0].reason = CORBA::string_dup("no data - group member is disabled");
	    errors[0].origin = CORBA::string_dup("GroupAttrReply::operator>>");
      DevFailed df(errors);
      throw df;
    }
    result = false;
  }
  else if (GroupReply::has_failed_m == true)
  {
    if (exception_enabled)
      throw GroupReply::exception_m;
    result = false;
  }
  else
  {
    std::bitset<DeviceAttribute::numFlags> bs;
    data_m.exceptions(exception_enabled ? bs.set() : bs.reset());
    try
    {
      result = data_m >> dest;
    }
    catch (const DevFailed& df)
    {
      GroupReply::exception_m = df;
      if (exception_enabled)
        throw GroupReply::exception_m;
      result = false;
    }
    catch (...)
    {
      if (exception_enabled)
      {
        Tango::DevErrorList errors(1);
	      errors.length(1);
	      errors[0].severity = Tango::ERR;
	      errors[0].desc = CORBA::string_dup("unknown exception caught");
	      errors[0].reason = CORBA::string_dup("an error occured while trying to extract data");
	      errors[0].origin = CORBA::string_dup("GroupAttrReply::operator>>");
        DevFailed df(errors);
        GroupReply::exception_m = df;
        throw GroupReply::exception_m;
      }
      result = false;
    }
  }
  return result;
}

//=============================================================================
// Group::command_inout template impl.
//=============================================================================
template<typename T>
GroupCmdReplyList Group::command_inout (const std::string& c, const std::vector<T>& d, bool fwd)
{
  long id = command_inout_asynch_i<T>(c, const_cast<std::vector<T>&>(d), false, fwd, -1);
  return command_inout_reply_i(id, 0);
}

//=============================================================================
// Group::command_inout_asynch template impl.
//=============================================================================
template<typename T>
long Group::command_inout_asynch (const std::string& c, const std::vector<T>& d, bool fgt, bool fwd)
{
  return command_inout_asynch_i<T>(c, const_cast<std::vector<T>&>(d), fgt, fwd, -1);
}

//=============================================================================
// Group::command_inout_asynch template impl.
//=============================================================================
template<typename T>
long Group::command_inout_asynch_i (const std::string& c, /*const*/ std::vector<T>& d, bool fgt, bool fwd, long ari)
{
  #ifdef TANGO_GROUP_HAS_THREAD_SAFE_IMPL
    omni_mutex_lock guard(elements_mutex);
  #endif

  long gsize = get_size_i(fwd);
  if (gsize != static_cast<long>(d.size()))
  {
    TangoSys_OMemStream desc;
	  desc << "the size of the input argument list must equal the number of device in the group"
         << " [expected:"
         << gsize
         << " - got:"
         << d.size()
         << "]"
         << ends;
    ApiDataExcept::throw_exception((const char*)API_MethodArgument,
                                   (const char*)desc.str().c_str(),
                                   (const char*)"Group::command_inout_asynch");
  }

  if (ari == -1)
    ari = next_asynch_request_id();

  for (unsigned int i = 0, j = 0; i < elements.size(); i++)
  {
    if (elements[i]->is_device_i())
    {
      Tango::DeviceData dd;
      dd << d[j++];
      elements[i]->command_inout_asynch_i(c, dd, fgt, false, ari);
    }
    else if (fwd)
    {
      Tango::Group * g = reinterpret_cast<Tango::Group*>(elements[i]);
      long gsize = g->get_size_i(fwd);
      std::vector<T> sub_d(d.begin() + j,  d.begin() + j + gsize);
      reinterpret_cast<Tango::Group*>(elements[i])->command_inout_asynch_i<T>(c, sub_d, fgt, fwd, ari);
      j += gsize;
    }
  }

  if (fgt == false) {
    push_async_request(ari, fwd);
  }

  return ari;
}

//=============================================================================
// Group::write_attribute_asynch template impl.
//=============================================================================
template<typename T>
GroupReplyList Group::write_attribute (const std::string& a, const std::vector<T>& d, bool fwd)
{
  long id = write_attribute_asynch_i<T>(a, const_cast<std::vector<T>&>(d), fwd, -1);
  return write_attribute_reply(id);
}

//=============================================================================
// Group::write_attribute_asynch template impl.
//=============================================================================
template<typename T>
long Group::write_attribute_asynch (const std::string& a, const std::vector<T>& d, bool fwd)
{
  return write_attribute_asynch_i<T>(a, const_cast<std::vector<T>&>(d), fwd, -1);
}

//=============================================================================
// Group::write_attribute_asynch_i template impl.
//=============================================================================
template<typename T>
long Group::write_attribute_asynch_i (const std::string& a, /*const*/ std::vector<T>& d, bool fwd, long ari)
{
#ifdef TANGO_GROUP_HAS_THREAD_SAFE_IMPL
  omni_mutex_lock guard(elements_mutex);
#endif

  GroupReplyList rl;
  long gsize = get_size_i(fwd);
  if (gsize != static_cast<long>(d.size()))
  {
    TangoSys_OMemStream desc;
	  desc << "the size of the input argument list must equal the number of device in the group"
         << " [expected:"
         << gsize
         << " - got:"
         << d.size()
         << "]"
         << ends;
    ApiDataExcept::throw_exception((const char*)API_MethodArgument,
                                   (const char*)desc.str().c_str(),
                                   (const char*)"Group::write_attribute_asynch");
  }

  if (ari == -1)
    ari = next_asynch_request_id();

  DeviceAttribute da;
  da.name = a;

  for (unsigned int i = 0, j = 0; i < elements.size(); i++)
  {
    if (elements[i]->is_device_i())
    {
      da << d[j++];
      elements[i]->write_attribute_asynch_i(da, false, ari);
    }
    else if (fwd)
    {
      Tango::Group * g = reinterpret_cast<Tango::Group*>(elements[i]);
      long gsize = g->get_size_i(fwd);
      std::vector<T> sub_d(d.begin() + j,  d.begin() + j + gsize);
      reinterpret_cast<Tango::Group*>(elements[i])->write_attribute_asynch_i(a, sub_d, fwd, ari);
      j += gsize;
    }
  }
  push_async_request(ari, fwd);
  return ari;
}

} // namespace Tango


#endif /* _GROUP_H_ */