powerpoint presentation › ... › edm › images › keynote2_visualstudio2012_se… · •...
TRANSCRIPT
![Page 1: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/1.jpg)
![Page 2: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/2.jpg)
![Page 3: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/3.jpg)
![Page 4: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/4.jpg)
Optimized for Windows Store
![Page 5: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/5.jpg)
![Page 6: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/6.jpg)
![Page 7: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/7.jpg)
ref class ref new ^
collection.h
PPL Tasks Library
property
event
delegate
partial class
![Page 8: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/8.jpg)
Defining public ref class Person {
public:
Person(String^ name);
void Greet(Person^ other);
private:
void SetPassword(const std::wstring& passwd);
std::wstring pwd;
};
Using Person^ p = ref new Person(“John Surname”);
p->Greet(ref new Person(“Jim Surname”);
• Public methods restricted to WinRT typed
parameters
• Private/internal methods can use any legal C++
type parameters
![Page 9: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/9.jpg)
• Handle (^) is a pointer to a Windows Runtime object for
which the compiler performs automatic reference
counting
• ref new instantiates or activates a Windows Runtime class
Person^ p; { Person^ p2 = ref new Person(); // refcount = 1 p2->Name = “John”; // refcount = 1 p = p2; // refcount = 2 } // refcount = 1 p = nullptr; // refcount = 0; ~Person()
![Page 10: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/10.jpg)
8. String^ str6(str1); 9. String^ str7 = str2; // using wchar_t’s 10.wchar_t msg[] = L"Test"; 11.String^ str8 = ref new
String(msg); // using wstring’s 12.std::wstring wstr1(L"Test"); 13.String^ str9 = ref new
String(wstr1.c_str()); //init wstring from String^ 14.std::wstring wstr(str1->Data());
• Platform::String^ as a boundary type
• Immutable
• Interop with std::wstring and wchar_t*
1. using namespace Platform; 2. #include <string>
// init String^ from literal 3. String^ str1 = "Test"; // no need for L 4. String^ str2("Test"); 5. String^ str3 = L"Test"; 6. String^ str4(L"Test"); 7. String^ str5 = ref new
String(L"Test");
![Page 11: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/11.jpg)
Vector Map
VectorView MapView
IVector
IVectorView
IObservable
Vector
IMap
IMapView
IObservable
Map
IIterable
IIterator
Windows Runtime
Interfaces
Concrete collection
types for C++
![Page 12: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/12.jpg)
Producing and Consuming
1. #include <vector>
2. #include <algorithm>
3. #include <utility>
4. #include <collection.h>
5. namespace WFC = Windows::Foundation::Collections;
6.
7. WFC::IVectorView<int>^ Producer() {
8. std::vector<int> v;
9. v.push_back(1);
10. v.push_back(2);
11.
12. return ref new Platform::VectorView<int>(std::move(v));
13. }
14.
15. int sum = 0;
16. WFC::IVectorView<int>^ v = Producer();
17. std::for_each(begin(v), end(v), [&sum](int i) { sum += i; });
• WinRT objects are
STL friendly
• WinRT collections
are STL friendly
• STL containers are
the backing
stores for C++
collections
![Page 13: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/13.jpg)
PPL tasks simplify async Windows Runtime programming
StorageFolder^ item = KnownFolders::PicturesLibrary; StorageFileRetrievalOperation^ createStorageFileOp = item->CreateFileAsync("myfile.txt"); createStorageFileOp->Completed = ref new AsyncOperationCompletedHandler<StorageFile^>( [](IAsyncOperation<StorageFile^>^ asyncOp) { StorageFile^ storageFile = asyncOp->GetResults(); }); createStorageFileOp->Start();
StorageFolder^ item = KnownFolders::PicturesLibrary; task<StorageFile^> (item->CreateFileAsync("myfile.txt")).then([](StorageFile^ createdFile) {});
Without PPL tasks
With PPL tasks
![Page 14: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/14.jpg)
• Properties: provide a flexible mechanism to read, write, or
compute the value of a private field
• Delegates: A type that safely encapsulates a method,
similar to a function pointer in C and C++.
• Events: enable a class or object to notify other classes or
objects when something of interest occurs
![Page 15: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/15.jpg)
![Page 16: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/16.jpg)
![Page 17: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/17.jpg)
![Page 18: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/18.jpg)
![Page 19: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/19.jpg)
![Page 20: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/20.jpg)
C++ WinRT Component
Extension SDKs
![Page 21: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/21.jpg)
![Page 22: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/22.jpg)
![Page 23: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/23.jpg)
![Page 24: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/24.jpg)
http://www.microsoft.com/visualstudio/en-us
http://blogs.msdn.com/b/jasonz/
http://www.facebook.com/visualstudio
http://twitter.com/#!/visualstudio
Somasegar’s Blog http://blogs.msdn.com/b/somasegar/
![Page 25: PowerPoint Presentation › ... › edm › images › Keynote2_VisualStudio2012_Se… · • Handle (^) is a pointer to a Windows Runtime object for which the compiler performs automatic](https://reader033.vdocuments.us/reader033/viewer/2022060404/5f0ed3247e708231d4411ea8/html5/thumbnails/25.jpg)