SectorZone: add attribute arc_boundary
[xcsoar.git] / src / Task / TaskStore.hpp
blob0f8f44c4213bdbc6a2bb89e7c2f4509f057f6ee5
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program 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
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef TASK_STORE_HPP
25 #define TASK_STORE_HPP
27 #include "Compiler.h"
28 #include "Util/tstring.hpp"
30 #include <vector>
32 #include <tchar.h>
34 struct TaskBehaviour;
35 class OrderedTask;
37 /**
38 * Class to load multiple tasks on demand, e.g. for browsing
40 class TaskStore
42 public:
43 struct Item
45 tstring task_name;
46 tstring filename;
47 unsigned task_index;
48 OrderedTask* task;
49 bool valid;
51 Item(tstring::const_pointer the_filename,
52 tstring::const_pointer _task_name,
53 unsigned _task_index = 0)
54 :task_name(_task_name),
55 filename(the_filename),
56 task_index(_task_index),
57 task(NULL),
58 valid(true) {}
60 ~Item();
62 gcc_pure
63 tstring::const_pointer GetName() const {
64 return task_name.c_str();
67 gcc_pure
68 tstring::const_pointer GetPath() const {
69 return filename.c_str();
72 OrderedTask *GetTask(const TaskBehaviour &task_behaviour);
74 gcc_pure
75 bool operator<(const TaskStore::Item &other) const {
76 return task_name.compare(other.task_name) < 0;
80 typedef std::vector<TaskStore::Item> ItemVector;
82 private:
83 /**
84 * Internal task storage
86 ItemVector store;
88 public:
89 /**
90 * Scan the XCSoarData folder for .tsk files and add them to the TaskStore
92 * @param extra scan all "extra" (non-XCSoar) task files, e.g. *.cup
93 * and task declarations from *.igc
95 void Scan(bool extra=false);
97 /**
98 * Clear all the tasks from the TaskStore
100 void Clear();
103 * Return the number of tasks in the TaskStore
104 * @return The number of tasks in the TaskStore
106 gcc_pure
107 size_t Size() const {
108 return store.size();
112 * Return the filename of the task defined by the given index
113 * (e.g. TestTask.tsk)
114 * @param index TaskStore index of the desired Task
115 * @return Filename of the task defined by the given index
117 gcc_pure
118 tstring::const_pointer GetName(unsigned index) const;
121 * Return the pathname of the task defined by the given index
122 * (e.g. tasks/TestTask.tsk)
123 * @param index TaskStore index of the desired Task
124 * @return pathname of the task defined by the given index
126 gcc_pure
127 tstring::const_pointer GetPath(unsigned index) const;
130 * Return the task defined by the given index
131 * @param index TaskStore index of the desired Task
132 * @return The task defined by the given index
134 OrderedTask *GetTask(unsigned index, const TaskBehaviour &task_behaviour);
137 #endif