GetFEM  5.4.3
dal_static_stored_objects.h File Reference

Stores interdependent getfem objects. More...

#include "dal_config.h"
#include "getfem_omp.h"
#include <algorithm>
#include "dal_singleton.h"
#include <set>
#include <list>
#include "getfem/getfem_arch_config.h"
#include <atomic>

Go to the source code of this file.

Classes

class  dal::static_stored_object
 base class for static stored objects More...
 
struct  dal::enr_static_stored_object
 Pointer to an object with the dependencies. More...
 
struct  dal::enr_static_stored_object_key
 Pointer to a key with a coherent order. More...
 
struct  dal::stored_object_tab
 Table of stored objects. More...
 

Namespaces

 dal
 Dynamic Array Library.
 

Functions

pstatic_stored_object dal::search_stored_object (pstatic_stored_object_key k)
 Gives a pointer to an object from a key pointer.
 
bool dal::exists_stored_object (pstatic_stored_object o)
 Test if an object is stored.
 
void dal::add_dependency (pstatic_stored_object o1, pstatic_stored_object o2)
 Add a dependency, object o1 will depend on object o2.
 
bool dal::del_dependency (pstatic_stored_object o1, pstatic_stored_object o2)
 remove a dependency. More...
 
void dal::add_stored_object (pstatic_stored_object_key k, pstatic_stored_object o, permanence perm=STANDARD_STATIC_OBJECT)
 Add an object with two optional dependencies.
 
void dal::del_stored_object (const pstatic_stored_object &o, bool ignore_unstored=false)
 Delete an object and the object which depend on it.
 
void dal::del_stored_objects (int perm)
 Delete all the object whose permanence is greater or equal to perm.
 
void dal::list_stored_objects (std::ostream &ost)
 Show a list of stored objects (for debugging purpose).
 
size_t dal::nb_stored_objects (void)
 Return the number of stored objects (for debugging purpose).
 
void dal::del_stored_objects (std::list< pstatic_stored_object > &to_delete, bool ignore_unstored)
 Delete a list of objects and their dependencies.
 
void dal::test_stored_objects (void)
 Test the validity of the whole global storage.
 
template<typename OBJECT_TYPE >
void dal::delete_specific_type_stored_objects (bool all_threads=false)
 delete all the specific type of stored objects
 

Detailed Description

Stores interdependent getfem objects.

Author
Yves Renard Yves..nosp@m.Rena.nosp@m.rd@in.nosp@m.sa-l.nosp@m.yon.f.nosp@m.r
Date
February 19, 2005

Stored object :

A type of object to be stored should derive from dal::static_stored_object and a key should inherit from static_stored_object_key with an overloaded "compare" method.

To store a new object, you have to test if the object is not already stored and then call dal::add_stored_object:

pstatic_stored_object_key p = make_shared<your_object_key>(parameters);
add_stored_object(p, make_shared<your_object>(parameters));
}
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
pstatic_stored_object search_stored_object(pstatic_stored_object_key k)
Gives a pointer to an object from a key pointer.

You can add a dependency of your new object with

add_dependency(pointer_on_your_object,
pointer_on_the_object_object_from_which_it_depends);
void add_dependency(pstatic_stored_object o1, pstatic_stored_object o2)
Add a dependency, object o1 will depend on object o2.

and then your object will be automatically deleted if the second object is deleted. The dependency can be added within the add_stored_object call:

add_stored_object(new your_object_key(parameters),
new your_object(parameters),
dependency);

std::shared_ptr are used.

Definition in file dal_static_stored_objects.h.