Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2ce5a857
Commit
2ce5a857
authored
Nov 18, 2012
by
Davis King
Browse files
Converted the bound_function_pointer into a single implementation component.
parent
68658f88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
102 deletions
+27
-102
dlib/bound_function_pointer.h
dlib/bound_function_pointer.h
+0
-23
dlib/bound_function_pointer/bound_function_pointer_kernel_1.h
.../bound_function_pointer/bound_function_pointer_kernel_1.h
+27
-13
dlib/bound_function_pointer/bound_function_pointer_kernel_c.h
.../bound_function_pointer/bound_function_pointer_kernel_c.h
+0
-66
No files found.
dlib/bound_function_pointer.h
View file @
2ce5a857
...
@@ -4,29 +4,6 @@
...
@@ -4,29 +4,6 @@
#define DLIB_BOUND_FUNCTION_POINTEr_
#define DLIB_BOUND_FUNCTION_POINTEr_
#include "bound_function_pointer/bound_function_pointer_kernel_1.h"
#include "bound_function_pointer/bound_function_pointer_kernel_1.h"
#include "bound_function_pointer/bound_function_pointer_kernel_c.h"
namespace
dlib
{
class
bound_function_pointer
{
bound_function_pointer
()
{}
public:
//----------- kernels ---------------
// kernel_1a
typedef
bound_function_pointer_kernel_1
kernel_1a
;
typedef
bound_function_pointer_kernel_c
<
kernel_1a
>
kernel_1a_c
;
};
}
#endif // DLIB_BOUND_FUNCTION_POINTEr_
#endif // DLIB_BOUND_FUNCTION_POINTEr_
...
...
dlib/bound_function_pointer/bound_function_pointer_kernel_1.h
View file @
2ce5a857
...
@@ -221,27 +221,34 @@ namespace dlib
...
@@ -221,27 +221,34 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class
bound_function_pointer
_kernel_1
class
bound_function_pointer
{
{
typedef
bfp1_helpers
::
bound_function_helper_T
<
bfp1_helpers
::
bound_function_helper
<
void
,
int
>
>
bf_null_type
;
typedef
bfp1_helpers
::
bound_function_helper_T
<
bfp1_helpers
::
bound_function_helper
<
void
,
int
>
>
bf_null_type
;
public:
public:
bound_function_pointer_kernel_1
(
// These typedefs are here for backwards compatibility with previous versions of
// dlib.
typedef
bound_function_pointer
kernel_1a
;
typedef
bound_function_pointer
kernel_1a_c
;
bound_function_pointer
(
)
{
bf_null_type
().
safe_clone
(
bf_memory
);
}
)
{
bf_null_type
().
safe_clone
(
bf_memory
);
}
bound_function_pointer
_kernel_1
(
bound_function_pointer
(
const
bound_function_pointer
_kernel_1
&
item
const
bound_function_pointer
&
item
)
{
item
.
bf
()
->
clone
(
bf_memory
.
get
());
}
)
{
item
.
bf
()
->
clone
(
bf_memory
.
get
());
}
~
bound_function_pointer
_kernel_1
()
~
bound_function_pointer
()
{
destroy_bf_memory
();
}
{
destroy_bf_memory
();
}
bound_function_pointer
_kernel_1
&
operator
=
(
bound_function_pointer
&
operator
=
(
const
bound_function_pointer
_kernel_1
&
item
const
bound_function_pointer
&
item
)
{
bound_function_pointer
_kernel_1
(
item
).
swap
(
*
this
);
return
*
this
;
}
)
{
bound_function_pointer
(
item
).
swap
(
*
this
);
return
*
this
;
}
void
clear
(
void
clear
(
)
{
bound_function_pointer
_kernel_1
().
swap
(
*
this
);
}
)
{
bound_function_pointer
().
swap
(
*
this
);
}
bool
is_set
(
bool
is_set
(
)
const
)
const
...
@@ -250,11 +257,11 @@ namespace dlib
...
@@ -250,11 +257,11 @@ namespace dlib
}
}
void
swap
(
void
swap
(
bound_function_pointer
_kernel_1
&
item
bound_function_pointer
&
item
)
)
{
{
// make a temp copy of item
// make a temp copy of item
bound_function_pointer
_kernel_1
temp
(
item
);
bound_function_pointer
temp
(
item
);
// destory the stuff in item
// destory the stuff in item
item
.
destroy_bf_memory
();
item
.
destroy_bf_memory
();
...
@@ -270,6 +277,13 @@ namespace dlib
...
@@ -270,6 +277,13 @@ namespace dlib
void
operator
()
(
void
operator
()
(
)
const
)
const
{
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_set
()
==
true
,
"
\t
void bound_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
bf
()
->
call
();
bf
()
->
call
();
}
}
...
@@ -748,8 +762,8 @@ namespace dlib
...
@@ -748,8 +762,8 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
inline
void
swap
(
inline
void
swap
(
bound_function_pointer
_kernel_1
&
a
,
bound_function_pointer
&
a
,
bound_function_pointer
_kernel_1
&
b
bound_function_pointer
&
b
)
{
a
.
swap
(
b
);
}
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/bound_function_pointer/bound_function_pointer_kernel_c.h
deleted
100644 → 0
View file @
68658f88
// Copyright (C) 2008 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_BOUND_FUNCTION_POINTER_KERNEl_C_
#define DLIB_BOUND_FUNCTION_POINTER_KERNEl_C_
#include "bound_function_pointer_kernel_abstract.h"
#include "../algs.h"
#include "../assert.h"
namespace
dlib
{
template
<
typename
bound_function_pointer_base
// is an implementation of bound_function_pointer_kernel_abstract.h
>
class
bound_function_pointer_kernel_c
:
public
bound_function_pointer_base
{
public:
void
operator
()
(
)
const
;
};
template
<
typename
bound_function_pointer_base
>
inline
void
swap
(
bound_function_pointer_kernel_c
<
bound_function_pointer_base
>&
a
,
bound_function_pointer_kernel_c
<
bound_function_pointer_base
>&
b
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
bound_function_pointer_base
>
void
bound_function_pointer_kernel_c
<
bound_function_pointer_base
>::
operator
()
(
)
const
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_set
()
==
true
,
"
\t
void bound_function_pointer::operator()"
<<
"
\n\t
You must call set() before you can use this function"
<<
"
\n\t
this: "
<<
this
);
// call the real function
bound_function_pointer_base
::
operator
()();
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_BOUND_FUNCTION_POINTER_KERNEl_C_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment