Generic SmartRest library
Dependents: SmartRestUnitTest MbedSmartRest MbedSmartRestStreaming
ComposedRecord.h@1:3e7b4c9e0821, 2014-04-16 (annotated)
- Committer:
- vwochnik
- Date:
- Wed Apr 16 08:30:49 2014 +0000
- Revision:
- 1:3e7b4c9e0821
- Parent:
- 0:744801d5734d
fix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vwochnik | 0:744801d5734d | 1 | /* |
vwochnik | 0:744801d5734d | 2 | * ComposedRecord.h |
vwochnik | 0:744801d5734d | 3 | * |
vwochnik | 0:744801d5734d | 4 | * Created on: Nov 1, 2013 |
vwochnik | 0:744801d5734d | 5 | * * Authors: Vincent Wochnik <v.wochnik@gmail.com> |
vwochnik | 0:744801d5734d | 6 | * |
vwochnik | 0:744801d5734d | 7 | * Copyright (c) 2013 Cumulocity GmbH |
vwochnik | 0:744801d5734d | 8 | * |
vwochnik | 0:744801d5734d | 9 | * Permission is hereby granted, free of charge, to any person obtaining |
vwochnik | 0:744801d5734d | 10 | * a copy of this software and associated documentation files (the |
vwochnik | 0:744801d5734d | 11 | * "Software"), to deal in the Software without restriction, including |
vwochnik | 0:744801d5734d | 12 | * without limitation the rights to use, copy, modify, merge, publish, |
vwochnik | 0:744801d5734d | 13 | * distribute, sublicense, and/or sell copies of the Software, and to |
vwochnik | 0:744801d5734d | 14 | * permit persons to whom the Software is furnished to do so, subject to |
vwochnik | 0:744801d5734d | 15 | * the following conditions: |
vwochnik | 0:744801d5734d | 16 | * |
vwochnik | 0:744801d5734d | 17 | * The above copyright notice and this permission notice shall be |
vwochnik | 0:744801d5734d | 18 | * included in all copies or substantial portions of the Software. |
vwochnik | 0:744801d5734d | 19 | * |
vwochnik | 0:744801d5734d | 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
vwochnik | 0:744801d5734d | 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
vwochnik | 0:744801d5734d | 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
vwochnik | 0:744801d5734d | 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
vwochnik | 0:744801d5734d | 24 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
vwochnik | 0:744801d5734d | 25 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
vwochnik | 0:744801d5734d | 26 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
vwochnik | 0:744801d5734d | 27 | */ |
vwochnik | 0:744801d5734d | 28 | |
vwochnik | 0:744801d5734d | 29 | #ifndef COMPOSEDRECORD_H |
vwochnik | 0:744801d5734d | 30 | #define COMPOSEDRECORD_H |
vwochnik | 0:744801d5734d | 31 | |
vwochnik | 0:744801d5734d | 32 | #ifdef HAVE_CONFIG_H |
vwochnik | 0:744801d5734d | 33 | #include <config.h> |
vwochnik | 0:744801d5734d | 34 | #endif |
vwochnik | 0:744801d5734d | 35 | |
vwochnik | 0:744801d5734d | 36 | #include "DataGenerator.h" |
vwochnik | 0:744801d5734d | 37 | #include "Record.h" |
vwochnik | 0:744801d5734d | 38 | #include "Value.h" |
vwochnik | 0:744801d5734d | 39 | |
vwochnik | 0:744801d5734d | 40 | #ifndef COMPOSED_INITIAL_CAPACITY |
vwochnik | 0:744801d5734d | 41 | #define COMPOSED_INITIAL_CAPACITY 10 |
vwochnik | 0:744801d5734d | 42 | #endif |
vwochnik | 0:744801d5734d | 43 | #ifndef COMPOSED_MEMORY_INCREMENT |
vwochnik | 0:744801d5734d | 44 | #define COMPOSED_MEMORY_INCREMENT 5 |
vwochnik | 0:744801d5734d | 45 | #endif |
vwochnik | 0:744801d5734d | 46 | //#define COMPOSED_FIXED_SIZE 25 |
vwochnik | 0:744801d5734d | 47 | |
vwochnik | 0:744801d5734d | 48 | /** |
vwochnik | 0:744801d5734d | 49 | * This value set collects values and serializes them. |
vwochnik | 0:744801d5734d | 50 | */ |
vwochnik | 0:744801d5734d | 51 | class ComposedRecord : public Record |
vwochnik | 0:744801d5734d | 52 | { |
vwochnik | 0:744801d5734d | 53 | public: |
vwochnik | 0:744801d5734d | 54 | ComposedRecord(bool=false); |
vwochnik | 0:744801d5734d | 55 | ~ComposedRecord(); |
vwochnik | 0:744801d5734d | 56 | |
vwochnik | 0:744801d5734d | 57 | ComposedRecord& add(const Value&); |
vwochnik | 0:744801d5734d | 58 | void clear(); |
vwochnik | 0:744801d5734d | 59 | |
vwochnik | 0:744801d5734d | 60 | size_t values() const; |
vwochnik | 0:744801d5734d | 61 | const Value& value(size_t index) const; |
vwochnik | 0:744801d5734d | 62 | |
vwochnik | 0:744801d5734d | 63 | DataGenerator* copy() const; |
vwochnik | 0:744801d5734d | 64 | |
vwochnik | 0:744801d5734d | 65 | private: |
vwochnik | 0:744801d5734d | 66 | #ifndef COMPOSED_FIXED_SIZE |
vwochnik | 0:744801d5734d | 67 | const Value **_values; |
vwochnik | 0:744801d5734d | 68 | size_t _capacity; |
vwochnik | 0:744801d5734d | 69 | #else |
vwochnik | 0:744801d5734d | 70 | Value *_values[COMPOSED_FIXED_SIZE]; |
vwochnik | 0:744801d5734d | 71 | #endif |
vwochnik | 0:744801d5734d | 72 | size_t _count; |
vwochnik | 0:744801d5734d | 73 | bool _alloc; |
vwochnik | 0:744801d5734d | 74 | }; |
vwochnik | 0:744801d5734d | 75 | |
vwochnik | 0:744801d5734d | 76 | #endif |