Upload
nodin
View
40
Download
0
Embed Size (px)
DESCRIPTION
C ++/ CX の紹介. めとべや 東京 #2 2013/10/12 Sat 遥佐保(はるか・さお). 自己紹介. @ hr_sao コミュニティ Room metro (大阪) ExceptionalC ++ 読書会(大阪 ) Microsoft MVP for Client App Dev [ Jan,2010 - Dec,2013]. Visual Studio 2013 の C++ の世界. Store apps. Desktop. DirectX apps for phone. MFC. WRL. WTL. DirectX. - PowerPoint PPT Presentation
Citation preview
C++/CX の紹介めとべや東京 #22013/10/12 Sat
遥佐保(はるか・さお)
@hr_sao
コミュニティ• Room metro (大阪)• ExceptionalC++ 読書会(大阪)Microsoft MVP for Client App Dev
[Jan,2010 - Dec,2013]
自己紹介
Store apps Desktop
Visual Studio 2013 の C++ の世界
Windows8
DirectX
Windows Phone8
DirectX apps for phone
XAML for C++
WRL WTLMFC
C++ 言語の拡張 (/ZW オプション )
Visual C++ コンパイラの拡張機能です C++11 対応 C++/CLI のサブセットに相当しますWindows ストアアプリの作成用 ※ストアアプリ以外でも例外的に利用可能
C++/CXCLI はマネージ
CX はネイティブ
Windows Runtime APIs
Windows Kernel Services
Windows Runtime APIs
Communication & Data
Devices & Printing
Graphics & Media
Application Model
Application binary Interface (ABI)
• アプリケーションバイナリインタフェース (ABI)• バイナリレベルの互換が保障
• ABI を利用して API を提供
OS process
WindowsStoreApps 環境 (UI XAML)http://msdn.microsoft.com/ja-jp/library/windows/apps/jj160326.aspx
Windows Kernel Services
Windows Runtime Win32 and COM CRT STL PPL
App container ( package manifest )
UI controls( XAML )
相互互換のためのC++ 言語拡張機能( 中間の変換無し ) C++ 実装クラス
( ネイティブ )VS プロジェクト
テンプレートC++/CX
混ぜるな危険!
• 型違いによるコンパイルエラー• ネイティブ C++ 型を public メンバとするア
プリケーション設計
学習してもつまづく部分が多いC++ という言語を知っているがゆえに、ストア
用設計に頭が切り替わりにくい
動く環境を知らないで作ると…
public ref class MainPage sealed{
public:
MainPage();
private:
pplx::task<void> get_http_request();
};
例) Web から情報をとってきたい#include <pplx.h>#include <http_client.h>などインクルードした
い
using namespace concurrency;using namespace pplx;using namespace web::http::client;
など宣言したい
MainPage.xaml.cpp に通信処理をまるっと入れようとしたのが間違い
ネイティブで処理できる処理と、Windows ストアアプリの処理の境界は?
例)何がダメだったのか?
• C++/CX は Visual C++ コンパイラの拡張機能
• Windows Runtime API は ABI 互換• C++ ネイティブと C++/CX の役割は異なる
public 部分→ Platform 名前空間
• 情報は多いが、実際には慣れが必要
C++/CX WinRT まとめ
補足 C++11 PPL Taskppl::task<int> t([](){ return (1);});
ppl::task<int> t2 = t.then ([](int n){ return( n+1 );});
ppl::task<int> t3 = t.then ([](int n){ return( n+1 );});int result = t.get()
同じ型
.then の return は 次のタスクに引き継がれる
補足 C++/CX - concurrency::taskconcurrency::task<int> t([](){ return (1);});
concurrency::task<int> t2 = t.then ([](int n){ return( n+1 );});
concurrency::task<int> t3 = t.then ([](int n){ return( n+1 );});int result = t.get()
つなげて書くとtask<int> t([](){ return 1;}).then([](int n){ return n+1;}).then([](int n){ return n+1;}).then([](int n){ return n+1;})
Task のつなぎ方task<int> tasks[] = {t1, t2, t3};auto taskResult = when_all (begin(tasks), end(tasks)) .then([](std::vector<int> results) { (t1 && t2 && t3).then // 全部終わったあと
task<int> tasks[] = {t1, t2, t3};auto taskResult = when_any (begin(tasks), end(tasks)) .then([](int result) {
(t1 || t2 || t3).then // どれか終わったあと
C++/CX リファレンスサイトhttp://cppcx.azurewebsites.net
2013/10/26( 土 ) Room metro 大阪
2013/11/2( 土 ) C++ 例外安全 Day
ありがとうございました!