diff options
author | Jakob Odersky <jodersky@gmail.com> | 2011-04-12 21:31:48 +0000 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2011-04-12 21:31:48 +0000 |
commit | d1040b56e9b8657a73a62a2868eb11ac11b517c1 (patch) | |
tree | 3ab11dd9356c220e3d2f13424da327c621351152 /src | |
parent | eec0022a0de769336d1b1f984498427f71136508 (diff) | |
download | vhc-d1040b56e9b8657a73a62a2868eb11ac11b517c1.tar.gz vhc-d1040b56e9b8657a73a62a2868eb11ac11b517c1.tar.bz2 vhc-d1040b56e9b8657a73a62a2868eb11ac11b517c1.zip |
Renomme la methode 'copy()' a 'clone()'. Cette methode est declaree dans une classe abstraite 'Cloneable'
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/Makefile | 2 | ||||
-rw-r--r-- | src/main/Accelerator.h | 8 | ||||
-rw-r--r-- | src/main/CurvedElement.h | 2 | ||||
-rw-r--r-- | src/main/Dipole.h | 2 | ||||
-rw-r--r-- | src/main/Element.h | 7 | ||||
-rw-r--r-- | src/main/FODO.cc | 2 | ||||
-rw-r--r-- | src/main/FODO.h | 2 | ||||
-rw-r--r-- | src/main/Makefile | 2 | ||||
-rw-r--r-- | src/main/Particle.h | 2 | ||||
-rw-r--r-- | src/main/Quadrupole.h | 2 | ||||
-rw-r--r-- | src/main/StraightElement.h | 4 |
11 files changed, 18 insertions, 17 deletions
diff --git a/src/gui/Makefile b/src/gui/Makefile index 05fc929..3e704f0 100644 --- a/src/gui/Makefile +++ b/src/gui/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: $(BINDIR)/gui/gui -# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Apr 12 22:34:18 2011 +# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Apr 12 23:26:29 2011 # Project: gui.pro # Template: app # Command: /usr/bin/qmake -o Makefile gui.pro diff --git a/src/main/Accelerator.h b/src/main/Accelerator.h index 788fa74..8f4249a 100644 --- a/src/main/Accelerator.h +++ b/src/main/Accelerator.h @@ -26,7 +26,7 @@ private : protected: - /** Attributs d'un accélérateur : une collection d'éléments, et une de particules. */ + /* Attributs d'un accélérateur : une collection d'éléments, et une de particules. */ std::vector< Element* > elementCollec; std::vector< Particle* > particleCollec; @@ -52,11 +52,9 @@ public: /** Retourne une représentation en chaîne de caractères de cet accélérateur. */ virtual std::string toString() const; - // TODO ou va le delete ? /** Ajoute un élément (non spécifié) à l'accélérateur. */ - void addElement() { - ptr = new Element; - elementCollec.push_back(ptr); + void add(const Element& element) { + elementCollec.push_back(element.clone()); } // TODO où va le delete? diff --git a/src/main/CurvedElement.h b/src/main/CurvedElement.h index 3bde1da..036fe0e 100644 --- a/src/main/CurvedElement.h +++ b/src/main/CurvedElement.h @@ -43,7 +43,7 @@ public: virtual ~CurvedElement() {}; - //virtual CurvedElement* copy() const {return new CurvedElement(*this);} + //virtual CurvedElement* clone() const {return new CurvedElement(*this);} virtual bool isOutside(const Particle& particle) const { Vector3D x(particle.getPosition() - entryPosition); diff --git a/src/main/Dipole.h b/src/main/Dipole.h index c4f7bc0..6edfb91 100644 --- a/src/main/Dipole.h +++ b/src/main/Dipole.h @@ -67,7 +67,7 @@ public: virtual void accept(ElementVisitor& v) {v.visit(this);} - virtual Dipole* copy() const { + virtual Dipole* clone() const { return new Dipole(getEntryPosition(), getExitPosition(), getSectionRadius(), getCurvature(), _magneticField); } diff --git a/src/main/Element.h b/src/main/Element.h index 3a32e3c..a8b0e90 100644 --- a/src/main/Element.h +++ b/src/main/Element.h @@ -14,17 +14,18 @@ #include "Particle.h" #include "Printable.h" #include "ElementVisitor.h" +#include "Cloneable.h" namespace vhc { /** Classe abstraite representant un element d'un accelerateur. */ -class Element: public Printable { +class Element: public Printable, public Cloneable { private: /** Empêche la copie d'éléments par le constructeur de copie. - * Si on veut explicitement copier un element utiliser <code>copy()</code>.*/ + * Si on veut explicitement copier un element utiliser <code>clone()</code>.*/ //Element(const Element& e); protected: @@ -69,7 +70,7 @@ public: /** Copie l'element sur le heap et renvoye un pointeur sur la copie. * En copiant un element, le pointeur sur l'element suivant est remis a zero. * ATTENTION: La delocation de memoire est sous la responsabilite de l'appelant. */ - virtual Element* copy() const = 0; + virtual Element* clone() const = 0; /** Determine si la particule donnee a heurte le bord de cet element. */ virtual bool isOutside(const Particle& particle) const = 0; diff --git a/src/main/FODO.cc b/src/main/FODO.cc index 9ed5308..c1e6a69 100644 --- a/src/main/FODO.cc +++ b/src/main/FODO.cc @@ -51,7 +51,7 @@ FODO::~FODO() { } } -FODO* FODO::copy() const { +FODO* FODO::clone() const { return new FODO(getEntryPosition(), getExitPosition(), getSectionRadius(), straightLength, focalisingCoefficient); } diff --git a/src/main/FODO.h b/src/main/FODO.h index 31b5bb9..0375fe5 100644 --- a/src/main/FODO.h +++ b/src/main/FODO.h @@ -29,7 +29,7 @@ public: virtual ~FODO(); - virtual FODO* copy() const; + virtual FODO* clone() const; }; } diff --git a/src/main/Makefile b/src/main/Makefile index 1e9dca4..84e4a3e 100644 --- a/src/main/Makefile +++ b/src/main/Makefile @@ -14,7 +14,7 @@ LOCALDIR = main # Si un objet nécessite une compilation non-standard (i.e. pas de règle du style Foo.o : Foo.cc Foo.h), rajouter # cette règle. LOCALOBJS = Vector3D.o Particle.o Printable.o Element.o CurvedElement.o StraightElement.o \ - CompositeElement.o Dipole.o Quadrupole.o FODO.o ElementVisitor.o + CompositeElement.o Dipole.o Quadrupole.o FODO.o ElementVisitor.o Cloneable.o OBJS=$(addprefix $(BINDIR)/$(LOCALDIR)/,$(LOCALOBJS)) .PHONY = all checkdirs lib diff --git a/src/main/Particle.h b/src/main/Particle.h index 1df2827..ef310fa 100644 --- a/src/main/Particle.h +++ b/src/main/Particle.h @@ -119,6 +119,8 @@ public: return s.str(); } + + }; } diff --git a/src/main/Quadrupole.h b/src/main/Quadrupole.h index 6179b71..1f4903b 100644 --- a/src/main/Quadrupole.h +++ b/src/main/Quadrupole.h @@ -48,7 +48,7 @@ public: virtual void accept(ElementVisitor& v) {v.visit(this);} - virtual Quadrupole* copy() const {return new Quadrupole(getEntryPosition(), getExitPosition(), getSectionRadius(), focusingCoefficient);} + virtual Quadrupole* clone() const {return new Quadrupole(getEntryPosition(), getExitPosition(), getSectionRadius(), focusingCoefficient);} }; } diff --git a/src/main/StraightElement.h b/src/main/StraightElement.h index 1f61635..95b5ddf 100644 --- a/src/main/StraightElement.h +++ b/src/main/StraightElement.h @@ -26,7 +26,7 @@ public: virtual ~StraightElement() {}; - //virtual StraightElement* copy() const {return new StraightElement(*this);} + //virtual StraightElement* clone() const {return new StraightElement(*this);} virtual bool isOutside(const Particle& particle) const { Vector3D a(particle.getPosition() - entryPosition); @@ -48,7 +48,7 @@ public: virtual void accept(ElementVisitor& v) {v.visit(this);} - virtual StraightElement* copy() const {return new StraightElement(getEntryPosition(), getExitPosition(), getSectionRadius());} + virtual StraightElement* clone() const {return new StraightElement(getEntryPosition(), getExitPosition(), getSectionRadius());} }; |