|
| 1 | +#include <capi/producertable.h> |
| 2 | +#include <producertable.h> |
| 3 | +#include <dbconnector.h> |
| 4 | +#include <redispipeline.h> |
| 5 | + |
| 6 | +#include <string> |
| 7 | +#include <vector> |
| 8 | +#include <tuple> |
| 9 | + |
| 10 | +producer_table_t producer_table_new(db_connector_t db, const char *tableName) |
| 11 | +{ |
| 12 | + auto pt = new swss::ProducerTable(static_cast<swss::DBConnector*>(db), std::string(tableName)); |
| 13 | + return static_cast<producer_table_t>(pt); |
| 14 | +} |
| 15 | + |
| 16 | +producer_table_t producer_table_new2(redis_pipeline_t pipeline, const char *tableName, bool buffered) |
| 17 | +{ |
| 18 | + auto pt = new swss::ProducerTable(static_cast<swss::RedisPipeline*>(pipeline), std::string(tableName), buffered); |
| 19 | + return static_cast<producer_table_t>(pt); |
| 20 | +} |
| 21 | + |
| 22 | +producer_table_t producer_table_new3(db_connector_t db, const char *tableName, const char *dumpFile) |
| 23 | +{ |
| 24 | + auto pt = new swss::ProducerTable(static_cast<swss::DBConnector*>(db), std::string(tableName), std::string(dumpFile)); |
| 25 | + return static_cast<producer_table_t>(pt); |
| 26 | +} |
| 27 | + |
| 28 | +void producer_table_delete(producer_table_t pt) |
| 29 | +{ |
| 30 | + delete static_cast<swss::ProducerTable*>(pt); |
| 31 | +} |
| 32 | + |
| 33 | +void producer_table_set_buffered(producer_table_t pt, bool buffered) |
| 34 | +{ |
| 35 | + static_cast<swss::ProducerTable*>(pt)->setBuffered(buffered); |
| 36 | +} |
| 37 | + |
| 38 | +void producer_table_set(producer_table_t pt, |
| 39 | + const char *key, |
| 40 | + const field_value_tuple_t *values, |
| 41 | + size_t count, |
| 42 | + const char *op, |
| 43 | + const char *prefix) |
| 44 | +{ |
| 45 | + std::vector<swss::FieldValueTuple> tuples; |
| 46 | + for(size_t i = 0; i < count; i++) |
| 47 | + { |
| 48 | + auto tuple = std::make_pair(std::string(values[i].field), std::string(values[i].value)); |
| 49 | + tuples.push_back(tuple); |
| 50 | + } |
| 51 | + static_cast<swss::ProducerTable*>(pt)->set(std::string(key), tuples, std::string(op), std::string(prefix)); |
| 52 | +} |
| 53 | + |
| 54 | +void producer_table_del(producer_table_t pt, |
| 55 | + const char *key, |
| 56 | + const char *op, |
| 57 | + const char *prefix) |
| 58 | +{ |
| 59 | + static_cast<swss::ProducerTable*>(pt)->del(std::string(key), std::string(op), std::string(prefix)); |
| 60 | +} |
| 61 | + |
| 62 | +void producer_table_flush(producer_table_t pt) |
| 63 | +{ |
| 64 | + static_cast<swss::ProducerTable*>(pt)->flush(); |
| 65 | +} |
0 commit comments