Page MenuHomec4science

container.hh
No OneTemporary

File Metadata

Created
Mon, May 27, 06:04

container.hh

/**
* @file container.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date Tue Jul 22 14:47:56 2014
*
* @brief This is the generic container class
*
* @section LICENSE
*
* Copyright INRIA and CEA
*
* The LibMultiScale is a C++ parallel framework for the multiscale
* coupling methods dedicated to material simulations. This framework
* provides an API which makes it possible to program coupled simulations
* and integration of already existing codes.
*
* This Project was initiated in a collaboration between INRIA Futurs Bordeaux
* within ScAlApplix team and CEA/DPTA Ile de France.
* The project is now continued at the Ecole Polytechnique Fédérale de Lausanne
* within the LSMS/ENAC laboratory.
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/
#ifndef __LIBMULTISCALE_CONTAINER_HH__
#define __LIBMULTISCALE_CONTAINER_HH__
/* -------------------------------------------------------------------------- */
#include "cube.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
class Communicator;
class ReferenceManagerInterface;
class ComponentNull;
/* -------------------------------------------------------------------------- */
class ContainerInterface {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ContainerInterface(){
release = 0;
refmanager = NULL;
comm_group = group_invalid;
};
virtual ~ContainerInterface(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! return actual release
UInt getRelease(){return release;};
//! return actual release
virtual void setRelease(UInt r){release=r;};
//! increment the release
virtual void incRelease(){++release;};
//! return bounding box
Cube & getBoundingBox(){return bounding_box;};
//! ste bounding box
void setBoundingBox(Cube & c){bounding_box = c;};
//! return the communication group
CommGroup getCommGroup(){return comm_group;};
//! return the ReferenceManager
ReferenceManagerInterface & getRefManager(){
if (!refmanager) LM_THROW("cannot access undefined Reference Manager");
return *refmanager;
};
bool hasRefManager(){
return refmanager;
};
//! set the ReferenceManager
void setRefManager(ReferenceManagerInterface * refMgr){
refmanager = refMgr;
};
//! return the communication group
void setCommGroup(CommGroup group){comm_group = group;};
//! copy the container info
void copyContainerInfo(ContainerInterface & cont){
bounding_box = cont.getBoundingBox();
comm_group = cont.getCommGroup();
refmanager = cont.refmanager;
}
//! copy the release number
void copyReleaseInfo(ContainerInterface & cont){
release = cont.getRelease();
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
UInt release;
Cube bounding_box;
CommGroup comm_group;
ReferenceManagerInterface * refmanager;
};
/* -------------------------------------------------------------------------- */
template <typename T> class ContainerArray;
/* -------------------------------------------------------------------------- */
/**
* Interface Container<T>.
* Generic container
*/
template <typename T>
class Container_base : public ContainerInterface {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
typedef ContainerArray<T> ContainerSubset;
typedef T Ref;
class iterator_base;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
Container_base(){};
virtual ~Container_base(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! sort conained items
virtual void sort(){LM_TOIMPLEMENT;};
//! search for a given item index
virtual UInt search(T & el){LM_TOIMPLEMENT;};
//! add a given item
virtual void add(T & el){LM_TOIMPLEMENT;};
//! get an item from its index
virtual T & get(UInt index){LM_TOIMPLEMENT;};
//! get an item from its index
virtual T & operator[](UInt index){LM_TOIMPLEMENT;};
//! remove an item from its index
virtual void remove(UInt index){LM_TOIMPLEMENT;};
//! return the number of items
virtual UInt nbElem(DOFType dt = dt_local){LM_TOIMPLEMENT;};
//! return the number of items
UInt size(DOFType dt = dt_local){return nbElem(dt);};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
/* -------------------------------------------------------------------------- */
template <typename T>
class Container_base<T>::iterator_base {
public:
iterator_base(Container_base<T> & c):
my_cont(c),end_flag(false),ghost_flags(false) {};
virtual ~iterator_base(){};
//! test function to know if the course is over
bool end(){
return end_flag;
};
virtual T & getFirst(){LM_TOIMPLEMENT;};
virtual T & getNext(){LM_TOIMPLEMENT;};
void includeGhosts(bool f){
ghost_flags = f;
};
protected:
//! associated container
Container_base<T> & my_cont;
//! end test flag
bool end_flag;
bool ghost_flags;
};
/* -------------------------------------------------------------------------- */
#define DECLARE_CONTAINER_ACCEPT_FUNCTIONS \
template <typename D> \
void accept(D & dumper){ \
dumper.dump(*this); \
}
__END_LIBMULTISCALE__
#endif /* __LIBMULTISCALE_CONTAINER_HH__ */

Event Timeline