IPKIFColleague.cpp

Go to the documentation of this file.
00001 
00010 #include <vector>
00011 #include <iterator>
00012 #include "PKIFMediators.h"
00013 
00014 // 2006-12-29 GIB: Note: All functions from the mediator interface have been merged into the Colleague interface to solve a circular
00015 // dependency problem that was caused by the way some compilers evaluated the template functions in the two interfaces.
00016 
00017 using namespace std;
00018 
00027 IPKIFColleague::~IPKIFColleague()
00028 {
00029     Terminate();
00030 }
00039 IPKIFColleague::IPKIFColleague()
00040 {
00041 }
00055 void IPKIFColleague::AddParent(
00058     IPKIFMediator* p)
00059 {
00060     if(!IsParent(p))
00061         m_parents.push_back(p);
00062 
00063 #ifdef _DEBUG
00064     size_t parentCount = m_parents.size();
00065 #endif
00066 }
00067 
00076 void IPKIFColleague::RemoveParent(
00078     IPKIFMediator* p)
00079 {
00080     if(NULL != p)
00081     {
00082         std::vector<IPKIFMediator*>::iterator end = remove(m_parents.begin(), m_parents.end(), p);
00083 
00084         //added call to erase 04/21/2003 CRW
00085         //delete *end;
00086         m_parents.erase(end, m_parents.end());
00087     }
00088 #ifdef _DEBUG
00089         size_t parentCount = m_parents.size();
00090 #endif
00091 }
00092 
00102 bool IPKIFColleague::IsParent(
00104                               IPKIFMediator* p) const
00105 {
00106     //see if p is already a parent of this instance...
00107     vector<IPKIFMediator*>::const_iterator parentEnd = m_parents.end();
00108     if(!p || parentEnd == find(m_parents.begin(), parentEnd, p))
00109         return false;
00110     else
00111         return true;
00112 }
00113 
00124 void IPKIFColleague::AddMediator(
00126                                 IPKIFMediatorPtr& m)
00127 {
00128     if(!m)
00129         return;
00130     
00131     m->AddParent(this);
00132     m_mediators.push_back(m);
00133 }
00134 
00146 void IPKIFColleague::InitializeMediator(
00148                                        std::vector<CPKIFException*>* errorInfo) 
00149 {
00150 }
00151 
00159 void IPKIFColleague::Terminate() 
00160 {
00161     
00162 }
00163 
00175 void IPKIFColleague::Initialize() 
00176 {
00177 }
00178 
00186 //added 12/04/02
00187 void IPKIFColleague::RemoveMediator(
00189                                    IPKIFMediator* m)
00190 {
00191     if(NULL != m)
00192     {
00193         std::vector<IPKIFMediatorPtr>::iterator end = remove(m_mediators.begin(), m_mediators.end(), m);
00194         
00195         //added call to erase 04/21/2003 CRW
00196         //delete *end;
00197         m_mediators.erase(end, m_mediators.end());
00198     }
00199 }
00200 
00209 void IPKIFColleague::RemoveMediatorAssociations()
00210 {
00211     std::vector<IPKIFMediator*>::iterator pos = m_parents.begin();
00212     std::vector<IPKIFMediator*>::iterator end = m_parents.end();
00213     for(;pos != end; ++pos)
00214     {
00215         (*pos)->RemoveMediator(this);
00216     }
00217     
00218     std::vector<IPKIFMediatorPtr>::iterator mpos = m_mediators.begin();
00219     std::vector<IPKIFMediatorPtr>::iterator mend = m_mediators.end();
00220     for(;mpos != mend; ++mpos)
00221     {
00222         (*mpos)->RemoveParent(this);
00223     }
00224     
00225     //added 10/17/2003
00226     //  - having told our parents and children that we no longer want to associate
00227     //  with them, let's wipe them from our memory
00228     m_mediators.clear();
00229     m_parents.clear();
00230 }
00231 
00241 void IPKIFColleague::GetMediators(std::vector<IPKIFMediatorPtr>& v) const
00242 {
00243     copy(m_mediators.begin(),m_mediators.end(), back_inserter(v));
00244 }

Generated on Mon Nov 15 11:15:51 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6