Changeset 57:f52efb9ba3d8 in xplra for src/client


Ignore:
Timestamp:
03/07/13 18:13:05 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the C++ client part of the re-registration support

Location:
src/client
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/client/c/hu/varadiistvan/xplra/MultiBuffer.cc

    r40 r57  
    251251//------------------------------------------------------------------------------
    252252
    253 MultiBuffer::~MultiBuffer() throw(Exception)
    254 {
    255     unregisterFromXPlane();
     253MultiBuffer::~MultiBuffer() throw()
     254{
     255    unregisterSafelyFromXPlane();
    256256    delete[] data;
    257257}
     
    358358        xplane.checkResult();
    359359        registeredID = -1;
     360    }
     361}
     362
     363//------------------------------------------------------------------------------
     364
     365bool MultiBuffer::unregisterSafelyFromXPlane() throw()
     366{
     367    try {
     368        unregisterFromXPlane();
     369        return true;
     370    } catch(...) {
     371        registeredID = -1;
     372        return false;
    360373    }
    361374}
     
    615628//------------------------------------------------------------------------------
    616629
     630void MultiBuffer::reregisterInXPlane() throw(Exception)
     631{
     632    if (registeredID>=0) {
     633        int origRegisteredID = registeredID;
     634        try {
     635            registeredID = -1;
     636            registerInXPlane();
     637        } catch(...) {
     638            registeredID = origRegisteredID;
     639            throw;
     640        }
     641    }
     642}
     643
     644//------------------------------------------------------------------------------
     645
    617646// Local Variables:
    618647// mode: C++
  • src/client/c/hu/varadiistvan/xplra/MultiBuffer.h

    r33 r57  
    159159     * made to unregister it.
    160160     */
    161     virtual ~MultiBuffer() throw(Exception);
     161    virtual ~MultiBuffer() throw();
    162162
    163163public:
     
    236236     */
    237237    void unregisterFromXPlane() throw(Exception);
     238
     239    /**
     240     * Unregister this buffer from X-Plane safely, i.e. without
     241     * throwing any exceptions. If unregistration fails, the
     242     * registered ID will be cleared anyway.
     243     *
     244     * @return whether unregistration succeeded.
     245     */
     246    bool unregisterSafelyFromXPlane() throw();
    238247
    239248    /**
     
    480489     */
    481490    void writeSpec(uint8_t command) const throw(Exception);
     491
     492    /**
     493     * Re-register the buffer in X-Plane, if it has been registered
     494     * earlier.
     495     *
     496     * it has not been registered, nothing is done. Otherwise the
     497     * buffer gets registered, and the old ID is forgotten. This
     498     * function is meant to be used by the XPlane object when it
     499     * creates a new connection. If the registration fails, the
     500     * original ID is restored, so that this function could be called
     501     * again
     502     */
     503    void reregisterInXPlane() throw(Exception);
    482504
    483505private:
  • src/client/c/hu/varadiistvan/xplra/XPlane.cc

    r54 r57  
    169169    socket = clientSocket.release();
    170170    stream = new DataStream(*socket);
     171
     172    for(multiBuffers_t::iterator i = multiBuffers.begin();
     173        i!=multiBuffers.end(); ++i)
     174    {
     175        MultiBuffer* buffer = *i;
     176        buffer->reregisterInXPlane();
     177    }
    171178}
    172179
  • src/client/python/xplra.py

    r56 r57  
    508508            self.finalize()
    509509        return self._values
    510 
    511     @property
    512     def wasRegistered(self):
    513         """Determine if this buffer was registered."""
    514         return self._wasRegistered
    515510
    516511    def addInt(self, name):
Note: See TracChangeset for help on using the changeset viewer.