blob: be2d895ab8e11b76ea43378c917f09969ffae347 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001#ifndef TESTOBJECT_H
2#define TESTOBJECT_H
3
4// Copyright (C) 2002-2003 Chad C. Yates cyates@uidaho.edu
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19//
20// As a special exception to the GNU General Public License, permission is
21// granted for additional uses of the text contained in its release
22// of Common C++.
23//
24// The exception is that, if you link the Common C++ library with other
25// files to produce an executable, this does not by itself cause the
26// resulting executable to be covered by the GNU General Public License.
27// Your use of that executable is in no way restricted on account of
28// linking the Common C++ library code into it.
29//
30// This exception does not however invalidate any other reasons why
31// the executable file might be covered by the GNU General Public License.
32//
33// This exception applies only to the code released under the
34// name Common C++. If you copy code from other releases into a copy of
35// Common C++, as the General Public License permits, the exception does
36// not apply to the code that you add in this way. To avoid misleading
37// anyone as to the status of such modified files, you must delete
38// this exception notice from them.
39//
40// If you write modifications of your own for Common C++, it is your choice
41// whether to permit this exception to apply to your modifications.
42// If you do not wish that, delete this exception notice.
43
44#include <cc++/persist.h>
45#include <iterator>
46#include "SampleSubObject.h"
47
48using std::cout;
49using std::endl;
50using std::string;
51
52// an object used to test object graph persistence
53class Test : public BaseObject
54{
55 DECLARE_PERSISTENCE(Test)
56
57public:
58 int32 iInteger; // basic type test
59 string strString;
60 string strString2;
61 std::vector<double> numbers;
62 std::vector<string> strings;
63 std::deque<string> moreStrings;
64
65 TestSub* nullPtr; // NULL initialized pointer test
66 TestSub* uninitializedNullPtr; // NULL that is uninitialized in constructor
67 TestSub* subObjectPtr; // pointer to an object initially null, but later initialized
68 TestSub* subObjectPtr2; // second pointer to the same instance of an object
69 TestSub subObjectRef;
70 std::deque<TestSub> subObjects;
71
72 Test();
73 ~Test() { delete subObjectPtr; };
74 Test(Test &ob);
75 bool operator==(const Test &ob) const;
76 bool operator!=(const Test &ob) const { return !(*this == ob); };
77
78 void print(const string& name);
79
80 virtual bool write(Engine& archive) const;
81 virtual bool read(Engine& archive);
82};
83
84#endif