M
Mosfet
Hi,
I have a code shown below :
ULONG CClientMgr::SetDbSyncType( ULong_t a_ulId, ULong_t a_ulType )
{
return Set( SM_PRIV_CMD_SET_DB_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbAutoSyncType( ULong_t a_ulId, ULong_t& a_ulType )
{
return Set( SM_PRIV_CMD_GET_DB_AUTO_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::SetDbAutoSyncType( ULong_t a_ulId, ULong_t a_ulType )
{
return Set( SM_PRIV_CMD_SET_DB_AUTO_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbAutoSyncTask( ULong_t a_ulId, ULong_t& a_ulTask )
{
return Get( SM_PRIV_CMD_GET_DB_AUTO_SYNC_TASK,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulTask );
}
ULONG CClientMgr::SetDbAutoSyncTask( ULong_t a_ulId, ULong_t a_ulTask )
{
return Set( SM_PRIV_CMD_SET_DB_AUTO_SYNC_TASK,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulTask );
}
ULONG CClientMgr::GetCurrentSyncType( ULong_t& a_ulType )
{
return Get( SM_PRIV_CMD_GET_CURRENT_SYNC_TYPE,
0,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbFlags( ULong_t a_ulId, UShort_t
a_nIndex,
ULong_t& a_ulFalgs )
{
}
ULONG CClientMgr::GetCustomLongParam( ULong_t& a_ulParam )
{
return Get( SM_PRIV_CMD_GET_CUSTOM_LONG_PARAM,
0,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulParam );
}
ULONG CClientMgr::SetLogin( char* a_pLogin )
{
ULong_t ulLen = 0;
if( a_pLogin != NULL )
{
ulLen = ( ULong_t ) ( strlen( a_pLogin ) + 1 );
}
return Set( SM_PRIV_CMD_SET_LOGIN,
0,
0,
ulLen,
( void* ) a_pLogin );
}
Ret_t CSyncClientSession::Stop()
{
return Set( SM_PRIV_CMD_STOP, 0, 0, 0, NULL );
}
I would like to replace all this stuff with a more generic approach.
A king of policy design.
The problem is some functions takes one or two parameters and some
specializations takes some string.
What would you propose ?
We can see that everytime there is a a_ulId as parameter it's passed as
a first parameter to the Get or Set function.
It could be the first policy.
when a char* is passed I also have a special treatment.
I have a code shown below :
ULONG CClientMgr::SetDbSyncType( ULong_t a_ulId, ULong_t a_ulType )
{
return Set( SM_PRIV_CMD_SET_DB_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbAutoSyncType( ULong_t a_ulId, ULong_t& a_ulType )
{
return Set( SM_PRIV_CMD_GET_DB_AUTO_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::SetDbAutoSyncType( ULong_t a_ulId, ULong_t a_ulType )
{
return Set( SM_PRIV_CMD_SET_DB_AUTO_SYNC_TYPE,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbAutoSyncTask( ULong_t a_ulId, ULong_t& a_ulTask )
{
return Get( SM_PRIV_CMD_GET_DB_AUTO_SYNC_TASK,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulTask );
}
ULONG CClientMgr::SetDbAutoSyncTask( ULong_t a_ulId, ULong_t a_ulTask )
{
return Set( SM_PRIV_CMD_SET_DB_AUTO_SYNC_TASK,
a_ulId,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulTask );
}
ULONG CClientMgr::GetCurrentSyncType( ULong_t& a_ulType )
{
return Get( SM_PRIV_CMD_GET_CURRENT_SYNC_TYPE,
0,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulType );
}
ULONG CClientMgr::GetDbFlags( ULong_t a_ulId, UShort_t
a_nIndex,
ULong_t& a_ulFalgs )
{
}
ULONG CClientMgr::GetCustomLongParam( ULong_t& a_ulParam )
{
return Get( SM_PRIV_CMD_GET_CUSTOM_LONG_PARAM,
0,
0,
( ULong_t ) sizeof( ULong_t ),
( void* ) &a_ulParam );
}
ULONG CClientMgr::SetLogin( char* a_pLogin )
{
ULong_t ulLen = 0;
if( a_pLogin != NULL )
{
ulLen = ( ULong_t ) ( strlen( a_pLogin ) + 1 );
}
return Set( SM_PRIV_CMD_SET_LOGIN,
0,
0,
ulLen,
( void* ) a_pLogin );
}
Ret_t CSyncClientSession::Stop()
{
return Set( SM_PRIV_CMD_STOP, 0, 0, 0, NULL );
}
I would like to replace all this stuff with a more generic approach.
A king of policy design.
The problem is some functions takes one or two parameters and some
specializations takes some string.
What would you propose ?
We can see that everytime there is a a_ulId as parameter it's passed as
a first parameter to the Get or Set function.
It could be the first policy.
when a char* is passed I also have a special treatment.