]> Dogcows Code - chaz/yoink/blobdiff - src/moof/resource.hh
the massive refactoring effort
[chaz/yoink] / src / moof / resource.hh
diff --git a/src/moof/resource.hh b/src/moof/resource.hh
new file mode 100644 (file)
index 0000000..ed8a7d0
--- /dev/null
@@ -0,0 +1,89 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_RESOURCE_HH_
+#define _MOOF_RESOURCE_HH_
+
+/**
+ * \file resource.hh
+ * Interface for textures, sounds, and other types of resources.
+ */
+
+#include <cstdio>
+#include <string>
+#include <vector>
+
+
+namespace moof {
+
+
+/**
+ * Generic resource class.  
+ */
+
+class resource
+{
+public:
+
+       virtual ~resource() {}
+
+
+       /**
+        * Add a directory to search when looking for resource files.
+        * \param paths A colon-separated list of directory paths.
+        */
+       static void add_search_paths(const std::string& paths);
+
+       /**
+        * Add directories to search when looking for resource files.
+        * \param pathList The list of directory paths.
+        */
+       static void add_search_paths(const std::vector<std::string>& pathList);
+
+
+       /**
+        * Get the path to a resource of a given name.
+        * \param path The name of the resource to find.  Upon successful
+        * return, this is changed to an absolute path to the resource.
+        * \param prefix A colon-separated list of subdirectories to search.
+        * \param extension A colon-separated list of possible extensions.
+        * \return True if a path to a resource was found, false otherwise.
+        */
+       static bool find_path(std::string& path,
+                                                 const std::string& prefix = "",
+                                                 const std::string& extension = "");
+
+       /**
+        * Get the path to a resource of a given name and open it if a resource
+        * was found.
+        * \param path The name of the resource to find.  Upon successful
+        * return, this is changed to an absolute path to the resource.
+        * \param prefix A colon-separated list of subdirectories to search.
+        * \param extension A colon-separated list of possible extensions.
+        * \param mode The open mode.
+        * \return The FILE* if the resource was found, 0 otherwise.
+        */
+       static FILE* open_file(std::string& path,
+                                                  const std::string& prefix = "",
+                                                  const std::string& extension = "",
+                                                  const std::string& mode = "rb");
+
+
+private:
+
+       static std::vector<std::string> search_paths_;
+};
+
+
+} // namespace moof
+
+#endif // _MOOF_RESOURCE_HH_
+
This page took 0.020872 seconds and 4 git commands to generate.