Xmipp  v3.23.11-Nereus
Public Member Functions | Static Public Member Functions | List of all members
cif::ResourcePool Class Reference

Public Member Functions

void pushDir (fs::path dir)
 
void pushDir (const char *path)
 
void pushAlias (const std::string &name, std::filesystem::path dataFile)
 
std::unique_ptr< std::istream > load (fs::path name)
 

Static Public Member Functions

static ResourcePoolinstance ()
 

Detailed Description

Definition at line 825 of file utilities.cpp.

Member Function Documentation

◆ instance()

static ResourcePool& cif::ResourcePool::instance ( )
inlinestatic

Definition at line 828 of file utilities.cpp.

829  {
830  static std::unique_ptr<ResourcePool> s_instance(new ResourcePool);
831  return *s_instance;
832  }

◆ load()

std::unique_ptr< std::istream > cif::ResourcePool::load ( fs::path  name)

Definition at line 903 of file utilities.cpp.

904 {
905  std::unique_ptr<std::istream> result;
906  std::error_code ec;
907 
908  fs::path p = name;
909 
910  if (mLocalResources.count(name.string()))
911  result = open(mLocalResources[name.string()]);
912 
913  for (auto di = mDirs.begin(); not result and di != mDirs.end(); ++di)
914  {
915  auto p2 = *di / p;
916  if (fs::exists(p2, ec) and not ec)
917  result = open(p2);
918  }
919 
920  // if (not result and gResourceData)
921  if (not result and (gResourceIndex[0].m_child > 0 or gResourceIndex[0].m_size > 0))
922  {
923  mrsrc::rsrc rsrc(name);
924  if (rsrc)
925  result.reset(new mrsrc::istream(rsrc));
926  }
927 
928  return result;
929 }
const mrsrc::rsrc_imp gResourceIndex[1]
Definition: utilities.cpp:428
double * di
Class mrsrc::rsrc contains a pointer to the data in the resource, as well as offering an iterator int...
Definition: utilities.cpp:479

◆ pushAlias()

void cif::ResourcePool::pushAlias ( const std::string &  name,
std::filesystem::path  dataFile 
)
inline

Definition at line 848 of file utilities.cpp.

849  {
850  std::error_code ec;
851  if (not fs::exists(dataFile, ec) or ec)
852  throw std::runtime_error("Attempt to add a file resource for " + name + " that cannot be used (" + dataFile.string() + ") :" + ec.message());
853 
854  mLocalResources[name] = dataFile;
855  }

◆ pushDir() [1/2]

void cif::ResourcePool::pushDir ( fs::path  dir)
inline

Definition at line 834 of file utilities.cpp.

835  {
836  std::error_code ec;
837 
838  if (fs::exists(dir, ec) and not ec)
839  mDirs.push_front(dir);
840  }

◆ pushDir() [2/2]

void cif::ResourcePool::pushDir ( const char *  path)
inline

Definition at line 842 of file utilities.cpp.

843  {
844  if (path != nullptr)
845  pushDir(fs::path(path));
846  }
void pushDir(fs::path dir)
Definition: utilities.cpp:834

The documentation for this class was generated from the following file: