JEMRIS  2.8.1
open-source MRI simulations
SequenceTree.h
Go to the documentation of this file.
1 
5 /*
6  * JEMRIS Copyright (C)
7  * 2006-2015 Tony Stoecker
8  * 2007-2015 Kaveh Vahedipour
9  * 2009-2015 Daniel Pflugfelder
10  *
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 
27 #ifndef SEQUENCETREE_H_
28 #define SEQUENCETREE_H_
29 
30 #include "ModulePrototypeFactory.h"
31 #include "XMLIO.h"
32 
33 
34 using std::map;
35 
36 using std::string;
37 
38 // Class declarations to avoid including Module.h and thus a rereferenciation.
39 class Module;
40 class ConcatSequence;
41 class ContainerSequence;
42 
44 
45 class SequenceTree {
46 
47  friend class Container;
48 
49  public:
50 
51  SequenceTree();
52  ~SequenceTree();
61  void Initialize (string seqFile);
62 
70  DOMNodeList* GetChildNodes (DOMNode* node);
71 
78  DOMNode* GetParentNode (DOMNode* node);
79 
85  DOMNamedNodeMap* GetAttributes (DOMNode* node);
86 
92  Module* GetModule (DOMNode* node);
93 
99  unsigned int AddModule (string name);
100 
111  int RunTree (DOMNode* node, void* ptr, unsigned int (*fun) (void*, DOMNode*) , int depth = 0);
112 
118  unsigned int Populate ();
119 
128  static unsigned int CreateModule(void* ptr, DOMNode* node);
129 
135  Module* GetParent (DOMNode* node);
136 
142  vector<Module*> GetChildren (DOMNode* node);
143 
144 
151  Module* GetChild (DOMNode* node, unsigned int position);
152 
159 
166 
175  Module* GetModuleByAttributeValue (string name, string value);
176 
184  static vector<string> Tokenize(const string& str, const string& delimiters = ",");
185 
191  DOMDocument* GetDOMDocument(){return m_dom_doc;};
192 
198  ModulePrototypeFactory* GetMPF(){return m_mpf;};
199 
205  map<DOMNode*, Module*>* GetModuleMap(){return &m_Modules;};
206 
212  int GetDepth(){return m_depth;};
213 
219  string GetSequenceDirectory();
220 
224  void SerializeModules(string xml_file);
225 
230 
234  bool GetStatus () { return m_state; }
235 
236 
237 
238  private:
239  bool m_state;
240  int m_depth;
243  DOMDocument* m_dom_doc;
244  ModulePrototypeFactory* m_mpf;
245  XMLIO* m_xio;
246  map<DOMNode*, Module*> m_Modules;
247  string m_seq_file;
249 };
250 
251 #endif /*SEQUENCETREE_H_*/
ConcatSequence * GetRootConcatSequence()
Definition: SequenceTree.cpp:294
XML file-IO class.
Definition: XMLIO.h:61
ModulePrototypeFactory * GetMPF()
Definition: SequenceTree.h:198
Implementation of JEMRIS ModulePrototypeFactory.
Parameters * GetParameters()
Definition: SequenceTree.h:229
string m_seq_file
Definition: SequenceTree.h:247
ContainerSequence * GetContainerSequence()
Definition: SequenceTree.cpp:303
void Initialize(string seqFile)
Definition: SequenceTree.cpp:68
Prototype of a Container.
Definition: Container.h:39
Module factory.
Definition: ModulePrototypeFactory.h:35
vector< Module * > GetChildren(DOMNode *node)
Definition: SequenceTree.cpp:268
Concat sequence prototype.
Definition: ConcatSequence.h:37
Module * GetParent(DOMNode *node)
Definition: SequenceTree.cpp:256
DOMNode * GetParentNode(DOMNode *node)
Definition: SequenceTree.cpp:92
Module * GetModuleByAttributeValue(string name, string value)
Definition: SequenceTree.cpp:312
DOMDocument * GetDOMDocument()
Definition: SequenceTree.h:191
World parameters provide the parametric data of the sequence.
Definition: Parameters.h:37
~SequenceTree()
Definition: SequenceTree.cpp:51
unsigned int AddModule(string name)
Definition: SequenceTree.cpp:123
unsigned int Populate()
Definition: SequenceTree.cpp:131
bool GetStatus()
Get my status of parsing XML.
Definition: SequenceTree.h:234
Module super class! ABC for all Objects in the sequence framework.
Definition: Module.h:41
ConcatSequence * m_root_seq
Definition: SequenceTree.h:242
static unsigned int CreateModule(void *ptr, DOMNode *node)
Definition: SequenceTree.cpp:239
Tree representation of the sequence.
Definition: SequenceTree.h:45
int GetDepth()
Definition: SequenceTree.h:212
Module * GetChild(DOMNode *node, unsigned int position)
Definition: SequenceTree.cpp:285
DOMDocument * m_dom_doc
Definition: SequenceTree.h:243
int RunTree(DOMNode *node, void *ptr, unsigned int(*fun)(void *, DOMNode *), int depth=0)
Definition: SequenceTree.cpp:196
Parameters * m_parameters
Definition: SequenceTree.h:241
DOMNamedNodeMap * GetAttributes(DOMNode *node)
Definition: SequenceTree.cpp:106
Prototype of a SequenceContainer.
Definition: ContainerSequence.h:38
Implementation of JEMRIS XMLIO.
static vector< string > Tokenize(const string &str, const string &delimiters=",")
DOMNodeList * GetChildNodes(DOMNode *node)
Definition: SequenceTree.cpp:99
SequenceTree()
Definition: SequenceTree.cpp:38
bool m_state
Definition: SequenceTree.h:239
Module * GetModule(DOMNode *node)
Definition: SequenceTree.cpp:111
string GetSequenceDirectory()
Definition: SequenceTree.cpp:87
int m_depth
Definition: SequenceTree.h:240
map< DOMNode *, Module * > * GetModuleMap()
Definition: SequenceTree.h:205
void SerializeModules(string xml_file)
Definition: SequenceTree.cpp:325

-- last change 17.06.2016 | Tony Stoecker | Imprint --