Aspose.Tasks for C++
TimephasedDataCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="TimephasedDataCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2025 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/eventhandler.h>
9 #include <system/collections/ilist.h>
10 #include <system/collections/icomparer.h>
11 #include <system/array.h>
12 #include <cstdint>
13 
14 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
15 
16 namespace Aspose
17 {
18 namespace Tasks
19 {
20 class BaselineTimephasedDataMaker;
21 namespace Calculations
22 {
23 class TimeScaledCalculator;
24 } // namespace Calculations
25 class Calendar;
26 namespace IO
27 {
28 namespace MSProject
29 {
30 class MPP9ResourceAssignmentReader;
31 class MppTimephasedDataWriter;
32 } // namespace MSProject
33 namespace Xml
34 {
35 class TimephasedDataNodeReader;
36 } // namespace Xml
37 } // namespace IO
38 class OptimizedForSearchingTimephasedDataCollection;
39 namespace Recalculation
40 {
41 class TaskSplitCalculator;
42 } // namespace Recalculation
43 class Resource;
44 class ResourceAssignment;
45 class ResourceAssignmentTimephasedDataCollection;
46 class ResourceTimephasedDataCollection;
47 class Task;
48 class TaskPlanner;
49 class TaskTimephasedDataCollection;
50 namespace Timephased
51 {
52 class CostInterval;
53 class WorkInterval;
54 } // namespace Timephased
55 class TimephasedData;
56 enum class TimephasedDataType : int8_t;
57 class TimephasedWorkCostSelector;
58 namespace Util
59 {
60 class BaselineHelper;
61 } // namespace Util
62 } // namespace Tasks
63 } // namespace Aspose
64 namespace System
65 {
66 namespace Collections
67 {
68 namespace Generic
69 {
70 template <typename> class IEnumerable;
71 template <typename> class IEnumerator;
72 template <typename> class List;
73 } // namespace Generic
74 } // namespace Collections
75 class DateTime;
76 class TimeSpan;
77 } // namespace System
78 
79 namespace Aspose {
80 
81 namespace Tasks {
82 
83 /// <summary>
84 /// Represents a collection of <see cref="TimephasedData"></see> objects.
85 /// </summary>
86 class ASPOSE_TASKS_SHARED_CLASS TimephasedDataCollection : public System::Collections::Generic::IList<System::SharedPtr<TimephasedData>>
87 {
89  typedef System::Collections::Generic::IList<System::SharedPtr<TimephasedData>> BaseType;
90 
91  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
92  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
93 
94  friend class Aspose::Tasks::IO::MSProject::MppTimephasedDataWriter;
95  friend class TimephasedData;
96  friend class Aspose::Tasks::IO::MSProject::MPP9ResourceAssignmentReader;
97  friend class Task;
98  friend class ResourceAssignment;
99  friend class Aspose::Tasks::Recalculation::TaskSplitCalculator;
100  friend class TimephasedWorkCostSelector;
101  friend class TaskPlanner;
102  friend class Resource;
103  friend class ResourceTimephasedDataCollection;
104  friend class Aspose::Tasks::Calculations::TimeScaledCalculator;
105  friend class Aspose::Tasks::IO::Xml::TimephasedDataNodeReader;
106  friend class ResourceAssignmentTimephasedDataCollection;
107  friend class Aspose::Tasks::Util::BaselineHelper;
108  friend class BaselineTimephasedDataMaker;
109  friend class TaskTimephasedDataCollection;
110 
111 protected:
112 
113  class ASPOSE_TASKS_SHARED_CLASS TimephasedDataFinishDateAscComparer final : public System::Collections::Generic::IComparer<System::SharedPtr<TimephasedData>>
114  {
115  typedef TimephasedDataFinishDateAscComparer ThisType;
116  typedef System::Collections::Generic::IComparer<System::SharedPtr<TimephasedData>> BaseType;
117 
118  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
119  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
120 
121  private:
122 
123  /// <summary>
124  /// Compares two time phased data units.
125  /// </summary>
126  /// <param name="x">Left time phased data unit.</param>
127  /// <param name="y">Right time phased data unit.</param>
128  /// <returns>1 if left is greater, -1 if it's less and 0 otherwise.</returns>
129  int32_t Compare(const System::SharedPtr<TimephasedData>& x, const System::SharedPtr<TimephasedData>& y) const override;
130 
131  };
132 
133 
134 public:
135 
136  /// <summary>
137  /// Gets the number of objects contained in this <see cref="TimephasedDataCollection"></see> object.
138  /// </summary>
139  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
140  /// <summary>Gets a value indicating whether the <see cref="System::Collections::Generic::ICollection{T}"></see> is read-only.</summary>
141  /// <returns>true if the <see cref="System::Collections::Generic::ICollection{T}"></see> is read-only; otherwise, false.</returns>
142  ASPOSE_TASKS_SHARED_API bool get_IsReadOnly() const override;
143 
144  /// <summary>
145  /// Returns the element at the specified index. The set accessor is not supported.
146  /// property to set timephased data.
147  /// </summary>
148  /// <param name="index">The zero-based index of the element to get.</param>
149  /// <returns>the element at the specified index.</returns>
150  ASPOSE_TASKS_SHARED_API System::SharedPtr<TimephasedData> idx_get(int32_t index) const override;
151  /// <summary>
152  /// Returns the element at the specified index. The set accessor is not supported.
153  /// property to set timephased data.
154  /// </summary>
155  /// <param name="index">The zero-based index of the element to get.</param>
156  /// <param name="value">the element at the specified index.</param>
157  ASPOSE_TASKS_SHARED_API void idx_set(int32_t index, System::SharedPtr<TimephasedData> value) override;
158 
159  /// <summary>
160  /// Removes all items from the <see cref="TimephasedDataCollection"></see>.
161  /// </summary>
162  ASPOSE_TASKS_SHARED_API void Clear() override;
163  /// <summary>
164  /// Determines whether the <see cref="TimephasedDataCollection"></see> contains a specific value.
165  /// </summary>
166  /// <returns>true if <paramref name="item" ></paramref> is found in the collection; otherwise, false.</returns>
167  /// <param name="item">The object to locate in the collection.</param>
168  ASPOSE_TASKS_SHARED_API bool Contains(const System::SharedPtr<TimephasedData>& item) const override;
169  /// <summary>
170  /// Adds <see cref="TimephasedData"></see> instance to this collection object.
171  /// </summary>
172  /// <param name="item">The item to add.</param>
173  /// <exception cref="ArgumentNullException"> if parameter td is null. </exception>
174  ASPOSE_TASKS_SHARED_API void Add(const System::SharedPtr<TimephasedData>& item) override;
175  /// <summary>
176  /// Adds a collection of <see cref="TimephasedData"></see> instances to this collection object.
177  /// </summary>
178  /// <param name="timephasedCollection">A collection of <see cref="TimephasedData"></see> objects to add.</param>
179  ASPOSE_TASKS_SHARED_API void AddRange(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TimephasedData>>>& timephasedCollection);
180  /// <summary>
181  /// Converts the <see cref="TimephasedDataCollection"></see> object to a list of <see cref="TimephasedData"></see> objects.
182  /// </summary>
183  /// <returns>List of <see cref="TimephasedData"></see> objects.</returns>
184  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TimephasedData>>> ToList();
185  /// <summary>
186  /// Copies the elements of the <see cref="TimephasedDataCollection"></see> to an <see cref="System::Array"></see>,
187  /// starting at a particular <see cref="System::Array"></see> index.
188  /// </summary>
189  /// <param name="array">The one-dimensional <see cref="System::Array"></see> that is the destination of the elements copied from <see cref="TimephasedDataCollection"></see>.
190  /// The <see cref="System::Array"></see> must have zero-based indexing.</param>
191  /// <param name="arrayIndex">The zero-based index in <paramref name="array" ></paramref> at which copying begins.</param>
192  /// <exception cref="System::ArgumentNullException">
193  /// <paramref name="array" ></paramref> is null.</exception>
194  /// <exception cref="System::ArgumentOutOfRangeException">
195  /// <paramref name="arrayIndex" ></paramref> is less than 0.</exception>
196  /// <exception cref="System::ArgumentException">The number of elements in the source <see cref="TimephasedDataCollection"></see>
197  /// is greater than the available space from <paramref name="arrayIndex" ></paramref> to the end of the destination <paramref name="array" ></paramref>.
198  /// </exception>
199  ASPOSE_TASKS_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<TimephasedData>> array, int32_t arrayIndex) override;
200  /// <summary>
201  /// Removes <see cref="TimephasedData"></see> instance from this collection object.
202  /// </summary>
203  /// <param name="item">The item to remove.</param>
204  /// <returns>
205  /// true if <paramref name="item" ></paramref> was successfully removed from the <see cref="TimephasedDataCollection"></see>; otherwise, false.
206  /// This method also returns false if <paramref name="item" ></paramref> is not found in the <see cref="TimephasedDataCollection"></see>.
207  /// </returns>
208  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<TimephasedData>& item) override;
209  /// <summary>
210  /// Returns an enumerator for this collection.
211  /// </summary>
212  /// <returns>an enumerator for this collection.</returns>
213  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<TimephasedData>>> GetEnumerator() override;
214  /// <summary>
215  /// Selects all time phases between <paramref name="startTime"></paramref> and <paramref name="finishTime"></paramref>. Has O(log n) complexity in average case.
216  /// </summary>
217  /// <param name="timephasedDataType">
218  /// Type of time phases to select.
219  /// </param>
220  /// <param name="startTime">
221  /// Interval's start.
222  /// </param>
223  /// <param name="finishTime">
224  /// Interval's finish.
225  /// </param>
226  /// <returns> Returns new list instance of <see cref="TimephasedDataCollection"></see> data ordered by Start property. </returns>
227  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<TimephasedData>>> SelectBetweenStartAndFinish(TimephasedDataType timephasedDataType, System::DateTime startTime, System::DateTime finishTime);
228 
229 protected:
230 
231  ASPOSE_TASKS_SHARED_API System::EventHandler<> get_Changed() const;
232  ASPOSE_TASKS_SHARED_API void set_Changed(System::EventHandler<> value);
233 
234  /// <summary>Initializes a new instance of the <see cref="TimephasedDataCollection"></see> class.</summary>
235  ASPOSE_TASKS_SHARED_API TimephasedDataCollection();
236  ASPOSE_TASKS_SHARED_API TimephasedDataCollection(const System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<TimephasedData>>>& items);
237 
238  ASPOSE_TASKS_SHARED_API System::TimeSpan GetDayWork(const System::SharedPtr<Calendar>& calendar, TimephasedDataType timephasedDataType, System::DateTime date);
239  ASPOSE_TASKS_SHARED_API Timephased::WorkInterval GetIntervalWork(const System::SharedPtr<Calendar>& calendar, TimephasedDataType timephasedDataType, System::DateTime startDate, System::DateTime finishDate);
240  ASPOSE_TASKS_SHARED_API Timephased::CostInterval GetIntervalCost(const System::SharedPtr<Calendar>& calendar, TimephasedDataType timephasedDataType, System::DateTime startDate, System::DateTime finishDate);
241  /// <summary>
242  /// Adds <see cref="TimephasedData"></see> instance to this collection object.
243  /// </summary>
244  /// <param name="item">The item to add.</param>
245  /// <exception cref="ArgumentNullException"> if parameter td is null. </exception>
246  ASPOSE_TASKS_SHARED_API void AddInternal(const System::SharedPtr<TimephasedData>& item);
247  /// <summary>
248  /// Adds a collection of <see cref="TimephasedData"></see> instances to this collection object.
249  /// </summary>
250  /// <param name="timephasedCollection">A collection of <see cref="TimephasedData"></see> objects to add.</param>
251  ASPOSE_TASKS_SHARED_API void AddRangeInternal(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TimephasedData>>>& timephasedCollection);
252  /// <summary>
253  /// Adds a collection of <see cref="TimephasedData"></see> instances to this collection object.
254  /// </summary>
255  /// <param name="timephasedCollection">A collection of <see cref="TimephasedData"></see> objects to add.</param>
256  ASPOSE_TASKS_SHARED_API void AddRangeInternal(const System::SharedPtr<TimephasedDataCollection>& timephasedCollection);
257  ASPOSE_TASKS_SHARED_API int32_t GetSearchDictionaryCount();
258  ASPOSE_TASKS_SHARED_API System::TimeSpan GetDuration();
259  /// <summary>
260  /// Adds <see cref="TimephasedData"></see> instance to this collection object.
261  /// </summary>
262  /// <param name="item">The item to add.</param>
263  /// <param name="isCustomTd">A flag shows whether is custom timephased datum or not.</param>
264  /// <exception cref="ArgumentNullException"> if parameter td is null. </exception>
265  ASPOSE_TASKS_SHARED_API virtual void AddInternal(System::SharedPtr<TimephasedData> item, bool isCustomTd);
266  ASPOSE_TASKS_SHARED_API virtual void InsertInternal(int32_t index, System::SharedPtr<TimephasedData> item);
267  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TimephasedData>>> GetByType(TimephasedDataType type);
268 
269  ASPOSE_TASKS_SHARED_API virtual ~TimephasedDataCollection();
270 
271  #ifdef ASPOSE_GET_SHARED_MEMBERS
272  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
273  #endif
274 
275 
276 private:
277 
278  System::SharedPtr<OptimizedForSearchingTimephasedDataCollection> timephasesOptimizedForSearchingByStartDate;
279  System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<TimephasedData>>> items;
280  System::EventHandler<> pr_Changed;
281 
282  ASPOSE_TASKS_SHARED_API int32_t IndexOf(const System::SharedPtr<TimephasedData>& item) const override;
283  ASPOSE_TASKS_SHARED_API void Insert(int32_t index, const System::SharedPtr<TimephasedData>& item) override;
284  ASPOSE_TASKS_SHARED_API void RemoveAt(int32_t index) override;
285  /// <summary>
286  /// Initializes the search-optimized collection of timephased data.
287  /// </summary>
288  /// <param name="list">The list of timephased items to optimize the searching for.</param>
289  void InitializeSearch(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TimephasedData>>>& list);
290  /// <summary>
291  /// Returns timephased data list.
292  /// </summary>
293  /// <returns>Return timephased data.</returns>
294  /// <summary>
295  /// Returns timephased data list.
296  /// </summary>
297  /// <returns>Return timephased data.</returns>
298  System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<TimephasedData>>> GetTimephasedData() const;
299  /// <summary>
300  /// Adds a collection of <see cref="TimephasedData"></see> instances to this collection object.
301  /// </summary>
302  /// <param name="timephasedCollection">A collection of <see cref="TimephasedData"></see> objects to add.</param>
303  /// <param name="collectionContainsCustomTds">A flag indicating whether collection contains custom time phase data (i.e. time phase data created by user, not AT).</param>
304  void AddRangeInternal(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TimephasedData>>>& timephasedCollection, bool collectionContainsCustomTds);
305  void OnChange();
306 
307 };
308 
309 } // namespace Tasks
310 } // namespace Aspose
311 
312 
Represents a resource assignment in a project.
Definition: ResourceAssignment.h:228
Represents a resource in a project.
Definition: Resource.h:213
Represents a task in a project.
Definition: Task.h:391
Represents a collection of TimephasedData objects.
Definition: TimephasedDataCollection.h:87
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< TimephasedData > > > GetEnumerator() override
Returns an enumerator for this collection.
void CopyTo(System::ArrayPtr< System::SharedPtr< TimephasedData >> array, int32_t arrayIndex) override
Copies the elements of the TimephasedDataCollection to an System::Array, starting at a particular Sys...
System::SharedPtr< System::Collections::Generic::IList< System::SharedPtr< TimephasedData > > > SelectBetweenStartAndFinish(TimephasedDataType timephasedDataType, System::DateTime startTime, System::DateTime finishTime)
Selects all time phases between startTime and finishTime . Has O(log n) complexity in average case.
bool get_IsReadOnly() const override
Gets a value indicating whether the System::Collections::Generic::ICollection<T> is read-only.
bool Remove(const System::SharedPtr< TimephasedData > &item) override
Removes TimephasedData instance from this collection object.
void Add(const System::SharedPtr< TimephasedData > &item) override
Adds TimephasedData instance to this collection object.
int32_t get_Count() const override
Gets the number of objects contained in this TimephasedDataCollection object.
void idx_set(int32_t index, System::SharedPtr< TimephasedData > value) override
Returns the element at the specified index. The set accessor is not supported. property to set timeph...
System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< TimephasedData > > > ToList()
Converts the TimephasedDataCollection object to a list of TimephasedData objects.
void AddRange(const System::SharedPtr< System::Collections::Generic::IEnumerable< System::SharedPtr< TimephasedData >>> &timephasedCollection)
Adds a collection of TimephasedData instances to this collection object.
System::SharedPtr< TimephasedData > idx_get(int32_t index) const override
Returns the element at the specified index. The set accessor is not supported. property to set timeph...
bool Contains(const System::SharedPtr< TimephasedData > &item) const override
Determines whether the TimephasedDataCollection contains a specific value.
void Clear() override
Removes all items from the TimephasedDataCollection.
Represents a time phased data.
Definition: TimephasedData.h:78
Aspose.
Definition: Asn.h:13