Google Talkのライブラリのソース公開

ITmedia エンタープライズGoogle TalkAPIソースコードのリリース
http://www.itmedia.co.jp/enterprise/articles/0601/18/news003.html


https://sourceforge.net/projects/libjingle/からダウンロードできます。
Googleのコードを読むといえば、JavaScriptは読んだことがありますがC++のコードは初めて。
Mona以外で他人の書いたC++のコードを読むのはなかなかない機会なので読んでみようと思います。


ぱっと見た感じの感想を適当に列挙

  • 拡張子は .ccなのね。
  • namespaceちゃんと使っている
  • 初期化リストちゃんと使っている
  • メンバー変数名は 後ろに_をつけている
  • defineよりもconst使っている
  • bytebuffer.ccとか、僕も作ったなぁとか。
  • グローバル変数は g_xxxx
  • thread.ccはMona版も書いてみようかな?
  • 例外使ってない?
  • this->は省略傾向。そのかわりに _か。
  • インデントは 2 * space 。(これはGoogle 標準?)


ということで、なかなか好印象ですね。
コーディング規約とかあるんでしょうか?>中の人

おまけ

Singletonっぽいのキタコレ

MessageQueueManager* MessageQueueManager::instance_;

MessageQueueManager* MessageQueueManager::Instance() {
  // Note: This is not thread safe, but it is first called before threads are
  // spawned.
  if (!instance_)
    instance_ = new MessageQueueManager;
  return instance_;
}