GPSTK日志五 TimeTag

6 篇文章 0 订阅

    文章转自:http://blog.csdn.net/liuci3234/article/details/9388427

【正文部分】

        看完 commontime 的定义又回过头来看了下 TimeTag 这个类,这是一个具体时间系统的基类,所以楼主觉得有必要仔细的介绍下里面的方法。注意 commontime 并不是 TimeTag 的子类,之所以要先介绍它,应为它是所有时间系统转转的一个中间过程。转换的实现由 TimeTag 的虚函数定义的以下两个方法完成:  

      virtual CommonTime convertToCommonTime() const       
         throw( gpstk::InvalidRequest ) = 0;     
           //对应时间系统转换为CommonTime 
      
      virtual void convertFromCommonTime( const CommonTime& ct ) 
         throw( gpstk::InvalidRequest ) = 0;
     // CommonTime  转换为对应时间系统

        这里顺道对上面函数的几个基本语法注明下吧, 函数后面的 const 意味着函数返回值是不可修改的,throw 表示该函数跑出的异常,

      func() throw(type) ,会抛出某种异常

      func() throw(),不会抛出

      func() throw(...),可能是任何类型的异常

      函数后面 = 0;表示这是一个纯虚函数,没有具体的函数体,只有一个函数声名,函数体留给它的派生类来实现,而且,这个类的派生类必须重载全部纯虚函数(重载的时候不能指定为纯虚)。 可以理解为表示将这个函数指针设置为0。

       两个纯虚打印函数,  

      virtual std::string printf( const std::string& fmt ) const throw( gpstk::StringUtils::StringException ) = 0;
      virtual std::string printError( const std::string& fmt ) const throw( gpstk::StringUtils::StringException ) = 0;

       virtual void scanf( const std::string& str,  const std::string& fmt )
 throw( gpstk::InvalidRequest,  gpstk::StringUtils::StringException ); 
   // This function sets this object to the time stored in the given 这个具体的结合实例来说

     typedef std::map< char, std::string> IdToValue;  // 定义map容器

     static void getInfo( const std::string& str, const std::string& fmt,IdToValue& info )
 throw( gpstk::StringUtils::StringException ); 
 //这个是 scanf 成员函数实现的具体方法,在sacnf中需要调用它

      virtual bool setFromInfo( const IdToValue& info )   throw() = 0;   // 将对象按 IdToValue 格式进行设置
      virtual std::string getPrintChars() const throw() = 0;     // 这个留在下一篇讲吧
      virtual std::string getDefaultFormat() const throw() = 0;   // 返回一个打印格式的字符串的 

      virtual bool isValid() const throw() = 0;   // 检查对象的成员是否有效

      virtual void reset() throw() = 0;   // 将对象设置为默认值

        virtual std::string asString() const throw( gpstk::StringUtils::StringException )    // 这个函数前面已经说过
                  { return printf( getDefaultFormat() ); }


         /// Hey, it's an implicit casting operator!  Basically just a lazy
         /// way to get at convertToCommonTime().
       virtual operator CommonTime() const throw(InvalidRequest)  { return convertToCommonTime(); }   //看下原文注释这个没什么好说的
 

         /// This returns the regular expression prefix that is used when 
         /// searching for integer specifiers.
      static inline std::string getFormatPrefixInt()
      { return "%[ 0-]?[[:digit:]]*"; }
      
         /// This returns the regular expression prefix that is used when
         /// searching for float specifiers.
      static inline std::string getFormatPrefixFloat()     
      { return getFormatPrefixInt() + "(\\.[[:digit:]]+)?"; }     // 以上两个均与正则表达式有关

      static inline std::string getError()    //返回一个默认错误信息
      { return "ErrorBadTime"; }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值