]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2014 Adam Crume <adamcrume@gmail.com> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef _INCLUDED_RBD_REPLAY_IMAGENAMEMAP_HPP | |
16 | #define _INCLUDED_RBD_REPLAY_IMAGENAMEMAP_HPP | |
17 | ||
18 | #include <map> | |
19 | #include <string> | |
20 | #include "rbd_loc.hpp" | |
21 | ||
22 | namespace rbd_replay { | |
23 | ||
24 | /** | |
25 | Maps image names. | |
26 | */ | |
27 | class ImageNameMap { | |
28 | public: | |
29 | typedef std::pair<rbd_loc, rbd_loc> Mapping; | |
30 | ||
31 | /** | |
32 | Parses a mapping. | |
33 | If parsing fails, the contents of \c mapping are undefined. | |
34 | @param[in] mapping_string string representation of the mapping | |
35 | @param[out] mapping stores the parsed mapping | |
36 | @retval true parsing was successful | |
37 | */ | |
38 | bool parse_mapping(std::string mapping_string, Mapping *mapping) const; | |
39 | ||
40 | void add_mapping(const Mapping& mapping); | |
41 | ||
42 | /** | |
43 | Maps an image name. | |
44 | If no mapping matches the name, it is returned unmodified. | |
45 | */ | |
46 | rbd_loc map(const rbd_loc& name) const; | |
47 | ||
48 | private: | |
49 | std::map<rbd_loc, rbd_loc> m_map; | |
50 | }; | |
51 | ||
52 | } | |
53 | ||
54 | #endif |