SemOpt  0.2alpha2-SCC
AF.cpp
Go to the documentation of this file.
1 
10 #include "AF.h"
11 
16 {
17  this->arguments = new SetArguments();
18  //this->raw_attacks = map<int, int >();
19  //this->attacks = map<Argument *, SetArguments *>();
20  //this->attackers = map<Argument *, SetArguments *>();
21 }
22 
23 
24 AF::~AF()
25 {
26  // TODO Auto-generated destructor stub
27 }
28 
35 bool AF::readFile(string file)
36 {
37  string inLine;
38  ifstream infile;
39  infile.open(file.c_str());
40  if (!infile.good())
41  return false;
42  infile >> inLine;
43  while (inLine.find("arg") != string::npos && !infile.eof())
44  {
45  this->arguments->add_Argument(new Argument(
46  inLine.substr(4, inLine.find_last_of(")") - 4),
47  this->numArgs(),
48  this
49  ));
50  infile >> inLine;
51  }
52 
53  while (!infile.eof())
54  {
55  if (inLine.find("att") != string::npos)
56  {
57  Argument *source = this->getArgumentByName(
58  (inLine.substr(4,
59  inLine.find_last_of(",") - 4)));
60  Argument *target = this->getArgumentByName(
61  (inLine.substr(inLine.find_last_of(",") + 1,
62  inLine.find_last_of(")")
63  - inLine.find_last_of(",")
64  - 1)));
65 
66  source->add_attacks(target);
67  target->add_attackers(source);
68 // this->raw_attacks.push_back(
69 // pair<int, int>(
70 // this->argNameToCode(
71 // (inLine.substr(4,
72 // inLine.find_last_of(",") - 4))),
73 // this->argNameToCode(
74 // (inLine.substr(inLine.find_last_of(",") + 1,
75 // inLine.find_last_of(")")
76 // - inLine.find_last_of(",")
77 // - 1)))));
78  }
79  infile >> inLine;
80  }
81  infile.close();
82  return true;
83 }
84 
91 {
92  return this->arguments->getArgumentByName(name);
93 }
94 
100 {
101  return this->arguments->cardinality();
102 }
103 
104 
111 {
112  return this->arguments->getArgumentByNumber(num);
113 }
114 
120 {
121  return this->arguments->begin();
122 }
123 
129 {
130  return this->arguments->end();
131 }
132 
138 {
139  return this->arguments;
140 }