Program Listing for File map-manager.h

Return to documentation for file (backend/map-manager/include/map-manager/map-manager.h)

#ifndef MAP_MANAGER_MAP_MANAGER_H_
#define MAP_MANAGER_MAP_MANAGER_H_

#include <string>
#include <type_traits>
#include <unordered_set>
#include <vector>

#include <maplab-common/map-manager-config.h>
#include <maplab-common/monitor.h>

#include "map-manager/map-storage.h"

namespace backend {

template <typename MapType>
class MapManager {
 public:
  typedef typename common::Monitor<MapType>::WriteAccess MapWriteAccess;
  typedef typename common::Monitor<MapType>::ReadAccess MapReadAccess;

  MapManager();
  ~MapManager() {}

  MapType* getMapMutable(const std::string& key);
  const MapType& getMap(const std::string& key) const;

  MapWriteAccess getMapWriteAccess(const std::string& key);

  MapReadAccess getMapReadAccess(const std::string& key) const;

  bool hasMap(const std::string& key) const;

  bool isKeyValid(const std::string& key) const;

  std::string removeProhibitedCharactersFromKey(const std::string& key) const;

  void getAllMapKeys(std::unordered_set<std::string>* all_map_keys_list) const;
  void getAllMapKeys(std::vector<std::string>* all_map_keys_list) const;

  size_t numberOfMaps() const;

  void addMap(
      const std::string& key, AlignedUniquePtr<MapType>& map);  // NOLINT

  void deleteMap(const std::string& key);

  AlignedUniquePtr<MapType> releaseMap(const std::string& key);

  void renameMap(const std::string& old_key, const std::string& new_key);

  void copyMap(const std::string& source_key, const std::string& target_key);

  bool mergeMaps(
      const std::string& source_key_merge_base,
      const std::string& source_key_merge_from);

  bool mergeSubmapIntoBaseMap(
      const std::string& source_key_merge_base_map,
      const std::string& source_key_merge_submap);

  // TODO(eggerk): implement split.

  void getMapFolder(const std::string& map_key, std::string* map_folder) const;

  void setMapFolder(const std::string& map_key, const std::string& map_folder);

  bool loadMapFromFolder(
      const std::string& folder_path, const std::string& key_in);
  bool loadMapFromFolder(const std::string& folder_path, std::string* key_out);
  bool loadMapFromFolder(const std::string& folder_path);

  bool loadAllMapsFromFolder(const std::string& folder_path);
  bool loadAllMapsFromFolder(
      const std::string& folder_path,
      std::unordered_set<std::string>* new_keys);

  bool saveMapToFolder(
      const std::string& key, const std::string& folder_path) const;
  bool saveMapToFolder(
      const std::string& key, const std::string& folder_path,
      const SaveConfig& config) const;

  bool saveMapToMapFolder(const std::string& key) const;
  bool saveMapToMapFolder(
      const std::string& key, const SaveConfig& config) const;

  bool saveAllMapsToFolder(const std::string& folder_path) const;
  bool saveAllMapsToFolder(
      const std::string& folder_path, const SaveConfig& config) const;

  bool saveAllMapsToMapFolder() const;
  bool saveAllMapsToMapFolder(const SaveConfig& config) const;

  bool hasMapOnFileSystem(const std::string& folder_path) const;

  void getDefaultMapKeys(
      const std::vector<std::string>& map_list,
      std::vector<std::string>* key_list);

  void listAllMapsInFolder(
      const std::string& folder_path, std::vector<std::string>* map_list);

 protected:
  MapStorage<MapType>* map_storage_;
};

}  // namespace backend

#include "map-manager/map-manager-inl.h"

#endif  // MAP_MANAGER_MAP_MANAGER_H_