Changeset 29:5ab375f73489 in xplra


Ignore:
Timestamp:
02/09/13 08:21:45 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the rest of the multi-dataref API and the multi-dataref getting test program in C

Files:
1 added
6 edited

Legend:

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

    r26 r29  
    163163public:
    164164    /**
     165     * Get the X-Plane object this buffer belongs to.
     166     */
     167    XPlane& getXPlane() const throw();
     168
     169    /**
    165170     * Add an integer dataref.
    166171     *
    167      * @return the ID if the dataref, that can be used later to set or
     172     * @return the ID of the dataref, that can be used later to set or
    168173     * get the value.
    169174     */
     
    173178     * Add a float dataref.
    174179     *
    175      * @return the ID if the dataref, that can be used later to set or
     180     * @return the ID of the dataref, that can be used later to set or
    176181     * get the value.
    177182     */
     
    181186     * Add a double dataref.
    182187     *
    183      * @return the ID if the dataref, that can be used later to set or
     188     * @return the ID of the dataref, that can be used later to set or
    184189     * get the value.
    185190     */
     
    189194     * Add a float array dataref.
    190195     *
    191      * @return the ID if the dataref, that can be used later to set or
     196     * @return the ID of the dataref, that can be used later to set or
    192197     * get the value.
    193198     */
     
    198203     * Add an integer array dataref.
    199204     *
    200      * @return the ID if the dataref, that can be used later to set or
     205     * @return the ID of the dataref, that can be used later to set or
    201206     * get the value.
    202207     */
     
    207212     * Add a byte array dataref.
    208213     *
    209      * @return the ID if the dataref, that can be used later to set or
     214     * @return the ID of the dataref, that can be used later to set or
    210215     * get the value.
    211216     */
     
    535540    friend class XPlane;
    536541};
     542
     543//------------------------------------------------------------------------------
     544// Inline definitions
     545//------------------------------------------------------------------------------
     546
     547inline XPlane& MultiBuffer::getXPlane() const throw()
     548{
     549    return xplane;
     550}
    537551
    538552//------------------------------------------------------------------------------
  • src/client/c/hu/varadiistvan/xplra/xplra.cc

    r28 r29  
    244244    typedef std::set<int> multiBufferIDs_t;
    245245
     246public:
     247    /**
     248     * Get the connection for the given multi-dataref buffer.
     249     */
     250    static Connection& get(const MultiBuffer& buffer) throw();
     251
     252private:
    246253    /**
    247254     * The last error code.
     
    319326    bool destroyMultiBuffer(int bufferID) throw(Exception);
    320327};
     328
     329//------------------------------------------------------------------------------
     330
     331inline Connection& Connection::get(const MultiBuffer& buffer) throw()
     332{
     333    return static_cast<Connection&>(buffer.getXPlane());
     334}
    321335
    322336//------------------------------------------------------------------------------
     
    737751//------------------------------------------------------------------------------
    738752
    739 extern "C" int xplra_create_multi_getter(int connectionID)
     753extern "C" int xplra_multi_create_getter(int connectionID)
    740754{
    741755    Connection* connection = ConnectionSlot::getValue(connectionID);
     
    745759//------------------------------------------------------------------------------
    746760
    747 extern "C" int xplra_create_multi_setter(int connectionID)
     761extern "C" int xplra_multi_create_setter(int connectionID)
    748762{
    749763    Connection* connection = ConnectionSlot::getValue(connectionID);
     
    753767//------------------------------------------------------------------------------
    754768
    755 extern "C" int xplra_destroy_multi_buffer(int connectionID, int bufferID)
     769extern "C" size_t xplra_multi_add_int(int bufferID, const char* name)
     770{
     771    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     772    return (buffer==0) ? INVALID_DATAREF_ID : buffer->addInt(name);
     773}
     774
     775//------------------------------------------------------------------------------
     776
     777extern "C" size_t xplra_multi_add_float(int bufferID, const char* name)
     778{
     779    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     780    return (buffer==0) ? INVALID_DATAREF_ID : buffer->addFloat(name);
     781}
     782
     783//------------------------------------------------------------------------------
     784
     785extern "C" size_t xplra_multi_add_double(int bufferID, const char* name)
     786{
     787    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     788    return (buffer==0) ? INVALID_DATAREF_ID : buffer->addDouble(name);
     789}
     790
     791/*----------------------------------------------------------------------------*/
     792
     793extern "C" size_t xplra_multi_add_float_array(int bufferID, const char* name,
     794                                              size_t length, size_t offset)
     795{
     796    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     797    return (buffer==0) ?
     798        INVALID_DATAREF_ID : buffer->addFloatArray(name, length, offset);
     799}
     800
     801/*----------------------------------------------------------------------------*/
     802
     803extern "C" size_t xplra_multi_add_int_array(int bufferID, const char* name,
     804                                            size_t length, size_t offset)
     805{
     806    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     807    return (buffer==0) ?
     808        INVALID_DATAREF_ID : buffer->addIntArray(name, length, offset);
     809}
     810
     811/*----------------------------------------------------------------------------*/
     812
     813extern "C" size_t xplra_multi_add_byte_array(int bufferID, const char* name,
     814                                             size_t length, size_t offset)
     815{
     816    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     817    return (buffer==0) ?
     818        INVALID_DATAREF_ID : buffer->addByteArray(name, length, offset);
     819}
     820
     821/*----------------------------------------------------------------------------*/
     822
     823extern "C" int xplra_multi_finalize(int bufferID)
     824{
     825    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     826    return (buffer==0) ? -1 : (buffer->finalize() ? 1 : 0);
     827}
     828
     829/*----------------------------------------------------------------------------*/
     830
     831extern "C" int xplra_multi_register(int bufferID)
     832{
     833    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     834    if (buffer==0) return -1;
     835    try {
     836        buffer->registerInXPlane();
     837        return 0;
     838    } catch (...) {
     839        Connection::get(*buffer).handleException();
     840        return -1;
     841    }
     842}
     843
     844/*----------------------------------------------------------------------------*/
     845
     846extern "C" int xplra_multi_unregister(int bufferID)
     847{
     848    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     849    if (buffer==0) return -1;
     850    try {
     851        buffer->unregisterFromXPlane();
     852        return 0;
     853    } catch (...) {
     854        Connection::get(*buffer).handleException();
     855        return -1;
     856    }
     857}
     858
     859/*----------------------------------------------------------------------------*/
     860
     861extern "C" int xplra_multi_execute(int bufferID)
     862{
     863    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     864    if (buffer==0) return -1;
     865    try {
     866        buffer->execute();
     867        return 0;
     868    } catch (...) {
     869        Connection::get(*buffer).handleException();
     870        return -1;
     871    }
     872}
     873
     874//------------------------------------------------------------------------------
     875
     876extern "C" int xplra_multi_set_int(int bufferID, size_t datarefID, int value)
     877{
     878    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     879    if (buffer==0) return -1;
     880    try {
     881        buffer->setInt(datarefID, value);
     882        return 0;
     883    } catch (...) {
     884        Connection::get(*buffer).handleException();
     885        return -1;
     886    }
     887}
     888
     889/*----------------------------------------------------------------------------*/
     890
     891extern "C" int xplra_multi_get_int(int* dest, int bufferID, size_t datarefID)
     892{
     893    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     894    if (buffer==0) return -1;
     895    try {
     896        *dest = buffer->getInt(datarefID);
     897        return 0;
     898    } catch (...) {
     899        Connection::get(*buffer).handleException();
     900        return -1;
     901    }
     902}
     903
     904/*----------------------------------------------------------------------------*/
     905
     906extern "C"
     907const int32_t* xplra_multi_get_int_const_ptr(int bufferID, size_t datarefID)
     908{
     909    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     910    if (buffer==0) return 0;
     911    try {
     912        return &(buffer->getIntRef(datarefID));
     913    } catch (...) {
     914        Connection::get(*buffer).handleException();
     915        return 0;
     916    }
     917}
     918
     919/*----------------------------------------------------------------------------*/
     920
     921extern "C"
     922int32_t* xplra_multi_get_int_ptr(int bufferID, size_t datarefID)
     923{
     924    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     925    if (buffer==0) return 0;
     926    try {
     927        return &(buffer->getIntRef(datarefID));
     928    } catch (...) {
     929        Connection::get(*buffer).handleException();
     930        return 0;
     931    }
     932}
     933
     934//------------------------------------------------------------------------------
     935
     936extern "C"
     937int xplra_multi_set_float(int bufferID, size_t datarefID, float value)
     938{
     939    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     940    if (buffer==0) return -1;
     941    try {
     942        buffer->setFloat(datarefID, value);
     943        return 0;
     944    } catch (...) {
     945        Connection::get(*buffer).handleException();
     946        return -1;
     947    }
     948}
     949
     950/*----------------------------------------------------------------------------*/
     951
     952extern "C"
     953int xplra_multi_get_float(float* dest, int bufferID, size_t datarefID)
     954{
     955    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     956    if (buffer==0) return -1;
     957    try {
     958        *dest = buffer->getFloat(datarefID);
     959        return 0;
     960    } catch (...) {
     961        Connection::get(*buffer).handleException();
     962        return -1;
     963    }
     964}
     965
     966/*----------------------------------------------------------------------------*/
     967
     968extern "C"
     969const float* xplra_multi_get_float_const_ptr(int bufferID, size_t datarefID)
     970{
     971    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     972    if (buffer==0) return 0;
     973    try {
     974        return &(buffer->getFloatRef(datarefID));
     975    } catch (...) {
     976        Connection::get(*buffer).handleException();
     977        return 0;
     978    }
     979}
     980
     981/*----------------------------------------------------------------------------*/
     982
     983extern "C"
     984float* xplra_multi_get_float_ptr(int bufferID, size_t datarefID)
     985{
     986    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     987    if (buffer==0) return 0;
     988    try {
     989        return &(buffer->getFloatRef(datarefID));
     990    } catch (...) {
     991        Connection::get(*buffer).handleException();
     992        return 0;
     993    }
     994}
     995
     996//------------------------------------------------------------------------------
     997
     998extern "C"
     999int xplra_multi_set_double(int bufferID, size_t datarefID, double value)
     1000{
     1001    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1002    if (buffer==0) return -1;
     1003    try {
     1004        buffer->setDouble(datarefID, value);
     1005        return 0;
     1006    } catch (...) {
     1007        Connection::get(*buffer).handleException();
     1008        return -1;
     1009    }
     1010}
     1011
     1012/*----------------------------------------------------------------------------*/
     1013
     1014extern "C"
     1015int xplra_multi_get_double(double* dest, int bufferID, size_t datarefID)
     1016{
     1017    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1018    if (buffer==0) return -1;
     1019    try {
     1020        *dest = buffer->getDouble(datarefID);
     1021        return 0;
     1022    } catch (...) {
     1023        Connection::get(*buffer).handleException();
     1024        return -1;
     1025    }
     1026}
     1027
     1028/*----------------------------------------------------------------------------*/
     1029
     1030extern "C"
     1031const double* xplra_multi_get_double_const_ptr(int bufferID, size_t datarefID)
     1032{
     1033    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1034    if (buffer==0) return 0;
     1035    try {
     1036        return &(buffer->getDoubleRef(datarefID));
     1037    } catch (...) {
     1038        Connection::get(*buffer).handleException();
     1039        return 0;
     1040    }
     1041}
     1042
     1043/*----------------------------------------------------------------------------*/
     1044
     1045extern "C"
     1046double* xplra_multi_get_double_ptr(int bufferID, size_t datarefID)
     1047{
     1048    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1049    if (buffer==0) return 0;
     1050    try {
     1051        return &(buffer->getDoubleRef(datarefID));
     1052    } catch (...) {
     1053        Connection::get(*buffer).handleException();
     1054        return 0;
     1055    }
     1056}
     1057
     1058//------------------------------------------------------------------------------
     1059
     1060extern "C"
     1061ssize_t xplra_multi_set_float_array(int bufferID, size_t datarefID,
     1062                                    const float* value, size_t length,
     1063                                    size_t offset)
     1064{
     1065    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1066    if (buffer==0) return -1;
     1067    try {
     1068        return buffer->setFloatArray(datarefID, value, length, offset);
     1069    } catch (...) {
     1070        Connection::get(*buffer).handleException();
     1071        return -1;
     1072    }
     1073}
     1074
     1075/*----------------------------------------------------------------------------*/
     1076
     1077extern "C"
     1078ssize_t xplra_multi_get_float_array(float* value,
     1079                                    size_t length, size_t offset,
     1080                                    int bufferID, size_t datarefID)
     1081{
     1082    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1083    if (buffer==0) return -1;
     1084    try {
     1085        return buffer->getFloatArray(datarefID, value, length, offset);
     1086    } catch (...) {
     1087        Connection::get(*buffer).handleException();
     1088        return -1;
     1089    }
     1090}
     1091
     1092/*----------------------------------------------------------------------------*/
     1093
     1094extern "C"
     1095const float* xplra_multi_get_float_array_ptr(int bufferID, size_t datarefID,
     1096                                             size_t offset)
     1097{
     1098    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1099    if (buffer==0) return 0;
     1100    try {
     1101        return buffer->getFloatArray(datarefID, offset);
     1102    } catch (...) {
     1103        Connection::get(*buffer).handleException();
     1104        return 0;
     1105    }
     1106}
     1107
     1108//------------------------------------------------------------------------------
     1109
     1110extern "C"
     1111ssize_t xplra_multi_set_int_array(int bufferID, size_t datarefID,
     1112                                  const int32_t* value, size_t length,
     1113                                  size_t offset)
     1114{
     1115    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1116    if (buffer==0) return -1;
     1117    try {
     1118        return buffer->setIntArray(datarefID, value, length, offset);
     1119    } catch (...) {
     1120        Connection::get(*buffer).handleException();
     1121        return -1;
     1122    }
     1123}
     1124
     1125/*----------------------------------------------------------------------------*/
     1126
     1127extern "C"
     1128ssize_t xplra_multi_get_int_array(int32_t* value,
     1129                                  size_t length, size_t offset,
     1130                                  int bufferID, size_t datarefID)
     1131{
     1132    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1133    if (buffer==0) return -1;
     1134    try {
     1135        return buffer->getIntArray(datarefID, value, length, offset);
     1136    } catch (...) {
     1137        Connection::get(*buffer).handleException();
     1138        return -1;
     1139    }
     1140}
     1141
     1142/*----------------------------------------------------------------------------*/
     1143
     1144extern "C"
     1145const int32_t* xplra_multi_get_int_array_ptr(int bufferID, size_t datarefID,
     1146                                             size_t offset)
     1147{
     1148    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1149    if (buffer==0) return 0;
     1150    try {
     1151        return buffer->getIntArray(datarefID, offset);
     1152    } catch (...) {
     1153        Connection::get(*buffer).handleException();
     1154        return 0;
     1155    }
     1156}
     1157
     1158//------------------------------------------------------------------------------
     1159
     1160extern "C"
     1161ssize_t xplra_multi_set_byte_array(int bufferID, size_t datarefID,
     1162                                   const void* value, size_t length,
     1163                                   size_t offset)
     1164{
     1165    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1166    if (buffer==0) return -1;
     1167    try {
     1168        return buffer->setByteArray(datarefID,
     1169                                    reinterpret_cast<const uint8_t*>(value),
     1170                                    length, offset);
     1171    } catch (...) {
     1172        Connection::get(*buffer).handleException();
     1173        return -1;
     1174    }
     1175}
     1176
     1177/*----------------------------------------------------------------------------*/
     1178
     1179extern "C"
     1180ssize_t xplra_multi_get_byte_array(void* value,
     1181                                   size_t length, size_t offset,
     1182                                   int bufferID, size_t datarefID)
     1183{
     1184    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1185    if (buffer==0) return -1;
     1186    try {
     1187        return buffer->getByteArray(datarefID,
     1188                                    reinterpret_cast<uint8_t*>(value),
     1189                                    length, offset);
     1190    } catch (...) {
     1191        Connection::get(*buffer).handleException();
     1192        return -1;
     1193    }
     1194}
     1195
     1196/*----------------------------------------------------------------------------*/
     1197
     1198extern "C"
     1199const uint8_t* xplra_multi_get_byte_array_ptr(int bufferID, size_t datarefID,
     1200                                              size_t offset)
     1201{
     1202    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1203    if (buffer==0) return 0;
     1204    try {
     1205        return buffer->getByteArray(datarefID, offset);
     1206    } catch (...) {
     1207        Connection::get(*buffer).handleException();
     1208        return 0;
     1209    }
     1210}
     1211
     1212//------------------------------------------------------------------------------
     1213
     1214extern "C" ssize_t xplra_multi_set_string(int bufferID, size_t datarefID,
     1215                                          const char* value, size_t offset)
     1216{
     1217    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1218    if (buffer==0) return -1;
     1219    try {
     1220        return buffer->setString(datarefID, value, offset);
     1221    } catch (...) {
     1222        Connection::get(*buffer).handleException();
     1223        return -1;
     1224    }
     1225}
     1226
     1227/*----------------------------------------------------------------------------*/
     1228
     1229extern "C"
     1230const char* xplra_multi_get_string_ptr(int bufferID, size_t datarefID,
     1231                                       size_t offset)
     1232{
     1233    MultiBuffer* buffer = MultiBufferSlot::getValue(bufferID);
     1234    if (buffer==0) return 0;
     1235    try {
     1236        return buffer->getStringPtr(datarefID, offset);
     1237    } catch (...) {
     1238        Connection::get(*buffer).handleException();
     1239        return 0;
     1240    }
     1241}
     1242
     1243//------------------------------------------------------------------------------
     1244
     1245extern "C" int xplra_multi_destroy_buffer(int connectionID, int bufferID)
    7561246{
    7571247    Connection* connection = ConnectionSlot::getValue(connectionID);
  • src/client/c/hu/varadiistvan/xplra/xplra.h

    r28 r29  
    9696/*----------------------------------------------------------------------------*/
    9797
     98#define INVALID_DATAREF_ID ((size_t)-1)
     99
     100/*----------------------------------------------------------------------------*/
     101
    98102/**
    99103 * Get the last error code with the subcode.
     
    325329 * @return the ID of the new getter, or -1 on error
    326330 */
    327 int xplra_create_multi_getter(int connectionID);
     331int xplra_multi_create_getter(int connectionID);
    328332
    329333/*----------------------------------------------------------------------------*/
     
    334338 * @return the ID of the new setter, or -1 on error
    335339 */
    336 int xplra_create_multi_setter(int connectionID);
     340int xplra_multi_create_setter(int connectionID);
     341
     342/*----------------------------------------------------------------------------*/
     343
     344/**
     345 * Add an integer dataref to a multi-dataref buffer.
     346 *
     347 * @return the ID of the dataref that can be used later. If the buffer
     348 * ID is invalid, INVALID_DATAREF_ID is returned.
     349 */
     350size_t xplra_multi_add_int(int bufferID, const char* name);
     351
     352/*----------------------------------------------------------------------------*/
     353
     354/**
     355 * Add a float dataref to a multi-dataref buffer.
     356 *
     357 * @return the ID of the dataref that can be used later. If the buffer
     358 * ID is invalid, INVALID_DATAREF_ID is returned.
     359 */
     360size_t xplra_multi_add_float(int bufferID, const char* name);
     361
     362/*----------------------------------------------------------------------------*/
     363
     364/**
     365 * Add a double dataref to a multi-dataref buffer.
     366 *
     367 * @return the ID of the dataref that can be used later. If the buffer
     368 * ID is invalid, INVALID_DATAREF_ID is returned.
     369 */
     370size_t xplra_multi_add_double(int bufferID, const char* name);
     371
     372/*----------------------------------------------------------------------------*/
     373
     374/**
     375 * Add a float array dataref to a multi-dataref buffer.
     376 *
     377 * @return the ID of the dataref that can be used later. If the buffer
     378 * ID is invalid, INVALID_DATAREF_ID is returned.
     379 */
     380size_t xplra_multi_add_float_array(int bufferID, const char* name,
     381                                   size_t length, size_t offset);
     382
     383/*----------------------------------------------------------------------------*/
     384
     385/**
     386 * Add an integer array dataref to a multi-dataref buffer.
     387 *
     388 * @return the ID of the dataref that can be used later. If the buffer
     389 * ID is invalid, INVALID_DATAREF_ID is returned.
     390 */
     391size_t xplra_multi_add_int_array(int bufferID, const char* name,
     392                                 size_t length, size_t offset);
     393
     394/*----------------------------------------------------------------------------*/
     395
     396/**
     397 * Add a byte array dataref to a multi-dataref buffer.
     398 *
     399 * @return the ID of the dataref that can be used later. If the buffer
     400 * ID is invalid, INVALID_DATAREF_ID is returned.
     401 */
     402size_t xplra_multi_add_byte_array(int bufferID, const char* name,
     403                                  size_t length, size_t offset);
     404
     405/*----------------------------------------------------------------------------*/
     406
     407/**
     408 * Finalize the given buffer, if not finalized yet.
     409 *
     410 * @return -1 on error (if the buffer ID is invalid), 0 if there is no
     411 * data in the buffer, 1 if there is data in it.
     412 */
     413int xplra_multi_finalize(int bufferID);
     414
     415/*----------------------------------------------------------------------------*/
     416
     417/**
     418 * Register the buffer with the given ID in X-Plane. If needed, it
     419 * will be finalized too.
     420 *
     421 * @return 0 on success, -1 on error
     422 */
     423int xplra_multi_register(int bufferID);
     424
     425/*----------------------------------------------------------------------------*/
     426
     427/**
     428 * Unregister the buffer with the given ID from X-Plane. If needed, it
     429 * will be finalized too.
     430 *
     431 * @return 0 on success, -1 on error
     432 */
     433int xplra_multi_unregister(int bufferID);
     434
     435/*----------------------------------------------------------------------------*/
     436
     437/**
     438 * Execute the buffer with the given ID. If the buffer is not
     439 * finalized, it will be finalized. If it is not finalized, but
     440 * registered, the registration will be cleared, and it will be
     441 * re-registered after finalizing.
     442 *
     443 * @return 0 on success, -1 on error
     444 */
     445int xplra_multi_execute(int bufferID);
     446
     447/*----------------------------------------------------------------------------*/
     448
     449/**
     450 * Set the value of an integer dataref with the given ID.
     451 *
     452 * @return 0 on success, -1 on error.
     453 */
     454int xplra_multi_set_int(int bufferID, size_t datarefID, int value);
     455
     456/*----------------------------------------------------------------------------*/
     457
     458/**
     459 * Get the value of an integer dataref with the given ID.
     460 *
     461 * @param dest pointer to the variable that will receive the value
     462 *
     463 * @return 0 on success, -1 on error.
     464 */
     465int xplra_multi_get_int(int* dest, int bufferID, size_t datarefID);
     466
     467/*----------------------------------------------------------------------------*/
     468
     469/**
     470 * Get a const pointer to the integer dataref with the given ID
     471 *
     472 * @return the pointer or success, 0 on error.
     473 */
     474const int32_t* xplra_multi_get_int_const_ptr(int bufferID, size_t datarefID);
     475
     476/*----------------------------------------------------------------------------*/
     477
     478/**
     479 * Get a pointer to the integer dataref with the given ID
     480 *
     481 * @return the pointer or success, 0 on error.
     482 */
     483int32_t* xplra_multi_get_int_ptr(int bufferID, size_t datarefID);
     484
     485/*----------------------------------------------------------------------------*/
     486
     487/**
     488 * Set the value of a float dataref with the given ID.
     489 *
     490 * @return 0 on success, -1 on error.
     491 */
     492int xplra_multi_set_float(int bufferID, size_t datarefID, float value);
     493
     494/*----------------------------------------------------------------------------*/
     495
     496/**
     497 * Get the value of a float dataref with the given ID.
     498 *
     499 * @param dest pointer to the variable that will receive the value
     500 *
     501 * @return 0 on success, -1 on error.
     502 */
     503int xplra_multi_get_float(float* dest, int bufferID, size_t datarefID);
     504
     505/*----------------------------------------------------------------------------*/
     506
     507/**
     508 * Get a const pointer to the float dataref with the given ID
     509 *
     510 * @return the pointer or success, 0 on error.
     511 */
     512const float* xplra_multi_get_float_const_ptr(int bufferID, size_t datarefID);
     513
     514/*----------------------------------------------------------------------------*/
     515
     516/**
     517 * Get a pointer to the float dataref with the given ID
     518 *
     519 * @return the pointer or success, 0 on error.
     520 */
     521float* xplra_multi_get_float_ptr(int bufferID, size_t datarefID);
     522
     523/*----------------------------------------------------------------------------*/
     524
     525/**
     526 * Set the value of a double dataref with the given ID.
     527 *
     528 * @return 0 on success, -1 on error.
     529 */
     530int xplra_multi_set_double(int bufferID, size_t datarefID, double value);
     531
     532/*----------------------------------------------------------------------------*/
     533
     534/**
     535 * Get the value of a double dataref with the given ID.
     536 *
     537 * @param dest pointer to the variable that will receive the value
     538 *
     539 * @return 0 on success, -1 on error.
     540 */
     541int xplra_multi_get_double(double* dest, int bufferID, size_t datarefID);
     542
     543/*----------------------------------------------------------------------------*/
     544
     545/**
     546 * Get a const pointer to the double dataref with the given ID
     547 *
     548 * @return the pointer or success, 0 on error.
     549 */
     550const double* xplra_multi_get_double_const_ptr(int bufferID, size_t datarefID);
     551
     552/*----------------------------------------------------------------------------*/
     553
     554/**
     555 * Get a pointer to the double dataref with the given ID
     556 *
     557 * @return the pointer or success, 0 on error.
     558 */
     559double* xplra_multi_get_double_ptr(int bufferID, size_t datarefID);
     560
     561/*----------------------------------------------------------------------------*/
     562
     563/**
     564 * Set the contents of the float array dataref with the given ID.
     565 *
     566 * @param length the amount of data. If 0, it is assumed to be the
     567 * length of the data in the buffer minus the offset.
     568 * @param offset the offset within the buffer to set the data from
     569 *
     570 * @return the number of data items set, or -1 on error.
     571 */
     572ssize_t xplra_multi_set_float_array(int bufferID, size_t datarefID,
     573                                    const float* value, size_t length,
     574                                    size_t offset);
     575
     576/*----------------------------------------------------------------------------*/
     577
     578/**
     579 * Get the contents of the float array with the given ID.
     580 *
     581 * @param length the amount of data. If 0, it is assumed to be the
     582 * length of the data in the buffer minus the offset.
     583 * @param offset the offset within the buffer to get the data from
     584 *
     585 * @return the number of data items retrieved, or -1 on error.
     586 */
     587ssize_t xplra_multi_get_float_array(float* value,
     588                                    size_t length, size_t offset,
     589                                    int bufferID, size_t datarefID);
     590
     591/*----------------------------------------------------------------------------*/
     592
     593/**
     594 * Get a pointer to the float array with the given ID.
     595 *
     596 * @param offset the offset within the buffer.
     597 *
     598 * @return the pointer on success, 0 on error.
     599 */
     600const float* xplra_multi_get_float_array_ptr(int bufferID, size_t datarefID,
     601                                             size_t offset);
     602
     603/*----------------------------------------------------------------------------*/
     604
     605/**
     606 * Set the contents of the integer array dataref with the given ID.
     607 *
     608 * @param length the amount of data. If 0, it is assumed to be the
     609 * length of the data in the buffer minus the offset.
     610 * @param offset the offset within the buffer to set the data from
     611 *
     612 * @return the number of data items set, or -1 on error.
     613 */
     614ssize_t xplra_multi_set_int_array(int bufferID, size_t datarefID,
     615                                  const int32_t* value, size_t length,
     616                                  size_t offset);
     617
     618/*----------------------------------------------------------------------------*/
     619
     620/**
     621 * Get the contents of the integer array with the given ID.
     622 *
     623 * @param length the amount of data. If 0, it is assumed to be the
     624 * length of the data in the buffer minus the offset.
     625 * @param offset the offset within the buffer to get the data from
     626 *
     627 * @return the number of data items retrieved, or -1 on error.
     628 */
     629ssize_t xplra_multi_get_int_array(int32_t* value,
     630                                  size_t length, size_t offset,
     631                                  int bufferID, size_t datarefID);
     632
     633/*----------------------------------------------------------------------------*/
     634
     635/**
     636 * Get a pointer to the integer array with the given ID.
     637 *
     638 * @param offset the offset within the buffer.
     639 *
     640 * @return the pointer on success, 0 on error.
     641 */
     642const int32_t* xplra_multi_get_int_array_ptr(int bufferID, size_t datarefID,
     643                                             size_t offset);
     644
     645/*----------------------------------------------------------------------------*/
     646
     647/**
     648 * Set the contents of the byte array dataref with the given ID.
     649 *
     650 * @param length the amount of data. If 0, it is assumed to be the
     651 * length of the data in the buffer minus the offset.
     652 * @param offset the offset within the buffer to set the data from
     653 *
     654 * @return the number of data items set, or -1 on error.
     655 */
     656ssize_t xplra_multi_set_byte_array(int bufferID, size_t datarefID,
     657                                   const void* value, size_t length,
     658                                   size_t offset);
     659
     660/*----------------------------------------------------------------------------*/
     661
     662/**
     663 * Get the contents of the byte array with the given ID.
     664 *
     665 * @param length the amount of data. If 0, it is assumed to be the
     666 * length of the data in the buffer minus the offset.
     667 * @param offset the offset within the buffer to get the data from
     668 *
     669 * @return the number of data items retrieved, or -1 on error.
     670 */
     671ssize_t xplra_multi_get_byte_array(void* value,
     672                                   size_t length, size_t offset,
     673                                   int bufferID, size_t datarefID);
     674
     675/*----------------------------------------------------------------------------*/
     676
     677/**
     678 * Get a pointer to the byte array with the given ID.
     679 *
     680 * @param offset the offset within the buffer.
     681 *
     682 * @return the pointer on success, 0 on error.
     683 */
     684const uint8_t* xplra_multi_get_byte_array_ptr(int bufferID, size_t datarefID,
     685                                              size_t offset);
     686
     687/*----------------------------------------------------------------------------*/
     688
     689/**
     690 * Set the value of the byte array with the given ID from the given
     691 * string. If the string is shorter than the array, the rest will be
     692 * filled with 0s.
     693 *
     694 * @return the number of bytes set, or -1 on error
     695 */
     696ssize_t xplra_multi_set_string(int bufferID, size_t datarefID,
     697                               const char* value, size_t offset);
     698
     699/*----------------------------------------------------------------------------*/
     700
     701/**
     702 * Get a pointer as a string pointer to the byte array with the given
     703 * ID.
     704 *
     705 * @return the pointer on success, 0 on error.
     706 */
     707const char* xplra_multi_get_string_ptr(int bufferID, size_t datarefID,
     708                                       size_t offset);
    337709
    338710/*----------------------------------------------------------------------------*/
     
    346718 * @return 0 on success, -1 on error.
    347719 */
    348 int xplra_destroy_multi_buffer(int connectionID, int bufferID);
     720int xplra_multi_destroy_buffer(int connectionID, int bufferID);
    349721
    350722/*----------------------------------------------------------------------------*/
  • test/Makefile.am

    r23 r29  
    66endif
    77
    8 noinst_PROGRAMS=ctest basictest basicctest multigettest multisettest
     8noinst_PROGRAMS=ctest basictest basicctest multigettest multigetctest multisettest
    99
    1010ctest_SOURCES=ctest.c
     
    2222multigettest_SOURCES=multigettest.cc
    2323
     24multigetctest_SOURCES=multigetctest.c
     25if TARGET_API_WIN32
     26multigetctest_LDFLAGS=-lstdc++
     27endif
     28
    2429multisettest_SOURCES=multisettest.cc
  • test/basicctest.c

    r25 r29  
    340340
    341341    retval = 1;
     342
    342343cleanup:
    343344    if (connectionID>=0) xplra_disconnect(connectionID);
  • test/multigettest.cc

    r26 r29  
    146146        const int32_t& pitot = getter.getIntRef(pitotID);
    147147        const float& parking = getter.getFloatRef(parkingID);
    148         const int32_t& gearControl = getter.getInt(gearControlID);
     148        const int32_t& gearControl = getter.getIntRef(gearControlID);
    149149        const float& noseGear = getter.getFloatArray(noseGearID)[0];
    150150        const float& altimeter = getter.getFloatRef(altimeterID);
Note: See TracChangeset for help on using the changeset viewer.