OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProtocolBufferSerializer.h
Go to the documentation of this file.
1 /*
2  * opencog/atomspace/ProtocolBufferSerializer.h
3  *
4  * Copyright (C) 2008-2010 OpenCog Foundation
5  * All Rights Reserved
6  *
7  * Written by Erwin Joosten
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License v3 as
11  * published by the Free Software Foundation and including the exceptions
12  * at http://opencog.org/wiki/Licenses
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program; if not, write to:
21  * Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 //TODO move this file to the persist directory
26 
27 #ifndef _OPENCOG_PROTOCOLBUFFER_SERIALIZER_H
28 #define _OPENCOG_PROTOCOLBUFFER_SERIALIZER_H
29 
31 #include <string>
32 #include "ZMQMessages.pb.h"
33 
34 using namespace std;
35 
36 namespace opencog {
41 class AttentionValue;
42 class AttentionValueHolder;
43 class Atom;
44 class Link;
45 class Node;
46 class TruthValue;
47 class CompositeTruthValue;
48 class CountTruthValue;
49 class IndefiniteTruthValue;
50 class NullTruthValue;
51 class SimpleTruthValue;
52 class Trail;
53 class VersionHandle;
54 
56  static void deserializeAtom(const ZMQAtomMessage& atomMessage, Atom& atom);
57  static void serializeAtom(Atom& atom, ZMQAtomMessage* atomMessage);
58 
59  static void deserializeAttentionValue(
60  const ZMQAttentionValueHolderMessage &attentionValueHolderMessage,
62  static void serializeAttentionValue(
63  AttentionValue& av, ZMQAttentionValueHolderMessage* attentionValueHolderMessage);
64  static void deserializeAttentionValueHolder(
65  const ZMQAttentionValueHolderMessage& attentionValueHolderMessage,
66  AttentionValueHolder& attentionValueHolder);
67  static void serializeAttentionValueHolder(
68  AttentionValueHolder& attentionValueHolder,
69  ZMQAttentionValueHolderMessage *attentionValueHolderMessage);
70 
71  static void deserializeLink(const ZMQAtomMessage& atomMessage, Link& link);
72  static void serializeLink(Link& link, ZMQAtomMessage *atomMessage);
73  static void deserializeNode(const ZMQAtomMessage& atomMessage, Node& node);
74  static void serializeNode(Node& node, ZMQAtomMessage *atomMessage);
75 
76  static void deserializeCompositeTruthValue(
77  const ZMQTruthValueMessage& truthValueMessage, CompositeTruthValue& tv);
78  static void serializeCompositeTruthValue(
79  CompositeTruthValue& tv, ZMQTruthValueMessage * truthValueMessage);
80  static void deserializeCountTruthValue(
81  const ZMQSingleTruthValueMessage& singleTruthValue, CountTruthValue& tv);
82  static void serializeCountTruthValue(
83  CountTruthValue& tv, ZMQTruthValueMessage* truthValueMessage);
84  static void deserializeIndefiniteTruthValue(
85  const ZMQSingleTruthValueMessage& singleTruthValue, IndefiniteTruthValue& tv);
86  static void serializeIndefiniteTruthValue(
87  IndefiniteTruthValue& tv, ZMQTruthValueMessage* truthValueMessage);
88  static void serializeNullTruthValue(
89  NullTruthValue& tv, ZMQTruthValueMessage* truthValueMessage);
90  static void deserializeSimpleTruthValue(
91  const ZMQSingleTruthValueMessage& singleTruthValue, SimpleTruthValue& tv);
92  static void serializeSimpleTruthValue(
93  SimpleTruthValue& tv, ZMQTruthValueMessage* truthValueMessage);
94 
95  static void deserializeTrail(const ZMQTrailMessage& trailMessage, Trail& trail);
96  static void serializeTrail(Trail& trail, ZMQTrailMessage* trailMessage);
97  static void deserializeVersionHandle(
98  const ZMQVersionHandleMessage& versionHandleMessage, VersionHandle& vh);
99  static void serializeVersionHandle(
100  VersionHandle& vh, ZMQVersionHandleMessage* versionHandleMessage);
101  static TruthValue* deserialize(
102  const ZMQSingleTruthValueMessage& singleTruthValueMessage);
103 
104 public:
107 
108  static Atom* deserialize(const ZMQAtomMessage& atomMessage);
109  static void serialize(Atom &atom, ZMQAtomMessage* atomMessage);
110 
111  static TruthValue* deserialize(const ZMQTruthValueMessage& truthValueMessage);
112  static void serialize(TruthValue &tv, ZMQTruthValueMessage* truthValueMessage);
113 };
114 
116 } // namespace opencog
117 
118 #endif // _OPENCOG_PROTOCOLBUFFER_SERIALIZER_H
a TruthValue that stores a mean and the number of observations (strength and confidence) ...
a special type of TruthValue
a TruthValue that stores a mean, a confidence and the number of observations