pycram.cache_manager
====================

.. py:module:: pycram.cache_manager


Classes
-------

.. autoapisummary::

   pycram.cache_manager.CacheManager


Module Contents
---------------

.. py:class:: CacheManager(cache_dir: str, data_directory: typing_extensions.List[str], clear_cache: bool = True)

   The CacheManager is responsible for caching object description files and managing the cache directory.


   .. py:attribute:: cache_cleared
      :type:  bool
      :value: False


      Indicate whether the cache directory has been cleared at least once since beginning or not.



   .. py:attribute:: cache_dir


   .. py:attribute:: data_directories


   .. py:method:: clear_cache()

      Clear the cache directory.



   .. py:method:: delete_cache_dir()

      Delete the cache directory.



   .. py:method:: update_cache_dir_with_object(path: str, ignore_cached_files: bool, object_description: pycram.description.ObjectDescription, object_name: str, scale_mesh: typing_extensions.Optional[float] = None, mesh_transform: typing_extensions.Optional[pycram.datastructures.pose.TransformStamped] = None, color: typing_extensions.Optional[pycram.datastructures.dataclasses.Color] = None) -> str

      Check if the file is already in the cache directory, if not preprocess and save in the cache.

      :param path: The path of the file to preprocess and save in the cache directory.
      :param ignore_cached_files: If True, the file will be preprocessed and saved in the cache directory even if it
       is already cached.
      :param object_description: The object description of the file.
      :param object_name: The name of the object.
      :param scale_mesh: The scale of the mesh.
      :param mesh_transform: The transformation matrix to apply to the mesh.
      :param color: The color of the object.
      :return: The path of the cached file.



   .. py:method:: look_for_file_in_data_dir(path_object: pathlib.Path) -> str

      Look for a file in the data directory of the World. If the file is not found in the data directory, raise a
       FileNotFoundError.

      :param path_object: The pathlib object of the file to look for.



   .. py:method:: create_cache_dir_if_not_exists()

      Create the cache directory if it does not exist.



   .. py:method:: is_cached(path: str, object_description: pycram.description.ObjectDescription) -> bool

      Check if the file in the given path is already cached or if
      there is already a cached file with the given name, this is the case if a .stl, .obj file or a description from
      the parameter server is used.

      :param path: The path of the file to check.
      :param object_description: The object description of the file.
      :return: True if there already exists a cached file, False in any other case.



   .. py:method:: check_with_extension(path: str) -> bool

      Check if the file in the given ath exists in the cache directory including file extension.

      :param path: The path of the file to check.



   .. py:method:: check_without_extension(path: str, object_description: pycram.description.ObjectDescription) -> bool

      Check if the file in the given path exists in the cache directory the given file extension.
      Instead, replace the given extension with the extension of the used ObjectDescription and check for that one.

      :param path: The path of the file to check.
      :param object_description: The object description of the file.



