|
1 | | ---- |
2 | | -title: "Platform::Agile Class | Microsoft Docs" |
3 | | -ms.custom: "" |
4 | | -ms.date: "12/30/2016" |
| 1 | +--- |
| 2 | +title: "Platform::Agile Class | Microsoft Docs" |
| 3 | +ms.custom: "" |
| 4 | +ms.date: "12/30/2016" |
5 | 5 | ms.prod: "windows-client-threshold" |
6 | | -ms.technology: "" |
7 | | -ms.reviewer: "" |
8 | | -ms.suite: "" |
9 | | -ms.tgt_pltfrm: "" |
10 | | -ms.topic: "language-reference" |
11 | | -f1_keywords: |
12 | | - - "agile/Platform::Agile" |
13 | | -dev_langs: |
14 | | - - "C++" |
15 | | -helpviewer_keywords: |
16 | | - - "Platform::Agile" |
17 | | -ms.assetid: e34459a9-c429-4c79-97fd-030c43ca4155 |
18 | | -caps.latest.revision: 4 |
19 | | -author: "ghogen" |
20 | | -ms.author: "ghogen" |
21 | | -manager: "ghogen" |
22 | | ---- |
23 | | -# Platform::Agile Class |
| 6 | +ms.technology: "" |
| 7 | +ms.reviewer: "" |
| 8 | +ms.suite: "" |
| 9 | +ms.tgt_pltfrm: "" |
| 10 | +ms.topic: "language-reference" |
| 11 | +f1_keywords: |
| 12 | + - "agile/Platform::Agile" |
| 13 | +dev_langs: |
| 14 | + - "C++" |
| 15 | +helpviewer_keywords: |
| 16 | + - "Platform::Agile" |
| 17 | +ms.assetid: e34459a9-c429-4c79-97fd-030c43ca4155 |
| 18 | +caps.latest.revision: 4 |
| 19 | +author: "ghogen" |
| 20 | +ms.author: "ghogen" |
| 21 | +manager: "ghogen" |
| 22 | +--- |
| 23 | +# Platform::Agile Class |
24 | 24 | Represents an object that has a MashalingBehavior=Standard as an agile object, which greatly reduces the chances for runtime threading exceptions. The `Agile<T>` enables the non-agile object to call, or be called from, the same or a different thread. For more information, see [Threading and Marshaling](../cppcx/threading-and-marshaling-c-cx.md). |
25 | 25 |
|
26 | 26 | ## Syntax |
27 | 27 |
|
28 | 28 | ```scr |
29 | 29 | |
30 | 30 | template <typename T> |
31 | | - class Agile |
32 | | -; |
| 31 | +class Agile; |
33 | 32 | ``` |
34 | 33 |
|
35 | 34 | #### Parameters |
@@ -79,6 +78,177 @@ template <typename T> |
79 | 78 | **Namespace:** Platform |
80 | 79 |
|
81 | 80 | **Header:** agile.h |
| 81 | + |
| 82 | + # Agile::Agile Constructor |
| 83 | +Initializes a new instance of the Agile class. |
| 84 | + |
| 85 | +## Syntax |
| 86 | + |
| 87 | +```cpp |
| 88 | + |
| 89 | + Agile(); |
| 90 | + |
| 91 | +Agile(T^ object); |
| 92 | + |
| 93 | +Agile(const Agile<T>& object); |
| 94 | + |
| 95 | +Agile(Agile<T>&& object); |
| 96 | + |
| 97 | +``` |
| 98 | + |
| 99 | +#### Parameters |
| 100 | + `T` |
| 101 | + A type specified by the template typename parameter. |
| 102 | + |
| 103 | + `object` |
| 104 | + In the second version of this constructor, an object used to initialize a new Agile instance. In the third version, the object that is copied to the new Agile instance. In the fourth version, the object that is moved to the new Agile instance. |
| 105 | + |
| 106 | +## Remarks |
| 107 | + The first version of this constructor is the default constructor. The second version initializes new Agile instance class from the object specified by the `object` parameter. The third version is the copy constructor. The fourth version is the move constructor. This constructor cannot throw exceptions. |
| 108 | +
|
| 109 | + # Agile::~Agile Destructor |
| 110 | +Destroys the current instance of the Agile class. |
| 111 | + |
| 112 | +## Syntax |
| 113 | + |
| 114 | +```cpp |
| 115 | + |
| 116 | +~Agile(); |
| 117 | +``` |
| 118 | + |
| 119 | +## Remarks |
| 120 | + This destructor also releases the object represented by the current Agile object. |
| 121 | + |
| 122 | +# Agile::Get Method |
| 123 | +Returns a handle to the object that is represented by the current Agile object. |
| 124 | + |
| 125 | +## Syntax |
| 126 | + |
| 127 | +```cpp |
| 128 | + |
| 129 | + T^ Get() const |
| 130 | +; |
| 131 | +``` |
| 132 | + |
| 133 | +## Return Value |
| 134 | + A handle to the object that is represented by the current Agile object. |
| 135 | + |
| 136 | + The type of the return value is actually an undisclosed internal type. A convenient way to hold the return value is to assign it to a variable that is declared with the **auto** type deduction keyword. For example, `auto x = myAgileTvariable->Get();`. |
| 137 | + |
| 138 | +# Agile::GetAddressOf Method |
| 139 | +Reinitializes the current Agile object, and then returns the address of a handle to an object of type `T`. |
| 140 | + |
| 141 | +## Syntax |
| 142 | + |
| 143 | +```cpp |
| 144 | + |
| 145 | +T^* GetAddressOf() |
| 146 | +throw(); |
| 147 | +``` |
| 148 | + |
| 149 | +#### Parameters |
| 150 | + `T` |
| 151 | + A type specified by the template typename parameter. |
| 152 | + |
| 153 | +## Return Value |
| 154 | + The address of a handle to an object of type `T`. |
| 155 | + |
| 156 | +## Remarks |
| 157 | + This operation releases the current representation of a object of type `T`, if any; reinitializes the Agile object's data members; acquires the current threading context; and then returns the address of a handle-to-object variable that can represent a non-agile object. To cause an Agile class instance to represent an object, use the assignment operator ([Agile::operator=](../cppcx/agile-operator-assign-operator.md)) to assign the object to the Agile class instance. |
| 158 | + |
| 159 | +# Agile::GetAddressOfForInOut Method |
| 160 | +Returns the address of a handle to the object represented by the current Agile object. |
| 161 | + |
| 162 | +## Syntax |
| 163 | + |
| 164 | +```cpp |
| 165 | + |
| 166 | +T^* GetAddressOfForInOut() throw(); |
| 167 | + |
| 168 | +``` |
| 169 | + |
| 170 | +#### Parameters |
| 171 | + `T` |
| 172 | + A type specified by the template typename parameter. |
| 173 | + |
| 174 | +## Return Value |
| 175 | + The address of a handle to the object represented by the current Agile object. |
| 176 | + |
| 177 | +## Remarks |
| 178 | + This operation acquires the current threading context and then returns the address of a handle to the underlying the object. |
| 179 | + |
| 180 | +# Agile::Release Method |
| 181 | +Discards the current Agile object's underlying object and context. |
| 182 | + |
| 183 | +## Syntax |
| 184 | + |
| 185 | +```cpp |
| 186 | + |
| 187 | +void Release() throw(); |
| 188 | + |
| 189 | +``` |
| 190 | + |
| 191 | +## Remarks |
| 192 | + The current Agile object's underlying object and context are discarded, if they exist, and then the value of the Agile object is set to null. |
| 193 | + |
| 194 | +# Agile::operator-> Operator |
| 195 | +Retrieves a handle to the object represented by the current Agile object. |
| 196 | + |
| 197 | +## Syntax |
| 198 | + |
| 199 | +```cpp |
| 200 | + |
| 201 | +T^ operator->() |
| 202 | +const throw(); |
| 203 | +``` |
| 204 | + |
| 205 | +## Return Value |
| 206 | + A handle to the object represented by the current Agile object. |
| 207 | + |
| 208 | + This operator actually returns an undisclosed internal type. A convenient way to hold the return value is to assign it to a variable that is declared with the **auto** type deduction keyword. |
| 209 | + |
| 210 | +# Agile::operator= Operator |
| 211 | +Assigns the specified object to the current Agile object. |
| 212 | + |
| 213 | +## Syntax |
| 214 | + |
| 215 | +```cpp |
| 216 | + |
| 217 | + Agile<T> operator=( |
| 218 | + T^ object |
| 219 | +) throw(); |
| 220 | + |
| 221 | + Agile<T> operator=( |
| 222 | + const Agile<T>& object |
| 223 | +) throw(); |
| 224 | + |
| 225 | + Agile<T> operator=( |
| 226 | + Agile<T>&& object |
| 227 | +) throw(); |
| 228 | + |
| 229 | + T^ operator=( |
| 230 | + IUnknown* lp |
| 231 | +) throw(); |
| 232 | + |
| 233 | +``` |
| 234 | + |
| 235 | +#### Parameters |
| 236 | + `T` |
| 237 | + The type specified by the template typename. |
| 238 | + |
| 239 | + `object` |
| 240 | + The object or handle to an object that is copied or moved to the current Agile object. |
| 241 | + |
| 242 | + `lp` |
| 243 | + The IUnknown interface pointer of a object. |
| 244 | + |
| 245 | +## Return Value |
| 246 | + A handle to an object of type `T` |
| 247 | + |
| 248 | +## Remarks |
| 249 | + The first version of the assignment operator copies a handle to a reference type to the current Agile object. The second version copies a reference to an Agile type to the current Agile object. The third version moves an Agile type to the current Agile object. The fourth version moves a pointer to a COM object to the current Agile object. |
82 | 250 |
|
| 251 | + The assignment operation automatically persists the context of the current Agile object. |
| 252 | + |
83 | 253 | ## See Also |
84 | 254 | [Platform Namespace](platform-namespace-c-cx.md) |
0 commit comments