From 1328d62f9d3a2eb9f089d531614302005c29ec37 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 21 Jun 2015 21:56:59 +0200 Subject: Replace MGMT socket by ZMQ, make services shared_ptr --- src/ConfigParser.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/ConfigParser.cpp') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 254a385..b210ac0 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -221,18 +221,35 @@ void parse_ptree(boost::property_tree::ptree& pt, /******************** READ SERVICES PARAMETERS *************/ - map allservices; + map > allservices; /* For each service, we keep a separate SCIdS counter */ - map SCIdS_per_service; + map, int> SCIdS_per_service; ptree pt_services = pt.get_child("services"); for (ptree::iterator it = pt_services.begin(); it != pt_services.end(); ++it) { string serviceuid = it->first; ptree pt_service = it->second; - DabService* service = new DabService(serviceuid); - ensemble->services.push_back(service); + + shared_ptr service; + + bool service_already_existing = false; + + for (auto srv : ensemble->services) + { + if (srv->uid == serviceuid) { + service = srv; + service_already_existing = true; + break; + } + } + + if (not service_already_existing) { + auto new_srv = make_shared(serviceuid); + ensemble->services.push_back(new_srv); + service = new_srv; + } int success = -5; @@ -298,7 +315,7 @@ void parse_ptree(boost::property_tree::ptree& pt, ptree pt_subchans = pt.get_child("subchannels"); for (ptree::iterator it = pt_subchans.begin(); it != pt_subchans.end(); ++it) { string subchanuid = it->first; - dabSubchannel* subchan = new dabSubchannel(); + dabSubchannel* subchan = new dabSubchannel(subchanuid); ensemble->subchannels.push_back(subchan); @@ -331,7 +348,7 @@ void parse_ptree(boost::property_tree::ptree& pt, string componentuid = it->first; ptree pt_comp = it->second; - DabService* service; + shared_ptr service; try { // Those two uids serve as foreign keys to select the service+subchannel string service_uid = pt_comp.get("service"); -- cgit v1.2.3