Aspose.Tasks for C++
TaskLinkCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="TaskLinkCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2025 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/collections/list.h>
9 #include <system/collections/ilist.h>
10 #include <system/array.h>
11 #include <cstdint>
12 
13 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
14 #include "aspose.tasks.cpp/TaskLink.h"
15 
16 namespace Aspose
17 {
18 namespace Tasks
19 {
20 namespace Connectivity
21 {
22 class MpdTaskLinkMapper;
23 class MspTaskLinksMapper;
24 class PmTaskRelationMapper;
25 } // namespace Connectivity
26 class Duration;
27 namespace IO
28 {
29 namespace Html
30 {
31 class HtmlTaskTableReader;
32 } // namespace Html
33 namespace Mpx
34 {
35 class MpxReader;
36 } // namespace Mpx
37 namespace MSProject
38 {
39 class MPP12Reader;
40 class MPP14Reader;
41 class MPP9Reader;
42 } // namespace MSProject
43 namespace PrimaveraXml
44 {
45 class PrimaveraRelationshipNodeReader;
46 } // namespace PrimaveraXml
47 namespace Pwa
48 {
49 namespace InternalApi
50 {
51 namespace Mapping
52 {
53 class TaskLinkEntityMapper;
54 } // namespace Mapping
55 } // namespace InternalApi
56 } // namespace Pwa
57 namespace Xer
58 {
59 class XerRelationReader;
60 } // namespace Xer
61 namespace Xml
62 {
63 class TaskLinksNodeReader;
64 } // namespace Xml
65 } // namespace IO
66 class Project;
67 class Task;
68 enum class TaskLinkType;
69 } // namespace Tasks
70 } // namespace Aspose
71 namespace System
72 {
73 namespace Collections
74 {
75 namespace Generic
76 {
77 template <typename> class IComparer;
78 template <typename> class IEnumerable;
79 template <typename> class IEnumerator;
80 } // namespace Generic
81 } // namespace Collections
82 } // namespace System
83 
84 namespace Aspose {
85 
86 namespace Tasks {
87 
88 /// <summary>
89 /// Represents a collection of <see cref="Task"></see> objects.
90 /// </summary>
91 class ASPOSE_TASKS_SHARED_CLASS TaskLinkCollection : public System::Collections::Generic::IList<System::SharedPtr<TaskLink>>
92 {
94  typedef System::Collections::Generic::IList<System::SharedPtr<TaskLink>> BaseType;
95 
96  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
97  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
98 
99  friend class Project;
100  friend class Aspose::Tasks::Connectivity::PmTaskRelationMapper;
101  friend class Aspose::Tasks::IO::Html::HtmlTaskTableReader;
102  friend class Aspose::Tasks::IO::Xml::TaskLinksNodeReader;
103  friend class Aspose::Tasks::IO::MSProject::MPP12Reader;
104  friend class Task;
105  friend class Aspose::Tasks::IO::Xer::XerRelationReader;
106  friend class Aspose::Tasks::Connectivity::MpdTaskLinkMapper;
107  friend class Aspose::Tasks::Connectivity::MspTaskLinksMapper;
108  friend class Aspose::Tasks::IO::Mpx::MpxReader;
109  friend class Aspose::Tasks::IO::MSProject::MPP9Reader;
110  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::TaskLinkEntityMapper;
111  friend class Aspose::Tasks::IO::MSProject::MPP14Reader;
112  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraRelationshipNodeReader;
113 
114 public:
115  /// A collection type whose iterator types is used as iterator types in the current collection.
116  using iterator_holder_type = System::Collections::Generic::List<System::SharedPtr<TaskLink>>;
117  /// Iterator type.
118  using iterator = typename iterator_holder_type::iterator;
119  /// Const iterator type.
120  using const_iterator = typename iterator_holder_type::const_iterator;
121  /// Virtualized element type.
122  using virtualized_iterator_element = typename iterator_holder_type::virtualized_iterator_element;
123  /// Virtualized type.
124  using virtualized_iterator = typename iterator_holder_type::virtualized_iterator;
125 
126 public:
127 
128  /// <summary>
129  /// Gets the parent project of the ResourceAssignmentCollection object.
130  /// <returns>parent <see cref="Project"></see> for this object.</returns>
131  /// </summary>
132  ASPOSE_TASKS_SHARED_API System::SharedPtr<Project> get_ParentProject() const;
133  /// <summary>
134  /// Gets the number of objects contained in this <see cref="TaskLinkCollection"></see> object.
135  /// </summary>
136  ASPOSE_TASKS_SHARED_API int32_t get_Count() const override;
137 
138  /// <summary>
139  /// Returns the element at the specified index.
140  /// </summary>
141  /// <param name="index">The zero-based index of the element to get or set.</param>
142  /// <returns>the element at the specified index.</returns>
143  ASPOSE_TASKS_SHARED_API System::SharedPtr<TaskLink> idx_get(int32_t index) const override;
144  /// <summary>
145  /// Sets the element at the specified index.
146  /// </summary>
147  /// <param name="index">The zero-based index of the element to get or set.</param>
148  /// <param name="value">the element at the specified index.</param>
149  ASPOSE_TASKS_SHARED_API void idx_set(int32_t index, System::SharedPtr<TaskLink> value) override;
150 
151  /// <summary>
152  /// Returns an enumerator for this collection.
153  /// </summary>
154  /// <returns>an enumerator for this collection.</returns>
155  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<TaskLink>>> GetEnumerator() override;
156  /// <summary>
157  /// Returns an instance of Finish-Start <see cref="TaskLink"></see> which has been added to the TaskLinkCollection object.
158  /// </summary>
159  /// <param name="pred">Predecessor task.</param>
160  /// <param name="succ">Successor task.</param>
161  /// <returns>a task link instance which has been added to this object.</returns>
162  /// <exception cref="ArgumentNullException">If any of input tasks is equal to null then <see cref="ArgumentNullException"></see> will be thrown.</exception>
163  ASPOSE_TASKS_SHARED_API System::SharedPtr<TaskLink> Add(const System::SharedPtr<Task>& pred, const System::SharedPtr<Task>& succ);
164  /// <summary>
165  /// Returns an instance of <see cref="TaskLink"></see> which has been added to the TaskLinkCollection object.
166  /// </summary>
167  /// <param name="pred">Predecessor task.</param>
168  /// <param name="succ">Successor task.</param>
169  /// <param name="linkType">Link type <see cref="TaskLinkType"></see> </param>
170  /// <returns>a task link instance which has been added to this object.</returns>
171  /// <exception cref="ArgumentNullException">If any of input tasks is equal to null then <see cref="ArgumentNullException"></see> will be thrown.</exception>
172  ASPOSE_TASKS_SHARED_API System::SharedPtr<TaskLink> Add(const System::SharedPtr<Task>& pred, const System::SharedPtr<Task>& succ, TaskLinkType linkType);
173  /// <summary>
174  /// Returns an instance of <see cref="TaskLink"></see> which has been added to the TaskLinkCollection object.
175  /// </summary>
176  /// <param name="pred">Predecessor task.</param>
177  /// <param name="succ">Successor task.</param>
178  /// <param name="linkType">Link type <see cref="TaskLinkType"></see> </param>
179  /// <param name="lag">Link lag <see cref="Duration"></see>.</param>
180  /// <returns>a task link which has been added to this object.</returns>
181  /// <exception cref="ArgumentNullException">If any of input tasks is equal to null then <see cref="ArgumentNullException"></see> will be thrown.</exception>
182  ASPOSE_TASKS_SHARED_API System::SharedPtr<TaskLink> Add(const System::SharedPtr<Task>& pred, const System::SharedPtr<Task>& succ, TaskLinkType linkType, Duration lag);
183  /// <summary>
184  /// This is the stub implementation of ICollection's Add method, that only throws NotSupportedException
185  /// </summary>
186  /// <param name="item">The item to add.</param>
187  ASPOSE_TASKS_SHARED_API void Add(const System::SharedPtr<TaskLink>& item) override;
188  /// <summary>
189  /// Removes task link from a project.
190  /// </summary>
191  /// <param name="item">TaskLink to remove.</param>
192  /// <returns>removed TaskLink.</returns>
193  ASPOSE_TASKS_SHARED_API bool Remove(const System::SharedPtr<TaskLink>& item) override;
194  /// <summary>
195  /// Converts the TaskLinkCollection object to a list of <see cref="TaskLink"></see> objects.
196  /// </summary>
197  /// <returns>List of <see cref="TaskLink"></see> objects.</returns>
198  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TaskLink>>> ToList();
199  /// Gets iterator pointing to the first element (if any) of the collection.
200  /// @return An iterator pointing to the first element (if any) of the collection
201  ASPOSE_TASKS_SHARED_API iterator begin() noexcept;
202  /// Gets iterator pointing right after the last element (if any) of the collection.
203  /// @return An iterator pointing right after the last element (if any) of the collection
204  ASPOSE_TASKS_SHARED_API iterator end() noexcept;
205  /// Gets iterator pointing to the first element (if any) of the const-qualified instance of the collection.
206  /// @return An iterator pointing to the first element (if any) of the const-qualified instance of the collection
207  ASPOSE_TASKS_SHARED_API const_iterator begin() const noexcept;
208  /// Gets iterator pointing right after the last element (if any) of the const-qualified instance of the collection.
209  /// @return An iterator pointing right after the last element (if any) of the const-qualified instance of the collection
210  ASPOSE_TASKS_SHARED_API const_iterator end() const noexcept;
211  /// Gets iterator pointing to the first const-qualified element (if any) of the collection.
212  /// @return An iterator pointing to the first const-qualified element (if any) of the collection
213  ASPOSE_TASKS_SHARED_API const_iterator cbegin() const noexcept;
214  /// Gets iterator pointing right after the last const-qualified element (if any) of the collection.
215  /// @return An iterator pointing right after the last const-qualified element (if any) of the collection
216  ASPOSE_TASKS_SHARED_API const_iterator cend() const noexcept;
217  /// Gets iterator pointing to the first element (if any) of the collection.
218  /// @return An iterator pointing to the first element (if any) of the collection
219  /// Provides iterator implementation to container's first element.
220  /// @return Newly-created iterator object.
221  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginIterator() override;
222  /// Gets iterator pointing right after the last element (if any) of the collection.
223  /// @return An iterator pointing right after the last element (if any) of the collection
224  /// Provides iterator implementation to container's end.
225  /// @return Newly-created iterator object.
226  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndIterator() override;
227  /// Gets iterator pointing to the first element (if any)of the const-qualified instance of the collection.
228  /// @return An iterator pointing to the first element (if any)of the const-qualified instance of the collection
229  /// Provides const iterator implementation to container's first element.
230  /// @return Newly-created iterator object.
231  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeBeginConstIterator() const override;
232  /// Gets iterator pointing right after the last element (if any)of the const-qualified instance of the collection.
233  /// @return An iterator pointing right after the last element (if any)of the const-qualified instance of the collection
234  /// Provides const iterator implementation to container's end.
235  /// @return Newly-created iterator object.
236  ASPOSE_TASKS_SHARED_API virtualized_iterator* virtualizeEndConstIterator() const override;
237 
238 protected:
239 
240  ASPOSE_TASKS_SHARED_API TaskLinkCollection(const System::SharedPtr<Project>& parentProject);
241 
242  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(TaskLinkCollection, CODEPORTING_ARGS(const System::SharedPtr<Project>& parentProject));
243 
244  ASPOSE_TASKS_SHARED_API TaskLinkCollection(const System::SharedPtr<Project>& parentProject, const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TaskLink>>>& links);
245 
246  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(TaskLinkCollection, CODEPORTING_ARGS(const System::SharedPtr<Project>& parentProject, const System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<TaskLink>>>& links));
247 
248  ASPOSE_TASKS_SHARED_API void AddInternal(const System::SharedPtr<TaskLink>& link);
249  ASPOSE_TASKS_SHARED_API void Sort(const System::SharedPtr<System::Collections::Generic::IComparer<System::SharedPtr<TaskLink>>>& comparer);
250 
251  ASPOSE_TASKS_SHARED_API virtual ~TaskLinkCollection();
252 
253  #ifdef ASPOSE_GET_SHARED_MEMBERS
254  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
255  #endif
256 
257 
258 private:
259 
260  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TaskLink>>> links;
261  System::WeakPtr<Project> parentProject;
262 
263  bool get_IsReadOnly() const override;
264 
265  ASPOSE_TASKS_SHARED_API void Clear() override;
266  ASPOSE_TASKS_SHARED_API bool Contains(const System::SharedPtr<TaskLink>& item) const override;
267  ASPOSE_TASKS_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<TaskLink>> array, int32_t arrayIndex) override;
268  ASPOSE_TASKS_SHARED_API int32_t IndexOf(const System::SharedPtr<TaskLink>& item) const override;
269  ASPOSE_TASKS_SHARED_API void Insert(int32_t index, const System::SharedPtr<TaskLink>& item) override;
270  ASPOSE_TASKS_SHARED_API void RemoveAt(int32_t index) override;
271  /// <summary>
272  /// Add a task link to a project.
273  /// </summary>
274  /// <param name="link">TaskLink to add.</param>
275  bool AddTaskLink(const System::SharedPtr<TaskLink>& link);
276 
277 };
278 
279 } // namespace Tasks
280 } // namespace Aspose
281 
282 
Represents duration in a project.
Definition: Duration.h:161
Represents a project.
Definition: Project.h:551
Represents a task in a project.
Definition: Task.h:394
Aspose.
Definition: Asn.h:13