Ocean
apple/macos/ImageList.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_PLATFORM_APPLE_MACOS_IMAGE_LIST_H
9 #define META_OCEAN_PLATFORM_APPLE_MACOS_IMAGE_LIST_H
10 
13 
14 #include "ocean/base/Frame.h"
15 
16 #ifndef __OBJC__
17  #error Platform::Apple::MacOS::ImageList.h needs to be included from an ObjectiveC++ file
18 #endif
19 
20 namespace Ocean
21 {
22 
23 namespace Platform
24 {
25 
26 namespace Apple
27 {
28 
29 namespace MacOS
30 {
31 
32 /**
33  * This class implements an image list.
34  * @ingroup platformapplemacos
35  */
36 class ImageList
37 {
38  protected:
39 
40  /**
41  * Definition of a vector holding image object.
42  */
43  typedef std::vector<Image> Images;
44 
45  public:
46 
47  /**
48  * Creates a new image list object.
49  */
50  inline ImageList();
51 
52  /**
53  * Move constructor.
54  * @param imageList The image list to be moved
55  */
56  inline ImageList(ImageList&& imageList) noexcept;
57 
58  /**
59  * Not existing copy constructor.
60  * @param imageList The image list to be copied
61  */
62  inline ImageList(const ImageList& imageList) = delete;
63 
64  /**
65  * Creates a new image list object from one large frame containing the individual images within the same row.
66  * The with of the given frame must be a multiple of the height of the given frame.<br>
67  * @param frame The large frame containing all individual images, must be valid
68  * @param scaleFactor The scale factor converting the number of pixels in the (virtual) display coordinate system to the number of pixels in the (native/pyhsical) screen coordinate system, with range (0, infinity)
69  */
70  explicit ImageList(const Frame& frame, const double scaleFactor = 1.0);
71 
72  /**
73  * Returns the number of images of this list.
74  * @return The number of images
75  */
76  inline size_t size() const;
77 
78  /**
79  * Clears this image list.
80  */
81  inline void clear();
82 
83  /**
84  * Returns whether this image list does not hold any image.
85  * @return True, if so
86  */
87  inline bool isEmpty() const;
88 
89  /**
90  * Move operator.
91  * @param imageList The image list object to be moved
92  * @return Reference to this object
93  */
94  inline ImageList& operator=(ImageList&& imageList) noexcept;
95 
96  /**
97  * Not exisiting assign operator.
98  * @param imageList The image list object to be copied
99  * @return Reference to this object
100  */
101  inline ImageList& operator=(const ImageList& imageList) = delete;
102 
103  /**
104  * The index access object providing access to a specific frame of this frame list.
105  * @param index The index of the frame to access, with range [0, size())
106  * @return The requested frame
107  */
108  inline Image& operator[](const size_t index);
109 
110  protected:
111 
112  /// The images of this list.
114 };
115 
117 {
118  // nothing to do here
119 }
120 
121 inline ImageList::ImageList(ImageList&& imageList) noexcept :
122  listImages(std::move(imageList.listImages))
123 {
124  // nothing to do here
125 }
126 
127 inline size_t ImageList::size() const
128 {
129  return listImages.size();
130 }
131 
132 inline void ImageList::clear()
133 {
134  listImages.clear();
135 }
136 
137 inline bool ImageList::isEmpty() const
138 {
139  return listImages.empty();
140 }
141 
142 inline ImageList& ImageList::operator=(ImageList&& imageList) noexcept
143 {
144  if (this != &imageList)
145  {
146  listImages = std::move(imageList.listImages);
147  }
148 
149  return *this;
150 }
151 
152 inline Image& ImageList::operator[](const size_t index)
153 {
154  ocean_assert(index < listImages.size());
155  return listImages[index];
156 }
157 
158 }
159 
160 }
161 
162 }
163 
164 }
165 
166 #endif // META_OCEAN_PLATFORM_APPLE_MACOS_IMAGE_LIST_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a wrapper for the NSImage object.
Definition: platform/apple/macos/Image.h:38
This class implements an image list.
Definition: apple/macos/ImageList.h:37
std::vector< Image > Images
Definition of a vector holding image object.
Definition: apple/macos/ImageList.h:43
ImageList & operator=(ImageList &&imageList) noexcept
Move operator.
Definition: apple/macos/ImageList.h:142
Image & operator[](const size_t index)
The index access object providing access to a specific frame of this frame list.
Definition: apple/macos/ImageList.h:152
size_t size() const
Returns the number of images of this list.
Definition: apple/macos/ImageList.h:127
ImageList()
Creates a new image list object.
Definition: apple/macos/ImageList.h:116
ImageList(const Frame &frame, const double scaleFactor=1.0)
Creates a new image list object from one large frame containing the individual images within the same...
bool isEmpty() const
Returns whether this image list does not hold any image.
Definition: apple/macos/ImageList.h:137
ImageList(const ImageList &imageList)=delete
Not existing copy constructor.
Images listImages
The images of this list.
Definition: apple/macos/ImageList.h:113
ImageList & operator=(const ImageList &imageList)=delete
Not exisiting assign operator.
void clear()
Clears this image list.
Definition: apple/macos/ImageList.h:132
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15