Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
CollectionDecorator.h
1// trax track library
2// AD 2014
3//
4// "Were do the children play?"
5//
6// Cat Stevens
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
29#include "trax/IDType.h"
30
31#include <string>
32#include <memory>
33
34namespace trax{
35
36
43 template<class BaseDecorator>
44 class CollectionDecorator : public BaseDecorator{
45 public:
46
51 typedef typename BaseDecorator::InterfaceType InterfaceType;
52 typedef typename BaseDecorator::collection_type collection_type;
53 typedef typename BaseDecorator::value_type value_type;
55
58 CollectionDecorator( std::shared_ptr<InterfaceType> pComponent )
59 : BaseDecorator{ pComponent }
60 {}
61
64 const char* TypeName() const noexcept override{
65 return m_pComponent->TypeName();
66 }
67
68 IDType Add( std::shared_ptr<value_type> pItem ) override{
69 return m_pComponent->Add(pItem);
70 }
71
72 IDType AddRelaxed( std::shared_ptr<value_type> pItem ) override{
73 return m_pComponent->AddRelaxed(pItem);
74 }
75
76 bool Remove( value_type* pItem, bool zeroIDs = false ) override{
77 return m_pComponent->Remove( pItem, zeroIDs );
78 }
79
80 int Take( collection_type& ct ) override{
81 return m_pComponent->Take(ct);
82 }
83
84 void Clear() override{
85 return m_pComponent->Clear();
86 }
87
88 int Count() const override{
89 return m_pComponent->Count();
90 }
91
92 typename collection_type::iterator begin() override{
93 return m_pComponent->begin();
94 }
95
96 typename collection_type::const_iterator begin() const override{
97 return m_pComponent->cbegin();
98 }
99
100 typename collection_type::const_iterator cbegin() const override{
101 return m_pComponent->cbegin();
102 }
103
104 typename collection_type::iterator end() override{
105 return m_pComponent->end();
106 }
107
108 typename collection_type::const_iterator end() const override{
109 return m_pComponent->cend();
110 }
111
112 typename collection_type::const_iterator cend() const override{
113 return m_pComponent->cend();
114 }
115
116 std::shared_ptr<value_type> GetFirst() const override{
117 return m_pComponent->GetFirst();
118 }
119
120 std::shared_ptr<value_type> GetNext( const std::shared_ptr<value_type>& pItem ) const override{
121 return m_pComponent->GetNext(pItem);
122 }
123
124 std::shared_ptr<value_type> GetLast() const override{
125 return m_pComponent->GetLast();
126 }
127
128 std::shared_ptr<value_type> GetPrevious( const std::shared_ptr<value_type>& pItem ) const override{
129 return m_pComponent->GetPrevious(pItem);
130 }
131
132 std::shared_ptr<value_type> Get( IDType id ) const override{
133 return m_pComponent->Get(id);
134 }
135
136 std::shared_ptr<value_type> Get( const std::string& name ) const override{
137 return m_pComponent->Get(name);
138 }
139
140 void PushActive( IDType id ) override{
141 return m_pComponent->PushActive(id);
142 }
143
144 void PopActive() override{
145 return m_pComponent->PopActive();
146 }
147
148 std::shared_ptr<value_type> GetActive() const override{
149 return m_pComponent->GetActive();
150 }
151
152 bool IsMember( const value_type& item ) const override{
153 return m_pComponent->IsMember(item);
154 }
155
156 bool IsMember( IDType id ) const override{
157 return m_pComponent->IsMember(id);
158 }
159
160 void ShiftIDs( int offset ) override{
161 return m_pComponent->ShiftIDs( offset );
162 }
163
164 IDType MaxID() const override{
165 return m_pComponent->MaxID();
166 }
167
168 IDType MinID() const override{
169 return m_pComponent->MinID();
170 }
172 protected:
173 using BaseDecorator::m_pComponent;
174 };
175
176}
CollectionDecorator(std::shared_ptr< InterfaceType > pComponent)
Decorator constructor.
Definition CollectionDecorator.h:58
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17