Ocean
FileRecorder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_MEDIA_FILE_RECORDER_H
9 #define META_OCEAN_MEDIA_FILE_RECORDER_H
10 
11 #include "ocean/media/Media.h"
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 // Forward declaration.
23 class FileRecorder;
24 
25 /**
26  * Definition of a object reference holding a file recorder.
27  * @see SmartObjectRef, FileRecorder.
28  * @ingroup media
29  */
31 
32 /**
33  * This class is the base class for all file recorders.
34  * @ingroup media
35  */
36 class OCEAN_MEDIA_EXPORT FileRecorder : virtual public ExplicitRecorder
37 {
38  public:
39 
40  /**
41  * Returns the filename of this recorder.
42  * @return Recorder filename
43  * @see setFilename().
44  */
45  inline const std::string& filename() const;
46 
47  /**
48  * Returns whether the filename of this recorder will be suffixed with date and time.
49  * The default value is True.
50  * @return True, if so
51  * @see setFilenameSuffixed().
52  */
53  inline bool filenameSuffixed() const;
54 
55  /**
56  * Sets the filename of this recorder.
57  * @param filename Filename to set
58  * @return True, if succeeded
59  * @see filename().
60  */
61  virtual bool setFilename(const std::string& filename);
62 
63  /**
64  * Sets whether the filename will be suffixed with date and time.
65  * @param suffixed Determines whether the filename will be suffixed
66  * @return True, if succeeded
67  * @see filenameSuffixed().
68  */
69  virtual bool setFilenameSuffixed(const bool suffixed);
70 
71  protected:
72 
73  /**
74  * Creates a new file recorder.
75  */
77 
78  /**
79  * Destructs a file recorder.
80  */
81  ~FileRecorder() override;
82 
83 
84  // **TODO** Remove public access to the functions below once file recorders expose filenames
85  public:
86 
87  /**
88  * Determines the filename to be used for the next file.
89  * @param filename Initial name of the file, must be valid
90  * @param addSuffix True, to add a date/time-based suffix to the filename
91  * @return The filename to be used
92  */
93  static std::string addOptionalSuffixToFilename(const std::string& filename, const bool addSuffix);
94 
95  /**
96  * Determines the filename to be used for the next file.
97  * @param filename Initial name of the file, must be valid
98  * @param index The index of the file, with range [0, infinity)
99  * @param addSuffix True, to add a date/time-based suffix to the filename
100  * @return The filename to be used
101  */
102  static std::string addOptionalSuffixToFilename(const std::string& filename, const unsigned int index, const bool addSuffix);
103 
104  protected:
105 
106  /// Filename of this recorder.
107  std::string recorderFilename;
108 
109  /// Flag determining whether the filename will be suffixed with date and time.
111 };
112 
113 inline const std::string& FileRecorder::filename() const
114 {
115  return recorderFilename;
116 }
117 
119 {
121 }
122 
123 }
124 
125 }
126 
127 #endif // META_OCEAN_MEDIA_FILE_RECORDER_H
This class is the base class for all explicit media recorder.
Definition: ExplicitRecorder.h:40
This class is the base class for all file recorders.
Definition: FileRecorder.h:37
const std::string & filename() const
Returns the filename of this recorder.
Definition: FileRecorder.h:113
FileRecorder()
Creates a new file recorder.
virtual bool setFilenameSuffixed(const bool suffixed)
Sets whether the filename will be suffixed with date and time.
std::string recorderFilename
Filename of this recorder.
Definition: FileRecorder.h:107
virtual bool setFilename(const std::string &filename)
Sets the filename of this recorder.
bool recorderFilenameSuffixed
Flag determining whether the filename will be suffixed with date and time.
Definition: FileRecorder.h:110
static std::string addOptionalSuffixToFilename(const std::string &filename, const bool addSuffix)
Determines the filename to be used for the next file.
~FileRecorder() override
Destructs a file recorder.
bool filenameSuffixed() const
Returns whether the filename of this recorder will be suffixed with date and time.
Definition: FileRecorder.h:118
static std::string addOptionalSuffixToFilename(const std::string &filename, const unsigned int index, const bool addSuffix)
Determines the filename to be used for the next file.
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
Ocean::SmartObjectRef< FileRecorder, Recorder > FileRecorderRef
Definition of a object reference holding a file recorder.
Definition: FileRecorder.h:23
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15