Aspose.Tasks for C++
AvailabilityPeriodCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="AvailabilityPeriodCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/collections/list.h>
9 #include <system/collections/ilist.h>
10 #include <system/array.h>
11 #include <cstdint>
12 
13 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
14 #include "aspose.tasks.cpp/AvailabilityPeriod.h"
15 
16 namespace Aspose
17 {
18 namespace Tasks
19 {
20 namespace Calculations
21 {
22 class ResourceOverAllocationCalculator;
23 } // namespace Calculations
24 namespace IO
25 {
26 namespace MSProject
27 {
28 class MppAvailabilityWriter;
29 } // namespace MSProject
30 namespace Xml
31 {
32 class ResourceNodeReader;
33 } // namespace Xml
34 } // namespace IO
35 class Resource;
36 } // namespace Tasks
37 } // namespace Aspose
38 namespace System
39 {
40 namespace Collections
41 {
42 namespace Generic
43 {
44 template <typename> class IEnumerator;
45 } // namespace Generic
46 } // namespace Collections
47 class DateTime;
48 } // namespace System
49 
50 namespace Aspose {
51 
52 namespace Tasks {
53 
54 /// <summary>
55 /// Represents a collection which contains <see cref="AvailabilityPeriod"></see> objects.
56 /// </summary>
57 class ASPOSE_TASKS_SHARED_CLASS AvailabilityPeriodCollection : public System::Collections::Generic::IList<System::SharedPtr<AvailabilityPeriod>>
58 {
60  typedef System::Collections::Generic::IList<System::SharedPtr<AvailabilityPeriod>> BaseType;
61 
62  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
63  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
64 
65  friend class Aspose::Tasks::IO::MSProject::MppAvailabilityWriter;
66  friend class Aspose::Tasks::IO::Xml::ResourceNodeReader;
67  friend class Resource;
68  friend class Aspose::Tasks::Calculations::ResourceOverAllocationCalculator;
69 
70 public:
71  /// A collection type whose iterator types is used as iterator types in the current collection.
72  using iterator_holder_type = System::Collections::Generic::List<System::SharedPtr<AvailabilityPeriod>>;
73  /// Iterator type.
74  using iterator = typename iterator_holder_type::iterator;
75  /// Const iterator type.
76  using const_iterator = typename iterator_holder_type::const_iterator;
77  /// Virtualized element type.
78  using virtualized_iterator_element = typename iterator_holder_type::virtualized_iterator_element;
79  /// Virtualized type.
80  using virtualized_iterator = typename iterator_holder_type::virtualized_iterator;
81 
82 public:
83 
84  /// <summary>
85  /// Gets the parent <see cref="Resource"></see> for this object.
86  /// <returns>Parent <see cref="Resource"></see> object for this collection.</returns>
87  /// </summary>
88  ASPOSE_TASKS_SHARED_API System::SharedPtr<Resource> get_ParentResource() const;
89  /// <summary>
90  /// Gets the number of elements contained in this collection.
91  /// </summary>
92  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
93  /// <summary>
94  /// Gets a value indicating whether this collection is read-only; otherwise, false.
95  /// </summary>
96  ASPOSE_TASKS_SHARED_API bool get_IsReadOnly() const override;
97 
98  /// <summary>
99  /// Returns the element at the specified index.
100  /// </summary>
101  /// <param name="index">The zero-based index of the element to get or set.</param>
102  /// <returns>the element at the specified index.</returns>
103  ASPOSE_TASKS_SHARED_API System::SharedPtr<AvailabilityPeriod> idx_get(int32_t index) const override;
104  /// <summary>
105  /// Sets the element at the specified index.
106  /// </summary>
107  /// <param name="index">The zero-based index of the element to get or set.</param>
108  /// <param name="value">the element at the specified index.</param>
109  ASPOSE_TASKS_SHARED_API void idx_set(int32_t index, System::SharedPtr<AvailabilityPeriod> value) override;
110 
111  /// <summary>
112  /// Returns an enumerator for this collection.
113  /// </summary>
114  /// <returns>an enumerator for this collection.</returns>
115  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<AvailabilityPeriod>>> GetEnumerator() override;
116  /// <summary>
117  /// Adds the specified item to this collection.
118  /// </summary>
119  /// <param name="item">the specified item to add to this collection.</param>
120  ASPOSE_TASKS_SHARED_API void Add(const System::SharedPtr<AvailabilityPeriod>& item) override;
121  /// <summary>
122  /// Removes all items from this collection.
123  /// </summary>
124  ASPOSE_TASKS_SHARED_API void Clear() override;
125  /// <summary>
126  /// Returns true if the specified item is found in this collection; otherwise, false.
127  /// </summary>
128  /// <param name="item">the specified item to find.</param>
129  /// <returns>true if the specified item is found in this collection; otherwise, false.</returns>
130  ASPOSE_TASKS_SHARED_API bool Contains(const System::SharedPtr<AvailabilityPeriod>& item) const override;
131  /// <summary>
132  /// Copies the elements of this collection to the specified array, starting at the specified array index.
133  /// </summary>
134  /// <param name="array">the specified one-dimensional array to copy elements to</param>
135  /// <param name="arrayIndex">the zero-based index of the specified array at which copying begins.</param>
136  ASPOSE_TASKS_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<AvailabilityPeriod>> array, int32_t arrayIndex) override;
137  /// <summary>
138  /// Removes the first occurrence of a specific object from this collection.
139  /// </summary>
140  /// <param name="item">the specified object to remove.</param>
141  /// <returns>true if the specified object was successfully removed from this collection; otherwise, false.</returns>
142  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<AvailabilityPeriod>& item) override;
143  /// <summary>
144  /// Determines the index of the specified item in this collection.
145  /// </summary>
146  /// <param name="item">the specified item to locate in this collection.</param>
147  /// <returns>the index of the specified item if found; otherwise, -1.</returns>
148  ASPOSE_TASKS_SHARED_API int32_t IndexOf(const System::SharedPtr<AvailabilityPeriod>& item) const override;
149  /// <summary>
150  /// Inserts the specified item at the specified index.
151  /// </summary>
152  /// <param name="index">the specified zero-based index at which the item should be inserted.</param>
153  /// <param name="item">the specified item to insert to this collection.</param>
154  ASPOSE_TASKS_SHARED_API void Insert(int32_t index, const System::SharedPtr<AvailabilityPeriod>& item) override;
155  /// <summary>
156  /// Removes an item at the specified index.
157  /// </summary>
158  /// <param name="index">the specified zero-based index to remove an item at.</param>
159  ASPOSE_TASKS_SHARED_API void RemoveAt(int32_t index) override;
160  /// Gets iterator pointing to the first element (if any) of the collection.
161  /// @return An iterator pointing to the first element (if any) of the collection
162  ASPOSE_TASKS_SHARED_API iterator begin() noexcept;
163  /// Gets iterator pointing right after the last element (if any) of the collection.
164  /// @return An iterator pointing right after the last element (if any) of the collection
165  ASPOSE_TASKS_SHARED_API iterator end() noexcept;
166  /// Gets iterator pointing to the first element (if any) of the const-qualified instance of the collection.
167  /// @return An iterator pointing to the first element (if any) of the const-qualified instance of the collection
168  ASPOSE_TASKS_SHARED_API const_iterator begin() const noexcept;
169  /// Gets iterator pointing right after the last element (if any) of the const-qualified instance of the collection.
170  /// @return An iterator pointing right after the last element (if any) of the const-qualified instance of the collection
171  ASPOSE_TASKS_SHARED_API const_iterator end() const noexcept;
172  /// Gets iterator pointing to the first const-qualified element (if any) of the collection.
173  /// @return An iterator pointing to the first const-qualified element (if any) of the collection
174  ASPOSE_TASKS_SHARED_API const_iterator cbegin() const noexcept;
175  /// Gets iterator pointing right after the last const-qualified element (if any) of the collection.
176  /// @return An iterator pointing right after the last const-qualified element (if any) of the collection
177  ASPOSE_TASKS_SHARED_API const_iterator cend() const noexcept;
178  /// Gets iterator pointing to the first element (if any) of the collection.
179  /// @return An iterator pointing to the first element (if any) of the collection
180  /// Provides iterator implementation to container's first element.
181  /// @return Newly-created iterator object.
182  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginIterator() override;
183  /// Gets iterator pointing right after the last element (if any) of the collection.
184  /// @return An iterator pointing right after the last element (if any) of the collection
185  /// Provides iterator implementation to container's end.
186  /// @return Newly-created iterator object.
187  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndIterator() override;
188  /// Gets iterator pointing to the first element (if any)of the const-qualified instance of the collection.
189  /// @return An iterator pointing to the first element (if any)of the const-qualified instance of the collection
190  /// Provides const iterator implementation to container's first element.
191  /// @return Newly-created iterator object.
192  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginConstIterator() const override;
193  /// Gets iterator pointing right after the last element (if any)of the const-qualified instance of the collection.
194  /// @return An iterator pointing right after the last element (if any)of the const-qualified instance of the collection
195  /// Provides const iterator implementation to container's end.
196  /// @return Newly-created iterator object.
197  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndConstIterator() const override;
198 
199 protected:
200 
201  ASPOSE_TASKS_SHARED_API AvailabilityPeriodCollection(const System::SharedPtr<Resource>& parentRsc);
202 
203  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(AvailabilityPeriodCollection, CODEPORTING_ARGS(const System::SharedPtr<Resource>& parentRsc));
204 
205  ASPOSE_TASKS_SHARED_API AvailabilityPeriodCollection(const System::SharedPtr<Resource>& parentRsc, const System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<AvailabilityPeriod>>>& periods);
206 
207  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(AvailabilityPeriodCollection, CODEPORTING_ARGS(const System::SharedPtr<Resource>& parentRsc, const System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<AvailabilityPeriod>>>& periods));
208 
209  ASPOSE_TASKS_SHARED_API double GetMinAvailability(System::DateTime intervalStart, System::DateTime intervalEnd);
210  ASPOSE_TASKS_SHARED_API void Sort();
211 
212  ASPOSE_TASKS_SHARED_API virtual ~AvailabilityPeriodCollection();
213 
214  #ifdef ASPOSE_GET_SHARED_MEMBERS
215  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
216  #endif
217 
218 
219 private:
220 
221  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<AvailabilityPeriod>>> periods;
222  System::WeakPtr<Resource> resource;
223 
224  static int32_t Compare(const System::SharedPtr<AvailabilityPeriod>& period1, const System::SharedPtr<AvailabilityPeriod>& period2);
225 
226 };
227 
228 } // namespace Tasks
229 } // namespace Aspose
230 
231 
Represents a collection which contains AvailabilityPeriod objects.
Definition: AvailabilityPeriodCollection.h:58
typename iterator_holder_type::const_iterator const_iterator
Const iterator type.
Definition: AvailabilityPeriodCollection.h:76
void Add(const System::SharedPtr< AvailabilityPeriod > &item) override
Adds the specified item to this collection.
void RemoveAt(int32_t index) override
Removes an item at the specified index.
void Clear() override
Removes all items from this collection.
System::Collections::Generic::List< System::SharedPtr< AvailabilityPeriod > > iterator_holder_type
A collection type whose iterator types is used as iterator types in the current collection.
Definition: AvailabilityPeriodCollection.h:72
bool Contains(const System::SharedPtr< AvailabilityPeriod > &item) const override
Returns true if the specified item is found in this collection; otherwise, false.
int32_t IndexOf(const System::SharedPtr< AvailabilityPeriod > &item) const override
Determines the index of the specified item in this collection.
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< AvailabilityPeriod > > > GetEnumerator() override
Returns an enumerator for this collection.
bool get_IsReadOnly() const override
Gets a value indicating whether this collection is read-only; otherwise, false.
void CopyTo(System::ArrayPtr< System::SharedPtr< AvailabilityPeriod >> array, int32_t arrayIndex) override
Copies the elements of this collection to the specified array, starting at the specified array index.
void Insert(int32_t index, const System::SharedPtr< AvailabilityPeriod > &item) override
Inserts the specified item at the specified index.
int32_t get_Count() const override
Gets the number of elements contained in this collection.
typename iterator_holder_type::virtualized_iterator_element virtualized_iterator_element
Virtualized element type.
Definition: AvailabilityPeriodCollection.h:78
typename iterator_holder_type::iterator iterator
Iterator type.
Definition: AvailabilityPeriodCollection.h:74
System::SharedPtr< AvailabilityPeriod > idx_get(int32_t index) const override
Returns the element at the specified index.
void idx_set(int32_t index, System::SharedPtr< AvailabilityPeriod > value) override
Sets the element at the specified index.
bool Remove(const System::SharedPtr< AvailabilityPeriod > &item) override
Removes the first occurrence of a specific object from this collection.
typename iterator_holder_type::virtualized_iterator virtualized_iterator
Virtualized type.
Definition: AvailabilityPeriodCollection.h:80
System::SharedPtr< Resource > get_ParentResource() const
Gets the parent Resource for this object. Parent Resource object for this collection.
Represents a period when a resource is available.
Definition: AvailabilityPeriod.h:39
Represents a resource in a project.
Definition: Resource.h:213
/27/10/2004 by Roman Korchagin
Definition: Asn.h:13