Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit e5ebbff

Browse files
committed
Rename EventPar struct to EventSubscriptionState
1 parent 1a07976 commit e5ebbff

File tree

7 files changed

+60
-35
lines changed

7 files changed

+60
-35
lines changed

cppapi/server/device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6106,13 +6106,13 @@ void DeviceImpl::remove_local_command(const std::string &cmd_name)
61066106
//
61076107
//------------------------------------------------------------------------------------------------------------------
61086108

6109-
void DeviceImpl::get_event_param(std::vector<EventPar> &eve)
6109+
void DeviceImpl::get_event_param(EventSubscriptionStates& eve)
61106110
{
61116111
ZmqEventSupplier *event_supplier_zmq = Util::instance()->get_zmq_event_supplier();
61126112

61136113
if (event_supplier_zmq->any_dev_intr_client(this) == true)
61146114
{
6115-
EventPar ep;
6115+
EventSubscriptionState ep;
61166116

61176117
ep.notifd = false;
61186118
ep.zmq = true;
@@ -6139,7 +6139,7 @@ void DeviceImpl::get_event_param(std::vector<EventPar> &eve)
61396139
//
61406140
//------------------------------------------------------------------------------------------------------------------
61416141

6142-
void DeviceImpl::set_event_param(std::vector<EventPar> &eve)
6142+
void DeviceImpl::set_event_param(const EventSubscriptionStates& eve)
61436143
{
61446144
for (size_t loop = 0; loop < eve.size(); loop++)
61456145
{

cppapi/server/device.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <deviceclass.h>
4646
#include <devintr.h>
4747
#include <dintrthread.h>
48+
#include "event_subscription_state.h"
4849

4950
namespace Tango
5051
{
@@ -3423,8 +3424,8 @@ class DeviceImpl : public virtual POA_Tango::Device
34233424
void disable_intr_change_ev() {intr_change_ev = false;}
34243425
bool is_intr_change_ev_enable() {return intr_change_ev;}
34253426

3426-
void get_event_param(std::vector<EventPar> &);
3427-
void set_event_param(std::vector<EventPar> &);
3427+
void get_event_param(EventSubscriptionStates&);
3428+
void set_event_param(const EventSubscriptionStates&);
34283429

34293430
void set_client_lib(int _l) {if (count(client_lib.begin(),client_lib.end(),_l)==0)client_lib.push_back(_l);}
34303431

cppapi/server/dserver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ void DServer::restart(std::string &d_name)
882882

883883
std::vector<PollObj *> &p_obj = dev_to_del->get_poll_obj_list();
884884
std::vector<Pol> dev_pol;
885-
std::vector<EventPar> eve;
885+
EventSubscriptionStates eve;
886886

887887
for (i = 0;i < p_obj.size();i++)
888888
{
@@ -1193,7 +1193,7 @@ void ServRestartThread::run(void *ptr)
11931193
// Memorize event parameters and devices interface
11941194
//
11951195

1196-
std::map<std::string,std::vector<EventPar> > map_events;
1196+
ServerEventSubscriptionState map_events;
11971197
std::map<std::string,DevIntr> map_dev_inter;
11981198

11991199
dev->mem_event_par(map_events);
@@ -1977,14 +1977,14 @@ void DServer::mcast_event_for_att(std::string &dev_name,std::string &att_name,st
19771977
//
19781978
//------------------------------------------------------------------------------------------------------------------
19791979

1980-
void DServer::mem_event_par(std::map<std::string,std::vector<EventPar> > &_map)
1980+
void DServer::mem_event_par(ServerEventSubscriptionState& _map)
19811981
{
19821982
for (size_t i = 0;i < class_list.size();i++)
19831983
{
19841984
std::vector<DeviceImpl *> &dev_list = class_list[i]->get_device_list();
19851985
for (size_t j = 0;j < dev_list.size();j++)
19861986
{
1987-
std::vector<EventPar> eve;
1987+
EventSubscriptionStates eve;
19881988
dev_list[j]->get_device_attr()->get_event_param(eve);
19891989
dev_list[j]->get_event_param(eve);
19901990

@@ -2010,16 +2010,16 @@ void DServer::mem_event_par(std::map<std::string,std::vector<EventPar> > &_map)
20102010
//
20112011
//------------------------------------------------------------------------------------------------------------------
20122012

2013-
void DServer::apply_event_par(std::map<std::string,std::vector<EventPar> > &_map)
2013+
void DServer::apply_event_par(const ServerEventSubscriptionState& _map)
20142014
{
20152015
for (size_t i = 0;i < class_list.size();i++)
20162016
{
20172017
std::vector<DeviceImpl *> &dev_list = class_list[i]->get_device_list();
20182018
for (size_t j = 0;j < dev_list.size();j++)
20192019
{
20202020
std::string &dev_name = dev_list[j]->get_name();
2021-
std::map<std::string,std::vector<EventPar> >::iterator ite;
2022-
ite = _map.find(dev_name);
2021+
2022+
const auto ite = _map.find(dev_name);
20232023

20242024
if (ite != _map.end())
20252025
{

cppapi/server/dserver.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define _DSERVER_H
3939

4040
#include <tango.h>
41+
#include "event_subscription_state.h"
4142

4243
namespace Tango
4344
{
@@ -128,8 +129,8 @@ public :
128129
void _create_cpp_class(const char *c1,const char *c2) {this->create_cpp_class(c1,c2);}
129130

130131
void mcast_event_for_att(std::string &,std::string &,std::vector<std::string> &);
131-
void mem_event_par(std::map<std::string, std::vector<EventPar> > &);
132-
void apply_event_par(std::map<std::string,std::vector<EventPar> > &);
132+
void mem_event_par(ServerEventSubscriptionState&);
133+
void apply_event_par(const ServerEventSubscriptionState&);
133134

134135
void mem_devices_interface(std::map<std::string,DevIntr> &);
135136
void changed_devices_interface(std::map<std::string,DevIntr> &);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef _EVENT_SUBSCRIPTION_STATE_H
2+
#define _EVENT_SUBSCRIPTION_STATE_H
3+
4+
#include <map>
5+
#include <vector>
6+
#include <string>
7+
8+
namespace Tango
9+
{
10+
11+
using EventClientLibVersion = int;
12+
using EventClientLibVersions = std::vector<EventClientLibVersion>;
13+
14+
struct EventSubscriptionState
15+
{
16+
std::string attribute_name;
17+
18+
EventClientLibVersions change;
19+
EventClientLibVersions archive;
20+
EventClientLibVersions periodic;
21+
EventClientLibVersions user;
22+
EventClientLibVersions att_conf;
23+
24+
bool quality;
25+
bool data_ready;
26+
bool dev_intr_change;
27+
28+
bool notifd;
29+
bool zmq;
30+
};
31+
32+
using EventSubscriptionStates = std::vector<EventSubscriptionState>;
33+
using ServerEventSubscriptionState = std::map<std::string, EventSubscriptionStates>;
34+
35+
}
36+
37+
#endif

cppapi/server/multiattribute.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ void MultiAttribute::read_alarm(std::string &status)
14491449
//
14501450
//------------------------------------------------------------------------------------------------------------------
14511451

1452-
void MultiAttribute::get_event_param(std::vector<EventPar> &eve)
1452+
void MultiAttribute::get_event_param(EventSubscriptionStates& eve)
14531453
{
14541454
unsigned int i;
14551455

@@ -1508,7 +1508,7 @@ void MultiAttribute::get_event_param(std::vector<EventPar> &eve)
15081508

15091509
if (once_more == true)
15101510
{
1511-
EventPar ep;
1511+
EventSubscriptionState ep;
15121512

15131513
if (attr_list[i]->use_notifd_event() == true)
15141514
ep.notifd = true;
@@ -1548,7 +1548,7 @@ void MultiAttribute::get_event_param(std::vector<EventPar> &eve)
15481548
//
15491549
//------------------------------------------------------------------------------------------------------------------
15501550

1551-
void MultiAttribute::set_event_param(std::vector<EventPar> &eve)
1551+
void MultiAttribute::set_event_param(const EventSubscriptionStates& eve)
15521552
{
15531553
for (size_t i = 0;i < eve.size();i++)
15541554
{
@@ -1558,7 +1558,7 @@ void MultiAttribute::set_event_param(std::vector<EventPar> &eve)
15581558

15591559
{
15601560
omni_mutex_lock oml(EventSupplier::get_event_mutex());
1561-
std::vector<int>::iterator ite;
1561+
std::vector<int>::const_iterator ite;
15621562

15631563
if (eve[i].change.empty() == false)
15641564
{

cppapi/server/multiattribute.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,14 @@
3838
#define _MULTIATTRIBUTE_H
3939

4040
#include <tango.h>
41+
#include "event_subscription_state.h"
4142

4243
namespace Tango
4344
{
4445

4546
class AttrProperty;
4647
class DeviceClass;
4748

48-
struct EventPar
49-
{
50-
std::string attribute_name;
51-
std::vector<int> change;
52-
std::vector<int> archive;
53-
bool quality;
54-
std::vector<int> periodic;
55-
std::vector<int> user;
56-
std::vector<int> att_conf;
57-
bool data_ready;
58-
bool dev_intr_change;
59-
bool notifd;
60-
bool zmq;
61-
};
62-
6349
//=============================================================================
6450
//
6551
// The MultiAttribute class
@@ -280,8 +266,8 @@ class MultiAttribute
280266
void remove_attribute(std::string &,bool);
281267
std::vector<long> &get_w_attr_list() {return writable_attr_list;}
282268
bool is_att_quality_alarmed();
283-
void get_event_param(std::vector<EventPar> &);
284-
void set_event_param(std::vector<EventPar> &);
269+
void get_event_param(EventSubscriptionStates&);
270+
void set_event_param(const EventSubscriptionStates&);
285271
void add_alarmed_quality_factor(std::string &);
286272
void add_default(std::vector<AttrProperty> &,std::string &,std::string &,long);
287273
void add_attr(Attribute *att);

0 commit comments

Comments
 (0)