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