diff options
author | aleon | 2013-04-30 15:59:16 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2013-04-30 18:26:00 +0000 |
commit | bb755a01befd30c031965681aa8af8575bce52c5 (patch) | |
tree | f5b597f7cf5696b15c8e6481d8aa9586610a0605 /dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc | |
parent | cf3acef3f302dfc538ac0895ab90e421bc23df2c (diff) | |
download | org.eclipse.cdt-bb755a01befd30c031965681aa8af8575bce52c5.tar.gz org.eclipse.cdt-bb755a01befd30c031965681aa8af8575bce52c5.tar.xz org.eclipse.cdt-bb755a01befd30c031965681aa8af8575bce52c5.zip |
Bug 244865 – Support for Step Into Selection
First Implementation:
* Non-stop as well as All-stop debugging
* Function / Method name validation, arguments size validation
(no arguments signature yet)
* Ctrl-F5 as short key (consistent with JDT)
* Hyper link support with Ctrl-Shift click
* Junit Test (Services part)
Change-Id: I58903b4b6b7f9fd39a827f5297ad23ac3f96186d
Reviewed-on: https://git.eclipse.org/r/11305
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
IP-Clean: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc')
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc new file mode 100644 index 00000000000..dae86028134 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Composite.cc @@ -0,0 +1,210 @@ +/* + * Composite Pattern + */ +#include<iostream> +#include<string> +#include<vector> +#include "Leaf.cc" + +using namespace std; + +//The 'Composite' node +class CompositeNode: public Artifact { +public: + CompositeNode(string name) : + Artifact(name) { + } + + void Add(Artifact* child) { + child->setParent(*this); + fChildren.push_back(child); + } + + void setParent(Artifact &parent) { + fPath = parent.getLocation(); + fParent = &parent; + + //Refresh the parent information path to all children + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + Artifact* child = *it; + child->setParent(*this); + ++it; + } + } + + void Remove(Artifact* child) { + child->deleteParent(); + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + if (*it == child) { + delete child; + fChildren.erase(it); + break; + } + ++it; + } + + } + + void print() { + cout << getLocation() << endl; + + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + (*it)->print(); + ++it; + } + } + + void print(char& cpad) { + string padding(fPath.length(), cpad); + cout << padding << "+ " << fName << endl; + + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + (*it)->print(cpad); + ++it; + } + } + + string toString() { + string strAccumulator(getLocation() + "\n"); + + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + strAccumulator.append((*it)->toString()); + ++it; + } + + return strAccumulator; + } + + string toString(char& cpad) { + string strAccumulation(fPath.length(), cpad); + strAccumulation.append("+ " + fName + "\n"); + + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + strAccumulation.append((*it)->toString(cpad)); + ++it; + } + + return strAccumulation; + } + + virtual int getArtifactsSize() { + return fChildren.size(); + } + + virtual Artifact* getArtifact(int index) { + if (index < fChildren.size()) { + return fChildren.at(index); + } + + else + return 0; + } + + virtual Artifact* getArtifact(string description) { + vector<Artifact*>::iterator it = fChildren.begin(); + while (it != fChildren.end()) { + if ((*it)->getName().compare(description)) { + return *it; + } + ++it; + } + + return 0; + } + + virtual ~CompositeNode() { + while (!fChildren.empty()) { + vector<Artifact*>::iterator it = fChildren.begin(); + delete *it; + fChildren.erase(it); + } + } + +private: + CompositeNode(); + vector<Artifact*> fChildren; +}; + +//The Main method +int main() { + //Create a tree root + CompositeNode* root = new CompositeNode("Dogs"); + + //Create composite nodes + CompositeNode* comp = new CompositeNode("Companion"); + comp->Add(new LeafNode("Puddle")); + comp->Add(new LeafNode("Bichon")); + + CompositeNode* sport = new CompositeNode("Guardian"); + sport->Add(new LeafNode("Boxer")); + sport->Add(new LeafNode("Rottweiler")); + sport->Add(new LeafNode("Mastiff")); + + //Create a Branch + CompositeNode* gun = new CompositeNode("Gun"); + gun->Add(new LeafNode("Cocker")); + gun->Add(new LeafNode("Pointer")); + gun->Add(new LeafNode("Golden Retriever")); + + CompositeNode* herd = new CompositeNode("Herding"); + herd->Add(new LeafNode("Cattle dog")); + herd->Add(new LeafNode("Sheepdog")); + + CompositeNode* north = new CompositeNode("Northern"); + north->Add(new LeafNode("Akita")); + north->Add(new LeafNode("Chow Chow")); + + CompositeNode* hound = new CompositeNode("Hound"); + hound->Add(new LeafNode("Basset Hound")); + hound->Add(new LeafNode("Beagle")); + + CompositeNode* terrier = new CompositeNode("Terrier"); + terrier->Add(new LeafNode("Bull Terrier")); + terrier->Add(new LeafNode("Border Terrier")); + + //Create some leaf nodes + LeafNode* pe1 = new LeafNode("German Shepperd"); + LeafNode* pe2 = new LeafNode("Great Dane"); + + //Add nodes to start from the same root + root->Add(comp); + root->Add(sport); + root->Add(gun); + root->Add(herd); + root->Add(north); + root->Add(hound); + root->Add(terrier); + //Add leaf nodes to root + root->Add(pe1); + root->Add(pe2); + + char cpad = '-'; + char cpad2 = '_'; + //Test stub + toString variants + if (root->getArtifactsSize() > 0 + && (root->getArtifact(0) != 0 && (root->getArtifact("Bichon") != 0))) { + string sout = root->getArtifact(0)->toString() + "\n" + root->getArtifact(1)->toString(cpad2); + cout << sout << endl; + } + + //Test Remove primitive elements + root->Remove(pe1); + root->Remove(pe2); + + //Test Print variants + root->getArtifact(2)->print(); root->getArtifact(3)->print(cpad); + + //Test toString all + cout << "\n\nAll Tree\n" + root->toString(cpad); + + //delete the allocated memory + delete root; + + return 0; +} |