ElementData.cc 1.89 KB
Newer Older
1
#include "MemoryManager.h"
2
#include "ElementData.h"
Naumann, Andreas's avatar
Naumann, Andreas committed
3
#include "PartitionElementData.h"
4
5
namespace AMDiS {

6
7
8
9
10
11
  void ElementData::coarsenElementData(Element* parent, 
				       Element* thisChild,
				       Element* otherChild,
				       int elTypeParent) 
  {
    if (decorated_) {
Naumann, Andreas's avatar
Naumann, Andreas committed
12
13
14
15
16
17
18
19
 	PartitionElementData* ped=NULL;
	ped=dynamic_cast<PartitionElementData*> (thisChild->getElementData(PARTITION_ED));
 	ped=NULL;
 	ped=dynamic_cast<PartitionElementData*> (otherChild->getElementData(PARTITION_ED));
 	
	ped=NULL;
 	ped=dynamic_cast<PartitionElementData*> (parent->getElementData(PARTITION_ED));
 	
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
      decorated_->coarsenElementData(parent, thisChild, otherChild, elTypeParent);
      delete decorated_;
      decorated_ = NULL;
    }
  }

  bool ElementData::deleteDecorated(int typeID)
  {
    if (decorated_) {
      if (decorated_->isOfType(typeID)) {
	ElementData *tmp = decorated_;
	decorated_ = decorated_->decorated_;
	delete tmp;
	tmp = NULL;
	return true;
      } else {
	return decorated_->deleteDecorated(typeID);
      }
    } 
    return false;    
  }

  void ElementData::deleteDecorated()
  {
    if (decorated_) {
      decorated_->deleteDecorated();
      DELETE decorated_;
    }
  }
  
  ElementData::~ElementData()
  {
  }

  void ElementData::serialize(std::ostream& out) 
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
56
    std::string decoratedType;
57
    if (decorated_) {
58
      decoratedType = decorated_->getTypeName();
Thomas Witkowski's avatar
Thomas Witkowski committed
59
      out << decoratedType << "\n";
60
61
      decorated_->serialize(out);
    } else {
Thomas Witkowski's avatar
Thomas Witkowski committed
62
      out << "NULL\n";
63
64
65
    }
  }

66
67
  void ElementData::deserialize(std::istream& in) 
  {
68
69
    TEST_EXIT(decorated_ == NULL)
      ("there are already decorated element data\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
70
    std::string decoratedType;
71
72
    in >> decoratedType; 
    in.get();
73
    if (decoratedType != "NULL") {
74
75
76
77
      decorated_ = CreatorMap<ElementData>::getCreator(decoratedType)->create();
      decorated_->deserialize(in);
    } else {
      decorated_ = NULL;
78
    }
79
80
81
  }

}