OdbDesignLib
OdbDesign ODB++ Parsing Library
DesignCache.h
1 #pragma once
2 
3 #include "../FileModel/Design/FileArchive.h"
4 #include "../ProductModel/Design.h"
5 #include "../odbdesign_export.h"
6 #include "StringVector.h"
7 
8 
9 namespace Odb::Lib::App
10 {
11  class ODBDESIGN_EXPORT DesignCache
12  {
13  public:
14  DesignCache(std::string directory);
15  ~DesignCache();
16 
17  std::shared_ptr<ProductModel::Design> GetDesign(const std::string& designName);
18  std::shared_ptr<FileModel::Design::FileArchive> GetFileArchive(const std::string& designName);
19 
20  std::vector<std::string> getLoadedDesignNames(const std::string& filter = "") const;
21  std::vector<std::string> getLoadedFileArchiveNames(const std::string& filter = "") const;
22  std::vector<std::string> getUnloadedDesignNames(const std::string& filter = "") const;
23 
24  int loadAllFileArchives(bool stopOnError);
25  int loadAllDesigns(bool stopOnError);
26  int loadFileArchives(const Utils::StringVector& names);
27  int loadDesigns(const Utils::StringVector& names);
28 
29  void setDirectory(const std::string& directory);
30  const std::string& getDirectory() const;
31 
32  //bool isQueryValid(const std::string& query) const;
33 
34  void Clear();
35 
36  private:
37  std::string m_directory;
38 
39  FileModel::Design::FileArchive::StringMap m_fileArchivesByName;
40  ProductModel::Design::StringMap m_designsByName;
41 
42  std::shared_ptr<ProductModel::Design> LoadDesign(const std::string& designName);
43  std::shared_ptr<FileModel::Design::FileArchive> LoadFileArchive(const std::string& designName);
44 
45  constexpr inline static const char* DESIGN_EXTENSIONS[] = { "zip", "tgz", "tar.gz", "tar", "gzip" , "gz" };
46 
47  };
48 }