public method IO2GTableListener.onChanged

Brief

Processes a notification about the row change in a table.

Declaration
C++
virtual void  onChanged (const char * rowID, IO2GRow * rowData) = 0

Parameters
rowID

The identifier of the row. The parameter has the value of the row identifier for a specific trading table. For example, for the Accounts table, it has the value of the AccountID field. The complete list of the identifiers is shown below.

rowData

The object representing a row of a table. In order to process the parameter, you need to know what table it belongs to. It could be accomplished by calling the IO2GRow.getTableType method. After that, you must cast the parameter to an appropriate class. For example, for a row of the Accounts table, use the IO2GAccountTableRow class. The complete list of the classes is shown below.
In case the update has been received from the server, the parameter contains a new instance of the object. In case the cause of the update is calculated fields, the instance of the object is equal to the previous call of this method, but calculated fields contain new values.
One can use IO2GRow.isCellChanged to find out if fields have been changed.

Details

Table name

rowID

Cast rowData to

Casting syntax

Accounts

AccountID

IO2GAccountTableRow

IO2GAccountTableRow *row = (IO2GAccountTableRow *)(rowData);

Offers

OfferID

IO2GOfferTableRow

IO2GOfferTableRow *row = (IO2GOfferTableRow *)(rowData);

Trades

TradeID

IO2GTradeTableRow

IO2GTradeTableRow *row = (IO2GTradeTableRow *)(rowData);

ClosedTrades

TradeID

IO2GClosedTradeTableRow

IO2GClosedTradeTableRow *row = (IO2GClosedTradeTableRow *)(rowData);

Orders

OrderID

IO2GOrderTableRow

IO2GOrderTableRow *row = (IO2GOrderTableRow *)(rowData);

Messages

MsgID

IO2GMessageTableRow

IO2GMessageTableRow *row = (IO2GMessageTableRow *)(rowData);

Summary

OfferID

IO2GSummaryTableRow

IO2GSummaryTableRow *row = (IO2GSummaryTableRow *)(rowData);

To get notifications about row changes in a specific table, an instance of the class implementing the IO2GTableListener interface must be subscribed to the Update operation of this table. It is accompished by calling the IO2GTable.subscribeUpdate method with the O2GTableUpdateType.Update parameter. For example, if you want to get notifications about the updates of the Trades table, write the following line:

tradesTable->subscribeUpdate(Update, tableListener);

For the implementation details, please see the example below:

Process a notification about updates of the Trades table [hide]

    // Create session which uses table manager
    mSession = CO2GTransport::createSession();
    mSession->useTableManager(Yes, NULL);
 
    //...
    // After the login, get instances of the table manager and Trades table
    IO2GTableManager *tableManager = mSession->getTableManager();
    IO2GTradesTable *tradesTable = (IO2GTradesTable)tableManager->getTable(Trades);
 
    // ...
    // Subscribe listener, listen to inserts into the Trades table, unsubscribe listener
    TableListener *tableListener = new TableListener();
    tradesTable->subscribeUpdate(Update, tableListener);
    uni::Sleep(1000);
    offersTable->unsubscribeUpdate(Update, tableListener);
 
    // Implementation of IO2GTableListener interface public method onChanged
    void TableListener::onChanged(const char *rowID, IO2GRow *rowData)
~    {
        IO2GTradeTableRow *trade = (IO2GTradeTableRow *)(rowData);
        std::cout << "Trade information changed " << rowID << std::endl;
        std::cout << "TradeID: " << trade.getTradeID() <<
                     " Close = " << trade.getClose() << std::endl;
    }

Declared in IO2GTableListener

back