class IO2GEachRowListener
Parents | |
IAddRef |
Brief
The interface provides the method signature to process notifications about iteration through rows of a table.
Details
The interface can be implemented only when the application uses IO2GTableManager.
Prerequisites
You must specify that your session uses table manager before the login. For example,
mSession->useTableManager(Yes, NULL);
After the successful login, you must obtain an instance of the IO2GTableManager class. For example,
IO2GTableManager *tableManager = mSession->getTableManager();
Before processing notifications about iteration through rows of a specific table, you must obtain an instance of a class that represents the table. For example, if you
need information about opened positions, write the following line:
IO2GTradesTable *tradesTable = (IO2GTradesTable *)tableManager->getTable(Trades);
For complete instructions on the table manager usage, please refer to How to use table manager in ForexConnect API section.
Implementation
To use the onEachRow method of the IO2GEachRowListener
interface, you must create a class that implements the interface.
For example,
class EachRowListener : public IO2GEachRowListener { }
In your application you must create an instance of the class that implements the interface. For example,
EachRowListener *eachRowListener = new EachRowListener();
This instance must be passed as an argument to the IO2GTable.forEachRow method. For example, to iterate through
rows of the Trades table, write the following line:
tradesTable.forEachRow(eachRowListener);
For the interface implementation details, see the example below.
Iterate through open positions [hide]
class EachRowListener : public IO2GEachRowListener { public: ..... /** IO2GEachRowListener interface */ void onEachRow(const char *rowID, IO2GRow *rowData) { IO2GTradeTableRow *row = dynamic_cast<IO2GTradeTableRow *>(rowData); if (row) std::cout << "TradeID: " << trade.getTradeID() << "; Close = " << trade.getClose()) << std::endl; } };
Public Methods | |
Processes iteration through rows of a table. |