ASL  0.1.7
Advanced Simulation Library
aslMemElement.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 ASLMEMELEMENT
25 #define ASLMEMELEMENT
26 
27 #include <memory>
28 
29 
30 using namespace std;
31 
32 namespace asl
33 {
34 
36  {
37  protected:
38  unsigned int size;
39 
40  inline MemElementBase(unsigned int n = 0);
41  public:
42  virtual ~MemElementBase() = 0;
43  inline unsigned int getSize() const;
44  virtual void resize() = 0;
45 
46  };
47 
48  typedef std::shared_ptr<MemElementBase> MemElement;
49 
50  template <typename T> class MemVector: public MemElementBase
51  {
52  private:
53  T* container;
54  bool createdContainer;
55  public:
56  MemVector(unsigned int n = 0);
57  virtual ~MemVector();
58  virtual void resize(unsigned int n);
59  void setContainer(unsigned int n, T* p);
60  };
61 
62 
63 //------------------------ Implementations -----------------------
64 
65  inline MemElementBase::MemElementBase(unsigned int n): size(n)
66  {
67  }
68 
69  inline unsigned int MemElementBase::getSize() const
70  {
71  return size;
72  }
73 
74 
75 
76 } //asl
77 #endif //ASLMEMELEMNT
78 
Advanced Simulation Library.
Definition: aslDataInc.h:30
std::shared_ptr< MemElementBase > MemElement
Definition: aslMemElement.h:48
unsigned int size
Definition: aslMemElement.h:38
unsigned int getSize() const
Definition: aslMemElement.h:69