libosmscout  1.1.1
RouteData.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_ROUTEDATA_H
2 #define OSMSCOUT_ROUTEDATA_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2012 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <list>
24 #include <vector>
25 
26 #include <osmscout/Path.h>
27 #include <osmscout/OSMScoutTypes.h>
29 
30 namespace osmscout {
31 
36  {
37  public:
39  {
40  private:
41  DatabaseId database;
42  Id currentNodeId;
43  size_t currentNodeIndex;
44  std::vector<ObjectFileRef> objects;
45  ObjectFileRef pathObject;
46  size_t targetNodeIndex;
47 
48  public:
49  RouteEntry(DatabaseId database,
50  Id currentNodeId,
51  size_t currentNodeIndex,
52  const ObjectFileRef& pathObject,
53  size_t targetNodeIndex);
54 
55  void SetObjects(const std::vector<ObjectFileRef>& objects);
56 
57  inline Id GetCurrentNodeId() const
58  {
59  return currentNodeId;
60  }
61 
63  {
64  return DBFileOffset(GetDatabaseId(),GetPathObject().GetFileOffset());
65  }
66 
67  inline DatabaseId GetDatabaseId() const
68  {
69  return database;
70  }
71 
72  inline size_t GetCurrentNodeIndex() const
73  {
74  return currentNodeIndex;
75  }
76 
77  inline ObjectFileRef GetPathObject() const
78  {
79  return pathObject;
80  }
81 
82  inline size_t GetTargetNodeIndex() const
83  {
84  return targetNodeIndex;
85  }
86 
87  inline const std::vector<ObjectFileRef>& GetObjects() const
88  {
89  return objects;
90  }
91  };
92 
93  private:
94  std::list<RouteEntry> entries;
95 
96  public:
97  void Clear();
98 
99  inline bool IsEmpty() const
100  {
101  return entries.empty();
102  }
103 
104  void AddEntry(DatabaseId database,
105  Id currentNodeId,
106  size_t currentNodeIndex,
107  const ObjectFileRef& pathObject,
108  size_t targetNodeIndex);
109 
110  inline std::list<RouteEntry>& Entries()
111  {
112  return entries;
113  }
114 
115  inline const std::list<RouteEntry>& Entries() const
116  {
117  return entries;
118  }
119 
120  inline void Append(RouteData routePart)
121  {
122  entries.splice(entries.end(),routePart.Entries());
123  }
124 
125  inline void PopEntry()
126  {
127  entries.pop_back();
128  }
129  };
130 }
131 
132 #endif
uint64_t Id
Definition: OSMScoutTypes.h:41
const std::vector< ObjectFileRef > & GetObjects() const
Definition: RouteData.h:87
std::list< RouteEntry > & Entries()
Definition: RouteData.h:110
Id GetCurrentNodeId() const
Definition: RouteData.h:57
void PopEntry()
Definition: RouteData.h:125
bool IsEmpty() const
Definition: RouteData.h:99
DBFileOffset GetDBFileOffset() const
Definition: RouteData.h:62
Definition: RouteData.h:35
size_t GetCurrentNodeIndex() const
Definition: RouteData.h:72
const std::list< RouteEntry > & Entries() const
Definition: RouteData.h:115
Definition: Area.h:38
Definition: RouteData.h:38
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
void Append(RouteData routePart)
Definition: RouteData.h:120
ObjectFileRef GetPathObject() const
Definition: RouteData.h:77
Definition: DBFileOffset.h:92
size_t GetTargetNodeIndex() const
Definition: RouteData.h:82
DatabaseId GetDatabaseId() const
Definition: RouteData.h:67
uint32_t DatabaseId
Definition: DBFileOffset.h:30