ElementData.cc 1.5 KB
Newer Older
1
#include "ElementData.h"
2

3
4
namespace AMDiS {

5
6
7
8
9
  void ElementData::coarsenElementData(Element* parent, 
				       Element* thisChild,
				       Element* otherChild,
				       int elTypeParent) 
  {
10
11
12
13
    if (decorated) {
      decorated->coarsenElementData(parent, thisChild, otherChild, elTypeParent);
      delete decorated;
      decorated = NULL;
14
15
16
17
18
    }
  }

  bool ElementData::deleteDecorated(int typeID)
  {
19
20
21
22
    if (decorated) {
      if (decorated->isOfType(typeID)) {
	ElementData *tmp = decorated;
	decorated = decorated->decorated;
23
24
25
26
	delete tmp;
	tmp = NULL;
	return true;
      } else {
27
	return decorated->deleteDecorated(typeID);
28
29
30
31
32
33
34
      }
    } 
    return false;    
  }

  void ElementData::deleteDecorated()
  {
35
36
37
    if (decorated) {
      decorated->deleteDecorated();
      delete decorated;
38
39
40
41
42
43
44
45
46
    }
  }
  
  ElementData::~ElementData()
  {
  }

  void ElementData::serialize(std::ostream& out) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
47
    std::string decoratedType;
48
49
    if (decorated) {
      decoratedType = decorated->getTypeName();
Thomas Witkowski's avatar
Thomas Witkowski committed
50
      out << decoratedType << "\n";
51
      decorated->serialize(out);
52
    } else {
Thomas Witkowski's avatar
Thomas Witkowski committed
53
      out << "NULL\n";
54
55
56
    }
  }

57
58
  void ElementData::deserialize(std::istream& in) 
  {
59
    TEST_EXIT(decorated == NULL)
60
      ("there are already decorated element data\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
61
    std::string decoratedType;
62
63
    in >> decoratedType; 
    in.get();
64
    if (decoratedType != "NULL") {
65
66
      decorated = CreatorMap<ElementData>::getCreator(decoratedType)->create();
      decorated->deserialize(in);
67
    } else {
68
      decorated = NULL;
69
    }
70
71
72
  }

}