00001 /* 00002 * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved. 00003 * This software is released under the modified BSD license. 00004 * See the file LICENSE in the top-level directory for details. 00005 */ 00006 // 00007 // $Id: ShareCallback.h,v 1.3 2004/05/19 15:56:59 mmarsh Exp $ 00008 // 00009 // $Log: ShareCallback.h,v $ 00010 // Revision 1.3 2004/05/19 15:56:59 mmarsh 00011 // *** empty log message *** 00012 // 00013 // Revision 1.2 2003/11/04 22:31:51 mmarsh 00014 // *** empty log message *** 00015 // 00016 // 00017 00018 #ifndef __CODEX_SERVER_SHARECALLBACK_H__ 00019 #define __CODEX_SERVER_SHARECALLBACK_H__ 00020 00021 #include "CODEX_VSS/ShareLabel.h" 00022 #include "ServerExceptions.h" 00023 00024 namespace CODEX_Server 00025 { 00032 template< class _ShareType , class _OneWay > 00033 class ShareCallbackBase 00034 { 00035 public : 00037 typedef _ShareType ShareType; 00038 00040 typedef _OneWay OneWay; 00041 00043 typedef CODEX_VSS::LabeledShare< ShareType , OneWay > LSType; 00044 00046 typedef CODEX_VSS::ShareLabel< ShareType , OneWay > LabelType; 00047 00049 virtual ~ShareCallbackBase() {} 00050 00058 virtual const LSType& operator()( const LabelType& label, 00059 unsigned int server ) const = 0; 00060 }; 00061 00067 template< class _ShareType , class _OneWay > 00068 class DefaultShareCallback : 00069 public ShareCallbackBase< _ShareType , _OneWay > 00070 { 00071 public : 00073 typedef CODEX_VSS::LabeledShare< _ShareType , _OneWay > LSType; 00074 00076 typedef typename LSType::LabelType LabelType; 00077 00079 DefaultShareCallback( const LSType* ls ) : 00080 m_ls( ls ) 00081 {} 00082 00084 virtual ~DefaultShareCallback() {} 00085 00086 const LSType& operator()( const LabelType& label, 00087 unsigned int server ) const 00088 { 00089 if ( 0 == m_ls ) 00090 { 00091 throw KeySharesNotFoundException( __FILE__ , __LINE__ ); 00092 } 00093 return *m_ls; 00094 } 00095 00096 private : 00097 const LSType* m_ls; 00098 }; 00099 00100 } 00101 00102 #endif /* __CODEX_SERVER_SHARECALLBACK_H__ */
1.2.18