1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "FieldValues.h"
24 #include "TableImpl.h"
25 #include "FieldValue.h"
26 #include "FieldImpl.h"
28 #include "StringUtilities.h"
30 FieldValues::FieldValues(TableImplPtr table
) :
36 FieldValues::~FieldValues()
41 ValuePtr
FieldValues::getField(FieldImplPtr field
) const
44 ValueMap::const_iterator it
= m_fields
.find(field
.get());
45 Assert(it
!= m_fields
.end());
50 TableImplPtr
FieldValues::getTable() const
55 void FieldValues::addValue(ValuePtr value
)
59 TableImplPtr table
= value
->getTable();
60 bool isReachableTable
= false;
63 isReachableTable
= true;
65 for(TableImplVector::const_iterator it
= m_joinedTables
.begin(); it
!= m_joinedTables
.end(); it
++)
67 TableImplPtr joinedTable
= *it
;
68 if(table
== joinedTable
)
69 isReachableTable
= true;
72 Assert(isReachableTable
);
74 m_fields
[value
->getField().get()] = value
;
77 void FieldValues::addJoinedTable(TableImplPtr joinedTable
)
81 m_joinedTables
.push_back(joinedTable
);
84 size_t FieldValues::size() const
86 return m_fields
.size();
89 ValuePtr
FieldValues::first() const
91 Assert(m_fields
.size() > 0);
93 return m_fields
.begin()->second
;
96 ValueMap::const_iterator
FieldValues::begin() const
98 return m_fields
.begin();
101 ValueMap::const_iterator
FieldValues::end() const
103 return m_fields
.end();
106 ValueMap::const_iterator
FieldValues::find(FieldImplPtr field
) const
110 return m_fields
.find(field
.get());