Simpatico  v1.10
tools/storage/GroupStorage.h
1 #ifndef TOOLS_GROUP_STORAGE_H
2 #define TOOLS_GROUP_STORAGE_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/containers/DSArray.h> // member (template)
12 #include <tools/chemistry/Group.h> // member (template argument)
13 #include <util/containers/ArrayIterator.h> // inline function
14 
15 namespace Tools
16 {
17 
18  using namespace Util;
19 
25  template <int N>
26  class GroupStorage : private DSArray< Group<N> >
27  {
28 
29  public:
30 
31  typedef ArrayIterator< Group <N> > Iterator;
32 
33  typedef DSArray< Group<N> > Base;
34  using Base::allocate;
35  using Base::begin;
36  using Base::clear;
37  using Base::size;
38  using Base::capacity;
39 
43  ~GroupStorage();
44 
50  Group<N>* newPtr();
51 
52  private:
53 
54  using Base::resize;
55 
56  };
57 
58  // Function definition
59 
60  /*
61  * Return pointer to location for new group, and add to container.
62  */
63  template <int N>
65  {
66  resize(size() + 1);
67  return &(*this)[size()-1];
68  }
69 
70  /*
71  * Destructor
72  */
73  template <int N>
75  {}
76 
77 }
78 #endif
Group< N > * newPtr()
Append a new element to container and return its address.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Forward iterator for an Array or a C array.
Definition: ArrayIterator.h:39
Single-processor classes for pre- and post-processing MD trajectories.
A group of covalently interacting atoms.
Dynamically allocated array with variable logical size.
Definition: DSArray.h:30