Dynamic View Services > Implementing a Dynamic View Server and its Components > Overview > Subclassing a Dynamic View Server
 
Subclassing a Dynamic View Server
By default, initializing a dynamic view server implicitly creates an instance of IlsMvServer. You can decide to subclass the view server type. If you do, you must also define one or more new server factory classes as illustrated in the following code:
#include <ilserver/mvserver.h>
 
class MyServer : public IlsMvServer
{
public:
MyServer(int threadMode):IlsMvServer(threadMode){}
}
 
class MyServerFactory : public IlsMvServerFactory
{
protected:
virtual IlsMvServer* newInstance(int threadMode)
{ return new MyServer(threadMode);}
};
You must construct an instance of the factory class and declare it as the server singleton factory, like this:
int main(int argc, char** argv)
{
MyServerFactory* serverFactory=new MyServerFactory();
 
IlsMvServerFactory::SetSingleton(serverFactory);
if (!IlbMvProcess::Initialize(argc,argv)
       || !IlsMvServer::Initialize(argc,argv)){
...
}
...
}
Notice that the function IlsMvServerFactory::SetSingleton is called before the function IlsMvServer::Initialize and that the destruction of serverFactory is implicitly done by Rogue Wave® Server at exit, unless you set this factory to the null pointer before.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.