File.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*******************************************************************************
  2. * Copyright 2009-2016 Jörg Müller
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. /**
  18. * @file File.h
  19. * @ingroup file
  20. * The File class.
  21. */
  22. #include "ISound.h"
  23. #include <string>
  24. #include <memory>
  25. AUD_NAMESPACE_BEGIN
  26. class Buffer;
  27. /**
  28. * The File sound tries to read a sound file via all available file inputs
  29. * that have been registered in the FileManager class.
  30. */
  31. class AUD_API File : public ISound
  32. {
  33. private:
  34. /**
  35. * The filename of the sound source file.
  36. */
  37. std::string m_filename;
  38. /**
  39. * The buffer to read from.
  40. */
  41. std::shared_ptr<Buffer> m_buffer;
  42. // delete copy constructor and operator=
  43. File(const File&) = delete;
  44. File& operator=(const File&) = delete;
  45. public:
  46. /**
  47. * Creates a new sound.
  48. * The file is read from the file system using the given path.
  49. * \param filename The sound file path.
  50. */
  51. File(std::string filename);
  52. /**
  53. * Creates a new sound.
  54. * The file is read from memory using the supplied buffer.
  55. * \param buffer The buffer to read from.
  56. * \param size The size of the buffer.
  57. */
  58. File(const data_t* buffer, int size);
  59. virtual std::shared_ptr<IReader> createReader();
  60. };
  61. AUD_NAMESPACE_END