Aspose.Tasks for C++
WorkingTimeCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="WorkingTimeCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2025 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/timespan.h>
9 #include <system/eventhandler.h>
10 #include <system/collections/list.h>
11 #include <system/collections/ilist.h>
12 #include <system/array.h>
13 
14 #include "aspose.tasks.cpp/IReadOnlyWorkingTimeCollection.h"
15 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
16 
17 namespace Aspose
18 {
19 namespace Tasks
20 {
21 class AutoRecalculationState;
22 class Calendar;
23 class CalendarDatesCalculator;
24 class CalendarException;
25 class CalendarWorkingTimesBackwardsEnumerator;
26 class CalendarWorkingTimesForwardEnumerator;
27 class IntersectedCalendar;
28 namespace IO
29 {
30 namespace Html
31 {
32 class HtmlCalendarExceptionsReader;
33 class HtmlCalendarTableReader;
34 } // namespace Html
35 namespace MSProject
36 {
37 class MPPTimephasedDataReader;
38 } // namespace MSProject
39 namespace Xml
40 {
41 class WeekDayNodeWriter;
42 } // namespace Xml
43 } // namespace IO
44 class ResourceAssignment;
45 class TimephasedDataCalculationUtil;
46 class WeekDay;
47 class WorkingTime;
48 } // namespace Tasks
49 } // namespace Aspose
50 namespace System
51 {
52 namespace Collections
53 {
54 namespace Generic
55 {
56 template <typename> class IEnumerable;
57 template <typename> class IEnumerator;
58 } // namespace Generic
59 } // namespace Collections
60 class DateTime;
61 namespace Text
62 {
63 class StringBuilder;
64 } // namespace Text
65 } // namespace System
66 
67 namespace Aspose {
68 
69 namespace Tasks {
70 
71 /// <summary>
72 /// Represents a collection of <see cref="WorkingTimeCollection"></see> objects.
73 /// </summary>
74 class ASPOSE_TASKS_SHARED_CLASS WorkingTimeCollection : public System::Collections::Generic::IList<System::SharedPtr<Aspose::Tasks::WorkingTime>>, public Aspose::Tasks::IReadOnlyWorkingTimeCollection
75 {
76  typedef WorkingTimeCollection ThisType;
77  typedef System::Collections::Generic::IList<System::SharedPtr<Aspose::Tasks::WorkingTime>> BaseType;
78  typedef Aspose::Tasks::IReadOnlyWorkingTimeCollection BaseType1;
79 
80  typedef ::System::BaseTypesInfo<BaseType, BaseType1> ThisTypeBaseTypesInfo;
81  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
82 
83  friend class Aspose::Tasks::IntersectedCalendar;
84  friend class Aspose::Tasks::Calendar;
86  friend class Aspose::Tasks::CalendarWorkingTimesForwardEnumerator;
88  friend class Aspose::Tasks::TimephasedDataCalculationUtil;
89  friend class Aspose::Tasks::IO::Html::HtmlCalendarExceptionsReader;
90  friend class Aspose::Tasks::IO::Html::HtmlCalendarTableReader;
91  friend class Aspose::Tasks::IO::MSProject::MPPTimephasedDataReader;
92  friend class Aspose::Tasks::IO::Xml::WeekDayNodeWriter;
93  friend class Aspose::Tasks::AutoRecalculationState;
94  friend class Aspose::Tasks::CalendarDatesCalculator;
95  friend class Aspose::Tasks::CalendarWorkingTimesBackwardsEnumerator;
96  friend class Aspose::Tasks::WeekDay;
97 
98 public:
99  /// A collection type whose iterator types is used as iterator types in the current collection.
100  using iterator_holder_type = System::Collections::Generic::List<System::SharedPtr<WorkingTime>>;
101  /// Iterator type.
102  using iterator = typename iterator_holder_type::iterator;
103  /// Const iterator type.
104  using const_iterator = typename iterator_holder_type::const_iterator;
105  /// Virtualized element type.
106  using virtualized_iterator_element = typename iterator_holder_type::virtualized_iterator_element;
107  /// Virtualized type.
108  using virtualized_iterator = typename iterator_holder_type::virtualized_iterator;
109 
110 public:
111 
112  /// <summary>
113  /// Gets the number of objects contained in this <see cref="WorkingTimeCollection"></see> object.
114  /// </summary>
115  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
116 
117  /// <summary>
118  /// Returns the element at the specified index.
119  /// </summary>
120  /// <param name="index">The zero-based index of the element to get.</param>
121  /// <returns>the element at the specified index.</returns>
122  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> idx_get(int32_t index) const override;
123  /// <summary>
124  /// Returns the element at the specified index.
125  /// </summary>
126  /// <param name="index">The zero-based index of the element to get.</param>
127  /// <param name="value">the element at the specified index.</param>
128  ASPOSE_TASKS_SHARED_API void idx_set(int32_t index, System::SharedPtr<WorkingTime> value) override;
129 
130  /// <summary>
131  /// Returns an enumerator for this collection.
132  /// </summary>
133  /// <returns>an enumerator for this collection.</returns>
134  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<WorkingTime>>> GetEnumerator() override;
135  /// <summary>
136  /// Removes <see cref="WorkingTime"></see> instance from this collection.
137  /// </summary>
138  /// <param name="item">The item to remove.</param>
139  /// <returns>true if WorkingTime instance was successfully removed from this collection; otherwise, false.</returns>
140  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<WorkingTime>& item) override;
141  /// <summary>
142  /// Converts the WorkingTimeCollection object to a list of <see cref="WorkingTime"></see> objects.
143  /// </summary>
144  /// <returns>List of <see cref="WorkingTime"></see> objects.</returns>
145  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<WorkingTime>>> ToList();
146  ASPOSE_TASKS_SHARED_API void Add(const System::SharedPtr<WorkingTime>& item) override;
147  /// <summary>
148  /// Checks if the specified element is in the List.
149  /// Performs a linear O(n) search.
150  /// </summary>
151  /// <param name="item">the specified item.</param>
152  /// <returns>True, if specified element found in the list, false otherwise.</returns>
153  ASPOSE_TASKS_SHARED_API bool Contains(const System::SharedPtr<WorkingTime>& item) const override;
154  /// <summary>
155  /// copies a collection content into an Array, starting at a particular index
156  /// </summary>
157  /// <param name="array">an array to copy to.</param>
158  /// <param name="arrayIndex">starting array index</param>
159  ASPOSE_TASKS_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<WorkingTime>> array, int32_t arrayIndex) override;
160  /// <summary>
161  /// Removes all <see cref="WorkingTime"></see> items from collection.
162  /// </summary>
163  ASPOSE_TASKS_SHARED_API void Clear() override;
164  /// Gets iterator pointing to the first element (if any) of the collection.
165  /// @return An iterator pointing to the first element (if any) of the collection
166  ASPOSE_TASKS_SHARED_API iterator begin() noexcept;
167  /// Gets iterator pointing right after the last element (if any) of the collection.
168  /// @return An iterator pointing right after the last element (if any) of the collection
169  ASPOSE_TASKS_SHARED_API iterator end() noexcept;
170  /// Gets iterator pointing to the first element (if any) of the const-qualified instance of the collection.
171  /// @return An iterator pointing to the first element (if any) of the const-qualified instance of the collection
172  ASPOSE_TASKS_SHARED_API const_iterator begin() const noexcept;
173  /// Gets iterator pointing right after the last element (if any) of the const-qualified instance of the collection.
174  /// @return An iterator pointing right after the last element (if any) of the const-qualified instance of the collection
175  ASPOSE_TASKS_SHARED_API const_iterator end() const noexcept;
176  /// Gets iterator pointing to the first const-qualified element (if any) of the collection.
177  /// @return An iterator pointing to the first const-qualified element (if any) of the collection
178  ASPOSE_TASKS_SHARED_API const_iterator cbegin() const noexcept;
179  /// Gets iterator pointing right after the last const-qualified element (if any) of the collection.
180  /// @return An iterator pointing right after the last const-qualified element (if any) of the collection
181  ASPOSE_TASKS_SHARED_API const_iterator cend() const noexcept;
182  /// Gets iterator pointing to the first element (if any) of the collection.
183  /// @return An iterator pointing to the first element (if any) of the collection
184  /// Provides iterator implementation to container's first element.
185  /// @return Newly-created iterator object.
186  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginIterator() override;
187  /// Gets iterator pointing right after the last element (if any) of the collection.
188  /// @return An iterator pointing right after the last element (if any) of the collection
189  /// Provides iterator implementation to container's end.
190  /// @return Newly-created iterator object.
191  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndIterator() override;
192  /// Gets iterator pointing to the first element (if any)of the const-qualified instance of the collection.
193  /// @return An iterator pointing to the first element (if any)of the const-qualified instance of the collection
194  /// Provides const iterator implementation to container's first element.
195  /// @return Newly-created iterator object.
196  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginConstIterator() const override;
197  /// Gets iterator pointing right after the last element (if any)of the const-qualified instance of the collection.
198  /// @return An iterator pointing right after the last element (if any)of the const-qualified instance of the collection
199  /// Provides const iterator implementation to container's end.
200  /// @return Newly-created iterator object.
201  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndConstIterator() const override;
202 
203 protected:
204 
205  static ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> get_Empty();
206  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> get_First();
207  ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTime> get_Last();
208  ASPOSE_TASKS_SHARED_API System::TimeSpan get_TotalFrom();
209  ASPOSE_TASKS_SHARED_API System::TimeSpan get_TotalTo();
210  ASPOSE_TASKS_SHARED_API System::TimeSpan get_TotalSpan();
211  ASPOSE_TASKS_SHARED_API System::String get_DebuggerDisplay();
212 
213  System::EventHandler<> CollectionChanged;
214 
215  ASPOSE_TASKS_SHARED_API WorkingTimeCollection();
216 
217  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(WorkingTimeCollection, CODEPORTING_ARGS());
218 
219  ASPOSE_TASKS_SHARED_API WorkingTimeCollection(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<WorkingTime>>>& workingTimes);
220 
221  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(WorkingTimeCollection, CODEPORTING_ARGS(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<WorkingTime>>>& workingTimes));
222  static ASPOSE_TASKS_SHARED_API System::SharedPtr<WorkingTimeCollection> Intersect(const System::SharedPtr<WorkingTimeCollection>& wt1, const System::SharedPtr<WorkingTimeCollection>& wt2);
223  ASPOSE_TASKS_SHARED_API void Sort();
224  ASPOSE_TASKS_SHARED_API void UpdateWorkingTimes(const System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<WorkingTime>>>& times);
225  ASPOSE_TASKS_SHARED_API System::TimeSpan GetIntersectSpan(const System::SharedPtr<WorkingTime>& wt);
226  ASPOSE_TASKS_SHARED_API System::DateTime GetDayStart(System::DateTime date, System::TimeSpan nonWorkingDayStart);
227  ASPOSE_TASKS_SHARED_API System::TimeSpan GetWorkingHours();
228  ASPOSE_TASKS_SHARED_API System::TimeSpan GetDifferenceFromWorkStart(System::DateTime start);
229  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Text::StringBuilder> Dump(const System::SharedPtr<System::Text::StringBuilder>& sb);
230  ASPOSE_TASKS_SHARED_API System::String Dump();
231 
232  virtual ASPOSE_TASKS_SHARED_API ~WorkingTimeCollection();
233 
234  #ifdef ASPOSE_GET_SHARED_MEMBERS
235  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
236  #endif
237 
238 
239 private:
240 
241  static System::SharedPtr<WorkingTimeCollection>& EmptyInstance();
242 
243  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<WorkingTime>>> workingTimes;
244 
245  bool get_IsReadOnly() const override;
246 
247  bool valid;
248  bool sorted;
249  System::TimeSpan totalFrom;
250  System::TimeSpan totalTo;
251  System::TimeSpan totalSpan;
252 
253  /// <summary>
254  /// Returns the index of the first occurrence of a given item in a list
255  /// </summary>
256  /// <param name="item">value to search for.</param>
257  /// <returns>the index of the item</returns>
258  int32_t IndexOf(const System::SharedPtr<WorkingTime>& item) const override;
259  /// <summary>
260  /// Inserts an element into this list at a given index
261  /// </summary>
262  /// <param name="index">an index to insert to</param>
263  /// <param name="item">an element to insert</param>
264  void Insert(int32_t index, const System::SharedPtr<WorkingTime>& item) override;
265  /// <summary>
266  /// Removes an element at specified index.
267  /// </summary>
268  /// <param name="index">an index of item to remove.</param>
269  void RemoveAt(int32_t index) override;
270  bool AddInternal(const System::SharedPtr<WorkingTime>& item);
271  bool InvalidateSpans();
272  void Changed();
273 
274 };
275 
276 } // namespace Tasks
277 } // namespace Aspose
278 
279 
Represent exceptional time periods in a calendar.
Definition: CalendarException.h:72
Definition: Asn.h:12
Represents a working time during a weekday.
Definition: WorkingTime.h:57
typename iterator_holder_type::virtualized_iterator_element virtualized_iterator_element
Virtualized element type.
Definition: WorkingTimeCollection.h:106
typename iterator_holder_type::iterator iterator
Iterator type.
Definition: WorkingTimeCollection.h:102
Represents a collection of WorkingTimeCollection objects.
Definition: WorkingTimeCollection.h:74
typename iterator_holder_type::virtualized_iterator virtualized_iterator
Virtualized type.
Definition: WorkingTimeCollection.h:108
Represents a calendar used in a project.
Definition: Calendar.h:279
typename iterator_holder_type::const_iterator const_iterator
Const iterator type.
Definition: WorkingTimeCollection.h:104
Represents a resource assignment in a project.
Definition: ResourceAssignment.h:225
Represents a weekday which either defines regular days of a week or exception days in a calendar.
Definition: WeekDay.h:61
System::Collections::Generic::List< System::SharedPtr< WorkingTime > > iterator_holder_type
A collection type whose iterator types is used as iterator types in the current collection.
Definition: WorkingTimeCollection.h:100