[7] | 1 | // Copyright (c) 2013 by István Váradi
|
---|
| 2 |
|
---|
| 3 | // This file is part of XPLRA, a remote-access plugin for X-Plane
|
---|
| 4 |
|
---|
| 5 | // Redistribution and use in source and binary forms, with or without
|
---|
| 6 | // modification, are permitted provided that the following conditions are met:
|
---|
| 7 |
|
---|
| 8 | // 1. Redistributions of source code must retain the above copyright notice, this
|
---|
| 9 | // list of conditions and the following disclaimer.
|
---|
| 10 | // 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
| 11 | // this list of conditions and the following disclaimer in the documentation
|
---|
| 12 | // and/or other materials provided with the distribution.
|
---|
| 13 |
|
---|
| 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
| 15 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
| 16 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 17 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
---|
| 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
| 19 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
| 20 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 21 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
| 23 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 24 |
|
---|
| 25 | // The views and conclusions contained in the software and documentation are those
|
---|
| 26 | // of the authors and should not be interpreted as representing official policies,
|
---|
| 27 | // either expressed or implied, of the FreeBSD Project.
|
---|
| 28 |
|
---|
| 29 | #ifndef XPLRA_SETDATAREFTASK_H
|
---|
| 30 | #define XPLRA_SETDATAREFTASK_H
|
---|
| 31 | //------------------------------------------------------------------------------
|
---|
| 32 |
|
---|
| 33 | #include "DataRefTask.h"
|
---|
| 34 |
|
---|
[11] | 35 | #include <hu/varadiistvan/scpl/io/DataStream.h>
|
---|
[7] | 36 |
|
---|
| 37 | //------------------------------------------------------------------------------
|
---|
| 38 |
|
---|
| 39 | namespace xplra {
|
---|
| 40 |
|
---|
| 41 | //------------------------------------------------------------------------------
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * Base class for dataref tasks that set the value of some data
|
---|
| 45 | * referenced by a dataref.
|
---|
| 46 | *
|
---|
| 47 | * Since XPLM provides no feedback on whether the setting is
|
---|
| 48 | * successful, we detect only if the dataref is valid or not. So the
|
---|
| 49 | * isValid() function provides the only feedback if the task executed
|
---|
| 50 | * successfully or not. (We could use XPLMCanWriteDataRef, but for
|
---|
| 51 | * efficiency reasons we refrain from it. A separate task may be
|
---|
| 52 | * created for this purpose.)
|
---|
| 53 | */
|
---|
| 54 | class SetDataRefTask : public DataRefTask
|
---|
| 55 | {
|
---|
| 56 | public:
|
---|
| 57 | /**
|
---|
| 58 | * Read a dataref setting specification and create the appropriate
|
---|
| 59 | * SetDataRefTask instance.
|
---|
| 60 | *
|
---|
| 61 | * @param result will contain the result of the operation. It
|
---|
| 62 | * signifies an error only, if some wrong data is read. If the
|
---|
| 63 | * stream fails, it will indicate RESULT_OK.
|
---|
[66] | 64 | * @param stream the stream to read from
|
---|
[7] | 65 | *
|
---|
| 66 | * @return the new instance or 0 on error.
|
---|
| 67 | */
|
---|
[11] | 68 | static SetDataRefTask* create(uint8_t& result, hu::varadiistvan::scpl::io::DataStream& stream);
|
---|
[7] | 69 |
|
---|
| 70 | /**
|
---|
| 71 | * Construct the task for the dataref with the given name.
|
---|
| 72 | */
|
---|
| 73 | SetDataRefTask(const std::string& name);
|
---|
| 74 |
|
---|
| 75 | /**
|
---|
| 76 | * Construct the task for the given dataref.
|
---|
| 77 | */
|
---|
| 78 | SetDataRefTask(XPLMDataRef dataRef);
|
---|
| 79 |
|
---|
| 80 | /**
|
---|
| 81 | * Read and set the value to update from the given stream
|
---|
| 82 | */
|
---|
[11] | 83 | virtual void readValue(hu::varadiistvan::scpl::io::DataStream& stream) = 0;
|
---|
[7] | 84 | };
|
---|
| 85 |
|
---|
| 86 | //------------------------------------------------------------------------------
|
---|
| 87 | //------------------------------------------------------------------------------
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | * Base class for dataref setting tasks that set a single scalar
|
---|
| 91 | * value.
|
---|
| 92 | *
|
---|
| 93 | * ConcreteClass is the actual child class. It should have a function
|
---|
| 94 | * name setData() which performs the actual setting.
|
---|
| 95 | */
|
---|
| 96 | template <typename T, class ConcreteClass>
|
---|
| 97 | class SetScalarDataRefTask : public SetDataRefTask
|
---|
| 98 | {
|
---|
| 99 | protected:
|
---|
| 100 | /**
|
---|
| 101 | * The value to set.
|
---|
| 102 | */
|
---|
| 103 | T value;
|
---|
| 104 |
|
---|
| 105 | public:
|
---|
| 106 | /**
|
---|
| 107 | * Construct the task for setting the data referenced by the
|
---|
| 108 | * dataref with the given name.
|
---|
| 109 | */
|
---|
[9] | 110 | SetScalarDataRefTask(const std::string& name);
|
---|
[7] | 111 |
|
---|
| 112 | /**
|
---|
| 113 | * Construct the task for setting the data referenced by the given
|
---|
| 114 | * dataref.
|
---|
| 115 | */
|
---|
[9] | 116 | SetScalarDataRefTask(XPLMDataRef dataRef);
|
---|
[7] | 117 |
|
---|
| 118 | protected:
|
---|
| 119 | /**
|
---|
| 120 | * Perform the actual operation.
|
---|
| 121 | */
|
---|
| 122 | virtual void process();
|
---|
| 123 | };
|
---|
| 124 |
|
---|
| 125 | //------------------------------------------------------------------------------
|
---|
| 126 | //------------------------------------------------------------------------------
|
---|
| 127 |
|
---|
| 128 | /**
|
---|
| 129 | * Task to set the value of an integer data.
|
---|
| 130 | */
|
---|
| 131 | class SetIntDataRefTask :
|
---|
| 132 | public SetScalarDataRefTask<int, SetIntDataRefTask>
|
---|
| 133 | {
|
---|
| 134 | public:
|
---|
| 135 | /**
|
---|
| 136 | * Set the given dataref's value to the given value.
|
---|
| 137 | */
|
---|
| 138 | static void setData(XPLMDataRef dataRef, int value);
|
---|
| 139 |
|
---|
| 140 | /**
|
---|
| 141 | * Construct the task for the dataref with the given name.
|
---|
| 142 | */
|
---|
[9] | 143 | SetIntDataRefTask(const std::string& name);
|
---|
[7] | 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Construct the task for the given dataref.
|
---|
| 147 | */
|
---|
[9] | 148 | SetIntDataRefTask(XPLMDataRef dataRef);
|
---|
[7] | 149 |
|
---|
| 150 | /**
|
---|
| 151 | * Read and set the value to update from the given stream
|
---|
| 152 | */
|
---|
[11] | 153 | virtual void readValue(hu::varadiistvan::scpl::io::DataStream& stream);
|
---|
[7] | 154 | };
|
---|
| 155 |
|
---|
| 156 | //------------------------------------------------------------------------------
|
---|
| 157 | //------------------------------------------------------------------------------
|
---|
| 158 |
|
---|
| 159 | /**
|
---|
| 160 | * Task to set the value of a single-precision floating point data.
|
---|
| 161 | */
|
---|
| 162 | class SetFloatDataRefTask :
|
---|
| 163 | public SetScalarDataRefTask<float, SetFloatDataRefTask>
|
---|
| 164 | {
|
---|
| 165 | public:
|
---|
| 166 | /**
|
---|
| 167 | * Set the given dataref's value to the given value.
|
---|
| 168 | */
|
---|
| 169 | static void setData(XPLMDataRef dataRef, float value);
|
---|
| 170 |
|
---|
| 171 | /**
|
---|
| 172 | * Construct the task for the dataref with the given name.
|
---|
| 173 | */
|
---|
[9] | 174 | SetFloatDataRefTask(const std::string& name);
|
---|
[7] | 175 |
|
---|
| 176 | /**
|
---|
| 177 | * Construct the task for the given dataref.
|
---|
| 178 | */
|
---|
[9] | 179 | SetFloatDataRefTask(XPLMDataRef dataRef);
|
---|
[7] | 180 |
|
---|
| 181 | /**
|
---|
| 182 | * Read and set the value to update from the given stream
|
---|
| 183 | */
|
---|
[11] | 184 | virtual void readValue(hu::varadiistvan::scpl::io::DataStream& stream);
|
---|
[7] | 185 | };
|
---|
| 186 |
|
---|
| 187 | //------------------------------------------------------------------------------
|
---|
| 188 | //------------------------------------------------------------------------------
|
---|
| 189 |
|
---|
| 190 | /**
|
---|
| 191 | * Task to set the value of a double-precision floating point data.
|
---|
| 192 | */
|
---|
| 193 | class SetDoubleDataRefTask :
|
---|
| 194 | public SetScalarDataRefTask<double, SetDoubleDataRefTask>
|
---|
| 195 | {
|
---|
| 196 | public:
|
---|
| 197 | /**
|
---|
| 198 | * Set the given dataref's value to the given value.
|
---|
| 199 | */
|
---|
| 200 | static void setData(XPLMDataRef dataRef, double value);
|
---|
| 201 |
|
---|
| 202 | /**
|
---|
| 203 | * Construct the task for the dataref with the given name.
|
---|
| 204 | */
|
---|
[9] | 205 | SetDoubleDataRefTask(const std::string& name);
|
---|
[7] | 206 |
|
---|
| 207 | /**
|
---|
| 208 | * Construct the task for the given dataref.
|
---|
| 209 | */
|
---|
[9] | 210 | SetDoubleDataRefTask(XPLMDataRef dataRef);
|
---|
[7] | 211 |
|
---|
| 212 | /**
|
---|
| 213 | * Read and set the value to update from the given stream
|
---|
| 214 | */
|
---|
[11] | 215 | virtual void readValue(hu::varadiistvan::scpl::io::DataStream& stream);
|
---|
[7] | 216 | };
|
---|
| 217 |
|
---|
| 218 | //------------------------------------------------------------------------------
|
---|
| 219 | //------------------------------------------------------------------------------
|
---|
| 220 |
|
---|
| 221 | /**
|
---|
| 222 | * Base class for dataref setting tasks that set the values of an
|
---|
| 223 | * array.
|
---|
| 224 | *
|
---|
| 225 | * ConcreteClass is the actual child class. It should have a function
|
---|
| 226 | * name setData() which performs the actual setting.
|
---|
| 227 | */
|
---|
| 228 | template <typename T, class ConcreteClass>
|
---|
| 229 | class SetArrayDataRefTask : public SetDataRefTask
|
---|
| 230 | {
|
---|
| 231 | private:
|
---|
| 232 | /**
|
---|
| 233 | * The number of data items in the value.
|
---|
| 234 | */
|
---|
| 235 | int count;
|
---|
| 236 |
|
---|
| 237 | /**
|
---|
| 238 | * The offset starting with which the data should be set.
|
---|
| 239 | */
|
---|
| 240 | int offset;
|
---|
| 241 |
|
---|
| 242 | /**
|
---|
| 243 | * The value to set.
|
---|
| 244 | */
|
---|
| 245 | T* value;
|
---|
| 246 |
|
---|
| 247 | public:
|
---|
| 248 | /**
|
---|
| 249 | * Construct the data setting task for the dataref with the given
|
---|
| 250 | * name.
|
---|
| 251 | *
|
---|
| 252 | * The value array will be allocated, but not filled with
|
---|
| 253 | * data. Thus count should be positive!
|
---|
| 254 | */
|
---|
| 255 | SetArrayDataRefTask(const std::string& name, int count, int offset = 0);
|
---|
| 256 |
|
---|
| 257 | /**
|
---|
| 258 | * Construct the data setting task for the given dataref.
|
---|
| 259 | *
|
---|
| 260 | * The value array will be allocated, but not filled with
|
---|
| 261 | * data. Thus count should be positive!
|
---|
| 262 | */
|
---|
| 263 | SetArrayDataRefTask(XPLMDataRef dataRef, int count, int offset = 0);
|
---|
| 264 |
|
---|
| 265 | /**
|
---|
| 266 | * Destroy the task.
|
---|
| 267 | */
|
---|
| 268 | virtual ~SetArrayDataRefTask();
|
---|
| 269 |
|
---|
| 270 | /**
|
---|
| 271 | * Read and set the value to update from the given stream
|
---|
| 272 | */
|
---|
[11] | 273 | virtual void readValue(hu::varadiistvan::scpl::io::DataStream& stream);
|
---|
[7] | 274 |
|
---|
| 275 | protected:
|
---|
| 276 | /**
|
---|
| 277 | * Perform the actual operation.
|
---|
| 278 | */
|
---|
| 279 | virtual void process();
|
---|
| 280 | };
|
---|
| 281 |
|
---|
| 282 | //------------------------------------------------------------------------------
|
---|
| 283 | //------------------------------------------------------------------------------
|
---|
| 284 |
|
---|
| 285 | /**
|
---|
| 286 | * A dataref setting task which sets an array of integers.
|
---|
| 287 | */
|
---|
| 288 | class SetIntArrayDataRefTask :
|
---|
| 289 | public SetArrayDataRefTask<int, SetIntArrayDataRefTask>
|
---|
| 290 | {
|
---|
| 291 | public:
|
---|
| 292 | /**
|
---|
| 293 | * Perform the actual setting.
|
---|
| 294 | */
|
---|
| 295 | static void setData(XPLMDataRef dataRef, int* value, int count, int offset);
|
---|
| 296 |
|
---|
| 297 | /**
|
---|
| 298 | * Construct the task for the dataref with the given name.
|
---|
| 299 | */
|
---|
| 300 | SetIntArrayDataRefTask(const std::string& name, int count, int offset = 0);
|
---|
| 301 |
|
---|
| 302 | /**
|
---|
| 303 | * Construct the task for the given dataref.
|
---|
| 304 | */
|
---|
| 305 | SetIntArrayDataRefTask(XPLMDataRef dataRef, int count, int offset = 0);
|
---|
| 306 | };
|
---|
| 307 |
|
---|
| 308 | //------------------------------------------------------------------------------
|
---|
| 309 | //------------------------------------------------------------------------------
|
---|
| 310 |
|
---|
| 311 | /**
|
---|
| 312 | * A dataref setting task which sets an array of single-precision
|
---|
| 313 | * floating-point values.
|
---|
| 314 | */
|
---|
| 315 | class SetFloatArrayDataRefTask :
|
---|
| 316 | public SetArrayDataRefTask<float, SetFloatArrayDataRefTask>
|
---|
| 317 | {
|
---|
| 318 | public:
|
---|
| 319 | /**
|
---|
| 320 | * Perform the actual setting.
|
---|
| 321 | */
|
---|
| 322 | static void setData(XPLMDataRef dataRef, float* value, int count, int offset);
|
---|
| 323 |
|
---|
| 324 | /**
|
---|
| 325 | * Construct the task for the dataref with the given name.
|
---|
| 326 | */
|
---|
| 327 | SetFloatArrayDataRefTask(const std::string& name, int count, int offset = 0);
|
---|
| 328 |
|
---|
| 329 | /**
|
---|
| 330 | * Construct the task for the given dataref.
|
---|
| 331 | */
|
---|
| 332 | SetFloatArrayDataRefTask(XPLMDataRef dataRef, int count, int offset = 0);
|
---|
| 333 | };
|
---|
| 334 |
|
---|
| 335 | //------------------------------------------------------------------------------
|
---|
| 336 | //------------------------------------------------------------------------------
|
---|
| 337 |
|
---|
| 338 | /**
|
---|
| 339 | * A dataref setting task which sets an array of bytes.
|
---|
| 340 | */
|
---|
| 341 | class SetByteArrayDataRefTask :
|
---|
| 342 | public SetArrayDataRefTask<unsigned char, SetByteArrayDataRefTask>
|
---|
| 343 | {
|
---|
| 344 | public:
|
---|
| 345 | /**
|
---|
| 346 | * Perform the actual setting.
|
---|
| 347 | */
|
---|
| 348 | static void setData(XPLMDataRef dataRef, unsigned char* value,
|
---|
| 349 | int count, int offset);
|
---|
| 350 |
|
---|
| 351 | /**
|
---|
| 352 | * Construct the task for the dataref with the given name.
|
---|
| 353 | */
|
---|
| 354 | SetByteArrayDataRefTask(const std::string& name, int count, int offset = 0);
|
---|
| 355 |
|
---|
| 356 | /**
|
---|
| 357 | * Construct the task for the given dataref.
|
---|
| 358 | */
|
---|
| 359 | SetByteArrayDataRefTask(XPLMDataRef dataRef, int count, int offset = 0);
|
---|
| 360 | };
|
---|
| 361 |
|
---|
| 362 | //------------------------------------------------------------------------------
|
---|
| 363 | // Template definitions
|
---|
| 364 | //------------------------------------------------------------------------------
|
---|
| 365 |
|
---|
| 366 | template <typename T, class ConcreteClass>
|
---|
| 367 | inline SetScalarDataRefTask<T, ConcreteClass>::
|
---|
[9] | 368 | SetScalarDataRefTask(const std::string& name) :
|
---|
| 369 | SetDataRefTask(name)
|
---|
[7] | 370 | {
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | //------------------------------------------------------------------------------
|
---|
| 374 |
|
---|
| 375 | template <typename T, class ConcreteClass>
|
---|
| 376 | inline SetScalarDataRefTask<T, ConcreteClass>::
|
---|
[9] | 377 | SetScalarDataRefTask(XPLMDataRef dataRef) :
|
---|
| 378 | SetDataRefTask(dataRef)
|
---|
[7] | 379 | {
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | //------------------------------------------------------------------------------
|
---|
| 383 |
|
---|
| 384 | template <typename T, class ConcreteClass>
|
---|
| 385 | void SetScalarDataRefTask<T, ConcreteClass>::process()
|
---|
| 386 | {
|
---|
| 387 | ConcreteClass::setData(getDataRef(), value);
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | //------------------------------------------------------------------------------
|
---|
| 391 | //------------------------------------------------------------------------------
|
---|
| 392 |
|
---|
| 393 | template <typename T, class ConcreteClass>
|
---|
| 394 | inline SetArrayDataRefTask<T, ConcreteClass>::
|
---|
| 395 | SetArrayDataRefTask(const std::string& name, int count, int offset) :
|
---|
| 396 | SetDataRefTask(name),
|
---|
| 397 | count(count),
|
---|
| 398 | offset(offset),
|
---|
| 399 | value(new T[count])
|
---|
| 400 | {
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | //------------------------------------------------------------------------------
|
---|
| 404 |
|
---|
| 405 | template <typename T, class ConcreteClass>
|
---|
| 406 | inline SetArrayDataRefTask<T, ConcreteClass>::
|
---|
| 407 | SetArrayDataRefTask(XPLMDataRef dataRef, int count, int offset) :
|
---|
| 408 | SetDataRefTask(dataRef),
|
---|
| 409 | count(count),
|
---|
| 410 | offset(offset),
|
---|
| 411 | value(new T[count])
|
---|
| 412 | {
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 | //------------------------------------------------------------------------------
|
---|
| 416 |
|
---|
| 417 | template <typename T, class ConcreteClass>
|
---|
| 418 | inline SetArrayDataRefTask<T, ConcreteClass>::~SetArrayDataRefTask()
|
---|
| 419 | {
|
---|
| 420 | delete [] value;
|
---|
| 421 | }
|
---|
| 422 |
|
---|
| 423 | //------------------------------------------------------------------------------
|
---|
| 424 |
|
---|
| 425 | template <typename T, class ConcreteClass>
|
---|
| 426 | void SetArrayDataRefTask<T, ConcreteClass>::
|
---|
[11] | 427 | readValue(hu::varadiistvan::scpl::io::DataStream& stream)
|
---|
[7] | 428 | {
|
---|
| 429 | stream.read(value, count * sizeof(T));
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 | //------------------------------------------------------------------------------
|
---|
| 433 |
|
---|
| 434 | template <typename T, class ConcreteClass>
|
---|
| 435 | void SetArrayDataRefTask<T, ConcreteClass>::process()
|
---|
| 436 | {
|
---|
| 437 | ConcreteClass::setData(getDataRef(), value, count, offset);
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 | //------------------------------------------------------------------------------
|
---|
| 441 | // Inline definitions
|
---|
| 442 | //------------------------------------------------------------------------------
|
---|
| 443 |
|
---|
| 444 | inline SetDataRefTask::SetDataRefTask(const std::string& name) :
|
---|
| 445 | DataRefTask(name)
|
---|
| 446 | {
|
---|
| 447 | }
|
---|
| 448 |
|
---|
| 449 | //------------------------------------------------------------------------------
|
---|
| 450 |
|
---|
| 451 | inline SetDataRefTask::SetDataRefTask(XPLMDataRef dataRef) :
|
---|
| 452 | DataRefTask(dataRef)
|
---|
| 453 | {
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | //------------------------------------------------------------------------------
|
---|
| 457 | //------------------------------------------------------------------------------
|
---|
| 458 |
|
---|
| 459 | inline void SetIntDataRefTask::setData(XPLMDataRef dataRef, int value)
|
---|
| 460 | {
|
---|
| 461 | XPLMSetDatai(dataRef, value);
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | //------------------------------------------------------------------------------
|
---|
| 465 |
|
---|
[9] | 466 | inline SetIntDataRefTask::SetIntDataRefTask(const std::string& name) :
|
---|
| 467 | SetScalarDataRefTask<int, SetIntDataRefTask>(name)
|
---|
[7] | 468 | {
|
---|
| 469 | }
|
---|
| 470 |
|
---|
| 471 | //------------------------------------------------------------------------------
|
---|
| 472 |
|
---|
[9] | 473 | inline SetIntDataRefTask::SetIntDataRefTask(XPLMDataRef dataRef) :
|
---|
| 474 | SetScalarDataRefTask<int, SetIntDataRefTask>(dataRef)
|
---|
[7] | 475 | {
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | //------------------------------------------------------------------------------
|
---|
| 479 | //------------------------------------------------------------------------------
|
---|
| 480 |
|
---|
| 481 | inline void SetFloatDataRefTask::setData(XPLMDataRef dataRef, float value)
|
---|
| 482 | {
|
---|
| 483 | XPLMSetDatai(dataRef, value);
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | //------------------------------------------------------------------------------
|
---|
| 487 |
|
---|
[9] | 488 | inline SetFloatDataRefTask::SetFloatDataRefTask(const std::string& name) :
|
---|
| 489 | SetScalarDataRefTask<float, SetFloatDataRefTask>(name)
|
---|
[7] | 490 | {
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | //------------------------------------------------------------------------------
|
---|
| 494 |
|
---|
[9] | 495 | inline SetFloatDataRefTask::SetFloatDataRefTask(XPLMDataRef dataRef) :
|
---|
| 496 | SetScalarDataRefTask<float, SetFloatDataRefTask>(dataRef)
|
---|
[7] | 497 | {
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | //------------------------------------------------------------------------------
|
---|
| 501 | //------------------------------------------------------------------------------
|
---|
| 502 |
|
---|
| 503 | inline void SetDoubleDataRefTask::setData(XPLMDataRef dataRef, double value)
|
---|
| 504 | {
|
---|
| 505 | XPLMSetDatai(dataRef, value);
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | //------------------------------------------------------------------------------
|
---|
| 509 |
|
---|
[9] | 510 | inline SetDoubleDataRefTask::SetDoubleDataRefTask(const std::string& name) :
|
---|
| 511 | SetScalarDataRefTask<double, SetDoubleDataRefTask>(name)
|
---|
[7] | 512 | {
|
---|
| 513 | }
|
---|
| 514 |
|
---|
| 515 | //------------------------------------------------------------------------------
|
---|
| 516 |
|
---|
[9] | 517 | inline SetDoubleDataRefTask::SetDoubleDataRefTask(XPLMDataRef dataRef) :
|
---|
| 518 | SetScalarDataRefTask<double, SetDoubleDataRefTask>(dataRef)
|
---|
[7] | 519 | {
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | //------------------------------------------------------------------------------
|
---|
| 523 | //------------------------------------------------------------------------------
|
---|
| 524 |
|
---|
| 525 | inline void SetIntArrayDataRefTask::setData(XPLMDataRef dataRef, int* value,
|
---|
| 526 | int count, int offset)
|
---|
| 527 | {
|
---|
| 528 | XPLMSetDatavi(dataRef, value, offset, count);
|
---|
| 529 | }
|
---|
| 530 |
|
---|
| 531 | //------------------------------------------------------------------------------
|
---|
| 532 |
|
---|
| 533 | inline SetIntArrayDataRefTask::SetIntArrayDataRefTask(const std::string& name,
|
---|
| 534 | int count, int offset) :
|
---|
| 535 | SetArrayDataRefTask<int, SetIntArrayDataRefTask>(name, count, offset)
|
---|
| 536 | {
|
---|
| 537 | }
|
---|
| 538 |
|
---|
| 539 | //------------------------------------------------------------------------------
|
---|
| 540 |
|
---|
| 541 | inline SetIntArrayDataRefTask::SetIntArrayDataRefTask(XPLMDataRef dataRef,
|
---|
| 542 | int count, int offset) :
|
---|
| 543 | SetArrayDataRefTask<int, SetIntArrayDataRefTask>(dataRef, count, offset)
|
---|
| 544 | {
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | //------------------------------------------------------------------------------
|
---|
| 548 | //------------------------------------------------------------------------------
|
---|
| 549 |
|
---|
| 550 | inline void SetFloatArrayDataRefTask::setData(XPLMDataRef dataRef,
|
---|
| 551 | float* value,
|
---|
| 552 | int count, int offset)
|
---|
| 553 | {
|
---|
| 554 | XPLMSetDatavf(dataRef, value, offset, count);
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | //------------------------------------------------------------------------------
|
---|
| 558 |
|
---|
| 559 | inline
|
---|
| 560 | SetFloatArrayDataRefTask::SetFloatArrayDataRefTask(const std::string& name,
|
---|
| 561 | int count, int offset) :
|
---|
| 562 | SetArrayDataRefTask<float, SetFloatArrayDataRefTask>(name, count, offset)
|
---|
| 563 | {
|
---|
| 564 | }
|
---|
| 565 |
|
---|
| 566 | //------------------------------------------------------------------------------
|
---|
| 567 |
|
---|
| 568 | inline
|
---|
| 569 | SetFloatArrayDataRefTask::SetFloatArrayDataRefTask(XPLMDataRef dataRef,
|
---|
| 570 | int count, int offset) :
|
---|
| 571 | SetArrayDataRefTask<float, SetFloatArrayDataRefTask>(dataRef, count, offset)
|
---|
| 572 | {
|
---|
| 573 | }
|
---|
| 574 |
|
---|
| 575 | //------------------------------------------------------------------------------
|
---|
| 576 | //------------------------------------------------------------------------------
|
---|
| 577 |
|
---|
| 578 | inline void SetByteArrayDataRefTask::setData(XPLMDataRef dataRef,
|
---|
| 579 | unsigned char* value,
|
---|
| 580 | int count, int offset)
|
---|
| 581 | {
|
---|
| 582 | XPLMSetDatab(dataRef, value, offset, count);
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | //------------------------------------------------------------------------------
|
---|
| 586 |
|
---|
| 587 | inline
|
---|
| 588 | SetByteArrayDataRefTask::SetByteArrayDataRefTask(const std::string& name,
|
---|
| 589 | int count, int offset) :
|
---|
| 590 | SetArrayDataRefTask<unsigned char, SetByteArrayDataRefTask>(name,
|
---|
| 591 | count, offset)
|
---|
| 592 | {
|
---|
| 593 | }
|
---|
| 594 |
|
---|
| 595 | //------------------------------------------------------------------------------
|
---|
| 596 |
|
---|
| 597 | inline
|
---|
| 598 | SetByteArrayDataRefTask::SetByteArrayDataRefTask(XPLMDataRef dataRef,
|
---|
| 599 | int count, int offset) :
|
---|
| 600 | SetArrayDataRefTask<unsigned char, SetByteArrayDataRefTask>(dataRef,
|
---|
| 601 | count, offset)
|
---|
| 602 | {
|
---|
| 603 | }
|
---|
| 604 |
|
---|
| 605 | //------------------------------------------------------------------------------
|
---|
| 606 |
|
---|
| 607 | } /* namespace xplra */
|
---|
| 608 |
|
---|
| 609 | //------------------------------------------------------------------------------
|
---|
| 610 | #endif // XPLRA_SETDATAREFTASK_H
|
---|
| 611 |
|
---|
| 612 | // Local Variables:
|
---|
| 613 | // mode: C++
|
---|
| 614 | // c-basic-offset: 4
|
---|
| 615 | // indent-tabs-mode: nil
|
---|
| 616 | // End:
|
---|