第二人生的源码分析(七十四)LLStartUp类维护启动状态机
2008-05-28 21:33
537 查看
像第二人生这么复杂的大型程序,从你双击程序开始,直到它运行到真正的图形界面出来为止,经历的过程是漫长而复杂的,总共经历的状态就有22个,意思就是说每个状态里只会做一件事情,如果做那件事情不成功就会运行失败。那么第二人生采用这种状态机有什么好处呢?在我看来采用状态机的好处是利于把复杂的过程分解,利于把漫长的状态提示给用户,利于开发人员调试和分析,利于程序跳转到不同的状态。下面就来先看这个类的声明代码:
#001 class LLStartUp
#002 {
#003 public:
判断是否可以全屏运行程序。
#004 static bool canGoFullscreen();
#005 // returns true if we are far enough along in startup to allow
#006 // going full screen
#007
设置状态变量。
#008 // Always use this to set gStartupState so changes are logged
#009 static void setStartupState( S32 state );
获取当前状态变量。
#010 static S32 getStartupState() { return gStartupState; };
#011
让游览器显示URL串的内容。
#012 static bool dispatchURL();
#013 // if we have a SLURL or sim string ("Ahern/123/45") that started
#014 // the viewer, dispatch it
#015
保存SL的URL命令。
#016 static std::string sSLURLCommand;
#017 // *HACK: On startup, if we were passed a secondlife://app/do/foo
#018 // command URL, store it for later processing.
#019
#020 protected:
保存启动运行状态。
#021 static S32 gStartupState; // Do not set directly, use LLStartup::setStartupState
#022 };
下面再来分析几个函数的实现代码:
#001 bool LLStartUp::canGoFullscreen()
#002 {
只有大于STATE_WORLD_INIT状态,也就是渲染第二人生时才允许全屏显示。
#003 return gStartupState >= STATE_WORLD_INIT;
#004 }
调用这个函数来保存不同时候的状态,并且把这个状态输出到调试窗口,方便开发人员查找出错的原因。
#001 // static
#002 void LLStartUp::setStartupState( S32 state )
#003 {
#004 llinfos << "Startup state changing from " << gStartupState << " to " << state << llendl;
#005 gStartupState = state;
#006 }
#001 class LLStartUp
#002 {
#003 public:
判断是否可以全屏运行程序。
#004 static bool canGoFullscreen();
#005 // returns true if we are far enough along in startup to allow
#006 // going full screen
#007
设置状态变量。
#008 // Always use this to set gStartupState so changes are logged
#009 static void setStartupState( S32 state );
获取当前状态变量。
#010 static S32 getStartupState() { return gStartupState; };
#011
让游览器显示URL串的内容。
#012 static bool dispatchURL();
#013 // if we have a SLURL or sim string ("Ahern/123/45") that started
#014 // the viewer, dispatch it
#015
保存SL的URL命令。
#016 static std::string sSLURLCommand;
#017 // *HACK: On startup, if we were passed a secondlife://app/do/foo
#018 // command URL, store it for later processing.
#019
#020 protected:
保存启动运行状态。
#021 static S32 gStartupState; // Do not set directly, use LLStartup::setStartupState
#022 };
下面再来分析几个函数的实现代码:
#001 bool LLStartUp::canGoFullscreen()
#002 {
只有大于STATE_WORLD_INIT状态,也就是渲染第二人生时才允许全屏显示。
#003 return gStartupState >= STATE_WORLD_INIT;
#004 }
调用这个函数来保存不同时候的状态,并且把这个状态输出到调试窗口,方便开发人员查找出错的原因。
#001 // static
#002 void LLStartUp::setStartupState( S32 state )
#003 {
#004 llinfos << "Startup state changing from " << gStartupState << " to " << state << llendl;
#005 gStartupState = state;
#006 }
相关文章推荐
- 第二人生的源码分析(七十四)LLStartUp类维护启动状态机
- 第二人生的源码分析(七十四)LLStartUp类维护启动状态机
- 蔡军生先生第二人生的源码分析(七十四)LLStartUp类维护启动状态机
- 蔡军生先生第二人生的源码分析(七十五)启动状态详细说明
- 第二人生的源码分析(七十五)启动状态详细说明
- 第二人生的源码分析(七十五)启动状态详细说明
- 第二人生的源码分析(七十五)启动状态详细说明
- 第二人生的源码分析(九十五)LLCheckBoxCtrl类实现复选按钮 - 大坡3D软件开发 - CSDNBlog
- 蔡军生先生第二人生的源码分析(8)登录状态界面显示
- 第二人生的源码分析(六十一)LLCurl类实现libcurl库封装
- 蔡军生先生第二人生的源码分析(五十一)纹理图片的格式之LLImageBase类
- 蔡军生先生第二人生的源码分析(六十七)LLXMLNode使用Expat库打开文件
- 第二人生的源码分析(六十七)LLXMLNode使用Expat库打开文件
- 蔡军生先生第二人生的源码分析(六十八)LLXMLNode使用Expat库分析XML文件
- 第二人生的源码分析(九十六)LLMenuItemGL实现菜单的显示
- 第二人生的源码分析(六十一)LLCurl类实现libcurl库封装
- 第二人生的源码分析(六十七)LLXMLNode使用Expat库打开文件
- 蔡军生先生第二人生的源码分析(五十三) 纹理图片的格式之LLImageJ2C类
- 蔡军生先生第二人生的源码分析(六十一)LLCurl类实现libcurl库封装
- 第二人生的源码分析(九十六)LLMenuItemGL实现菜单的显示