PKIFFuncStorage.cpp
Go to the documentation of this file.00001
00010 #include "PKIFFuncStorage.h"
00011 #include "PKIFCertificateNodeEntry.h"
00012
00013 #include <iterator>
00014 using namespace std;
00016 struct CPKIFFuncStorageImpl
00017 {
00018 std::vector<void (*) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType)> m_storage;
00019 };
00021
00031 CPKIFFuncStorage::CPKIFFuncStorage(
00034 void (*f) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType)):m_impl (new CPKIFFuncStorageImpl)
00035 {
00036 if(f)
00037 m_impl->m_storage.push_back(f);
00038 }
00046 CPKIFFuncStorage::~CPKIFFuncStorage()
00047 {
00048 delete m_impl;
00049 m_impl = 0;
00050 }
00059 void CPKIFFuncStorage::addFuncs(
00061 CPKIFFuncStorage& v)
00062 {
00063 copy(v.m_impl->m_storage.begin(), v.m_impl->m_storage.end(), back_inserter(m_impl->m_storage));
00064 }
00072 void CPKIFFuncStorage::getFuncs(
00074 std::vector<void (*) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType)>& vec)
00075 {
00076
00077 copy(m_impl->m_storage.begin(), m_impl->m_storage.end(), back_inserter(vec));
00078 }
00089 void CPKIFFuncStorage::addFunc(
00091 void (*f) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType) )
00092 {
00093 m_impl->m_storage.push_back(f);
00094 }
00105 void CPKIFFuncStorage::operator()(
00107 const CPKIFCertificateNodeEntryPtr& p,
00109 CPKIFPathValidationResults& r,
00112 CertificateType t)
00113 {
00114 vector<void (*) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType)>::iterator pos;
00115 vector<void (*) (const CPKIFCertificateNodeEntryPtr&, CPKIFPathValidationResults&, CertificateType)>::iterator end = m_impl->m_storage.end();
00116
00117 for(pos = m_impl->m_storage.begin(); pos != end; ++pos)
00118 {
00119 (*pos)(p, r, t);
00120 }
00121 }
00130 bool CPKIFFuncStorage::empty()
00131 {
00132 return m_impl->m_storage.empty();
00133 }
00134
00135 CPKIFFuncStorageSingleton * CPKIFFuncStorageSingleton::m_hInstance = 0;
00136
00148 CPKIFFuncStorageSingleton * CPKIFFuncStorageSingleton::GetInstance(void)
00149 {
00150 if(m_hInstance) return m_hInstance;
00151 m_hInstance = new CPKIFFuncStorageSingleton();
00152 return m_hInstance;
00153 }
00154
00162 CPKIFFuncStorageSingleton::CPKIFFuncStorageSingleton() : CPKIFFuncStorage(NULL)
00163 {
00164 }
00165
00173 CPKIFFuncStorageSingleton::~CPKIFFuncStorageSingleton()
00174 {
00175 if(m_hInstance) delete m_hInstance;
00176 }