[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Moss-devel] CVS: moss/rmc/src/Server Makefile.am,NONE,1.1 RmcServer.cxx
From: |
Alexander Feder <address@hidden> |
Subject: |
[Moss-devel] CVS: moss/rmc/src/Server Makefile.am,NONE,1.1 RmcServer.cxx,NONE,1.1 |
Date: |
Sun, 23 Jun 2002 09:27:52 -0400 |
Update of /cvsroot/moss/moss/rmc/src/Server
In directory subversions:/tmp/cvs-serv2212/src/Server
Added Files:
Makefile.am RmcServer.cxx
Log Message:
added rmc
--- NEW FILE ---
noinst_LIBRARIES = libRmcServer.a
INCLUDES=-I../../include
CFLAGS=-D_REENTRANT
libRmcServer_a_SOURCES=RmcServer.cxx
#libRmcServer_a_LIBADD=../family/libFamily.la
--- NEW FILE ---
/***************************************************************************
RmcServer.cxx
-------------------
begin : Sun Jun 17 2001
copyright : (C) 2001 by Manfred Morgner
email : address@hidden
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* *
* Free Software Foundation, Inc., *
* 59 Temple Place Suite 330, *
* Boston, MA 02111-1307, USA. *
* *
***************************************************************************
*
* Server side RMC.2 Helper classes for remote connection and transport
*
*/
#include "generic.h"
#include "RmcServer.h"
#include <family/SignalHandler.h>
#include <family/PluginHandler.h>
using namespace std;
using namespace rmc;
using namespace family;
/***************************************************************************
*
* Construction/Destruction
*
*/
CRmcServer::CRmcServer()
{
Initialize();
} // CRmcServer::CRmcServer()
CRmcServer::~CRmcServer()
{
for (CVectorTransports::iterator it = m_voTransports.begin();
it != m_voTransports.end();
++it)
{
delete *it;
} // for (CVectorTransports::iterator it = m_voTr..
} // CRmcServer::~CRmcServer()
/***************************************************************************
*
* public Methods
*
*/
bool CRmcServer::TransportAdd(const string& sLibTransport)
{
TRACE("RmcServer::TransportSet\n")
typedef LONG (*pfnRegisterRmcServer)( CRmcServer *);
// a transport library manager
CPluginHandler *poLibTransport = new CPluginHandler;
//- oLibTransport.FilenameSet( sLibTransport );
// set the filename for the transport library to the manager
poLibTransport->FilenameSet( sLibTransport );
// the registration methode
pfnRegisterRmcServer fnRegisterRmcServer = 0;
// try to get the procedure address for the registration function
fnRegisterRmcServer = (pfnRegisterRmcServer)
poLibTransport->FunctionGet("RegisterRmcServer");
// if the methode doesn't exist, we return without success
if ( fnRegisterRmcServer == 0 )
{
TRACE("\tERROR: Could not find 'Register' function export.")
delete poLibTransport;
return false;
} // if ( fnRegisterRmcServer == 0 )
// ok, we got the procedure address, so we add the transport handler to
// the list of transport library managers
m_voTransports.push_back(poLibTransport);
// now the RMC server registers itself to the library, so the library is
// able to route the calls from the clients to the server
fnRegisterRmcServer(this);
return true;
} // void SetTransport(const string& sLibTransport)
// the rmc connect call generates a new stub object for
// the calling client and returns its identification code
//
// INPUT..: nClass - the RTTI of the client class request
// (RTTI = RunTime Type information)
//
// OUTPUT.: rnObject - the object ID
// rnVisum - the visum for the next call to the object
TRmcResult CRmcServer::RmcConnect(TRmcClass nClass,
TRmcObject &rnObject,
TRmcVisum &rnVisum)
{
TRACE("RmcServer::RmcConnect\n")
nClass = ntohl ( nClass );
TRmcResult nReturnVal = m_oObjectFactory.ObjectMake(nClass, rnObject,
rnVisum);
rnObject = htonl( rnObject );
return htonl( nReturnVal );
} // TRmcResult CRmcServer::RmcConnect(TRmcClass ..
// calls a methode in the given object if it an the requested methode exists
//
// INPUT..: rnObject - the ID of the object
// rnVisum - the Visum to access the object
// nMethode - the RMT index of the methode to call
// rnSize - the size of the data for the methode
// rpcData - the data itself or NULL if no data present
//
// OUTPUT.: rnObject - the new ID of the object, if changed
// rnVisum - the new Visum to access the object the next time
// rnSize - the size of the returned data from the methode
// rpcData - the returned data itself
TRmcResult CRmcServer::RmcCall(TRmcObject &rnObject,
TRmcVisum &rnVisum,
TRmcMethode
nMethode,
TRmcSize &rnSize,
TRmcData *&rpcData)
{
TRACE("RmcServer::RmcCall\n")
//- if ( m_poObjectFactory == 0 )
//- {
//- return RMC_FAILURE; // RMC_E_NO_OBJECT_FACTORY
//- } // if ( m_poObjectFactory == 0 )
// now we need a system matching value
rnObject = ntohl ( rnObject );
// we have to get the node as reference because we have to unlock
// the node-lock, that is incremented by the ..GetAndUse-Methode
TObjectNode &rtNode = m_oObjectFactory.ObjectGetAndUse(rnObject);
// may be changed during the previouse call (for security reason)
rnObject = htonl ( rnObject );
// all parameters have to be retranslated to "network format"
// because we have to able to easily return immediately
if (rtNode.pObject == 0)
{
return RMC_FAILURE;
} // if (rtNode.pObject == 0)
// the kill flag is ON, this means, there was a killme-request from
// the client, after this, we will not do anything with the object
if (rtNode.bKillme == true)
{
rtNode.nUseCount--;
return RMC_E_DELETING;
} // if (rtNode.bKillme == true)
// ok, seams we are ready to call, so we have to translate
// the parameters for the methode call to "local format"
//- rnVisum = ntohl( rnVisum );
nMethode = ntohl( nMethode );
rnSize = ntohl( rnSize );
// HINT: rpcData is generated by the transport, the pointer and
// variable itself is - thats why - in local format only
// we must not translate or retranslate it. the content
// behind the pointer may be translated in case of what it is
// this translation goes in the call wrapper level at the
// point where the data are interpretable
// now the call will be executed
// it seems stupid, to give "nClass" to the methode, because
// the factory knows it by itself, but THIS methode lays in the
// rmcgen-generated code range, and wi have to ensure, that any
// code from rmcgen has to contain only bits that are necessary.
// this is for 3 reasons:
// 1 - the more code rmcgen generate, the more work is necessary
// for any maintainance
// 2 - the rmcgen-code is a range, where the RMC user (=programmer)
// lays his hands on, so he should only see what he is able to
// understand without researching the library - in best case nothings
// 3 - finding the queried object is a important step, checking it's
// validity is mor important later - so we will change this process
// and we can do, if rmcgen is not affected by it
// "nClass" is necessary to determine the type of the object,
// because the object is typeless in the map
TRmcResult nReturnVal = m_oObjectFactory.Call( rtNode.nClass,
rtNode.pObject,
nMethode,
rnSize,
rpcData,
rnVisum );
// we are ready, and we don't need the object for this call anymore
rtNode.nUseCount--;
// we retranslate the changeable parameters for the transport
// back to the client
rnSize = htonl( rnSize );
//- rnVisum = htonl( rnVisum );
nReturnVal = htonl( nReturnVal );
return nReturnVal;
} // TRmcResult CRmcServer::RmcCall(TRmcObject ..
TRmcResult CRmcServer::RmcRelease(TRmcObject nObject, TRmcVisum nVisum)
{
TRACE("RmcServer::RmcRelease\n")
return htonl ( m_oObjectFactory.ObjectKill(nObject, nVisum) );
} // TRmcResult CRmcServer::RmcRelease(TRmcObject ..
/***************************************************************************
*
* protected Methods
*
*/
void CRmcServer::Initialize()
{
TRACE("RmcServer::Initialize\n")
static char acState[256];
for (int i = 0; i < sizeof(acState); i++)
{
acState[i] = (char) i;
}
#ifdef WIN32
// currently no solution
#else
initstate(0xdeadbeef, acState, sizeof(acState));
setstate((char*)acState);
#endif // else WIN32
} // void CRmcServer::Initialize()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Moss-devel] CVS: moss/rmc/src/Server Makefile.am,NONE,1.1 RmcServer.cxx,NONE,1.1,
Alexander Feder <address@hidden> <=
- Prev by Date:
[Moss-devel] CVS: moss/rmc/src/Transport Makefile.am,NONE,1.1 TransportClient.cxx,NONE,1.1 TransportClientHandler.cxx,NONE,1.1 TransportServer.cxx,NONE,1.1
- Next by Date:
[Moss-devel] CVS: moss/rmc/src/Transport/SSL Makefile.am,NONE,1.1 TransportClientSSLSocket.cxx,NONE,1.1 TransportServerSSLSocket.cxx,NONE,1.1
- Previous by thread:
[Moss-devel] CVS: moss/rmc/src/Transport Makefile.am,NONE,1.1 TransportClient.cxx,NONE,1.1 TransportClientHandler.cxx,NONE,1.1 TransportServer.cxx,NONE,1.1
- Next by thread:
[Moss-devel] CVS: moss/rmc/src/Transport/SSL Makefile.am,NONE,1.1 TransportClientSSLSocket.cxx,NONE,1.1 TransportServerSSLSocket.cxx,NONE,1.1
- Index(es):