Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / ParaMEDMEM / ProcessorGroup.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __PROCESSORGROUP_HXX__
20 #define __PROCESSORGROUP_HXX__
21
22 #include "CommInterface.hxx"
23
24 #include <set>
25
26 namespace ParaMEDMEM
27 {
28   class ProcessorGroup
29   {
30   public:
31   
32     ProcessorGroup(const CommInterface& interface):_comm_interface(interface) { }
33     ProcessorGroup(const CommInterface& interface, std::set<int> proc_ids):
34       _comm_interface(interface),_proc_ids(proc_ids) { }
35     ProcessorGroup (const ProcessorGroup& proc_group, std::set<int> proc_ids):
36       _comm_interface(proc_group.getCommInterface()) { }
37     ProcessorGroup (const CommInterface& interface, int start, int end);
38     virtual ~ProcessorGroup() { }
39     virtual ProcessorGroup* fuse (const ProcessorGroup&) const = 0;
40     virtual void intersect (ProcessorGroup&) = 0;
41     bool contains(int rank) const { return _proc_ids.find(rank)!=_proc_ids.end(); }
42     virtual bool containsMyRank() const= 0;
43     int size() const  { return _proc_ids.size(); }
44     const CommInterface& getCommInterface()const { return _comm_interface; }
45     virtual int myRank() const = 0;
46     virtual int translateRank(const ProcessorGroup*, int) const =0;
47     virtual ProcessorGroup* createComplementProcGroup() const =0;
48     virtual ProcessorGroup* createProcGroup() const=0;
49     virtual const std::set<int>& getProcIDs()const  { return _proc_ids; } 
50   protected:
51     const CommInterface _comm_interface;
52     std::set<int> _proc_ids;
53   };
54 }
55
56 #endif