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