| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 #ifndef MYAPI_H_ | |
| 6 #define MYAPI_H_ | |
| 7 | |
| 8 #include "cc/myapi_service.h" | |
| 9 | |
| 10 class MyObject; | |
| 11 | |
| 12 class MyApi { | |
| 13 public: | |
| 14 static MyApi create() { | |
| 15 MyApiService::setup(); | |
| 16 int api = MyApiService::create(); | |
| 17 return MyApi(api); | |
| 18 } | |
| 19 | |
| 20 void destroy() { | |
| 21 MyApiService::destroy(api_); | |
| 22 MyApiService::tearDown(); | |
| 23 } | |
| 24 | |
| 25 inline MyObject foo(); | |
| 26 | |
| 27 private: | |
| 28 int api_; | |
| 29 | |
| 30 explicit MyApi(int api) : api_(api) { } | |
| 31 }; | |
| 32 | |
| 33 class MyObject { | |
| 34 public: | |
| 35 void funk(MyObject o) { | |
| 36 // TODO(kasperl): Assert that o is from same api as 'this'. | |
| 37 MyApiService::MyObject_funk(api_, id_, o.id_); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 int api_; | |
| 42 int id_; | |
| 43 | |
| 44 MyObject(int api, int id) : api_(api), id_(id) { } | |
| 45 | |
| 46 friend class MyApi; | |
| 47 }; | |
| 48 | |
| 49 inline MyObject MyApi::foo() { | |
| 50 int id = MyApiService::foo(api_); | |
| 51 return MyObject(api_, id); | |
| 52 } | |
| 53 | |
| 54 #endif // MYAPI_H_ | |
| OLD | NEW |