Wouldn't it be a good idea to create an object oriented interface to
system services, libraries etc ? Now should be the right time to do this,
before Vsta grows too much.
What are the possibilities to also port g++ to the Vsta environment ?
For example, most servers use quite a lot of common code. How about making a
class for this ?
Define a basic class for client process message management. This class would
handle the switch-statement, and then call virtual member functions
depending on the message type.
It is now quite easy to override the function whose behaviour
you want to change. This is also a better solution than a C-mechanism
where you register call-back functions.
There is some overhead as functions will be called indirectly through pointers
instead of code being executed inline in the switch statement, but I really
think it is minor.
An example how it could look:
class ServerBase {
public:
ServerBase(const char *namerName, int numUsers=16);
void MainLoop();
protected:
virtual void Connect(msg&); // New client
virtual void Dup(msg&, file&); // Dup during exec
virtual void Abort(msg&, file&); // Aborted operation
virtual void Disconnect(msg&, file&); // Client done
virtual void Open(msg&, file&); // Look up file from directory
virtual void Read(msg&, file&); // Read file
virtual void AbsRead(msg&, file&); // Set position, then read
virtual void Write(msg&, file&); // Write file
virtual void AbsWrite(msg&, file&); // Set position, then write
virtual void Seek(msg&, file&); // Set new file position
virtual void Stat(msg&, file&); // Tell about file
virtual void Wstat(msg&, file&); // Set stuff on file
virtual void Remove(msg&, file&); // Get rid of file
virtual void Fid(msg&, file&); // File id.
virtual void Rename(msg&, file&=; // Rename file/dir
private:
port_name nm;
hash* filehash; // Map of all active users
port_t port; // Port we receive contacts through
};
This class should probably be split into two, where the base class doesn't
handle hashing of clients.
------
Distinct Systems
Lars Pensjo
Received on Wed Aug 17 00:32:53 1994
This archive was generated by hypermail 2.1.8 : Wed Sep 21 2005 - 21:04:28 PDT