Skip to content

Commit 58e27f3

Browse files
author
Daniele Giunchi
committed
stub for hierarchy store/restore
1 parent 59173f2 commit 58e27f3

File tree

6 files changed

+173
-4
lines changed

6 files changed

+173
-4
lines changed

src/mafCore/mafHierarchy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
using namespace mafCore;
1616

17-
mafHierarchy::mafHierarchy(const QString code_location) : mafObjectBase(code_location), m_Tree(NULL) {
17+
mafHierarchy::mafHierarchy(const QString code_location) : mafObject(code_location), m_Tree(NULL) {
1818
//create Tree
1919
m_Tree = new mafTree<QObject *>();
2020
m_TreeIterator = m_Tree->root();

src/mafCore/mafHierarchy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define MAFHIERARCHY_H
1414

1515
// Includes list
16-
#include "mafObjectBase.h"
16+
#include "mafObject.h"
1717
#include "mafTree.hpp"
1818

1919
namespace mafCore {
@@ -26,10 +26,10 @@ This class represents the base class to manage objects' hierarchy. A hierarchy i
2626
A node may have many children but often only a single parent, with the effect of a parent applied to all its child nodes.
2727
The tree is managed towards the class stlplus::ntree, included in MAF3 Foundation in utility section.
2828
*/
29-
class MAFCORESHARED_EXPORT mafHierarchy : public mafObjectBase {
29+
class MAFCORESHARED_EXPORT mafHierarchy : public mafObject {
3030
Q_OBJECT
3131
/// typedef macro.
32-
mafSuperclassMacro(mafCore::mafObjectBase);
32+
mafSuperclassMacro(mafCore::mafObject);
3333

3434
public:
3535
/// Object constructor.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* mafMementoHierarchy.cpp
3+
* mafResources
4+
*
5+
* Created by Roberto Mucci on 27/03/09.
6+
* Copyright 2009 B3C. All rights reserved.
7+
*
8+
* See Licence at: http://tiny.cc/QXJ4D
9+
*
10+
*/
11+
12+
#include "mafMementoHierarchy.h"
13+
#include "mafHierarchy.h"
14+
15+
using namespace mafCore;
16+
17+
mafMementoHierarchy::mafMementoHierarchy(const QString code_location) : mafMemento(code_location) {
18+
}
19+
20+
mafMementoHierarchy::mafMementoHierarchy(const mafObject *obj, const QString code_location) : mafMemento(obj, code_location) {
21+
REQUIRE(obj != NULL);
22+
23+
QStringList hashLists;
24+
QObject *o = NULL;
25+
26+
const mafHierarchy *tree = qobject_cast<const mafHierarchy*>(obj);
27+
28+
//traverse tree and memorize element hash and parent hash, then put them inside a list.
29+
30+
31+
32+
mafMementoPropertyList *list = mementoPropertyList();
33+
mafMementoPropertyItem item;
34+
item.m_Multiplicity = hashLists.count();
35+
item.m_Name = "Hierarchy";
36+
item.m_Value = QVariant(hashLists);
37+
list->append(item);
38+
}
39+
40+
mafMementoHierarchy::~mafMementoHierarchy() {
41+
}

src/mafCore/mafMementoHierarchy.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* mafMementoHierarchy
3+
* mafResources
4+
*
5+
* Created by Roberto Mucci on 27/03/09.
6+
* Copyright 2009 B3C. All rights reserved.
7+
*
8+
* See Licence at: http://tiny.cc/QXJ4D
9+
*
10+
*/
11+
12+
#ifndef MAFMEMENTOHIERARCHY_H
13+
#define MAFMEMENTOHIERARCHY_H
14+
15+
// Includes list
16+
#include "mafCoreDefinitions.h"
17+
#include "mafMemento.h"
18+
19+
namespace mafCore {
20+
21+
// Class forwarding list
22+
23+
/**
24+
Class name: mafMementoHierarchy
25+
This class defines the state which will be saved for mafHierarchy.
26+
This can be used to stroe/restore a tree of elements (undo mechanism or serialization porpouses).
27+
@sa mafCore::mafMemento
28+
*/
29+
class MAFCORESHARED_EXPORT mafMementoHierarchy : public mafMemento {
30+
Q_OBJECT
31+
/// typedef macro.
32+
mafSuperclassMacro(mafCore::mafMemento);
33+
34+
public:
35+
/// object constructor.
36+
mafMementoHierarchy(const QString code_location = "");
37+
/// object overloaded constructor.
38+
mafMementoHierarchy(const mafObject *obj, const QString code_location = "");
39+
40+
protected:
41+
/// Object destructor.
42+
/* virtual */ ~mafMementoHierarchy();
43+
44+
private:
45+
friend class mafHierarchy;
46+
};
47+
48+
} //mafResources
49+
#endif // MAFMEMENTOHIERARCHY_H
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* mafVisitorHierarchyInformation.cpp
3+
* mafCore
4+
*
5+
* Created by Daniele Giunchi on 16/09/09.
6+
* Copyright 2009 B3C. All rights reserved.
7+
*
8+
* See Licence at: http://tiny.cc/QXJ4D
9+
*
10+
*/
11+
12+
#include "mafVisitorHierarchyInformation.h"
13+
14+
using namespace mafCore;
15+
16+
mafVisitorHierarchyInformation::mafVisitorHierarchyInformation(const QString code_location) : mafVisitor(code_location) {
17+
m_ObjectsList = new mafObjectsList();
18+
}
19+
20+
mafVisitorHierarchyInformation::~mafVisitorHierarchyInformation(){
21+
delete m_ObjectsList;
22+
}
23+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* mafVisitorHierarchyInformation.h
3+
* mafCore
4+
*
5+
* Created by Daniele Giunchi on 16/09/09.
6+
* Copyright 2009 B3C. All rights reserved.
7+
*
8+
* See Licence at: http://tiny.cc/QXJ4D
9+
*
10+
*/
11+
12+
#ifndef MAFVISITORHIERARCHYINFORMATION_H
13+
#define MAFVISITORHIERARCHYINFORMATION_H
14+
15+
16+
// Includes list
17+
#include "mafVisitor.h"
18+
19+
namespace mafCore {
20+
21+
/**
22+
Class name: mafVisitorHierarchyInformation
23+
This class define an operation to be performed on the elements of an object structure.
24+
mafVisitorHierarchyInformation lets you define an operation that return a list of mafObjectBase.
25+
@sa mafVisitor
26+
*/
27+
class MAFCORESHARED_EXPORT mafVisitorHierarchyInformation : public mafVisitor {
28+
Q_OBJECT
29+
/// typedef macro.
30+
mafSuperclassMacro(mafCore::mafVisitor);
31+
32+
public:
33+
/// object constructor
34+
mafVisitorHierarchyInformation(const QString code_location = "");
35+
36+
/// Return the Objects List
37+
mafObjectsList *objectsList();
38+
39+
protected:
40+
/// Object destructor.
41+
/* virtual */ ~mafVisitorHierarchyInformation();
42+
43+
mafObjectsList *m_ObjectsList; ///< contains the list of found objects
44+
};
45+
46+
/////////////////////////////////////////////////////////////
47+
// Inline methods
48+
/////////////////////////////////////////////////////////////
49+
50+
inline mafObjectsList *mafVisitorHierarchyInformation::objectsList() {
51+
return m_ObjectsList;
52+
}
53+
54+
} //mafCore
55+
56+
#endif // MAFVISITORHIERARCHYINFORMATION_H

0 commit comments

Comments
 (0)