ASL  0.1.7
Advanced Simulation Library
aclVectorOfElementsDef.h
Go to the documentation of this file.
1 /*
2  * Advanced Simulation Library <http://asl.org.il>
3  *
4  * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5  *
6  *
7  * This file is part of Advanced Simulation Library (ASL).
8  *
9  * ASL is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU Affero General Public License as
11  * published by the Free Software Foundation, version 3 of the License.
12  *
13  * ASL is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #ifndef ACLVECTORELEMENTSDEF_H
25 #define ACLVECTORELEMENTSDEF_H
26 
27 #include <memory>
28 #include <vector>
29 #include "../aclTypes.h"
30 
31 using namespace std;
32 
33 namespace cl
34 {
35  class CommandQueue;
36 }
37 
38 namespace acl
39 {
40 
41  class ElementBase;
42  class MemBlock;
43 
44  typedef std::shared_ptr<ElementBase> Element;
45  typedef std::shared_ptr<MemBlock> ElementData;
46 
47  class VectorOfElements;
48  typedef std::shared_ptr<cl::CommandQueue> CommandQueue;
49 
51 
56  class VectorOfElementsData: public std::vector<ElementData>
57  {
60  bool checkCompatibility() const;
61  public:
63  bool checkSizesCompatibility(unsigned int n) const;
65  explicit VectorOfElementsData(unsigned int n);
72  template <typename T> VectorOfElementsData(unsigned int n,
73  unsigned int s,
74  T);
75  template <typename T> VectorOfElementsData(unsigned int n,
76  unsigned int s,
77  T,
78  CommandQueue queue);
79 
80  VectorOfElements operator=(const VectorOfElements & a) const;
81  VectorOfElements operator=(const VectorOfElementsData & a) const;
82  void resizeElements(unsigned int n);
83  };
84 
86 
91  class VectorOfElements: public std::vector<Element>
92  {
95  bool checkCompatibility() const;
96  public:
98  bool checkSizesCompatibility(unsigned int n) const;
100  explicit VectorOfElements(unsigned int n);
102  VectorOfElements operator=(const VectorOfElements & a) const;
103  };
104 
105  typedef shared_ptr<VectorOfElementsData> SPVectorOfElementsData;
106  typedef shared_ptr<VectorOfElements> SPVectorOfElements;
107 
108  inline bool compatibleSizes (unsigned int s, const VectorOfElements & a);
109 
111  acl::TypeID getElementType(const VectorOfElements & a, unsigned int i = 0);
112 
114  unsigned int getElementsSize(const VectorOfElements & a);
115 
116 //------------------------- Implementation -----------------
117 
118  inline bool compatibleSizes(unsigned int s, const VectorOfElements & a)
119  {
120  return a.checkSizesCompatibility(s);
121  }
122 
123 
124 } // namespace acl
125 
126 #endif // ACLVECTORELEMENTSDEF_H
Advanced Computational Language.
Definition: acl.h:40
The OpenCL C++ bindings are defined within this namespace.
Definition: acl.h:33
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition: acl.h:51
The class represents several ElementData.
shared_ptr< VectorOfElements > SPVectorOfElements
shared_ptr< VectorOfElementsData > SPVectorOfElementsData
std::shared_ptr< MemBlock > ElementData
Definition: acl.h:47
The class represents several Element.
bool compatibleSizes(unsigned int s, const VectorOfElements &a)
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
bool checkSizesCompatibility(unsigned int n) const
checks whether all Elements have sizes compatible with n
TypeID
Definition: aclTypes.h:38