1 
2 // This file is part of the Alliance Project.
3 // Copyright (C) Laboratoire LIP6 - Departement ASIM
4 // Universite Pierre et Marie Curie
5 //
6 // The Alliance Project  is free software;  you can  redistribute it and/or
7 // modify  it  under the  terms  of  the  GNU  General  Public License  as
8 // published by  the Free  Software Foundation; either  version 2  of  the
9 // License, or (at your option) any later version.
10 //
11 // The Alliance Project  is distributed in the hope that it will be useful,
12 // but  WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of
13 // MERCHANTABILITY  or  FITNESS  FOR A  PARTICULAR PURPOSE.   See  the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy  of  the  GNU  General  Public  License
17 // along with  the Alliance Project;  if  not,  write to the  Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 //
21 // License-Tag
22 //
23 // Date   : 29/01/2004
24 // Author : Christophe Alexandre  <Christophe.Alexandre@lip6.fr>
25 //
26 // Authors-Tag
27 #ifndef __PELEM_H
28 #define __PELEM_H
29 
30 #include <iostream>
31 #include <fstream>
32 #include <vector>
33 #include "PPos.h"
34 using namespace std;
35 
36 class PNet;
37 
38 class PElem {
39 
40   public:
41     typedef vector <PNet*> PNets;
42 
43   protected:
44     PNets		_nets;
45 
46   public:
PElem()47     PElem() : _nets() {}
48 
GetNets()49     PNets&		GetNets() 				{ return _nets; }
GetConstNets()50     const PNets&	GetConstNets() const			{ return _nets; }
51 
52     virtual PPos	GetPos() const = 0;
~PElem()53     virtual ~PElem() {}
54 
GetPosX()55     double		GetPosX() const				{ return GetPos().GetX(); }
GetPosY()56     double		GetPosY() const				{ return GetPos().GetY(); }
57 
58     virtual ostream&	Print(ostream& os) const = 0;
59     void		DescribeOn(ostream& os) const;
60 };
61 
62 static inline ostream& operator<<(ostream& os, const PElem& elem) {
63     return elem.Print(os);
64 }
65 
66 static inline ostream& operator<<(ostream& os, const PElem* elem) {
67     return elem ? elem->Print(os) : os << "(nil)";
68 }
69 
70 #endif /* __PELEM_H */
71