-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <capi/dbconnector.h> | ||
#include <dbconnector.h> | ||
|
||
#include <string> | ||
|
||
extern "C" db_connector_t db_connector_new(int db, const char *hostname, int port, unsigned int timeout) | ||
{ | ||
auto dbc = new swss::DBConnector(db, std::string(hostname), port, timeout); | ||
return static_cast<db_connector_t>(dbc); | ||
} | ||
|
||
extern "C" db_connector_t db_connector_new2(int db, const char *unixPath, unsigned int timeout) | ||
{ | ||
auto dbc = new swss::DBConnector(db, std::string(unixPath), timeout); | ||
return static_cast<db_connector_t>(dbc); | ||
} | ||
|
||
extern "C" void db_connector_delete(db_connector_t db) | ||
{ | ||
delete static_cast<swss::DBConnector*>(db); | ||
} | ||
|
||
extern "C" redisContext *db_connector_get_context(db_connector_t db) | ||
{ | ||
return static_cast<swss::DBConnector*>(db)->getContext(); | ||
} | ||
|
||
extern "C" int db_connector_get_db(db_connector_t db) | ||
{ | ||
return static_cast<swss::DBConnector*>(db)->getDbId(); | ||
} | ||
|
||
extern "C" void db_connector_select(db_connector_t db) | ||
{ | ||
swss::DBConnector::select(static_cast<swss::DBConnector*>(db)); | ||
} | ||
|
||
extern "C" db_connector_t db_connector_new_connector(db_connector_t db, unsigned int timeout) | ||
{ | ||
auto dbc = static_cast<swss::DBConnector*>(db)->newConnector(timeout); | ||
return static_cast<db_connector_t>(dbc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <capi/producerstatetable.h> | ||
#include <producerstatetable.h> | ||
#include <dbconnector.h> | ||
#include <redispipeline.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <tuple> | ||
|
||
producer_state_table_t producer_state_table_new(db_connector_t db, const char *tableName) | ||
{ | ||
auto pt = new swss::ProducerStateTable(static_cast<swss::DBConnector*>(db), std::string(tableName)); | ||
return static_cast<producer_state_table_t>(pt); | ||
} | ||
|
||
producer_state_table_t producer_state_table_new2(redis_pipeline_t pipeline, const char *tableName, bool buffered) | ||
{ | ||
auto pt = new swss::ProducerStateTable(static_cast<swss::RedisPipeline*>(pipeline), std::string(tableName), buffered); | ||
return static_cast<producer_state_table_t>(pt); | ||
} | ||
|
||
void producer_state_table_delete(producer_state_table_t pt) | ||
{ | ||
delete static_cast<swss::ProducerStateTable*>(pt); | ||
} | ||
|
||
void producer_state_table_set_buffered(producer_state_table_t pt, bool buffered) | ||
{ | ||
static_cast<swss::ProducerStateTable*>(pt)->setBuffered(buffered); | ||
} | ||
|
||
void producer_state_table_set(producer_state_table_t pt, | ||
const char *key, | ||
const field_value_tuple_t *values, | ||
size_t count, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
std::vector<swss::FieldValueTuple> tuples; | ||
for(size_t i = 0; i < count; i++) | ||
{ | ||
auto tuple = std::make_pair(std::string(values[i].field), std::string(values[i].value)); | ||
tuples.push_back(tuple); | ||
} | ||
static_cast<swss::ProducerStateTable*>(pt)->set(std::string(key), tuples, std::string(op), std::string(prefix)); | ||
} | ||
|
||
void producer_state_table_del(producer_state_table_t pt, | ||
const char *key, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
static_cast<swss::ProducerStateTable*>(pt)->del(std::string(key), std::string(op), std::string(prefix)); | ||
} | ||
|
||
void producer_state_table_flush(producer_state_table_t pt) | ||
{ | ||
static_cast<swss::ProducerStateTable*>(pt)->flush(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <capi/producertable.h> | ||
#include <producertable.h> | ||
#include <dbconnector.h> | ||
#include <redispipeline.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <tuple> | ||
|
||
producer_table_t producer_table_new(db_connector_t db, const char *tableName) | ||
{ | ||
auto pt = new swss::ProducerTable(static_cast<swss::DBConnector*>(db), std::string(tableName)); | ||
return static_cast<producer_table_t>(pt); | ||
} | ||
|
||
producer_table_t producer_table_new2(redis_pipeline_t pipeline, const char *tableName, bool buffered) | ||
{ | ||
auto pt = new swss::ProducerTable(static_cast<swss::RedisPipeline*>(pipeline), std::string(tableName), buffered); | ||
return static_cast<producer_table_t>(pt); | ||
} | ||
|
||
producer_table_t producer_table_new3(db_connector_t db, const char *tableName, const char *dumpFile) | ||
{ | ||
auto pt = new swss::ProducerTable(static_cast<swss::DBConnector*>(db), std::string(tableName), std::string(dumpFile)); | ||
return static_cast<producer_table_t>(pt); | ||
} | ||
|
||
void producer_table_delete(producer_table_t pt) | ||
{ | ||
delete static_cast<swss::ProducerTable*>(pt); | ||
} | ||
|
||
void producer_table_set_buffered(producer_table_t pt, bool buffered) | ||
{ | ||
static_cast<swss::ProducerTable*>(pt)->setBuffered(buffered); | ||
} | ||
|
||
void producer_table_set(producer_table_t pt, | ||
const char *key, | ||
const field_value_tuple_t *values, | ||
size_t count, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
std::vector<swss::FieldValueTuple> tuples; | ||
for(size_t i = 0; i < count; i++) | ||
{ | ||
auto tuple = std::make_pair(std::string(values[i].field), std::string(values[i].value)); | ||
tuples.push_back(tuple); | ||
} | ||
static_cast<swss::ProducerTable*>(pt)->set(std::string(key), tuples, std::string(op), std::string(prefix)); | ||
} | ||
|
||
void producer_table_del(producer_table_t pt, | ||
const char *key, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
static_cast<swss::ProducerTable*>(pt)->del(std::string(key), std::string(op), std::string(prefix)); | ||
} | ||
|
||
void producer_table_flush(producer_table_t pt) | ||
{ | ||
static_cast<swss::ProducerTable*>(pt)->flush(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <capi/table.h> | ||
#include <table.h> | ||
#include <dbconnector.h> | ||
#include <redispipeline.h> | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <tuple> | ||
|
||
table_t table_new(db_connector_t db, const char *tableName) | ||
{ | ||
auto pt = new swss::Table(static_cast<swss::DBConnector*>(db), std::string(tableName)); | ||
return static_cast<table_t>(pt); | ||
} | ||
|
||
table_t table_new2(redis_pipeline_t pipeline, const char *tableName, bool buffered) | ||
{ | ||
auto pt = new swss::Table(static_cast<swss::RedisPipeline*>(pipeline), std::string(tableName), buffered); | ||
return static_cast<table_t>(pt); | ||
} | ||
|
||
void table_delete(table_t pt) | ||
{ | ||
delete static_cast<swss::Table*>(pt); | ||
} | ||
|
||
void table_set_buffered(table_t pt, bool buffered) | ||
{ | ||
static_cast<swss::Table*>(pt)->setBuffered(buffered); | ||
} | ||
|
||
void table_set(table_t pt, | ||
const char *key, | ||
const field_value_tuple_t *values, | ||
size_t count, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
std::vector<swss::FieldValueTuple> tuples; | ||
for(size_t i = 0; i < count; i++) | ||
{ | ||
auto tuple = std::make_pair(std::string(values[i].field), std::string(values[i].value)); | ||
tuples.push_back(tuple); | ||
} | ||
static_cast<swss::Table*>(pt)->set(std::string(key), tuples, std::string(op), std::string(prefix)); | ||
} | ||
|
||
void table_del(table_t pt, | ||
const char *key, | ||
const char *op, | ||
const char *prefix) | ||
{ | ||
static_cast<swss::Table*>(pt)->del(std::string(key), std::string(op), std::string(prefix)); | ||
} | ||
|
||
void table_flush(table_t pt) | ||
{ | ||
static_cast<swss::Table*>(pt)->flush(); | ||
} |