xc
ArrayOfTaggedObjects.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 /* ****************************************************************** **
29 ** OpenSees - Open System for Earthquake Engineering Simulation **
30 ** Pacific Earthquake Engineering Research Center **
31 ** **
32 ** **
33 ** (C) Copyright 1999, The Regents of the University of California **
34 ** All Rights Reserved. **
35 ** **
36 ** Commercial use of this program without express permission of the **
37 ** University of California, Berkeley, is strictly prohibited. See **
38 ** file 'COPYRIGHT' in main directory for information on usage and **
39 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
40 ** **
41 ** Developed by: **
42 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
43 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
44 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
45 ** **
46 ** ****************************************************************** */
47 
48 // $Revision: 1.2 $
49 // $Date: 2003/02/14 23:02:10 $
50 // $Source: /usr/local/cvs/OpenSees/SRC/utility/tagged/storage/ArrayOfTaggedObjects.h,v $
51 
52 
53 #ifndef ArrayOfTaggedObjects_h
54 #define ArrayOfTaggedObjects_h
55 
56 // File: ~/utility/tagged/storage/ArrayOfTaggedObjects.h
57 //
58 // Written: fmk
59 // Created: 11/96
60 // Revision: A
61 //
62 // Description: This file contains the class definition for
63 // ArrayOfTaggedObjects.
64 //
65 // What: "@(#) ArrayOfTaggedObjects.h, revA"
66 
67 
68 #include <utility/tagged/storage/TaggedObjectStorage.h>
69 #include <utility/tagged/storage/ArrayOfTaggedObjectsIter.h>
70 
71 namespace XC
72  {
74 //
92 class ArrayOfTaggedObjects: public TaggedObjectStorage
93  {
94  typedef std::vector<TaggedObject *> tagged_vector;
95  public:
96  typedef tagged_vector::iterator iterator;
97  typedef tagged_vector::const_iterator const_iterator;
98  typedef tagged_vector::reference reference;
99  typedef tagged_vector::const_reference const_reference;
100  typedef tagged_vector::value_type value_type;
101  private:
102  int numComponents;
103  int sizeComponentArray;
104  int positionLastEntry;
105  int positionLastNoFitEntry;
106  bool fitFlag;
107 
108  tagged_vector theComponents;
109  ArrayOfTaggedObjectsIter myIter;
110  protected:
111  iterator begin(void)
112  { return theComponents.begin(); }
113  iterator end(void)
114  { return theComponents.end(); }
115  void clearComponents(void);
116 
117  public:
118  ArrayOfTaggedObjects(CommandEntity *owr,int size,const std::string &containerName);
121  ~ArrayOfTaggedObjects(void);
122 
123  // public methods to populate a domain
124  int setSize(int newSize);
125  bool addComponent(TaggedObject *newComponent);
126  bool removeComponent(int tag);
127  int getNumComponents(void) const;
128 
129  TaggedObject *getComponentPtr(int tag);
130  const TaggedObject *getComponentPtr(int tag) const;
132 
134 
135  const_iterator begin(void) const
136  { return theComponents.begin(); }
137  const_iterator end(void) const
138  { return theComponents.end(); }
139 
140  virtual TaggedObjectStorage *getEmptyCopy(void);
141  virtual void clearAll(bool invokeDestructor = true);
142 
143  void Print(std::ostream &s, int flag =0) const;
144  friend class ArrayOfTaggedObjectsIter;
145  };
146 
147 } // end of XC namespace
148 
149 #endif
150 
151 
ArrayOfTaggedObjects & operator=(const ArrayOfTaggedObjects &)
Assignment operator.
Definition: ArrayOfTaggedObjects.cpp:116
virtual TaggedObjectStorage * getEmptyCopy(void)
Return an empty copy of the container.
Definition: ArrayOfTaggedObjects.cpp:421
~ArrayOfTaggedObjects(void)
Destructor. Release memory.
Definition: ArrayOfTaggedObjects.cpp:131
void Print(std::ostream &s, int flag=0) const
Method which invokes Print on all components.
Definition: ArrayOfTaggedObjects.cpp:463
An TaggedObjectIter is an iter for returning the Components of an object of class TaggedObjectStorage...
Definition: TaggedObjectIter.h:74
TaggedObject * getComponentPtr(int tag)
Returns a pointer to the object with the given tag.
Definition: ArrayOfTaggedObjects.cpp:360
int getNumComponents(void) const
Returns the number of components currently stored in the container.
Definition: ArrayOfTaggedObjects.cpp:345
void clearComponents(void)
Free components memory.
Definition: ArrayOfTaggedObjects.cpp:69
ArrayOfTaggedObjectsIter getIter(void)
Return a new iterator to the components.
Definition: ArrayOfTaggedObjects.cpp:406
TaggedObjectIter & getComponents(void)
Reset the iter to point to first component and then return a reference to the iter.
Definition: ArrayOfTaggedObjects.cpp:399
ArrayOfTaggedObjects(CommandEntity *owr, int size, const std::string &containerName)
Constructor.
Definition: ArrayOfTaggedObjects.cpp:100
ArrayOfTaggedObjects is a storage class.
Definition: ArrayOfTaggedObjects.h:92
Objet that can execute python scripts.
Definition: CommandEntity.h:40
Object idenfied by an integer (tag).
Definition: TaggedObject.h:92
bool addComponent(TaggedObject *newComponent)
Adds a component to the container.
Definition: ArrayOfTaggedObjects.cpp:189
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Array of taggeds objects iterator.
Definition: ArrayOfTaggedObjectsIter.h:74
virtual void clearAll(bool invokeDestructor=true)
Free memory.
Definition: ArrayOfTaggedObjects.cpp:437
int setSize(int newSize)
Set the size of the container.
Definition: ArrayOfTaggedObjects.cpp:146
bool removeComponent(int tag)
Remove the component with the given tag.
Definition: ArrayOfTaggedObjects.cpp:266