Debian Codegraph @

tools/read_file_names/src/get_read_file_names.cpp

raw
1 #include <gatb/gatb_core.hpp>
2 #include <iostream>
3
4 /********************************************************************************/
5 bool isALeaf(IBank* bank)
6 {
7 if(dynamic_cast<BankComposite*> (bank) == 0) return true;
8 return false;
9 }
10
11 /********************************************************************************/
12 void printCis(IBank* bank, int* value_i, size_t depth=0)
13 {
14 LOCAL (bank);
15 if (depth==1){
16 cout <<"C_"<<*value_i<<" ";
17 (*value_i)+=1;
18 }
19 if (isALeaf(bank)){
20 cout << bank->getId() << " ";
21 }
22
23
24 BankComposite* composite = dynamic_cast<BankComposite*> (bank);
25 if (composite != 0)
26 {
27 const std::vector<IBank*> children = composite->getBanks();
28 for (size_t i=0; i<children.size(); i++) { printCis (children[i], value_i, depth+1); }
29 }
30
31 if (depth==1) cout<<endl;
32 }
33
34 /********************************************************************************/
35 void dump (IBank* bank, size_t depth=0)
36 {
37 LOCAL (bank);
38
39 for (size_t i=0; i<depth; i++) { cout << " "; } cout << bank->getId() << endl;
40
41 BankComposite* composite = dynamic_cast<BankComposite*> (bank);
42 if (composite != 0)
43 {
44 const std::vector<IBank*> children = composite->getBanks();
45 for (size_t i=0; i<children.size(); i++) { dump (children[i], depth+1); }
46 }
47 }
48
49 /********************************************************************************/
50 int main (int argc, char* argv[])
51 {
52 /** We create a command line parser. */
53 OptionsParser parser ("BankDump");
54 parser.push_back (new OptionOneParam (STR_URI_INPUT, "bank input", true));
55
56 try
57 {
58 /** We parse the user options. */
59 IProperties* options = parser.parse (argc, argv);
60
61 /** We dump the bank hierarchy. */
62 //dump (Bank::open (options->getStr(STR_URI_INPUT)));
63
64 /** We dump the bank leaves hierarchy. */
65 int value_i=1;
66 printCis (Bank::open (options->getStr(STR_URI_INPUT)), &value_i);
67 }
68 catch (OptionFailure& e)
69 {
70 return e.displayErrors (std::cout);
71 }
72 catch (Exception& e)
73 {
74 std::cerr << "EXCEPTION: " << e.getMessage() << std::endl;
75 }
76 }