Realistic 3D camera system
3D camera system components
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
asio-1.10.6
include
asio
detail
call_stack.hpp
Go to the documentation of this file.
1
//
2
// detail/call_stack.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~
4
//
5
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
//
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
//
10
11
#ifndef ASIO_DETAIL_CALL_STACK_HPP
12
#define ASIO_DETAIL_CALL_STACK_HPP
13
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
# pragma once
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18
#include "
asio/detail/config.hpp
"
19
#include "
asio/detail/noncopyable.hpp
"
20
#include "
asio/detail/tss_ptr.hpp
"
21
22
#include "
asio/detail/push_options.hpp
"
23
24
namespace
asio
{
25
namespace
detail {
26
27
// Helper class to determine whether or not the current thread is inside an
28
// invocation of io_service::run() for a specified io_service object.
29
template
<
typename
Key,
typename
Value =
unsigned
char
>
30
class
call_stack
31
{
32
public
:
33
// Context class automatically pushes the key/value pair on to the stack.
34
class
context
35
:
private
noncopyable
36
{
37
public
:
38
// Push the key on to the stack.
39
explicit
context
(Key* k)
40
: key_(k),
41
next_(
call_stack
<Key, Value>::top_)
42
{
43
value_ =
reinterpret_cast<
unsigned
char
*
>
(
this
);
44
call_stack<Key, Value>::top_
=
this
;
45
}
46
47
// Push the key/value pair on to the stack.
48
context
(Key* k, Value& v)
49
: key_(k),
50
value_(&v),
51
next_(
call_stack
<Key, Value>::top_)
52
{
53
call_stack<Key, Value>::top_
=
this
;
54
}
55
56
// Pop the key/value pair from the stack.
57
~context
()
58
{
59
call_stack<Key, Value>::top_
= next_;
60
}
61
62
// Find the next context with the same key.
63
Value*
next_by_key
()
const
64
{
65
context
* elem = next_;
66
while
(elem)
67
{
68
if
(elem->key_ == key_)
69
return
elem->value_;
70
elem = elem->next_;
71
}
72
return
0;
73
}
74
75
private
:
76
friend
class
call_stack
<Key, Value>;
77
78
// The key associated with the context.
79
Key* key_;
80
81
// The value associated with the context.
82
Value* value_;
83
84
// The next element in the stack.
85
context
* next_;
86
};
87
88
friend
class
context
;
89
90
// Determine whether the specified owner is on the stack. Returns address of
91
// key if present, 0 otherwise.
92
static
Value*
contains
(Key* k)
93
{
94
context
* elem = top_;
95
while
(elem)
96
{
97
if
(elem->key_ == k)
98
return
elem->value_;
99
elem = elem->next_;
100
}
101
return
0;
102
}
103
104
// Obtain the value at the top of the stack.
105
static
Value*
top
()
106
{
107
context
* elem = top_;
108
return
elem ? elem->value_ : 0;
109
}
110
111
private
:
112
// The top of the stack of calls for the current thread.
113
static
tss_ptr<context>
top_;
114
};
115
116
template
<
typename
Key,
typename
Value>
117
tss_ptr<typename call_stack<Key, Value>::context
>
118
call_stack<Key, Value>::top_
;
119
120
}
// namespace detail
121
}
// namespace asio
122
123
#include "
asio/detail/pop_options.hpp
"
124
125
#endif // ASIO_DETAIL_CALL_STACK_HPP
asio::detail::call_stack::context::~context
~context()
Definition:
call_stack.hpp:57
asio::detail::call_stack::context::next_by_key
Value * next_by_key() const
Definition:
call_stack.hpp:63
tss_ptr.hpp
asio::detail::tss_ptr
Definition:
tss_ptr.hpp:38
config.hpp
asio::detail::noncopyable
Definition:
noncopyable.hpp:25
push_options.hpp
asio::detail::call_stack::context::context
context(Key *k, Value &v)
Definition:
call_stack.hpp:48
asio::detail::call_stack::contains
static Value * contains(Key *k)
Definition:
call_stack.hpp:92
asio::detail::call_stack::top
static Value * top()
Definition:
call_stack.hpp:105
pop_options.hpp
noncopyable.hpp
asio::detail::call_stack::context::context
context(Key *k)
Definition:
call_stack.hpp:39
asio::detail::call_stack
Definition:
call_stack.hpp:30
asio::detail::call_stack::context
Definition:
call_stack.hpp:34
asio
Definition:
async_result.hpp:23
Generated by
1.8.11