Generic SmartRest library

Dependents:   SmartRestUnitTest MbedSmartRest MbedSmartRestStreaming

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DataGenerator.h Source File

DataGenerator.h

00001 /*
00002  * DataGenerator.h
00003  *
00004  * Created on: Nov 1, 2013
00005  * * Authors: Vincent Wochnik <v.wochnik@gmail.com>
00006  *
00007  * Copyright (c) 2013 Cumulocity GmbH
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining
00010  * a copy of this software and associated documentation files (the
00011  * "Software"), to deal in the Software without restriction, including
00012  * without limitation the rights to use, copy, modify, merge, publish,
00013  * distribute, sublicense, and/or sell copies of the Software, and to
00014  * permit persons to whom the Software is furnished to do so, subject to
00015  * the following conditions:
00016  *
00017  * The above copyright notice and this permission notice shall be
00018  * included in all copies or substantial portions of the Software.
00019  *
00020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00023  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00024  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00025  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00026  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00027  */
00028 
00029 #ifndef DATAGENERATOR_H
00030 #define DATAGENERATOR_H
00031 
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035 
00036 #include <stddef.h>
00037 #include "AbstractDataSink.h"
00038 
00039 /*
00040  * The DataGenerator class provides a way to stream data to a
00041  * connection..
00042  */
00043 class DataGenerator
00044 {
00045 public:
00046     virtual ~DataGenerator()
00047     {
00048     }
00049 
00050     /**
00051      * Writes the object to the specified destination.
00052      * @param s the destination
00053      * @return the number of bytes written
00054      */
00055     virtual size_t writeTo(AbstractDataSink&) const = 0;
00056 
00057     /**
00058      * Returns the estimated number of bytes which will be written.
00059      * @return the estimated number of bytes printed
00060      */
00061     virtual size_t writtenLength() const = 0;
00062 
00063     /**
00064      * Creates a deep copy on the heap. The class type may be different.
00065      * The only thing guaranteed is that the copy behaves exactly
00066      * the same.
00067      * @return cloned object with no memory dependencies
00068      */
00069     virtual DataGenerator* copy() const = 0;
00070 };
00071 
00072 #endif