00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "PLObjectManager.h"
00028
00029
00030
00031 #if defined(RIO_DEBUG2) || defined(RIO_EMUL)
00032 const char* const LOGFILE = "RIOPLObjectManager.log";
00033 #endif
00034
00035
00036
00037 PLObjectManager::PLObjectManager( char *LogsDirectory )
00038 {
00039 #ifdef RIO_DEBUG1
00040 RioErr << "### [PLObjectManager - Constructor] Start" << endl;
00041 #endif
00042
00043 #if defined(RIO_DEBUG2) || defined(RIO_EMUL)
00044
00045 char LogFileName[ MaxPathSize ];
00046
00047 strcpy( LogFileName, LogsDirectory );
00048 strcat( LogFileName, LOGFILE );
00049 m_log.open( LogFileName );
00050 #endif
00051
00052 #ifdef RIO_DEBUG1
00053 RioErr << "### [PLObjectManager - Constructor] Finish" << endl;
00054 #endif
00055
00056 }
00057
00058
00059 PLObjectManager::~PLObjectManager()
00060 {
00061 #ifdef RIO_DEBUG1
00062 RioErr << "### [PLObjectManager - Destructor] Start" << endl;
00063 #endif
00064
00065 #if defined(RIO_DEBUG2) || defined(RIO_EMUL)
00066 m_log.close();
00067 #endif
00068
00069 #ifdef RIO_DEBUG1
00070 RioErr << "### [PLObjectManager - Destructor] Finish" << endl;
00071 #endif
00072 }
00073
00074
00075 HRESULT PLObjectManager::Close( unsigned int *ResultSize,
00076 CRioObject *ObjectRioServer )
00077 {
00078 #ifdef RIO_DEBUG1
00079 RioErr << "### [PLObjectManager - Close] Start" << endl;
00080 #endif
00081
00082 unsigned int Size;
00083
00084
00085 HRESULT hresult = ObjectRioServer->Close();
00086
00087
00088 Size = MAX_LONG_STRING_SIZE;
00089 if( Size > *ResultSize )
00090 {
00091 #ifdef RIO_DEBUG1
00092 RioErr << "### [PLObjectManager - Close] Finish 1" << endl;
00093 #endif
00094
00095 return ERROR_CONNECTIONMANAGER + ERROR_RESULT_MESSAGE_OVERFLOW;
00096 }
00097
00098 #ifdef RIO_DEBUG1
00099 RioErr << "### [PLObjectManager - Close] Finish 2" << endl;
00100 #endif
00101
00102 return( hresult );
00103 }
00104
00105
00106 RioResult PLObjectManager::PrefetchBlock( int block,
00107 unsigned int BlockSize,
00108 RioRequest *RequestRioServer,
00109 CRioObject *ObjectRioServer,
00110 int ip,
00111 RioStreamType traffic,
00112 int port )
00113 {
00114 #ifdef RIO_DEBUG1
00115 RioErr << "### [PLObjectManager - PrefetchBlock] Start" << endl;
00116 #endif
00117
00118 RioResult hresult = 0;
00119 RioBlock Block = block;
00120
00121 RioObjectSize objectsize;
00122
00123 ObjectRioServer->GetSize( &objectsize );
00124
00125 RioBlock NumBlocks = (int) (( (objectsize - 1)/ BlockSize ) + 1);
00126
00127
00128
00129 if( Block <= ( NumBlocks - 1 ) )
00130 {
00131 hresult = Read( Block,
00132 ObjectRioServer,
00133 RequestRioServer,
00134 ip,
00135 traffic,
00136 port );
00137
00138 if( FAILED( hresult ) )
00139 {
00140 RioErr << "[PLObjectManager]: Failed to read block: " << Block
00141 << endl;
00142 }
00143 }
00144
00145 #ifdef RIO_DEBUG1
00146 RioErr << "### [PLObjectManager - Prefetch Block] Finish" << endl;
00147 #endif
00148
00149 return( hresult );
00150 }
00151
00152
00153 RioResult PLObjectManager::Read( RioBlock Block,
00154 CRioObject *ObjectRioServer,
00155 RioRequest* Request,
00156 int ip,
00157 RioStreamType traffic,
00158 int port )
00159 {
00160 #ifdef RIO_DEBUG1
00161 RioErr << "### [PLObjectManager - Read] Start" << endl;
00162 #endif
00163
00164 Request->Block = Block;
00165 Request->Result = S_OK;
00166 Request->Status = RIO_REQUEST_FREE;
00167 Request->BufferStatus = 0;
00168
00169 RioResult hResult = ObjectRioServer->StreamRead( Request, 0, traffic,
00170 ip, port );
00171
00172 if( FAILED( hResult ) )
00173 {
00174 RioErr << "[PLObjectManager]: Failed to read block: " << Block << endl;
00175 }
00176
00177 #ifdef RIO_DEBUG1
00178 RioErr << "### [PLObjectManager - Read] Finish" << endl;
00179 #endif
00180
00181 return( hResult );
00182 }