instance 函数

要在实际工厂中完成插入,必须创建 instance 函数(在 <env>OS.cpp 中定义),以将指针返回实际操作系统工厂。 instance 方法用于创建单一 OMOSFactory 实例。其定义如下所示:

static OMOSFactory* instance();

例如,在 VxWorks 中,声明如下所示:

OMOSFactory* OMOSFactory::instance()
{
   static VxOSFactory theFactory;
   return &theFactory;
}

反馈