Aspose.Tasks for C++
ResourceAssignmentCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="ResourceAssignmentCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/collections/ilist.h>
9 #include <system/array.h>
10 #include <cstdint>
11 
12 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
13 
14 namespace Aspose
15 {
16 namespace Tasks
17 {
18 namespace Connectivity
19 {
20 class MpdReader;
21 class MspDbReader;
22 class PrimaveraDbReader;
23 } // namespace Connectivity
24 class IdGenerator;
25 namespace IO
26 {
27 namespace Html
28 {
29 class HtmlResourceAssignmentTableReader;
30 } // namespace Html
31 namespace MSProject
32 {
33 class MPP12Reader;
34 class MPP12TaskWriter;
35 class MPP14Reader;
36 class MPP9Reader;
37 } // namespace MSProject
38 namespace PrimaveraXml
39 {
40 class PrimaveraProjectNodeReader;
41 } // namespace PrimaveraXml
42 namespace Pwa
43 {
44 namespace InternalApi
45 {
46 namespace Mapping
47 {
48 class ProjectAssignmentsMapper;
49 } // namespace Mapping
50 } // namespace InternalApi
51 } // namespace Pwa
52 namespace Xer
53 {
54 class XerPrimaveraReader;
55 class XerProjectNormalizer;
56 } // namespace Xer
57 namespace Xml
58 {
59 class XmlReader;
60 } // namespace Xml
61 } // namespace IO
62 class Project;
63 class Resource;
64 class ResourceAssignment;
65 class ResourceCollection;
66 namespace Scheduling
67 {
68 class FromFinishScheduler;
69 class FromStartScheduler;
70 } // namespace Scheduling
71 class Task;
72 class TaskPlanner;
73 namespace Visualization
74 {
75 class ApsResourceUsageBuilder;
76 } // namespace Visualization
77 } // namespace Tasks
78 } // namespace Aspose
79 namespace System
80 {
81 namespace Collections
82 {
83 namespace Generic
84 {
85 template <typename, typename> class IDictionary;
86 template <typename> class IEnumerable;
87 template <typename> class IEnumerator;
88 template <typename> class List;
89 } // namespace Generic
90 } // namespace Collections
91 class Decimal;
92 } // namespace System
93 
94 namespace Aspose {
95 
96 namespace Tasks {
97 
98 /// <summary>
99 /// Represents a collection of <see cref="ResourceAssignment"></see> objects.
100 /// </summary>
101 class ASPOSE_TASKS_SHARED_CLASS ResourceAssignmentCollection : public System::Collections::Generic::IList<System::SharedPtr<Aspose::Tasks::ResourceAssignment>>
102 {
104  typedef System::Collections::Generic::IList<System::SharedPtr<Aspose::Tasks::ResourceAssignment>> BaseType;
105 
106  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
107  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
108 
109  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraProjectNodeReader;
110  friend class Aspose::Tasks::Project;
111  friend class Aspose::Tasks::Resource;
113  friend class Aspose::Tasks::Task;
114  friend class Aspose::Tasks::Connectivity::MpdReader;
115  friend class Aspose::Tasks::Connectivity::MspDbReader;
116  friend class Aspose::Tasks::Connectivity::PrimaveraDbReader;
117  friend class Aspose::Tasks::IO::Html::HtmlResourceAssignmentTableReader;
118  friend class Aspose::Tasks::IO::MSProject::MPP12Reader;
119  friend class Aspose::Tasks::IO::MSProject::MPP14Reader;
120  friend class Aspose::Tasks::IO::MSProject::MPP9Reader;
121  friend class Aspose::Tasks::IO::MSProject::MPP12TaskWriter;
122  friend class Aspose::Tasks::IO::Xer::XerPrimaveraReader;
123  friend class Aspose::Tasks::IO::Xer::XerProjectNormalizer;
124  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ProjectAssignmentsMapper;
125  friend class Aspose::Tasks::IO::Xml::XmlReader;
126  friend class Aspose::Tasks::TaskPlanner;
128  friend class Aspose::Tasks::Scheduling::FromFinishScheduler;
129  friend class Aspose::Tasks::Scheduling::FromStartScheduler;
130  friend class Aspose::Tasks::Visualization::ApsResourceUsageBuilder;
131 
132 public:
133 
134  /// <summary>
135  /// Gets the parent project of the ResourceAssignmentCollection object.
136  /// </summary>
137  ASPOSE_TASKS_SHARED_API System::SharedPtr<Project> get_ParentProject() const;
138  /// <summary>
139  /// Gets a value indicating whether this collection is read only.
140  /// </summary>
141  ASPOSE_TASKS_SHARED_API bool get_IsReadOnly() const override;
142  /// <summary>
143  /// Gets the number of objects contained in the ResourceAssignmentCollection.
144  /// </summary>
145  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
146 
147  /// <summary>
148  /// Returns the element at the specified index.
149  /// </summary>
150  /// <param name="index">The zero-based index of the element to get.</param>
151  /// <returns>the element at the specified index.</returns>
152  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> idx_get(int32_t index) const override;
153  /// <summary>
154  /// Returns the element at the specified index.
155  /// </summary>
156  /// <param name="index">The zero-based index of the element to get.</param>
157  /// <param name="value">the element at the specified index.</param>
158  ASPOSE_TASKS_SHARED_API void idx_set(int32_t index, System::SharedPtr<ResourceAssignment> value) override;
159 
160  /// <summary>
161  /// Returns an enumerator for this collection.
162  /// </summary>
163  /// <returns>an enumerator for this collection.</returns>
164  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<ResourceAssignment>>> GetEnumerator() override;
165  /// <summary>
166  /// Converts the ResourceAssignmentCollection object to a list of <see cref="ResourceAssignment"></see> objects.
167  /// </summary>
168  /// <returns>List of <see cref="ResourceAssignment"></see> objects.</returns>
169  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<ResourceAssignment>>> ToList();
170  /// <summary>
171  /// Adds new assignment to the ResourceAssignmentCollection.
172  /// </summary>
173  /// <param name="task">A task to be assigned.</param>
174  /// <param name="resource">A resource to be assigned.</param>
175  /// <param name="units">The number of units for a new assignment.</param>
176  /// <returns>Added assignment.</returns>
177  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> Add(const System::SharedPtr<Task>& task, const System::SharedPtr<Resource>& resource, double units);
178  /// <summary>
179  /// Adds new assignment to the ResourceAssignmentCollection.
180  /// </summary>
181  /// <param name="task">A task to be assigned.</param>
182  /// <param name="resource">A cost resource to be assigned.</param>
183  /// <param name="cost">The cost for a new assignment.</param>
184  /// <returns>Added assignment.</returns>
185  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> Add(const System::SharedPtr<Task>& task, const System::SharedPtr<Resource>& resource, System::Decimal cost);
186  /// <summary>
187  /// Adds new assignment to the ResourceAssignmentCollection.
188  /// </summary>
189  /// <param name="task">A task to be assigned.</param>
190  /// <param name="resource">A resource to be assigned.</param>
191  /// <returns>Added assignment.</returns>
192  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> Add(const System::SharedPtr<Task>& task, const System::SharedPtr<Resource>& resource);
193  /// <summary>
194  /// Returns an assignment with the specified uid.
195  /// </summary>
196  /// <param name="uid">The specified uid.</param>
197  /// <remarks>O(1) complexity.</remarks>
198  /// <returns>ResourceAssignment with the specified uid if present; otherwise, null.</returns>
199  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> GetByUid(int32_t uid);
200  /// <summary>
201  /// Removes specified assignment from collection, if it is not read-only,
202  /// otherwise throws NotSupportedException.
203  /// </summary>
204  /// <param name="item">The assignment to remove.</param>
205  /// <returns>true, if specified item was removed, false otherwise.</returns>
206  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<ResourceAssignment>& item) override;
207  /// <summary>
208  /// Removes assignment at specified index, if collection is not read-only,
209  /// otherwise throws NotSupportedException.
210  /// </summary>
211  /// <param name="index">Zero-based index.</param>
212  ASPOSE_TASKS_SHARED_API void RemoveAt(int32_t index) override;
213  /// <summary>
214  /// This is the stub implementation of ICollection's Add method, that only throws NotSupportedException
215  /// </summary>
216  /// <param name="item">The item to remove.</param>
217  ASPOSE_TASKS_SHARED_API void Add(const System::SharedPtr<ResourceAssignment>& item) override;
218 
219 protected:
220 
221  ASPOSE_TASKS_SHARED_API System::SharedPtr<ResourceAssignment> get_First();
222 
223  ASPOSE_TASKS_SHARED_API ResourceAssignmentCollection(const System::SharedPtr<Project>& parentProject, bool isReadOnly);
224 
225  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ResourceAssignmentCollection, CODEPORTING_ARGS(const System::SharedPtr<Project>& parentProject, bool isReadOnly));
226 
227  ASPOSE_TASKS_SHARED_API ResourceAssignmentCollection(const System::SharedPtr<Project>& parentProject);
228 
229  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ResourceAssignmentCollection, CODEPORTING_ARGS(const System::SharedPtr<Project>& parentProject));
230 
231  ASPOSE_TASKS_SHARED_API ResourceAssignmentCollection(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ResourceAssignment>>>& assignments, const System::SharedPtr<Project>& parentProject);
232 
233  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ResourceAssignmentCollection, CODEPORTING_ARGS(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ResourceAssignment>>>& assignments, const System::SharedPtr<Project>& parentProject));
234 
235  ASPOSE_TASKS_SHARED_API ResourceAssignmentCollection(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ResourceAssignment>>>& assignments, const System::SharedPtr<Project>& parentProject, bool isReadOnly);
236 
237  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ResourceAssignmentCollection, CODEPORTING_ARGS(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ResourceAssignment>>>& assignments, const System::SharedPtr<Project>& parentProject, bool isReadOnly));
238  /// <summary>
239  /// Recalculate unique identifiers of assignments from 1 up to assignment collection length - 1.
240  /// </summary>
241  ASPOSE_TASKS_SHARED_API void CalcResourceAssignmentUids();
242  ASPOSE_TASKS_SHARED_API void AddInternal(const System::SharedPtr<ResourceAssignment>& assn);
243  ASPOSE_TASKS_SHARED_API bool RemoveInternal(const System::SharedPtr<ResourceAssignment>& assn, bool rebuildIndex = true);
244  ASPOSE_TASKS_SHARED_API void RemoveInternal(const System::SharedPtr<System::Collections::Generic::IList<int32_t>>& indexes);
245 
246  virtual ASPOSE_TASKS_SHARED_API ~ResourceAssignmentCollection();
247 
248  #ifdef ASPOSE_GET_SHARED_MEMBERS
249  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
250  #endif
251 
252 
253 private:
254 
255  System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<ResourceAssignment>>> assignments;
256  System::SharedPtr<System::Collections::Generic::IDictionary<System::SharedPtr<ResourceAssignment>, System::SharedPtr<ResourceAssignment>>> assnMap;
257  System::SharedPtr<System::Collections::Generic::IDictionary<int32_t, int32_t>> lookupIndex;
258  System::WeakPtr<Project> parentProject;
259  bool isReadOnly;
260  System::SharedPtr<IdGenerator> uidGenerator;
261 
262  void Clear() override;
263  bool Contains(const System::SharedPtr<ResourceAssignment>& item) const override;
264  void CopyTo(System::ArrayPtr<System::SharedPtr<ResourceAssignment>> array, int32_t arrayIndex) override;
265  int32_t IndexOf(const System::SharedPtr<ResourceAssignment>& item) const override;
266  void Insert(int32_t index, const System::SharedPtr<ResourceAssignment>& item) override;
267  void RebuildAssnLookupIndex();
268  void Init(const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ResourceAssignment>>>& assignmentCollection);
269 
270 };
271 
272 } // namespace Tasks
273 } // namespace Aspose
274 
275 
Represents a project.
Definition: Project.h:544
Represents a collection of ResourceAssignment objects.
Definition: ResourceAssignmentCollection.h:102
void idx_set(int32_t index, System::SharedPtr< ResourceAssignment > value) override
Returns the element at the specified index.
System::SharedPtr< ResourceAssignment > GetByUid(int32_t uid)
Returns an assignment with the specified uid.
System::SharedPtr< ResourceAssignment > Add(const System::SharedPtr< Task > &task, const System::SharedPtr< Resource > &resource, System::Decimal cost)
Adds new assignment to the ResourceAssignmentCollection.
bool Remove(const System::SharedPtr< ResourceAssignment > &item) override
Removes specified assignment from collection, if it is not read-only, otherwise throws NotSupportedEx...
void Add(const System::SharedPtr< ResourceAssignment > &item) override
This is the stub implementation of ICollection's Add method, that only throws NotSupportedException
System::SharedPtr< System::Collections::Generic::List< System::SharedPtr< ResourceAssignment > > > ToList()
Converts the ResourceAssignmentCollection object to a list of ResourceAssignment objects.
System::SharedPtr< Project > get_ParentProject() const
Gets the parent project of the ResourceAssignmentCollection object.
bool get_IsReadOnly() const override
Gets a value indicating whether this collection is read only.
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< ResourceAssignment > > > GetEnumerator() override
Returns an enumerator for this collection.
System::SharedPtr< ResourceAssignment > Add(const System::SharedPtr< Task > &task, const System::SharedPtr< Resource > &resource, double units)
Adds new assignment to the ResourceAssignmentCollection.
System::SharedPtr< ResourceAssignment > idx_get(int32_t index) const override
Returns the element at the specified index.
int32_t get_Count() const override
Gets the number of objects contained in the ResourceAssignmentCollection.
System::SharedPtr< ResourceAssignment > Add(const System::SharedPtr< Task > &task, const System::SharedPtr< Resource > &resource)
Adds new assignment to the ResourceAssignmentCollection.
void RemoveAt(int32_t index) override
Removes assignment at specified index, if collection is not read-only, otherwise throws NotSupportedE...
Represents a resource assignment in a project.
Definition: ResourceAssignment.h:215
Represents a collection of Resource objects.
Definition: ResourceCollection.h:98
Represents a resource in a project.
Definition: Resource.h:201
Represents a task in a project.
Definition: Task.h:378
Definition: Asn.h:13