source: branches/uq/src/core2/RpSerializer.h @ 5679

Last change on this file since 5679 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture::Serializer
4 *    The object collects a series of other objects together and
5 *    serializes them into a single byte stream.  That stream can
6 *    be written to a file, send over a socket, and so forth.  The
7 *    resulting stream can be loaded by a Serializer and the objects
8 *    can be reconstituted to their original form.
9 *
10 * ======================================================================
11 *  AUTHOR:  Michael McLennan, Purdue University
12 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
13 *
14 *  See the file "license.terms" for information on usage and
15 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 * ======================================================================
17 */
18#ifndef RPSERIALIZER_H
19#define RPSERIALIZER_H
20
21#include <map>
22#include <RpPtr.h>
23#include <RpOutcome.h>
24#include "RpSerialBuffer.h"
25#include "RpSerializable.h"
26
27namespace Rappture {
28
29class Serializer {
30public:
31    Serializer();
32    virtual ~Serializer();
33
34    virtual Ptr<SerialBuffer> serialize();
35    virtual Outcome deserialize(const char* bytes, int nbytes);
36
37    virtual int size() const;
38    virtual Ptr<Serializable> get(int pos) const;
39
40    virtual Serializer& clear();
41    virtual const char* add(Serializable* objPtr);
42
43private:
44    // disallow these operations
45    Serializer(const Serializer& status) { assert(0); }
46    Serializer& operator=(const Serializer& status) { assert(0); }
47
48    // list of objects being serialized or deserialized
49    std::vector<const char*> _idlist;
50
51    // map each id in _idlist to the corresponding object
52    typedef std::map<std::string, Ptr<Serializable> > SerializerId2Obj;
53    SerializerId2Obj _id2obj;
54};
55
56} // namespace Rappture
57
58#endif
Note: See TracBrowser for help on using the repository browser.