File indexing completed on 2023-03-17 10:45:55
0001 #ifndef mytestdata_H
0002 #define mytestdata_H
0003
0004 #include <iostream>
0005 #include <string>
0006
0007 #include "CondFormats/Serialization/interface/Serializable.h"
0008
0009 class MyTestData {
0010 public:
0011 MyTestData() : a(0), b(0.), s(" ") {
0012 for (size_t i = 0; i < 2; i++)
0013 for (size_t j = 0; j < 2; j++) {
0014 d[i][j] = 0;
0015 f[i][j] = 0;
0016 }
0017 }
0018 MyTestData(int seed) : a(seed), b(seed + 1.1), s("Bla bla") {
0019 for (size_t i = 0; i < 2; i++)
0020 for (size_t j = 0; j < 2; j++) {
0021 d[i][j] = 0;
0022 f[i][j] = 0;
0023 }
0024 d[0][0] = 1;
0025 d[0][1] = 2;
0026 d[1][0] = 3;
0027 d[1][1] = 4;
0028 f[0][0] = 5;
0029 f[0][1] = 6;
0030 f[1][0] = 7;
0031 f[1][1] = 8;
0032 }
0033 void print() {
0034 std::cout << "MyTestData: a=" << a << " b=" << b << " s=" << s << std::endl;
0035 for (size_t i = 0; i < 2; i++)
0036 for (size_t j = 0; j < 2; j++) {
0037 std::cout << "d[" << i << "][" << j << "]=" << d[i][j] << std::endl;
0038 }
0039 for (size_t i = 0; i < 2; i++)
0040 for (size_t j = 0; j < 2; j++) {
0041 std::cout << "f[" << i << "][" << j << "]=" << f[i][j] << std::endl;
0042 }
0043 }
0044
0045 bool operator==(const MyTestData& rhs) const {
0046 if (a != rhs.a) {
0047 return false;
0048 }
0049 if (b != rhs.b) {
0050 return false;
0051 }
0052 for (size_t i = 0; i < 2; i++)
0053 for (size_t j = 0; j < 2; j++) {
0054 if (d[i][j] != rhs.d[i][j]) {
0055 return false;
0056 }
0057 if (f[i][j] != rhs.f[i][j]) {
0058 return false;
0059 }
0060 }
0061 if (s != rhs.s) {
0062 return false;
0063 }
0064 return true;
0065 }
0066 bool operator!=(const MyTestData& rhs) const { return !operator==(rhs); }
0067
0068 private:
0069 int a;
0070 float b;
0071 std::string s;
0072 int d[2][2];
0073 float f[2][2];
0074
0075 COND_SERIALIZABLE;
0076 };
0077
0078 #if !defined(__GCCXML__)
0079
0080 #include <boost/serialization/nvp.hpp>
0081
0082 template <class Archive>
0083 void MyTestData::serialize(Archive& ar, const unsigned int) {
0084 ar& BOOST_SERIALIZATION_NVP(a);
0085 ar& BOOST_SERIALIZATION_NVP(b);
0086 ar& BOOST_SERIALIZATION_NVP(s);
0087 ar& BOOST_SERIALIZATION_NVP(d);
0088 ar& BOOST_SERIALIZATION_NVP(f);
0089 }
0090
0091 #endif
0092
0093 #endif