1 /* Copyright (C) 2014 InfiniDB, Inc.
2
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; version 2 of
6 the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 MA 02110-1301, USA. */
17
18 /***********************************************************************
19 * $Id: treenodeimpl.cpp 9210 2013-01-21 14:10:42Z rdempsey $
20 *
21 *
22 ***********************************************************************/
23 #include <string>
24 using namespace std;
25
26 #include "bytestream.h"
27 #include "treenodeimpl.h"
28 #include "objectreader.h"
29
30 namespace execplan
31 {
32 /**
33 * Constructors/Destructors
34 */
TreeNodeImpl()35 TreeNodeImpl::TreeNodeImpl()
36 {}
37
TreeNodeImpl(const string & sql)38 TreeNodeImpl::TreeNodeImpl(const string& sql) :
39 fData(sql)
40 {}
41
~TreeNodeImpl()42 TreeNodeImpl::~TreeNodeImpl()
43 {}
44
45 /**
46 * The serialization interface
47 */
serialize(messageqcpp::ByteStream & b) const48 void TreeNodeImpl::serialize(messageqcpp::ByteStream& b) const
49 {
50 b << (ObjectReader::id_t) ObjectReader::TREENODEIMPL;
51 b << fData;
52 }
53
unserialize(messageqcpp::ByteStream & b)54 void TreeNodeImpl::unserialize(messageqcpp::ByteStream& b)
55 {
56 ObjectReader::checkType(b, ObjectReader::TREENODEIMPL);
57 b >> fData;
58 }
59
toString() const60 const string TreeNodeImpl::toString() const
61 {
62 return string(">TreeNodeImpl<");
63 }
64
operator ==(const TreeNodeImpl & t) const65 bool TreeNodeImpl::operator==(const TreeNodeImpl& t) const
66 {
67 if (data() == t.data())
68 return true;
69
70 return false;
71 }
72
operator ==(const TreeNode * t) const73 bool TreeNodeImpl::operator==(const TreeNode* t) const
74 {
75 const TreeNodeImpl* tni;
76
77 tni = dynamic_cast<const TreeNodeImpl*>(t);
78
79 if (tni == NULL)
80 return false;
81
82 return *this == *tni;
83 }
84
operator !=(const TreeNodeImpl & t) const85 bool TreeNodeImpl::operator!=(const TreeNodeImpl& t) const
86 {
87 return !(*this == t);
88 }
89
operator !=(const TreeNode * t) const90 bool TreeNodeImpl::operator!=(const TreeNode* t) const
91 {
92 return !(*this == t);
93 }
94
95 /**
96 * Friend function
97 */
operator <<(ostream & output,const TreeNodeImpl & rhs)98 ostream& operator<<(ostream& output, const TreeNodeImpl& rhs)
99 {
100 output << rhs.toString();
101 return output;
102 }
103
104 } // namespace execplan
105