pulsar-client-cpp
Public Member Functions | Friends | List of all members
pulsar::TableView Class Reference

Public Member Functions

 TableView ()
 
bool retrieveValue (const std::string &key, std::string &value)
 
bool getValue (const std::string &key, std::string &value) const
 
bool containsKey (const std::string &key) const
 
std::unordered_map< std::string, std::string > snapshot ()
 
std::size_t size () const
 
void forEach (TableViewAction action)
 
void forEachAndListen (TableViewAction action)
 
void closeAsync (ResultCallback callback)
 
Result close ()
 

Friends

class PulsarFriend
 
class ClientImpl
 

Constructor & Destructor Documentation

◆ TableView()

pulsar::TableView::TableView ( )

Construct an uninitialized tableView object

Member Function Documentation

◆ close()

Result pulsar::TableView::close ( )

Close the table view and stop the broker to push more messages

◆ closeAsync()

void pulsar::TableView::closeAsync ( ResultCallback  callback)

Asynchronously close the tableview and stop the broker to push more messages

◆ containsKey()

bool pulsar::TableView::containsKey ( const std::string &  key) const

Check if the key exists in the table view.

Returns
true if the key exists in the table view

◆ forEach()

void pulsar::TableView::forEach ( TableViewAction  action)

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

◆ forEachAndListen()

void pulsar::TableView::forEachAndListen ( TableViewAction  action)

Performs the given action for each entry in this map until all entries have been processed and register the callback, which will be called each time a key-value pair is updated.

◆ getValue()

bool pulsar::TableView::getValue ( const std::string &  key,
std::string &  value 
) const

It's similar with retrievedValue except the value is copied into value.

Parameters
key
valuethe value associated with the key
Returns
Whether the key exists in the table view.

◆ retrieveValue()

bool pulsar::TableView::retrieveValue ( const std::string &  key,
std::string &  value 
)

Move the latest value associated with the key.

Example:

{c++}
TableView view;
std::string value;
while (true) {
if (view.retrieveValue("key")) {
std::cout << "value is updated to: " << value;
} else {
// sleep for a while or print the message that value is not updated
}
}
Parameters
key
valuethe value associated with the key
Returns
true if there is an associated value of the key, otherwise false

NOTE: Once the value has been retrieved successfully, the associated value will be removed from the table view until next time the value is updated.

◆ size()

std::size_t pulsar::TableView::size ( ) const

Get the size of the elements.

◆ snapshot()

std::unordered_map<std::string, std::string> pulsar::TableView::snapshot ( )

Move the table view data into the unordered map.


The documentation for this class was generated from the following file:
pulsar::TableView::TableView
TableView()