1 /******************************************************************************
2 
3  This source file is part of the Avogadro project.
4 
5  Copyright 2013 Kitware, Inc.
6 
7  This source code is released under the New BSD License, (the "License").
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  ******************************************************************************/
16 
17 #ifndef AVOGADRO_PROTOCALL_MOLECULEDESERIALIZER_H
18 #define AVOGADRO_PROTOCALL_MOLECULEDESERIALIZER_H
19 
20 #include "avogadro/core/molecule.h"
21 #include "avogadroprotocallexport.h"
22 #include <google/protobuf/io/coded_stream.h>
23 #include <protocall/serialization/deserializer.h>
24 
25 namespace Avogadro {
26 namespace Core {
27 
28 /**
29  * @class MoleculeDeserializer moleculedeserializer.h
30  *  <avogadro/protocall/moleculdeeserializer.h>
31  * @brief Implementation of ProtoCall::Serialization::Deserializer
32  *
33  */
34 class AVOGADROPROTOCALL_EXPORT MoleculeDeserializer
35   : public ProtoCall::Serialization::Deserializer
36 {
37 public:
38   /**
39    * @param molecule The molecule to deserialize into.
40    */
41   MoleculeDeserializer(Molecule* molecule);
42 
43   /**
44    * Deserialize buffer into molecules.
45    *
46    * @param data The buffer containing the molecule byte stream.
47    * @param size The size of the buffer.
48    *
49    * @return true if successful, false otherwise.
50    */
51   bool deserialize(const void* data, size_t size);
52 
53 private:
54   /**
55    * Deserialize bond pairs from stream.
56    *
57    * @return true if successful, false otherwise.
58    */
59   bool deserializeBondPairs(google::protobuf::io::CodedInputStream* stream);
60 
61   /**
62    *
63    * Deserialize bond order from stream.
64    *
65    * @return true if successful, false otherwise.
66    */
67   bool deserializeBondOrders(google::protobuf::io::CodedInputStream* stream);
68 
69   /**
70    * Deserialize atomic numbers from stream.
71    *
72    * @return true if successful, false otherwise.
73    */
74   bool deserializeAtomicNumbers(google::protobuf::io::CodedInputStream* stream);
75 
76   /**
77    * Deserialize 2d positions from stream.
78    *
79    * @return true if successful, false otherwise.
80    */
81   bool deserializePositions2d(google::protobuf::io::CodedInputStream* stream);
82 
83   /**
84    * Deserialize 3d positions from stream.
85    *
86    * @return true if successful, false otherwise.
87    */
88   bool deserializePostions3d(google::protobuf::io::CodedInputStream* stream);
89 
90   Molecule* m_molecule;
91 };
92 
93 } // namespace Core
94 } // namespace Avogadro
95 
96 #endif
97