2#ifndef _aspose_system_collection_read_only_collection_h_
3#define _aspose_system_collection_read_only_collection_h_
5#include <system/diagnostics/debug.h>
8#include "system/object.h"
9#include "system/collections/ilist.h"
10#include "system/exceptions.h"
11#include "system/cycles_detection.h"
12#include "system/array.h"
15namespace Collections {
16namespace ObjectModel {
52 throw System::ArgumentNullException(u
"list");
61 return m_list->GetEnumerator();
68 return m_list->get_Count();
78 virtual bool Contains(
const T& item)
const override
80 return m_list->Contains(item);
85 virtual int IndexOf(
const T& item)
const override
87 return m_list->IndexOf(item);
93 virtual T
idx_get(
int index)
const override
95 return m_list->idx_get(index);
103 m_list->CopyTo(array, index);
109 CODEPORTING_DEBUG_ASSERT(!
"ReadOnlyCollection is a wrapper and doesn't own any data, so it can't be used to store weak pointers if referenced container stores shared ones");
115 return m_list->virtualizeBeginIterator();
120 return m_list->virtualizeEndIterator();
125 return m_list->virtualizeBeginConstIterator();
130 return m_list->virtualizeEndConstIterator();
139 virtual void Add(
const T& item)
override
141 throw NotSupportedException(u
"Operation not supported on read-only collection");
144 virtual void Clear()
override
146 throw NotSupportedException(u
"Operation not supported on read-only collection");
149 virtual bool Remove(
const T& item)
override
151 throw NotSupportedException(u
"Operation not supported on read-only collection");
154 void RemoveAt(
int index)
override
156 throw NotSupportedException(u
"Operation not supported on read-only collection");
159 virtual void Insert(
int index,
const T& item)
override
161 throw NotSupportedException(u
"Operation not supported on read-only collection");
164 virtual T& operator[](
int index)
166 throw NotSupportedException(u
"Operation not supported on read-only collection");
169 virtual void idx_set(
int index, T value)
override
171 throw NotSupportedException(u
"Operation not supported on read-only collection");
175#ifdef ASPOSE_GET_SHARED_MEMBERS
177 virtual void GetSharedMembers(System::Object::shared_members_type& result)
const override
179 Object::GetSharedMembers(result);
180 result.Add(
"System::Collections::ObjectModel::ReadOnlyCollection<T>::m_list[]", m_list);
184#ifdef __DBG_FOR_EACH_MEMBER
188 void DBG_for_each_member(DBG::for_each_member_visitor &visitor)
const override
190 Object::DBG_for_each_member(visitor);
192 visitor.add_self(
this);
193 visitor.add_member(
this, m_list.
get_shared(),
"m_list");
198 const char* DBG_class_name()
const override {
return "ReadOnlyCollection<T>"; }
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:19
Wraps specific container to access it in read-only mode. Objects of this class should only be allocat...
Definition: read_only_collection.h:27
System::Details::VirtualizedIteratorBase< T > * virtualizeEndConstIterator() const override
Gets the implementation of end const iterator for the current container.
Definition: read_only_collection.h:128
SharedPtr< ReadOnlyCollection< T > > ThisPtr
This pointer.
Definition: read_only_collection.h:33
void SetTemplateWeakPtr(uint32_t argument) override
Does nothing as read-only collection only wraps data and stores nothing.
Definition: read_only_collection.h:107
virtual T idx_get(int index) const override
Gets item at specific position.
Definition: read_only_collection.h:93
System::Details::VirtualizedIteratorBase< T > * virtualizeEndIterator() override
Gets the implementation of end iterator for the current container.
Definition: read_only_collection.h:118
virtual int get_Count() const override
Gets count of container elements.
Definition: read_only_collection.h:66
T ValueType
Value type.
Definition: read_only_collection.h:39
virtual bool Contains(const T &item) const override
Checks if container contains specific item.
Definition: read_only_collection.h:78
virtual void CopyTo(System::ArrayPtr< T > array, int index) override
Copies container elements to existing array elements.
Definition: read_only_collection.h:101
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginConstIterator() const override
Gets the implementation of begin const iterator for the current container.
Definition: read_only_collection.h:123
virtual IEnumeratorPtr GetEnumerator() override
Gets collection enumerator.
Definition: read_only_collection.h:59
SharedPtr< Generic::IList< T > > m_list
Wrapped container.
Definition: read_only_collection.h:35
ReadOnlyCollection(const SharedPtr< Generic::IList< T > > &list)
Wraps read-only collection around specific collection.
Definition: read_only_collection.h:49
SharedPtr< System::Collections::Generic::IEnumerator< T > > IEnumeratorPtr
Container of same elements.
Definition: read_only_collection.h:45
~ReadOnlyCollection() override
Destructor.
Definition: read_only_collection.h:135
bool get_IsReadOnly() const override
Checks if collection is read only.
Definition: read_only_collection.h:73
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginIterator() override
Gets the implementation of begin iterator for the current container.
Definition: read_only_collection.h:113
virtual int IndexOf(const T &item) const override
Looks for specific item in collection.
Definition: read_only_collection.h:85
Generic::IList< T > BaseType
Implemented interface.
Definition: read_only_collection.h:41
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Pointee_ * get_shared() const
Gets pointed object, but asserts that pointer is in shared mode.
Definition: smart_ptr.h:524
Definition: db_command.h:9