FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fei_SharedIDs.hpp
Go to the documentation of this file.
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2009 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_SharedIDs_hpp_
10 #define _fei_SharedIDs_hpp_
11 
12 #include <fei_macros.hpp>
13 
14 #include <vector>
15 #include <set>
16 #include <map>
17 
18 namespace fei {
19 
21  template<typename T>
22  class SharedIDs {
23  public:
27  {}
28 
30  SharedIDs(const SharedIDs<T>& src)
32  {}
33 
35  virtual ~SharedIDs() {}
36 
38  typedef std::map<T,std::set<int> > map_type;
39 
45  void addSharedID(const T& ID, size_t numSharingProcs, const int* sharingProcs)
46  {
47  typename map_type::iterator iter = sharedIDs_.find(ID);
48  if (iter == sharedIDs_.end()) {
49  iter = sharedIDs_.insert(std::make_pair(ID,std::set<int>())).first;
50  }
51  for(size_t i=0; i<numSharingProcs; ++i) {
52  iter->second.insert(sharingProcs[i]);
53  }
54  }
55 
57  map_type& getSharedIDs() { return( sharedIDs_ ); }
58 
60  const map_type& getSharedIDs() const { return( sharedIDs_ ); }
61 
64  std::vector<int>& getOwningProcs() { return( owningProcs_ ); }
65 
68  const std::vector<int>& getOwningProcs() const { return( owningProcs_ ); }
69 
70  private:
72  std::vector<int> owningProcs_;
73  };
74 
75 } //namespace fei
76 
77 #endif // _fei_SharedIDs_hpp_
78 
std::vector< int > & getOwningProcs()
std::map< T, std::set< int > > map_type
map_type & getSharedIDs()
SharedIDs(const SharedIDs< T > &src)
const map_type & getSharedIDs() const
std::vector< int > owningProcs_
void addSharedID(const T &ID, size_t numSharingProcs, const int *sharingProcs)
const std::vector< int > & getOwningProcs() const
map_type sharedIDs_
virtual ~SharedIDs()