--- trunk/OOPSE-3.0/src/brains/DataStorage.hpp 2005/02/13 15:56:10 2007 +++ trunk/OOPSE-3.0/src/brains/DataStorage.hpp 2005/04/15 22:04:00 2204 @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a @@ -54,87 +54,87 @@ namespace oopse { #include namespace oopse { - /** - * @class DataStorage - * @warning do not try to insert element into (or ease element from) private member data - * of DataStorage directly. - * @todo DataStorage may need refactorying. Every std::vector can inherit from the same base class - * which will make it easy to maintain - */ - class DataStorage { - public: + /** + * @class DataStorage + * @warning do not try to insert element into (or ease element from) private member data + * of DataStorage directly. + * @todo DataStorage may need refactorying. Every std::vector can inherit from the same base class + * which will make it easy to maintain + */ + class DataStorage { + public: - enum{ - dslPosition = 1, - dslVelocity = 2, - dslAmat = 4, - dslAngularMomentum = 8, - dslElectroFrame = 16, - dslZAngle = 32, - dslForce = 64, - dslTorque = 128 - }; + enum{ + dslPosition = 1, + dslVelocity = 2, + dslAmat = 4, + dslAngularMomentum = 8, + dslElectroFrame = 16, + dslZAngle = 32, + dslForce = 64, + dslTorque = 128 + }; - DataStorage(); - DataStorage(int size, int storageLayout = 255); - /** return the size of this DataStorage. */ - int getSize(); - /** - * Changes the size of this DataStorage. - * @param size new size of this DataStorage - */ - void resize(int newSize); - /** - * Reallocates memory manually. The main reason for using reserve() is efficiency - * if you know the capacity to which your std::vector must eventually grow, then it is usually more - * efficient to allocate that memory all at once. - */ - void reserve(int size); - /** - * Copies data inside DataStorage class. - * Copy function actually call std::copy for every std::vector in DataStorage class. - * One Precondition of std::copy is that target is not within the range [soruce, soruce + num] - * @param souce - * @param num number of element to be moved - * @param target - */ - void copy(int source, int num, int target); - /** Returns the storage layout */ - int getStorageLayout(); - /** Sets the storage layout */ - void setStorageLayout(int layout); - /** Returns the pointer of internal array */ - double *getArrayPointer(int whichArray); + DataStorage(); + DataStorage(int size, int storageLayout = 255); + /** return the size of this DataStorage. */ + int getSize(); + /** + * Changes the size of this DataStorage. + * @param size new size of this DataStorage + */ + void resize(int newSize); + /** + * Reallocates memory manually. The main reason for using reserve() is efficiency + * if you know the capacity to which your std::vector must eventually grow, then it is usually more + * efficient to allocate that memory all at once. + */ + void reserve(int size); + /** + * Copies data inside DataStorage class. + * Copy function actually call std::copy for every std::vector in DataStorage class. + * One Precondition of std::copy is that target is not within the range [soruce, soruce + num] + * @param souce + * @param num number of element to be moved + * @param target + */ + void copy(int source, int num, int target); + /** Returns the storage layout */ + int getStorageLayout(); + /** Sets the storage layout */ + void setStorageLayout(int layout); + /** Returns the pointer of internal array */ + double *getArrayPointer(int whichArray); - std::vector position; /** position array */ - std::vector velocity; /** velocity array */ - std::vector aMat; /** rotation matrix array */ - std::vector angularMomentum;/** angular momentum array (body-fixed) */ - std::vector electroFrame; /** the lab frame unit std::vector array*/ - std::vector zAngle; /** z -angle array */ - std::vector force; /** force array */ - std::vector torque; /** torque array */ + std::vector position; /** position array */ + std::vector velocity; /** velocity array */ + std::vector aMat; /** rotation matrix array */ + std::vector angularMomentum;/** angular momentum array (body-fixed) */ + std::vector electroFrame; /** the lab frame unit std::vector array*/ + std::vector zAngle; /** z -angle array */ + std::vector force; /** force array */ + std::vector torque; /** torque array */ - static int getBytesPerStuntDouble(int layout); + static int getBytesPerStuntDouble(int layout); - private: + private: - double* internalGetArrayPointer(std::vector& v); + double* internalGetArrayPointer(std::vector& v); - double* internalGetArrayPointer(std::vector& v); - double* internalGetArrayPointer(std::vector& v); + double* internalGetArrayPointer(std::vector& v); + double* internalGetArrayPointer(std::vector& v); - template - void internalResize(std::vector& v, int newSize); + template + void internalResize(std::vector& v, int newSize); - template - void internalCopy(std::vector& v, int source, int num, int target); + template + void internalCopy(std::vector& v, int source, int num, int target); - int size_; - int storageLayout_; + int size_; + int storageLayout_; - }; + }; } #endif //BRAINS_DATASTORAGE_HPP