Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef BYTE_ARRAY_H
00033 #define BYTE_ARRAY_H
00034
00035 #ifdef ROS
00036
00037 #include "simple_message/shared_types.h"
00038
00039 #endif
00040
00041 #ifdef MOTOPLUS
00042
00043 #include "shared_types.h"
00044
00045 #endif
00046
00047 #include "string.h"
00048
00049 namespace industrial
00050 {
00051 namespace simple_serialize
00052 {
00053
00054 class SimpleSerialize;
00055 }
00056 }
00057
00058 namespace industrial
00059 {
00060 namespace byte_array
00061 {
00062
00083 class ByteArray
00084 {
00085 public:
00086
00087
00088 friend class SimpleSerialize;
00089
00096 ByteArray(void);
00097
00102 ~ByteArray(void);
00103
00110 void init();
00111
00125 bool init(const char* buffer, const industrial::shared_types::shared_int byte_size);
00126
00136 void copyFrom(ByteArray & buffer);
00137
00146 bool load(industrial::shared_types::shared_bool value);
00147
00158 bool load(industrial::shared_types::shared_real value);
00159
00169 bool load(industrial::shared_types::shared_int value);
00170
00179 bool load(industrial::simple_serialize::SimpleSerialize &value);
00180
00189 bool load(ByteArray &value);
00190
00201 bool load(void* value, const industrial::shared_types::shared_int byte_size);
00202
00210 bool unload(industrial::shared_types::shared_bool &value);
00211
00220 bool unload(industrial::shared_types::shared_real &value);
00221
00230 bool unload(industrial::shared_types::shared_int &value);
00231
00239 bool unload(industrial::simple_serialize::SimpleSerialize &value);
00240
00250 bool unload(ByteArray &value, const industrial::shared_types::shared_int byte_size);
00251
00261 bool unload(void* value, const industrial::shared_types::shared_int byteSize);
00262
00273 bool unloadFront(industrial::shared_types::shared_real &value);
00274
00285 bool unloadFront(industrial::shared_types::shared_int &value);
00286
00298 bool unloadFront(void* value, const industrial::shared_types::shared_int byteSize);
00299
00312 char* getRawDataPtr();
00313
00319 unsigned int getBufferSize();
00320
00326 unsigned int getMaxBufferSize();
00327
00335 static bool isByteSwapEnabled();
00336
00337 private:
00346 static const industrial::shared_types::shared_int MAX_SIZE = 1024;
00347
00351 char buffer_[MAX_SIZE];
00352
00356 industrial::shared_types::shared_int buffer_size_;
00357
00358 #ifdef BYTE_SWAPPING
00359
00366 void swap(void *value, industrial::shared_types::shared_int byteSize);
00367 #endif
00368
00376 bool setBufferSize(const industrial::shared_types::shared_int size);
00377
00385 bool extendBufferSize(const industrial::shared_types::shared_int size);
00386
00394 bool shortenBufferSize(industrial::shared_types::shared_int size);
00395
00403 char* getLoadPtr();
00404
00413 char* getUnloadPtr(const industrial::shared_types::shared_int num_bytes);
00414
00415 };
00416
00417 }
00418 }
00419
00420 #endif //BYTE_ARRAY_H