]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
adapt to improved Subscriptor scheme
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 22 May 2005 08:39:45 +0000 (08:39 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 22 May 2005 08:39:45 +0000 (08:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@10693 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/tria.cc

index 5aef13aa03981ed86d181efcd493e19a7a4dfc11..64d8c69ada6a41466f84bfefbd788d07229cd696 100644 (file)
@@ -17,6 +17,7 @@
 #include <base/config.h>
 #include <base/point.h>
 #include <base/subscriptor.h>
+#include <base/smartpointer.h>
 #include <grid/geometry_info.h>
 #include <grid/tria_iterator_selector.h>
 
@@ -294,6 +295,7 @@ struct TriaNumberCache<2> : public TriaNumberCache<1>
     unsigned int memory_consumption () const;
 };
 
+//TODO: Replace boundary[255] by a std::vector so we can use constructor of SmartPointer
 
 /**
  * Cache class used to store the number of used and active elements
@@ -3291,7 +3293,7 @@ class Triangulation : public Subscriptor
                                      *  and can thus never be
                                      *  associated with a boundary.
                                      */
-    const Boundary<dim>* boundary[255];
+    SmartPointer<const Boundary<dim> > boundary[255];
 
                                     /**
                                      *  Do some smoothing in the process
index f1f40e982fb7172ea43d025fb015a43de3bee95b..3e42403255bcaa70902689cbe97977017a26b940 100644 (file)
@@ -52,10 +52,7 @@ Triangulation<dim>::Triangulation (const MeshSmoothing smooth_grid) :
                                   // set default boundary for all
                                   // possible components
   for (unsigned int i=0;i<255;++i)
-    {
-      boundary[i] = straight_boundary;
-      boundary[i]->subscribe(typeid(*this).name());
-    }
+    boundary[i] = straight_boundary;
 }
 
 
@@ -77,9 +74,6 @@ Triangulation<dim>::~Triangulation ()
   for (unsigned int i=0; i<levels.size(); ++i)
     delete levels[i];
   levels.clear ();
-
-  for (unsigned int i=0;i<255;++i)
-    boundary[i]->unsubscribe(typeid(*this).name());
 }
 
 
@@ -91,21 +85,7 @@ void Triangulation<dim>::clear ()
                                   // more
   Assert (n_subscriptions() == 0, ExcInternalError());
   
-  for (unsigned int i=0; i<levels.size(); ++i)
-    delete levels[i];
-  levels.clear ();
-
-  vertices.clear ();
-  vertices_used.clear ();
-  
-  for (unsigned int i=0; i<255; ++i)
-    {
-      boundary[i]->unsubscribe(typeid(*this).name());
-      boundary[i] = straight_boundary;
-      boundary[i]->subscribe(typeid(*this).name());
-    };
-
-  number_cache = TriaNumberCache<dim>();
+  clear_despite_subscriptions();
 }
 
 
@@ -116,9 +96,7 @@ Triangulation<dim>::set_boundary (const unsigned int number,
 {
   Assert(number<255, ExcIndexRange(number,0,255));
   
-  boundary[number]->unsubscribe(typeid(*this).name());
   boundary[number] = &boundary_object;
-  boundary_object.subscribe(typeid(*this).name());
 }
 
 
@@ -216,11 +194,7 @@ void Triangulation<dim>::copy_triangulation (const Triangulation<dim> &old_tria)
   smooth_grid   = old_tria.smooth_grid;
 
   for (unsigned i=0;i<255;++i)
-    {
-      boundary[i]->unsubscribe(typeid(*this).name());
-      boundary[i]      = old_tria.boundary[i];
-      boundary[i]->subscribe(typeid(*this).name());
-    }
+    boundary[i] = old_tria.boundary[i];
 
   levels.reserve (old_tria.levels.size());
   for (unsigned int level=0; level<old_tria.levels.size(); ++level)
@@ -4158,15 +4132,21 @@ Triangulation<dim>::execute_coarsening_and_refinement ()
 template<int dim>
 void
 Triangulation<dim>::clear_despite_subscriptions()
-{  
-                                  // disable subscriptions, clear,
-                                  // and then set them again
-  const unsigned int n=n_subscriptions();
-  for (unsigned int i=0; i<n; ++i)
-    unsubscribe(typeid(*this).name());
-  clear ();
-  for (unsigned int i=0; i<n; ++i)
-    subscribe(typeid(*this).name());
+{
+                                  // This is the former function
+                                  // clear without the assertion in
+                                  // the beginning.
+  for (unsigned int i=0; i<levels.size(); ++i)
+    delete levels[i];
+  levels.clear ();
+  
+  vertices.clear ();
+  vertices_used.clear ();
+  
+  for (unsigned int i=0; i<255; ++i)
+    boundary[i] = straight_boundary;
+  
+  number_cache = TriaNumberCache<dim>();
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.