From 7e0b72294e955107d135b0e07cd929c737c94969 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Thu, 3 Oct 2019 00:13:38 +0000 Subject: [PATCH] Fix compile error caused by removing namespace swss Signed-off-by: Wenda Ni --- cfgmgr/buffermgr.h | 22 ++++----- cfgmgr/intfmgr.h | 12 ++--- cfgmgr/nbrmgr.h | 6 +-- cfgmgr/portmgr.h | 10 ++--- cfgmgr/teammgr.h | 26 +++++------ cfgmgr/vlanmgr.h | 16 +++---- cfgmgr/vrfmgr.h | 8 ++-- cfgmgr/vxlanmgr.h | 2 +- orchagent/copporch.h | 48 ++++++++++---------- orchagent/countercheckorch.h | 24 +++++----- orchagent/crmorch.cpp | 1 + orchagent/crmorch.h | 26 +++++------ orchagent/flexcounterorch.h | 6 +-- orchagent/notifier.h | 6 +-- orchagent/orch.h | 86 ++++++++++++++++++------------------ orchagent/request_parser.cpp | 3 ++ orchagent/request_parser.h | 40 ++++++++--------- orchagent/switchorch.h | 10 ++--- orchagent/timer.h | 6 +-- orchagent/tunneldecaporch.h | 28 ++++++------ orchagent/vrforch.cpp | 4 ++ orchagent/vrforch.h | 2 +- orchagent/watermarkorch.h | 42 +++++++++--------- 23 files changed, 221 insertions(+), 213 deletions(-) diff --git a/cfgmgr/buffermgr.h b/cfgmgr/buffermgr.h index d3ef1d50a8..a8ce998546 100644 --- a/cfgmgr/buffermgr.h +++ b/cfgmgr/buffermgr.h @@ -14,22 +14,22 @@ namespace swss { #define LOSSLESS_PGS "3-4" typedef struct{ - string size; - string xon; - string xon_offset; - string xoff; - string threshold; + std::string size; + std::string xon; + std::string xon_offset; + std::string xoff; + std::string threshold; } pg_profile_t; -typedef map speed_map_t; -typedef map pg_profile_lookup_t; +typedef std::map speed_map_t; +typedef std::map pg_profile_lookup_t; -typedef map port_cable_length_t; +typedef std::map port_cable_length_t; class BufferMgr : public Orch { public: - BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, string pg_lookup_file, const vector &tableNames); + BufferMgr(DBConnector *cfgDb, DBConnector *stateDb, std::string pg_lookup_file, const std::vector &tableNames); using Orch::doTask; private: @@ -44,8 +44,8 @@ class BufferMgr : public Orch port_cable_length_t m_cableLenLookup; std::string getPgPoolMode(); void readPgProfileLookupFile(std::string); - task_process_status doCableTask(string port, string cable_length); - task_process_status doSpeedUpdateTask(string port, string speed); + task_process_status doCableTask(std::string port, std::string cable_length); + task_process_status doSpeedUpdateTask(std::string port, std::string speed); void doTask(Consumer &consumer); }; diff --git a/cfgmgr/intfmgr.h b/cfgmgr/intfmgr.h index a250ff65fb..a0746e723e 100644 --- a/cfgmgr/intfmgr.h +++ b/cfgmgr/intfmgr.h @@ -13,7 +13,7 @@ namespace swss { class IntfMgr : public Orch { public: - IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; private: @@ -21,12 +21,12 @@ class IntfMgr : public Orch Table m_cfgIntfTable, m_cfgVlanIntfTable; Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable; - void setIntfIp(const string &alias, const string &opCmd, const IpPrefix &ipPrefix); - void setIntfVrf(const string &alias, const string vrfName); - bool doIntfGeneralTask(const vector& keys, const vector& data, const string& op); - bool doIntfAddrTask(const vector& keys, const vector& data, const string& op); + void setIntfIp(const std::string &alias, const std::string &opCmd, const IpPrefix &ipPrefix); + void setIntfVrf(const std::string &alias, const std::string vrfName); + bool doIntfGeneralTask(const std::vector& keys, const std::vector& data, const std::string& op); + bool doIntfAddrTask(const std::vector& keys, const std::vector& data, const std::string& op); void doTask(Consumer &consumer); - bool isIntfStateOk(const string &alias); + bool isIntfStateOk(const std::string &alias); }; } diff --git a/cfgmgr/nbrmgr.h b/cfgmgr/nbrmgr.h index 24d83971a1..6b0c664c80 100644 --- a/cfgmgr/nbrmgr.h +++ b/cfgmgr/nbrmgr.h @@ -17,14 +17,14 @@ namespace swss { class NbrMgr : public Orch { public: - NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + NbrMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; bool isNeighRestoreDone(); private: - bool isIntfStateOk(const string &alias); - bool setNeighbor(const string& alias, const IpAddress& ip, const MacAddress& mac); + bool isIntfStateOk(const std::string &alias); + bool setNeighbor(const std::string& alias, const IpAddress& ip, const MacAddress& mac); void doTask(Consumer &consumer); diff --git a/cfgmgr/portmgr.h b/cfgmgr/portmgr.h index eae407d13c..971f00024c 100644 --- a/cfgmgr/portmgr.h +++ b/cfgmgr/portmgr.h @@ -17,7 +17,7 @@ namespace swss { class PortMgr : public Orch { public: - PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + PortMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; private: @@ -26,12 +26,12 @@ class PortMgr : public Orch Table m_statePortTable; ProducerStateTable m_appPortTable; - set m_portList; + std::set m_portList; void doTask(Consumer &consumer); - bool setPortMtu(const string &alias, const string &mtu); - bool setPortAdminStatus(const string &alias, const bool up); - bool isPortStateOk(const string &alias); + bool setPortMtu(const std::string &alias, const std::string &mtu); + bool setPortAdminStatus(const std::string &alias, const bool up); + bool isPortStateOk(const std::string &alias); }; } diff --git a/cfgmgr/teammgr.h b/cfgmgr/teammgr.h index ce3864150f..e0e0410db1 100644 --- a/cfgmgr/teammgr.h +++ b/cfgmgr/teammgr.h @@ -14,7 +14,7 @@ class TeamMgr : public Orch { public: TeamMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *staDb, - const vector &tables); + const std::vector &tables); using Orch::doTask; private: @@ -28,7 +28,7 @@ class TeamMgr : public Orch ProducerStateTable m_appPortTable; ProducerStateTable m_appLagTable; - set m_lagList; + std::set m_lagList; MacAddress m_mac; @@ -37,19 +37,19 @@ class TeamMgr : public Orch void doLagMemberTask(Consumer &consumer); void doPortUpdateTask(Consumer &consumer); - task_process_status addLag(const string &alias, int min_links, bool fall_back); - bool removeLag(const string &alias); - task_process_status addLagMember(const string &lag, const string &member); - bool removeLagMember(const string &lag, const string &member); + task_process_status addLag(const std::string &alias, int min_links, bool fall_back); + bool removeLag(const std::string &alias); + task_process_status addLagMember(const std::string &lag, const std::string &member); + bool removeLagMember(const std::string &lag, const std::string &member); - bool setLagAdminStatus(const string &alias, const string &admin_status); - bool setLagMtu(const string &alias, const string &mtu); + bool setLagAdminStatus(const std::string &alias, const std::string &admin_status); + bool setLagMtu(const std::string &alias, const std::string &mtu); - bool isPortEnslaved(const string &); - bool findPortMaster(string &, const string &); - bool checkPortIffUp(const string &); - bool isPortStateOk(const string&); - bool isLagStateOk(const string&); + bool isPortEnslaved(const std::string &); + bool findPortMaster(std::string &, const std::string &); + bool checkPortIffUp(const std::string &); + bool isPortStateOk(const std::string&); + bool isLagStateOk(const std::string&); }; } diff --git a/cfgmgr/vlanmgr.h b/cfgmgr/vlanmgr.h index aff14999c2..469f16ccaf 100644 --- a/cfgmgr/vlanmgr.h +++ b/cfgmgr/vlanmgr.h @@ -14,7 +14,7 @@ namespace swss { class VlanMgr : public Orch { public: - VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; private: @@ -27,18 +27,18 @@ class VlanMgr : public Orch void doTask(Consumer &consumer); void doVlanTask(Consumer &consumer); void doVlanMemberTask(Consumer &consumer); - void processUntaggedVlanMembers(string vlan, const string &members); + void processUntaggedVlanMembers(std::string vlan, const std::string &members); bool addHostVlan(int vlan_id); bool removeHostVlan(int vlan_id); - bool setHostVlanAdminState(int vlan_id, const string &admin_status); + bool setHostVlanAdminState(int vlan_id, const std::string &admin_status); bool setHostVlanMtu(int vlan_id, uint32_t mtu); - bool addHostVlanMember(int vlan_id, const string &port_alias, const string& tagging_mode); - bool removeHostVlanMember(int vlan_id, const string &port_alias); - bool isMemberStateOk(const string &alias); - bool isVlanStateOk(const string &alias); + bool addHostVlanMember(int vlan_id, const std::string &port_alias, const std::string& tagging_mode); + bool removeHostVlanMember(int vlan_id, const std::string &port_alias); + bool isMemberStateOk(const std::string &alias); + bool isVlanStateOk(const std::string &alias); bool isVlanMacOk(); - bool isVlanMemberStateOk(const string &vlanMemberKey); + bool isVlanMemberStateOk(const std::string &vlanMemberKey); }; } diff --git a/cfgmgr/vrfmgr.h b/cfgmgr/vrfmgr.h index ab20b7ffd3..aae82a906c 100644 --- a/cfgmgr/vrfmgr.h +++ b/cfgmgr/vrfmgr.h @@ -15,18 +15,18 @@ namespace swss { class VrfMgr : public Orch { public: - VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + VrfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; private: - bool delLink(const string& vrfName); - bool setLink(const string& vrfName); + bool delLink(const std::string& vrfName); + bool setLink(const std::string& vrfName); void recycleTable(uint32_t table); uint32_t getFreeTable(void); void handleVnetConfigSet(KeyOpFieldsValuesTuple &t); void doTask(Consumer &consumer); - map m_vrfTableMap; + std::map m_vrfTableMap; set m_freeTables; Table m_stateVrfTable; diff --git a/cfgmgr/vxlanmgr.h b/cfgmgr/vxlanmgr.h index ab3a81938d..a916bf8bdd 100644 --- a/cfgmgr/vxlanmgr.h +++ b/cfgmgr/vxlanmgr.h @@ -14,7 +14,7 @@ namespace swss { class VxlanMgr : public Orch { public: - VxlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector &tableNames); + VxlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const std::vector &tableNames); using Orch::doTask; typedef struct VxlanInfo diff --git a/orchagent/copporch.h b/orchagent/copporch.h index 7f02935c84..5fc5bc2ae8 100644 --- a/orchagent/copporch.h +++ b/orchagent/copporch.h @@ -6,33 +6,33 @@ #include "orch.h" // trap fields -const string copp_trap_id_list = "trap_ids"; -const string copp_trap_action_field = "trap_action"; -const string copp_trap_priority_field = "trap_priority"; +const std::string copp_trap_id_list = "trap_ids"; +const std::string copp_trap_action_field = "trap_action"; +const std::string copp_trap_priority_field = "trap_priority"; -const string copp_queue_field = "queue"; +const std::string copp_queue_field = "queue"; // policer fields -const string copp_policer_meter_type_field = "meter_type"; -const string copp_policer_mode_field = "mode"; -const string copp_policer_color_field = "color"; -const string copp_policer_cbs_field = "cbs"; -const string copp_policer_cir_field = "cir"; -const string copp_policer_pbs_field = "pbs"; -const string copp_policer_pir_field = "pir"; -const string copp_policer_action_green_field = "green_action"; -const string copp_policer_action_red_field = "red_action"; -const string copp_policer_action_yellow_field = "yellow_action"; +const std::string copp_policer_meter_type_field = "meter_type"; +const std::string copp_policer_mode_field = "mode"; +const std::string copp_policer_color_field = "color"; +const std::string copp_policer_cbs_field = "cbs"; +const std::string copp_policer_cir_field = "cir"; +const std::string copp_policer_pbs_field = "pbs"; +const std::string copp_policer_pir_field = "pir"; +const std::string copp_policer_action_green_field = "green_action"; +const std::string copp_policer_action_red_field = "red_action"; +const std::string copp_policer_action_yellow_field = "yellow_action"; /* TrapGroupPolicerTable: trap group ID, policer ID */ -typedef map TrapGroupPolicerTable; +typedef std::map TrapGroupPolicerTable; /* TrapIdTrapGroupTable: trap ID, trap group ID */ -typedef map TrapIdTrapGroupTable; +typedef std::map TrapIdTrapGroupTable; class CoppOrch : public Orch { public: - CoppOrch(DBConnector *db, string tableName); + CoppOrch(swss::DBConnector *db, std::string tableName); protected: object_map m_trap_group_map; @@ -44,15 +44,15 @@ class CoppOrch : public Orch void initDefaultTrapIds(); task_process_status processCoppRule(Consumer& consumer); - bool isValidList(vector &trap_id_list, vector &all_items) const; - void getTrapIdList(vector &trap_id_name_list, vector &trap_id_list) const; - bool applyTrapIds(sai_object_id_t trap_group, vector &trap_id_name_list, vector &trap_id_attribs); - bool applyAttributesToTrapIds(sai_object_id_t trap_group_id, const vector &trap_id_list, vector &trap_id_attribs); + bool isValidList(std::vector &trap_id_list, std::vector &all_items) const; + void getTrapIdList(std::vector &trap_id_name_list, std::vector &trap_id_list) const; + bool applyTrapIds(sai_object_id_t trap_group, std::vector &trap_id_name_list, std::vector &trap_id_attribs); + bool applyAttributesToTrapIds(sai_object_id_t trap_group_id, const std::vector &trap_id_list, std::vector &trap_id_attribs); - bool createPolicer(string trap_group, vector &policer_attribs); - bool removePolicer(string trap_group_name); + bool createPolicer(std::string trap_group, std::vector &policer_attribs); + bool removePolicer(std::string trap_group_name); - sai_object_id_t getPolicer(string trap_group_name); + sai_object_id_t getPolicer(std::string trap_group_name); virtual void doTask(Consumer& consumer); }; diff --git a/orchagent/countercheckorch.h b/orchagent/countercheckorch.h index 7d951728bd..ec25344a5d 100644 --- a/orchagent/countercheckorch.h +++ b/orchagent/countercheckorch.h @@ -12,31 +12,31 @@ extern "C" { #include "sai.h" } -typedef vector QueueMcCounters; -typedef array PfcFrameCounters; +typedef std::vector QueueMcCounters; +typedef std::array PfcFrameCounters; class CounterCheckOrch: public Orch { public: - static CounterCheckOrch& getInstance(DBConnector *db = nullptr); - virtual void doTask(SelectableTimer &timer); + static CounterCheckOrch& getInstance(swss::DBConnector *db = nullptr); + virtual void doTask(swss::SelectableTimer &timer); virtual void doTask(Consumer &consumer) {} - void addPort(const Port& port); - void removePort(const Port& port); + void addPort(const swss::Port& port); + void removePort(const swss::Port& port); private: - CounterCheckOrch(DBConnector *db, vector &tableNames); + CounterCheckOrch(swss::DBConnector *db, std::vector &tableNames); virtual ~CounterCheckOrch(void); - QueueMcCounters getQueueMcCounters(const Port& port); + QueueMcCounters getQueueMcCounters(const swss::Port& port); PfcFrameCounters getPfcFrameCounters(sai_object_id_t portId); void mcCounterCheck(); void pfcFrameCounterCheck(); - map m_mcCountersMap; - map m_pfcFrameCountersMap; + std::map m_mcCountersMap; + std::map m_pfcFrameCountersMap; - shared_ptr m_countersDb = nullptr; - shared_ptr m_countersTable = nullptr; + std::shared_ptr m_countersDb = nullptr; + std::shared_ptr m_countersTable = nullptr; }; #endif diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index 9e26cd58aa..03dcea26dd 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -20,6 +20,7 @@ extern sai_switch_api_t *sai_switch_api; extern sai_acl_api_t *sai_acl_api; using namespace std; +using namespace swss; const map crmResTypeNameMap = diff --git a/orchagent/crmorch.h b/orchagent/crmorch.h index eac50da992..488a18b3a7 100644 --- a/orchagent/crmorch.h +++ b/orchagent/crmorch.h @@ -37,7 +37,7 @@ enum class CrmThresholdType class CrmOrch : public Orch { public: - CrmOrch(DBConnector *db, string tableName); + CrmOrch(swss::DBConnector *db, std::string tableName); void incCrmResUsedCounter(CrmResourceType resource); void decCrmResUsedCounter(CrmResourceType resource); // Increment "used" counter for the ACL table/group CRM resources @@ -50,9 +50,9 @@ class CrmOrch : public Orch void decCrmAclTableUsedCounter(CrmResourceType resource, sai_object_id_t tableId); private: - shared_ptr m_countersDb = nullptr; - shared_ptr
m_countersCrmTable = nullptr; - SelectableTimer *m_timer = nullptr; + std::shared_ptr m_countersDb = nullptr; + std::shared_ptr m_countersCrmTable = nullptr; + swss::SelectableTimer *m_timer = nullptr; struct CrmResourceCounter { @@ -63,29 +63,29 @@ class CrmOrch : public Orch struct CrmResourceEntry { - CrmResourceEntry(string name, CrmThresholdType thresholdType, uint32_t lowThreshold, uint32_t highThreshold); + CrmResourceEntry(std::string name, CrmThresholdType thresholdType, uint32_t lowThreshold, uint32_t highThreshold); - string name; + std::string name; CrmThresholdType thresholdType = CrmThresholdType::CRM_PERCENTAGE; uint32_t lowThreshold = 70; uint32_t highThreshold = 85; - map countersMap; + std::map countersMap; uint32_t exceededLogCounter = 0; }; - chrono::seconds m_pollingInterval; + std::chrono::seconds m_pollingInterval; - map m_resourcesMap; + std::map m_resourcesMap; void doTask(Consumer &consumer); - void handleSetCommand(const string& key, const vector& data); - void doTask(SelectableTimer &timer); + void handleSetCommand(const std::string& key, const std::vector& data); + void doTask(swss::SelectableTimer &timer); void getResAvailableCounters(); void updateCrmCountersTable(); void checkCrmThresholds(); - string getCrmAclKey(sai_acl_stage_t stage, sai_acl_bind_point_type_t bindPoint); - string getCrmAclTableKey(sai_object_id_t id); + std::string getCrmAclKey(sai_acl_stage_t stage, sai_acl_bind_point_type_t bindPoint); + std::string getCrmAclTableKey(sai_object_id_t id); }; diff --git a/orchagent/flexcounterorch.h b/orchagent/flexcounterorch.h index c651a49d38..27f6e64ab1 100644 --- a/orchagent/flexcounterorch.h +++ b/orchagent/flexcounterorch.h @@ -13,12 +13,12 @@ class FlexCounterOrch: public Orch { public: void doTask(Consumer &consumer); - FlexCounterOrch(DBConnector *db, vector &tableNames); + FlexCounterOrch(swss::DBConnector *db, std::vector &tableNames); virtual ~FlexCounterOrch(void); private: - shared_ptr m_flexCounterDb = nullptr; - shared_ptr m_flexCounterGroupTable = nullptr; + std::shared_ptr m_flexCounterDb = nullptr; + std::shared_ptr m_flexCounterGroupTable = nullptr; }; #endif diff --git a/orchagent/notifier.h b/orchagent/notifier.h index ca9011f23d..2df9c7ff6c 100644 --- a/orchagent/notifier.h +++ b/orchagent/notifier.h @@ -2,14 +2,14 @@ class Notifier : public Executor { public: - Notifier(NotificationConsumer *select, Orch *orch, const string &name) + Notifier(swss::NotificationConsumer *select, Orch *orch, const std::string &name) : Executor(select, orch, name) { } - NotificationConsumer *getNotificationConsumer() const + swss::NotificationConsumer *getNotificationConsumer() const { - return static_cast(getSelectable()); + return static_cast(getSelectable()); } void execute() diff --git a/orchagent/orch.h b/orchagent/orch.h index d9d934c241..69895a9cc1 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -50,14 +50,14 @@ typedef enum task_ignore } task_process_status; -typedef map object_map; -typedef pair object_map_pair; +typedef std::map object_map; +typedef std::pair object_map_pair; -typedef map type_map; -typedef pair type_map_pair; -typedef map SyncMap; +typedef std::map type_map; +typedef std::pair type_map_pair; +typedef std::map SyncMap; -typedef pair table_name_with_pri_t; +typedef std::pair table_name_with_pri_t; class Orch; @@ -65,10 +65,10 @@ class Orch; // 1. one Orch can have one or more Executor // 2. one Executor must belong to one and only one Orch // 3. Executor will hold an pointer to new-ed selectable, and delete it during dtor -class Executor : public Selectable +class Executor : public swss::Selectable { public: - Executor(Selectable *selectable, Orch *orch, const string &name) + Executor(swss::Selectable *selectable, Orch *orch, const std::string &name) : m_selectable(selectable) , m_orch(orch) , m_name(name) @@ -92,35 +92,35 @@ class Executor : public Selectable virtual void execute() { } virtual void drain() { } - virtual string getName() const + virtual std::string getName() const { return m_name; } protected: - Selectable *m_selectable; + swss::Selectable *m_selectable; Orch *m_orch; // Name for Executor - string m_name; + std::string m_name; // Get the underlying selectable - Selectable *getSelectable() const { return m_selectable; } + swss::Selectable *getSelectable() const { return m_selectable; } }; class Consumer : public Executor { public: - Consumer(ConsumerTableBase *select, Orch *orch, const string &name) + Consumer(swss::ConsumerTableBase *select, Orch *orch, const std::string &name) : Executor(select, orch, name) { } - ConsumerTableBase *getConsumerTable() const + swss::ConsumerTableBase *getConsumerTable() const { - return static_cast(getSelectable()); + return static_cast(getSelectable()); } - string getTableName() const + std::string getTableName() const { return getConsumerTable()->getTableName(); } @@ -130,11 +130,11 @@ class Consumer : public Executor { return getConsumerTable()->getDbId(); } - string dumpTuple(KeyOpFieldsValuesTuple &tuple); - void dumpPendingTasks(vector &ts); + std::string dumpTuple(swss::KeyOpFieldsValuesTuple &tuple); + void dumpPendingTasks(std::vector &ts); size_t refillToSync(); - size_t refillToSync(Table* table); + size_t refillToSync(swss::Table* table); void execute(); void drain(); @@ -144,10 +144,10 @@ class Consumer : public Executor { protected: // Returns: the number of entries added to m_toSync - size_t addToSync(std::deque &entries); + size_t addToSync(std::deque &entries); }; -typedef map> ConsumerMap; +typedef std::map> ConsumerMap; typedef enum { @@ -159,23 +159,23 @@ typedef enum failure } ref_resolve_status; -typedef pair TableConnector; -typedef pair> TablesConnector; +typedef std::pair TableConnector; +typedef std::pair> TablesConnector; class Orch { public: - Orch(DBConnector *db, const string tableName, int pri = default_orch_pri); - Orch(DBConnector *db, const vector &tableNames); - Orch(DBConnector *db, const vector &tableNameWithPri); - Orch(const vector& tables); + Orch(swss::DBConnector *db, const std::string tableName, int pri = default_orch_pri); + Orch(swss::DBConnector *db, const std::vector &tableNames); + Orch(swss::DBConnector *db, const std::vector &tableNameWithPri); + Orch(const std::vector& tables); virtual ~Orch(); - vector getSelectables(); + std::vector getSelectables(); // add the existing table data (left by warm reboot) to the consumer todo task list. - size_t addExistingData(Table *table); - size_t addExistingData(const string& tableName); + size_t addExistingData(swss::Table *table); + size_t addExistingData(const std::string& tableName); // Prepare for warm start if Redis contains valid input data // otherwise fallback to cold start @@ -186,28 +186,28 @@ class Orch /* Run doTask against a specific executor */ virtual void doTask(Consumer &consumer) = 0; - virtual void doTask(NotificationConsumer &consumer) { } - virtual void doTask(SelectableTimer &timer) { } + virtual void doTask(swss::NotificationConsumer &consumer) { } + virtual void doTask(swss::SelectableTimer &timer) { } /* TODO: refactor recording */ - static void recordTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple); + static void recordTuple(Consumer &consumer, swss::KeyOpFieldsValuesTuple &tuple); - void dumpPendingTasks(vector &ts); + void dumpPendingTasks(std::vector &ts); protected: ConsumerMap m_consumerMap; static void logfileReopen(); - string dumpTuple(Consumer &consumer, KeyOpFieldsValuesTuple &tuple); - ref_resolve_status resolveFieldRefValue(type_map&, const string&, KeyOpFieldsValuesTuple&, sai_object_id_t&); - bool parseIndexRange(const string &input, sai_uint32_t &range_low, sai_uint32_t &range_high); - bool parseReference(type_map &type_maps, string &ref, string &table_name, string &object_name); - ref_resolve_status resolveFieldRefArray(type_map&, const string&, KeyOpFieldsValuesTuple&, vector&); + std::string dumpTuple(Consumer &consumer, swss::KeyOpFieldsValuesTuple &tuple); + ref_resolve_status resolveFieldRefValue(type_map&, const std::string&, swss::KeyOpFieldsValuesTuple&, sai_object_id_t&); + bool parseIndexRange(const std::string &input, sai_uint32_t &range_low, sai_uint32_t &range_high); + bool parseReference(type_map &type_maps, std::string &ref, std::string &table_name, std::string &object_name); + ref_resolve_status resolveFieldRefArray(type_map&, const std::string&, swss::KeyOpFieldsValuesTuple&, std::vector&); /* Note: consumer will be owned by this class */ void addExecutor(Executor* executor); - Executor *getExecutor(string executorName); + Executor *getExecutor(std::string executorName); private: - void addConsumer(DBConnector *db, string tableName, int pri = default_orch_pri); + void addConsumer(swss::DBConnector *db, std::string tableName, int pri = default_orch_pri); }; #include "request_parser.h" @@ -215,12 +215,12 @@ class Orch class Orch2 : public Orch { public: - Orch2(DBConnector *db, const std::string& tableName, Request& request, int pri=default_orch_pri) + Orch2(swss::DBConnector *db, const std::string& tableName, Request& request, int pri=default_orch_pri) : Orch(db, tableName, pri), request_(request) { } - Orch2(DBConnector *db, const vector &tableNames, Request& request) + Orch2(swss::DBConnector *db, const std::vector &tableNames, Request& request) : Orch(db, tableNames), request_(request) { } diff --git a/orchagent/request_parser.cpp b/orchagent/request_parser.cpp index 610b191454..cdd74c3d40 100644 --- a/orchagent/request_parser.cpp +++ b/orchagent/request_parser.cpp @@ -12,6 +12,9 @@ #include "orch.h" #include "request_parser.h" +using namespace std; +using namespace swss; + void Request::parse(const KeyOpFieldsValuesTuple& request) { diff --git a/orchagent/request_parser.h b/orchagent/request_parser.h index 442e1a8f12..8c06e37eb0 100644 --- a/orchagent/request_parser.h +++ b/orchagent/request_parser.h @@ -30,7 +30,7 @@ typedef struct _request_description class Request { public: - void parse(const KeyOpFieldsValuesTuple& request); + void parse(const swss::KeyOpFieldsValuesTuple& request); void clear(); const std::string& getOperation() const @@ -51,19 +51,19 @@ class Request return key_item_strings_.at(position); } - const MacAddress& getKeyMacAddress(int position) const + const swss::MacAddress& getKeyMacAddress(int position) const { assert(is_parsed_); return key_item_mac_addresses_.at(position); } - const IpAddress& getKeyIpAddress(int position) const + const swss::IpAddress& getKeyIpAddress(int position) const { assert(is_parsed_); return key_item_ip_addresses_.at(position); } - const IpPrefix& getKeyIpPrefix(int position) const + const swss::IpPrefix& getKeyIpPrefix(int position) const { assert(is_parsed_); return key_item_ip_prefix_.at(position); @@ -93,7 +93,7 @@ class Request return attr_item_bools_.at(attr_name); } - const MacAddress& getAttrMacAddress(const std::string& attr_name) const + const swss::MacAddress& getAttrMacAddress(const std::string& attr_name) const { assert(is_parsed_); return attr_item_mac_addresses_.at(attr_name); @@ -111,7 +111,7 @@ class Request return attr_item_vlan_.at(attr_name); } - IpAddress getAttrIP(const std::string& attr_name) const + swss::IpAddress getAttrIP(const std::string& attr_name) const { assert(is_parsed_); return attr_item_ip_.at(attr_name); @@ -123,7 +123,7 @@ class Request return attr_item_uint_.at(attr_name); } - const set& getAttrSet(const std::string& attr_name) const + const std::set& getAttrSet(const std::string& attr_name) const { assert(is_parsed_); return attr_item_set_.at(attr_name); @@ -151,16 +151,16 @@ class Request private: - void parseOperation(const KeyOpFieldsValuesTuple& request); - void parseKey(const KeyOpFieldsValuesTuple& request); - void parseAttrs(const KeyOpFieldsValuesTuple& request); + void parseOperation(const swss::KeyOpFieldsValuesTuple& request); + void parseKey(const swss::KeyOpFieldsValuesTuple& request); + void parseAttrs(const swss::KeyOpFieldsValuesTuple& request); bool parseBool(const std::string& str); - MacAddress parseMacAddress(const std::string& str); - IpAddress parseIpAddress(const std::string& str); - IpPrefix parseIpPrefix(const std::string& str); + swss::MacAddress parseMacAddress(const std::string& str); + swss::IpAddress parseIpAddress(const std::string& str); + swss::IpPrefix parseIpPrefix(const std::string& str); uint64_t parseUint(const std::string& str); uint16_t parseVlan(const std::string& str); - set parseSet(const std::string& str); + std::set parseSet(const std::string& str); sai_packet_action_t parsePacketAction(const std::string& str); @@ -173,20 +173,20 @@ class Request std::string operation_; std::string full_key_; std::unordered_map key_item_strings_; - std::unordered_map key_item_mac_addresses_; - std::unordered_map key_item_ip_addresses_; - std::unordered_map key_item_ip_prefix_; + std::unordered_map key_item_mac_addresses_; + std::unordered_map key_item_ip_addresses_; + std::unordered_map key_item_ip_prefix_; std::unordered_map key_item_uint_; std::unordered_set attr_names_; // FIXME: Make one union with all the values, except string std::unordered_map attr_item_strings_; std::unordered_map attr_item_bools_; - std::unordered_map attr_item_mac_addresses_; + std::unordered_map attr_item_mac_addresses_; std::unordered_map attr_item_packet_actions_; std::unordered_map attr_item_vlan_; - std::unordered_map attr_item_ip_; + std::unordered_map attr_item_ip_; std::unordered_map attr_item_uint_; - std::unordered_map> attr_item_set_; + std::unordered_map> attr_item_set_; }; #endif // __REQUEST_PARSER_H diff --git a/orchagent/switchorch.h b/orchagent/switchorch.h index e30def4826..594226dc3d 100644 --- a/orchagent/switchorch.h +++ b/orchagent/switchorch.h @@ -12,20 +12,20 @@ struct WarmRestartCheck class SwitchOrch : public Orch { public: - SwitchOrch(DBConnector *db, string tableName); + SwitchOrch(swss::DBConnector *db, std::string tableName); bool checkRestartReady() { return m_warmRestartCheck.checkRestartReadyState; } bool checkRestartNoFreeze() { return m_warmRestartCheck.noFreeze; } bool skipPendingTaskCheck() { return m_warmRestartCheck.skipPendingTaskCheck; } void checkRestartReadyDone() { m_warmRestartCheck.checkRestartReadyState = false; } - void restartCheckReply(const string &op, const string &data, std::vector &values); + void restartCheckReply(const std::string &op, const std::string &data, std::vector &values); bool setAgingFDB(uint32_t sec); private: void doTask(Consumer &consumer); - NotificationConsumer* m_restartCheckNotificationConsumer; - void doTask(NotificationConsumer& consumer); - DBConnector *m_db; + swss::NotificationConsumer* m_restartCheckNotificationConsumer; + void doTask(swss::NotificationConsumer& consumer); + swss::DBConnector *m_db; // Information contained in the request from // external program for orchagent pre-shutdown state check diff --git a/orchagent/timer.h b/orchagent/timer.h index 732f8f4ebf..275d3f60e3 100644 --- a/orchagent/timer.h +++ b/orchagent/timer.h @@ -8,14 +8,14 @@ namespace swss { class ExecutableTimer : public Executor { public: - ExecutableTimer(SelectableTimer *timer, Orch *orch, const string &name) + ExecutableTimer(swss::SelectableTimer *timer, Orch *orch, const std::string &name) : Executor(timer, orch, name) { } - SelectableTimer *getSelectableTimer() + swss::SelectableTimer *getSelectableTimer() { - return static_cast(getSelectable()); + return static_cast(getSelectable()); } void execute() diff --git a/orchagent/tunneldecaporch.h b/orchagent/tunneldecaporch.h index dbd3126df9..31ca853e3d 100644 --- a/orchagent/tunneldecaporch.h +++ b/orchagent/tunneldecaporch.h @@ -11,40 +11,40 @@ struct TunnelTermEntry { - sai_object_id_t tunnel_term_id; - string ip_address; + sai_object_id_t tunnel_term_id; + std::string ip_address; }; struct TunnelEntry { - sai_object_id_t tunnel_id; // tunnel id - sai_object_id_t overlay_intf_id; // overlay interface id - vector tunnel_term_info; // tunnel_entry ids related to the tunnel abd ips related to the tunnel (all ips for tunnel entries that refer to this tunnel) + sai_object_id_t tunnel_id; // tunnel id + sai_object_id_t overlay_intf_id; // overlay interface id + std::vector tunnel_term_info; // tunnel_entry ids related to the tunnel abd ips related to the tunnel (all ips for tunnel entries that refer to this tunnel) }; /* TunnelTable: key string, tunnel object id */ -typedef map TunnelTable; +typedef std::map TunnelTable; /* ExistingIps: ips that currently have term entries */ -typedef unordered_set ExistingIps; +typedef std::unordered_set ExistingIps; class TunnelDecapOrch : public Orch { public: - TunnelDecapOrch(DBConnector *db, string tableName); + TunnelDecapOrch(swss::DBConnector *db, std::string tableName); private: TunnelTable tunnelTable; ExistingIps existingIps; - bool addDecapTunnel(string key, string type, IpAddresses dst_ip, IpAddress* p_src_ip, string dscp, string ecn, string ttl); - bool removeDecapTunnel(string key); + bool addDecapTunnel(std::string key, std::string type, swss::IpAddresses dst_ip, swss::IpAddress* p_src_ip, std::string dscp, std::string ecn, std::string ttl); + bool removeDecapTunnel(std::string key); - bool addDecapTunnelTermEntries(string tunnelKey, IpAddresses dst_ip, sai_object_id_t tunnel_id); - bool removeDecapTunnelTermEntry(sai_object_id_t tunnel_term_id, string ip); + bool addDecapTunnelTermEntries(std::string tunnelKey, swss::IpAddresses dst_ip, sai_object_id_t tunnel_id); + bool removeDecapTunnelTermEntry(sai_object_id_t tunnel_term_id, std::string ip); - bool setTunnelAttribute(string field, string value, sai_object_id_t existing_tunnel_id); - bool setIpAttribute(string key, IpAddresses new_ip_addresses, sai_object_id_t tunnel_id); + bool setTunnelAttribute(std::string field, std::string value, sai_object_id_t existing_tunnel_id); + bool setIpAttribute(std::string key, swss::IpAddresses new_ip_addresses, sai_object_id_t tunnel_id); void doTask(Consumer& consumer); }; diff --git a/orchagent/vrforch.cpp b/orchagent/vrforch.cpp index a67e6734bd..8258aacc90 100644 --- a/orchagent/vrforch.cpp +++ b/orchagent/vrforch.cpp @@ -11,6 +11,10 @@ #include "request_parser.h" #include "vrforch.h" +using namespace std; +using namespace swss; + + extern sai_virtual_router_api_t* sai_virtual_router_api; extern sai_object_id_t gSwitchId; diff --git a/orchagent/vrforch.h b/orchagent/vrforch.h index 22f5c64307..7512c51a41 100644 --- a/orchagent/vrforch.h +++ b/orchagent/vrforch.h @@ -30,7 +30,7 @@ class VRFRequest : public Request class VRFOrch : public Orch2 { public: - VRFOrch(DBConnector *db, const std::string& tableName) : Orch2(db, tableName, request_) + VRFOrch(swss::DBConnector *db, const std::string& tableName) : Orch2(db, tableName, request_) { } diff --git a/orchagent/watermarkorch.h b/orchagent/watermarkorch.h index 35279efbab..11a9ae5ab5 100644 --- a/orchagent/watermarkorch.h +++ b/orchagent/watermarkorch.h @@ -12,7 +12,7 @@ const uint8_t queue_wm_status_mask = 1 << 0; const uint8_t pg_wm_status_mask = 1 << 1; -static const map groupToMask = +static const std::map groupToMask = { { "QUEUE_WATERMARK", queue_wm_status_mask }, { "PG_WATERMARK", pg_wm_status_mask } @@ -21,28 +21,28 @@ static const map groupToMask = class WatermarkOrch : public Orch { public: - WatermarkOrch(DBConnector *db, const vector &tables); + WatermarkOrch(swss::DBConnector *db, const std::vector &tables); virtual ~WatermarkOrch(void); void doTask(Consumer &consumer); - void doTask(NotificationConsumer &consumer); - void doTask(SelectableTimer &timer); + void doTask(swss::NotificationConsumer &consumer); + void doTask(swss::SelectableTimer &timer); void init_pg_ids(); void init_queue_ids(); - void handleWmConfigUpdate(const std::string &key, const std::vector &fvt); - void handleFcConfigUpdate(const std::string &key, const std::vector &fvt); + void handleWmConfigUpdate(const std::string &key, const std::vector &fvt); + void handleFcConfigUpdate(const std::string &key, const std::vector &fvt); - void clearSingleWm(Table *table, string wm_name, vector &obj_ids); - void clearSingleWm(Table *table, string wm_name, const object_map &nameOidMap); + void clearSingleWm(swss::Table *table, std::string wm_name, std::vector &obj_ids); + void clearSingleWm(swss::Table *table, std::string wm_name, const object_map &nameOidMap); - shared_ptr
getCountersTable(void) + std::shared_ptr getCountersTable(void) { return m_countersTable; } - shared_ptr getCountersDb(void) + std::shared_ptr getCountersDb(void) { return m_countersDb; } @@ -56,19 +56,19 @@ class WatermarkOrch : public Orch uint8_t m_wmStatus = 0; bool m_timerChanged = false; - shared_ptr m_countersDb = nullptr; - shared_ptr m_appDb = nullptr; - shared_ptr
m_countersTable = nullptr; - shared_ptr
m_periodicWatermarkTable = nullptr; - shared_ptr
m_persistentWatermarkTable = nullptr; - shared_ptr
m_userWatermarkTable = nullptr; + std::shared_ptr m_countersDb = nullptr; + std::shared_ptr m_appDb = nullptr; + std::shared_ptr m_countersTable = nullptr; + std::shared_ptr m_periodicWatermarkTable = nullptr; + std::shared_ptr m_persistentWatermarkTable = nullptr; + std::shared_ptr m_userWatermarkTable = nullptr; - NotificationConsumer* m_clearNotificationConsumer = nullptr; - SelectableTimer* m_telemetryTimer = nullptr; + swss::NotificationConsumer* m_clearNotificationConsumer = nullptr; + swss::SelectableTimer* m_telemetryTimer = nullptr; - vector m_unicast_queue_ids; - vector m_multicast_queue_ids; - vector m_pg_ids; + std::vector m_unicast_queue_ids; + std::vector m_multicast_queue_ids; + std::vector m_pg_ids; }; #endif // WATERMARKORCH_H