Flutter iOS Embedder
flutter::ConnectionCollection Class Reference

Maintains a current integer assigned to a name (connections). More...

#include <connection_collection.h>

Public Types

typedef int64_t Connection
 

Public Member Functions

Connection AquireConnection (const std::string &name)
 
std::string CleanupConnection (Connection connection)
 

Static Public Member Functions

static bool IsValidConnection (Connection connection)
 
static Connection MakeErrorConnection (int errCode)
 

Static Public Attributes

static const Connection kInvalidConnection = 0
 

Detailed Description

Maintains a current integer assigned to a name (connections).

Definition at line 15 of file connection_collection.h.

Member Typedef Documentation

◆ Connection

Definition at line 17 of file connection_collection.h.

Member Function Documentation

◆ AquireConnection()

ConnectionCollection::Connection flutter::ConnectionCollection::AquireConnection ( const std::string &  name)

Definition at line 12 of file connection_collection.mm.

12  {
13  Connection nextConnection = ++counter_;
14  connections_[name] = nextConnection;
15  return nextConnection;
16 }

◆ CleanupConnection()

std::string flutter::ConnectionCollection::CleanupConnection ( ConnectionCollection::Connection  connection)
Returns
the name of the channel when cleanup is successful, otherwise the empty string.

Definition at line 18 of file connection_collection.mm.

18  {
19  if (connection > 0) {
20  std::string channel;
21  for (auto& keyValue : connections_) {
22  if (keyValue.second == connection) {
23  channel = keyValue.first;
24  break;
25  }
26  }
27  if (channel.length() > 0) {
28  connections_.erase(channel);
29  return channel;
30  }
31  }
32  return "";
33 }

◆ IsValidConnection()

bool flutter::ConnectionCollection::IsValidConnection ( ConnectionCollection::Connection  connection)
static

Definition at line 35 of file connection_collection.mm.

35  {
36  return connection > 0;
37 }

◆ MakeErrorConnection()

ConnectionCollection::Connection flutter::ConnectionCollection::MakeErrorConnection ( int  errCode)
static

Definition at line 39 of file connection_collection.mm.

39  {
40  if (errCode < 0) {
41  return -1 * errCode;
42  }
43  return errCode;
44 }

Member Data Documentation

◆ kInvalidConnection

const Connection flutter::ConnectionCollection::kInvalidConnection = 0
static

Definition at line 18 of file connection_collection.h.


The documentation for this class was generated from the following files:
flutter::ConnectionCollection::Connection
int64_t Connection
Definition: connection_collection.h:17