Skip to content

Commit 200f2b0

Browse files
authored
Removed DB specific get api's from Selectable class (#378)
* Address Review comments #376 to remove DB specific API from selectable class which is generic. However to access to the Derviced Class Redis Select API via python we need to downcast the the Selectable Object. Added Helpfer function to do same. Ref: http://www.swig.org/Doc3.0/Python.html Signed-off-by: Abhishek Dosi <[email protected]> * Align the code properly Signed-off-by: Abhishek Dosi <[email protected]> * Address Review Comments. Return the DBConnector Pointer. Since the DBConnector is unique_ptr return the reference to the contained object, or a non owning pointer Signed-off-by: Abhishek Dosi <[email protected]>
1 parent 646053f commit 200f2b0

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

common/redisselect.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ int RedisSelect::getFd()
1616
{
1717
return m_subscribe->getContext()->fd;
1818
}
19-
int RedisSelect::getDbConnectorId()
20-
{
21-
return m_subscribe->getDbId();
22-
}
2319

24-
std::string RedisSelect::getDbNamespace()
20+
const DBConnector* RedisSelect::getDbConnector() const
2521
{
26-
return m_subscribe->getNamespace();
22+
return m_subscribe.get();
2723
}
2824

2925
uint64_t RedisSelect::readData()

common/redisselect.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ class RedisSelect : public Selectable
2020
bool hasCachedData() override;
2121
bool initializedWithData() override;
2222
void updateAfterRead() override;
23-
int getDbConnectorId() override;
24-
std::string getDbNamespace() override;
23+
const DBConnector* getDbConnector() const;
2524

2625
/* Create a new redisContext, SELECT DB and SUBSCRIBE */
2726
void subscribe(DBConnector* db, const std::string &channelName);

common/selectable.h

-10
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ class Selectable
5858
return m_priority;
5959
}
6060

61-
virtual int getDbConnectorId()
62-
{
63-
return 0;
64-
}
65-
66-
virtual std::string getDbNamespace()
67-
{
68-
return std::string();
69-
}
70-
7161
private:
7262

7363
friend class Select;

pyext/swsscommon.i

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
%typemap(in, numinputs=0) swss::Selectable ** (swss::Selectable *temp) {
3636
$1 = &temp;
3737
}
38+
3839
%typemap(argout) swss::Selectable ** {
3940
PyObject* temp = NULL;
4041
if (!PyList_Check($result)) {
@@ -45,6 +46,13 @@
4546
temp = SWIG_NewPointerObj(*$1, SWIGTYPE_p_swss__Selectable, 0);
4647
SWIG_Python_AppendOutput($result, temp);
4748
}
49+
50+
%inline %{
51+
swss::RedisSelect *CastSelectableToRedisSelectObj(swss::Selectable *temp) {
52+
return dynamic_cast<swss::RedisSelect *>(temp);
53+
}
54+
%}
55+
4856
%include "schema.h"
4957
%include "dbconnector.h"
5058
%include "selectable.h"

0 commit comments

Comments
 (0)