@@ -132,49 +132,66 @@ class Executor : public swss::Selectable
132
132
swss::Selectable *getSelectable () const { return m_selectable; }
133
133
};
134
134
135
- class Consumer : public Executor {
135
+ class ConsumerBase : public Executor {
136
+ public:
137
+ ConsumerBase (swss::Selectable *selectable, Orch *orch, const std::string &name)
138
+ : Executor(selectable, orch, name)
139
+ {
140
+ }
141
+
142
+ virtual swss::TableBase *getConsumerTable () const = 0;
143
+
144
+ std::string getTableName () const
145
+ {
146
+ return getConsumerTable ()->getTableName ();
147
+ }
148
+
149
+ std::string dumpTuple (const swss::KeyOpFieldsValuesTuple &tuple);
150
+ void dumpPendingTasks (std::vector<std::string> &ts);
151
+
152
+ /* Store the latest 'golden' status */
153
+ // TODO: hide?
154
+ SyncMap m_toSync;
155
+
156
+ void addToSync (const swss::KeyOpFieldsValuesTuple &entry);
157
+
158
+ // Returns: the number of entries added to m_toSync
159
+ size_t addToSync (const std::deque<swss::KeyOpFieldsValuesTuple> &entries);
160
+ };
161
+
162
+ class Consumer : public ConsumerBase {
136
163
public:
137
164
Consumer (swss::ConsumerTableBase *select, Orch *orch, const std::string &name)
138
- : Executor (select, orch, name)
165
+ : ConsumerBase (select, orch, name)
139
166
{
140
167
}
141
168
142
- swss::ConsumerTableBase *getConsumerTable () const
169
+ swss::TableBase *getConsumerTable () const override
143
170
{
171
+ // ConsumerTableBase is a subclass of TableBase
144
172
return static_cast <swss::ConsumerTableBase *>(getSelectable ());
145
173
}
146
174
147
- std::string getTableName () const
175
+ const swss::DBConnector* getDbConnector () const
148
176
{
149
- return getConsumerTable ()->getTableName ();
177
+ auto table = static_cast <swss::ConsumerTableBase *>(getSelectable ());
178
+ return table->getDbConnector ();
150
179
}
151
180
152
181
int getDbId () const
153
182
{
154
- return getConsumerTable ()-> getDbConnector ()->getDbId ();
183
+ return getDbConnector ()->getDbId ();
155
184
}
156
185
157
186
std::string getDbName () const
158
187
{
159
- return getConsumerTable ()-> getDbConnector ()->getDbName ();
188
+ return getDbConnector ()->getDbName ();
160
189
}
161
190
162
- std::string dumpTuple (const swss::KeyOpFieldsValuesTuple &tuple);
163
- void dumpPendingTasks (std::vector<std::string> &ts);
164
-
165
191
size_t refillToSync ();
166
192
size_t refillToSync (swss::Table* table);
167
- void execute ();
168
- void drain ();
169
-
170
- /* Store the latest 'golden' status */
171
- // TODO: hide?
172
- SyncMap m_toSync;
173
-
174
- void addToSync (const swss::KeyOpFieldsValuesTuple &entry);
175
-
176
- // Returns: the number of entries added to m_toSync
177
- size_t addToSync (const std::deque<swss::KeyOpFieldsValuesTuple> &entries);
193
+ void execute () override ;
194
+ void drain () override ;
178
195
};
179
196
180
197
typedef std::map<std::string, std::shared_ptr<Executor>> ConsumerMap;
@@ -215,12 +232,12 @@ class Orch
215
232
virtual void doTask ();
216
233
217
234
/* Run doTask against a specific executor */
218
- virtual void doTask (Consumer &consumer) = 0 ;
235
+ virtual void doTask (Consumer &consumer) { } ;
219
236
virtual void doTask (swss::NotificationConsumer &consumer) { }
220
237
virtual void doTask (swss::SelectableTimer &timer) { }
221
238
222
239
/* TODO: refactor recording */
223
- static void recordTuple (Consumer &consumer, const swss::KeyOpFieldsValuesTuple &tuple);
240
+ static void recordTuple (ConsumerBase &consumer, const swss::KeyOpFieldsValuesTuple &tuple);
224
241
225
242
void dumpPendingTasks (std::vector<std::string> &ts);
226
243
0 commit comments