Aspose.Tasks for C++
TaskLinkCollection.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="TaskLinkCollection.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 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 
15 namespace Aspose
16 {
17 namespace Tasks
18 {
19 namespace Connectivity
20 {
21 class MpdTaskLinkMapper;
22 class MspTaskLinksMapper;
23 class PmTaskRelationMapper;
24 } // namespace Connectivity
25 class Duration;
26 namespace IO
27 {
28 namespace Html
29 {
30 class HtmlTaskTableReader;
31 } // namespace Html
32 namespace Mpx
33 {
34 class MpxReader;
35 } // namespace Mpx
36 namespace MSProject
37 {
38 class MPP12Reader;
39 class MPP14Reader;
40 class MPP9Reader;
41 } // namespace MSProject
42 namespace PrimaveraXml
43 {
44 class PrimaveraRelationshipNodeReader;
45 } // namespace PrimaveraXml
46 namespace Pwa
47 {
48 namespace InternalApi
49 {
50 namespace Mapping
51 {
52 class TaskLinkEntityMapper;
53 } // namespace Mapping
54 } // namespace InternalApi
55 } // namespace Pwa
56 namespace Xer
57 {
58 class XerRelationReader;
59 } // namespace Xer
60 namespace Xml
61 {
62 class TaskLinksNodeReader;
63 } // namespace Xml
64 } // namespace IO
65 class Project;
66 class Task;
67 class TaskLink;
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<Aspose::Tasks::TaskLink>>
92 {
94  typedef System::Collections::Generic::IList<System::SharedPtr<Aspose::Tasks::TaskLink>> BaseType;
95 
96  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
97  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
98 
99  friend class Aspose::Tasks::IO::PrimaveraXml::PrimaveraRelationshipNodeReader;
100  friend class Aspose::Tasks::Project;
101  friend class Aspose::Tasks::Task;
102  friend class Aspose::Tasks::Connectivity::MpdTaskLinkMapper;
103  friend class Aspose::Tasks::Connectivity::MspTaskLinksMapper;
104  friend class Aspose::Tasks::Connectivity::PmTaskRelationMapper;
105  friend class Aspose::Tasks::IO::Html::HtmlTaskTableReader;
106  friend class Aspose::Tasks::IO::MSProject::MPP12Reader;
107  friend class Aspose::Tasks::IO::MSProject::MPP14Reader;
108  friend class Aspose::Tasks::IO::MSProject::MPP9Reader;
109  friend class Aspose::Tasks::IO::Mpx::MpxReader;
110  friend class Aspose::Tasks::IO::Xer::XerRelationReader;
111  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::TaskLinkEntityMapper;
112  friend class Aspose::Tasks::IO::Xml::TaskLinksNodeReader;
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  ASPOSE_TASKS_SHARED_API void AddInternal(const System::SharedPtr<TaskLink>& link);
248  ASPOSE_TASKS_SHARED_API void Sort(const System::SharedPtr<System::Collections::Generic::IComparer<System::SharedPtr<TaskLink>>>& comparer);
249 
250  virtual ASPOSE_TASKS_SHARED_API ~TaskLinkCollection();
251 
252  #ifdef ASPOSE_GET_SHARED_MEMBERS
253  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
254  #endif
255 
256 
257 private:
258 
259  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<TaskLink>>> links;
260  System::WeakPtr<Project> parentProject;
261 
262  bool get_IsReadOnly() const override;
263 
264  void Clear() override;
265  bool Contains(const System::SharedPtr<TaskLink>& item) const override;
266  void CopyTo(System::ArrayPtr<System::SharedPtr<TaskLink>> array, int32_t arrayIndex) override;
267  int32_t IndexOf(const System::SharedPtr<TaskLink>& item) const override;
268  void Insert(int32_t index, const System::SharedPtr<TaskLink>& item) override;
269  void RemoveAt(int32_t index) override;
270  /// <summary>
271  /// Add a task link to a project.
272  /// </summary>
273  /// <param name="link">TaskLink to add.</param>
274  bool AddTaskLink(const System::SharedPtr<TaskLink>& link);
275 
276 };
277 
278 } // namespace Tasks
279 } // namespace Aspose
280 
281 
Represents a task in a project.
Definition: Task.h:383
Represents duration in a project.
Definition: Duration.h:162
Represents a project.
Definition: Project.h:551