sftools  2.0 dev
Bunch of tools for SFML application development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Locations.hpp
Go to the documentation of this file.
1 /*
2 
3  sftools - Copyright (c) 2012-2013 Marco Antognini <antognini.marco@gmail.com>
4 
5  This software is provided 'as-is', without any express or implied warranty. In
6  no event will the authors be held liable for any damages arising from the use
7  of this software.
8 
9  Permission is granted to anyone to use this software for any purpose, including
10  commercial applications, and to alter it and redistribute it freely, subject to
11  the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not claim
14  that you wrote the original software. If you use this software in a product,
15  an acknowledgment in the product documentation would be appreciated but is
16  not required.
17 
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source distribution.
22 
23  */
24 
30 #ifndef __SFTOOLS_LOCATIONS_HPP__
31 #define __SFTOOLS_LOCATIONS_HPP__
32 
34 #include <sftools/Singleton.hpp>
35 
36 #include <string>
37 #include <vector>
38 #include <algorithm>
39 
44 namespace sftools
45 {
69  {
70  typedef std::vector<std::string> Storage;
71  typedef Storage::iterator Iterator;
72  Storage m_locations;
73 
74  public:
75  typedef Storage::const_iterator ConstIterator;
76 
82  void add(std::string const& path)
83  {
84  m_locations.push_back(path);
85  }
86 
96  void remove(std::string const& path)
97  {
98  Iterator it = std::find(m_locations.begin(), m_locations.end(), path);
99  if (it != m_locations.end())
100  {
101  m_locations.erase(it);
102  }
103  }
104 
110  void clear()
111  {
112  m_locations.clear();
113  }
114 
123  {
124  return m_locations.begin();
125  }
126 
133  {
134  return m_locations.end();
135  }
136  };
137 
142  namespace singleton
143  {
165  }
166 }
167 
168 #endif // __SFTOOLS_LOCATIONS_HPP__