Ocean
IIOLibrary.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_IMAGEIO_IIO_LIBRARY_H
9 #define META_OCEAN_MEDIA_IMAGEIO_IIO_LIBRARY_H
10 
12 
13 #include "ocean/media/Library.h"
14 #include "ocean/media/Manager.h"
15 
16 namespace Ocean
17 {
18 
19 namespace Media
20 {
21 
22 namespace ImageIO
23 {
24 
25 /**
26  * This class implements the ImageIO library.
27  * @ingroup mediaiio
28  */
29 class OCEAN_MEDIA_IIO_EXPORT IIOLibrary : public Library
30 {
31  friend class Media::Manager;
32  friend class IIOBufferImage;
33  friend class IIOImage;
34  friend class IIOImageSequence;
35 
36  public:
37 
38  /**
39  * Creates a new medium by a given url.
40  * @see Library::newMedium().
41  */
42  MediumRef newMedium(const std::string& url, bool useExclusive = false) override;
43 
44  /**
45  * Creates a new medium by a given url and an expected type.
46  * @see Library::newMedium().
47  */
48  MediumRef newMedium(const std::string& url, const Medium::Type type, bool useExclusive = false) override;
49 
50  /**
51  * Creates a new recorder specified by the recorder type.
52  * @see Library::newRecorder().
53  */
54  RecorderRef newRecorder(const Recorder::Type type) override;
55 
56  /**
57  * Returns the supported medium types.
58  * @see Library::supportedTypes().
59  */
60  Medium::Type supportedTypes() const override;
61 
62  /**
63  * Returns the image types supported by this library.
64  * @return All image type currently supported, e.g., "jpg", "bmp"
65  */
66  static std::set<std::string> supportedImageTypes();
67 
68  /**
69  * Registers this library at the global media manager.
70  * With each register call, the reference counter for a specific library will be incremented.
71  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
72  * @return True, if the library has not been registered before
73  * @see Manager, unregisterLibrary()
74  */
75  static bool registerLibrary();
76 
77  /**
78  * Unregisters this library at the global media manager.
79  * With each unregister call, the reference counter for a specific library will be decremented and removed from the system if the counter reaches zero.
80  * Each call to registerLibrary() needs to be balanced with a corresponding call of unregisterLibrary() before shutting down.
81  * @return True, if the library was actually removed from the system (as the reference counter reached zero); False, if the library is still used by someone else
82  * @see registerLibrary().
83  */
84  static bool unregisterLibrary();
85 
86  protected:
87 
88  /**
89  * Creates a new IIOLibrary object.
90  */
92 
93  /**
94  * Destructs an IIOLibrary object.
95  */
96  ~IIOLibrary() override;
97 
98  /**
99  * Creates this library and returns it an object reference.
100  * @return The new library object
101  */
102  static LibraryRef create();
103 
104  /**
105  * Creates a new buffer image medium.
106  * @param url Url of the image medium to create
107  * @param useExclusive Determines whether the caller would like to use this medium exclusively
108  * @return Reference of the new medium
109  */
110  static MediumRef newBufferImage(const std::string& url, bool useExclusive);
111 
112  /**
113  * Creates a new image medium.
114  * @param url Url of the image medium to create
115  * @param useExclusive Determines whether the caller would like to use this medium exclusively
116  * @return Reference of the new medium
117  */
118  static MediumRef newImage(const std::string& url, bool useExclusive);
119 
120  /**
121  * Creates a new image sequence medium.
122  * @param url Url of the image sequence medium to create
123  * @param useExclusive Determines whether the caller would like to use this medium exclusively
124  * @return Reference of the new medium
125  */
126  static MediumRef newImageSequence(const std::string& url, bool useExclusive);
127 };
128 
129 }
130 
131 }
132 
133 }
134 
135 #endif // META_OCEAN_MEDIA_IMAGEIO_IIO_LIBRARY_H
This class implements a buffer image class for ImageIO.
Definition: IIOBufferImage.h:32
This class implements an image class for ImageIO.
Definition: IIOImage.h:32
This class implements an image class for ImageIO.
Definition: IIOImageSequence.h:32
This class implements the ImageIO library.
Definition: IIOLibrary.h:30
static MediumRef newImageSequence(const std::string &url, bool useExclusive)
Creates a new image sequence medium.
~IIOLibrary() override
Destructs an IIOLibrary object.
static MediumRef newImage(const std::string &url, bool useExclusive)
Creates a new image medium.
IIOLibrary()
Creates a new IIOLibrary object.
static LibraryRef create()
Creates this library and returns it an object reference.
MediumRef newMedium(const std::string &url, const Medium::Type type, bool useExclusive=false) override
Creates a new medium by a given url and an expected type.
static bool registerLibrary()
Registers this library at the global media manager.
RecorderRef newRecorder(const Recorder::Type type) override
Creates a new recorder specified by the recorder type.
static bool unregisterLibrary()
Unregisters this library at the global media manager.
MediumRef newMedium(const std::string &url, bool useExclusive=false) override
Creates a new medium by a given url.
static std::set< std::string > supportedImageTypes()
Returns the image types supported by this library.
static MediumRef newBufferImage(const std::string &url, bool useExclusive)
Creates a new buffer image medium.
Medium::Type supportedTypes() const override
Returns the supported medium types.
This class is the base class for all media libraries.
Definition: media/Library.h:42
This class is the manager for all media objects.
Definition: media/Manager.h:34
Type
Definition of different medium types.
Definition: Medium.h:57
Type
Definition of different recorder types.
Definition: Recorder.h:46
This template class implements a object reference with an internal reference counter.
Definition: base/ObjectRef.h:58
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15