Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
44bd8496
Commit
44bd8496
authored
Apr 22, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: reduce usage of constexpr
some compilers has lack of proper support for that
parent
8af96248
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
28 deletions
+59
-28
logtag.hpp
modules/core/include/opencv2/core/utils/logtag.hpp
+1
-1
logger.cpp
modules/core/src/logger.cpp
+8
-4
logtagconfigparser.cpp
modules/core/src/utils/logtagconfigparser.cpp
+1
-1
logtagmanager.cpp
modules/core/src/utils/logtagmanager.cpp
+4
-0
logtagmanager.hpp
modules/core/src/utils/logtagmanager.hpp
+1
-1
test_logtagmanager.cpp
modules/core/test/test_logtagmanager.cpp
+44
-21
No files found.
modules/core/include/opencv2/core/utils/logtag.hpp
View file @
44bd8496
...
@@ -17,7 +17,7 @@ struct LogTag
...
@@ -17,7 +17,7 @@ struct LogTag
const
char
*
name
;
const
char
*
name
;
LogLevel
level
;
LogLevel
level
;
inline
constexpr
LogTag
(
const
char
*
_name
,
LogLevel
_level
)
inline
LogTag
(
const
char
*
_name
,
LogLevel
_level
)
:
name
(
_name
)
:
name
(
_name
)
,
level
(
_level
)
,
level
(
_level
)
{}
{}
...
...
modules/core/src/logger.cpp
View file @
44bd8496
...
@@ -31,14 +31,13 @@ struct GlobalLoggingInitStruct
...
@@ -31,14 +31,13 @@ struct GlobalLoggingInitStruct
{
{
public
:
public
:
#if defined NDEBUG
#if defined NDEBUG
static
const
expr
bool
m_isDebugBuild
=
false
;
static
const
bool
m_isDebugBuild
=
false
;
#else
#else
static
const
expr
bool
m_isDebugBuild
=
true
;
static
const
bool
m_isDebugBuild
=
true
;
#endif
#endif
public
:
public
:
static
constexpr
LogLevel
m_defaultUnconfiguredGlobalLevel
=
static
LogLevel
m_defaultUnconfiguredGlobalLevel
;
m_isDebugBuild
?
LOG_LEVEL_DEBUG
:
LOG_LEVEL_WARNING
;
public
:
public
:
LogTagManager
logTagManager
;
LogTagManager
logTagManager
;
...
@@ -75,6 +74,11 @@ private:
...
@@ -75,6 +74,11 @@ private:
}
}
};
};
LogLevel
GlobalLoggingInitStruct
::
m_defaultUnconfiguredGlobalLevel
=
GlobalLoggingInitStruct
::
m_isDebugBuild
?
LOG_LEVEL_DEBUG
:
LOG_LEVEL_WARNING
;
// Static dynamic initialization guard function for the combined struct
// Static dynamic initialization guard function for the combined struct
// just defined above
// just defined above
//
//
...
...
modules/core/src/utils/logtagconfigparser.cpp
View file @
44bd8496
...
@@ -145,7 +145,7 @@ void LogTagConfigParser::parseNameAndLevel(const std::string& s)
...
@@ -145,7 +145,7 @@ void LogTagConfigParser::parseNameAndLevel(const std::string& s)
void
LogTagConfigParser
::
parseWildcard
(
const
std
::
string
&
name
,
LogLevel
level
)
void
LogTagConfigParser
::
parseWildcard
(
const
std
::
string
&
name
,
LogLevel
level
)
{
{
const
expr
size_t
npos
=
std
::
string
::
npos
;
const
size_t
npos
=
std
::
string
::
npos
;
const
size_t
len
=
name
.
length
();
const
size_t
len
=
name
.
length
();
if
(
len
==
0u
)
if
(
len
==
0u
)
{
{
...
...
modules/core/src/utils/logtagmanager.cpp
View file @
44bd8496
...
@@ -10,6 +10,10 @@ namespace cv {
...
@@ -10,6 +10,10 @@ namespace cv {
namespace
utils
{
namespace
utils
{
namespace
logging
{
namespace
logging
{
const
char
*
LogTagManager
::
m_globalName
=
"global"
;
LogTagManager
::
LogTagManager
(
LogLevel
defaultUnconfiguredGlobalLevel
)
LogTagManager
::
LogTagManager
(
LogLevel
defaultUnconfiguredGlobalLevel
)
:
m_mutex
()
:
m_mutex
()
,
m_globalLogTag
(
new
LogTag
(
m_globalName
,
defaultUnconfiguredGlobalLevel
))
,
m_globalLogTag
(
new
LogTag
(
m_globalName
,
defaultUnconfiguredGlobalLevel
))
...
...
modules/core/src/utils/logtagmanager.hpp
View file @
44bd8496
...
@@ -270,7 +270,7 @@ private:
...
@@ -270,7 +270,7 @@ private:
static
bool
internal_isNamePartMatch
(
MatchingScope
scope
,
size_t
matchingPos
);
static
bool
internal_isNamePartMatch
(
MatchingScope
scope
,
size_t
matchingPos
);
private
:
private
:
static
const
expr
const
char
*
m_globalName
=
"global"
;
static
const
char
*
m_globalName
;
private
:
private
:
mutable
MutexType
m_mutex
;
mutable
MutexType
m_mutex
;
...
...
modules/core/test/test_logtagmanager.cpp
View file @
44bd8496
...
@@ -23,18 +23,18 @@ using LogTag = cv::utils::logging::LogTag;
...
@@ -23,18 +23,18 @@ using LogTag = cv::utils::logging::LogTag;
using
LogTagManager
=
cv
::
utils
::
logging
::
LogTagManager
;
using
LogTagManager
=
cv
::
utils
::
logging
::
LogTagManager
;
// Value to initialize log tag constructors
// Value to initialize log tag constructors
static
const
expr
const
LogLevel
constTestLevelBegin
=
cv
::
utils
::
logging
::
LOG_LEVEL_SILENT
;
static
const
LogLevel
constTestLevelBegin
=
cv
::
utils
::
logging
::
LOG_LEVEL_SILENT
;
// Value to be set as part of test (to simulate runtime changes)
// Value to be set as part of test (to simulate runtime changes)
static
const
expr
const
LogLevel
constTestLevelChanged
=
cv
::
utils
::
logging
::
LOG_LEVEL_VERBOSE
;
static
const
LogLevel
constTestLevelChanged
=
cv
::
utils
::
logging
::
LOG_LEVEL_VERBOSE
;
// An alternate value to initialize log tag constructors,
// An alternate value to initialize log tag constructors,
// for test cases where two distinct initialization values are needed.
// for test cases where two distinct initialization values are needed.
static
const
expr
const
LogLevel
constTestLevelAltBegin
=
cv
::
utils
::
logging
::
LOG_LEVEL_FATAL
;
static
const
LogLevel
constTestLevelAltBegin
=
cv
::
utils
::
logging
::
LOG_LEVEL_FATAL
;
// An alternate value to be set as part of test (to simulate runtime changes),
// An alternate value to be set as part of test (to simulate runtime changes),
// for test cases where two distinct runtime set values are needed.
// for test cases where two distinct runtime set values are needed.
static
const
expr
const
LogLevel
constTestLevelAltChanged
=
cv
::
utils
::
logging
::
LOG_LEVEL_DEBUG
;
static
const
LogLevel
constTestLevelAltChanged
=
cv
::
utils
::
logging
::
LOG_LEVEL_DEBUG
;
// Enums for specifying which LogTagManager method to call.
// Enums for specifying which LogTagManager method to call.
// Used in parameterized tests.
// Used in parameterized tests.
...
@@ -153,7 +153,7 @@ protected:
...
@@ -153,7 +153,7 @@ protected:
LogTag
*
m_actualGlobalLogTag
;
LogTag
*
m_actualGlobalLogTag
;
protected
:
protected
:
static
const
expr
const
char
*
m_globalTagName
=
"global"
;
static
const
char
*
const
m_globalTagName
;
public
:
public
:
LogTagManagerGlobalSmokeTest
()
LogTagManagerGlobalSmokeTest
()
...
@@ -163,6 +163,9 @@ public:
...
@@ -163,6 +163,9 @@ public:
}
}
};
};
const
char
*
const
LogTagManagerGlobalSmokeTest
::
m_globalTagName
=
"global"
;
TEST_F
(
LogTagManagerGlobalSmokeTest
,
AfterCtorCanGetGlobalWithoutAssign
)
TEST_F
(
LogTagManagerGlobalSmokeTest
,
AfterCtorCanGetGlobalWithoutAssign
)
{
{
EXPECT_NE
(
m_logTagManager
.
get
(
m_globalTagName
),
nullptr
);
EXPECT_NE
(
m_logTagManager
.
get
(
m_globalTagName
),
nullptr
);
...
@@ -217,7 +220,7 @@ protected:
...
@@ -217,7 +220,7 @@ protected:
LogTag
m_something
;
LogTag
m_something
;
protected
:
protected
:
static
const
expr
const
char
*
m_somethingTagName
=
"something"
;
static
const
char
*
const
m_somethingTagName
;
public
:
public
:
LogTagManagerNonGlobalSmokeTest
()
LogTagManagerNonGlobalSmokeTest
()
...
@@ -227,6 +230,9 @@ public:
...
@@ -227,6 +230,9 @@ public:
}
}
};
};
const
char
*
const
LogTagManagerNonGlobalSmokeTest
::
m_somethingTagName
=
"something"
;
TEST_F
(
LogTagManagerNonGlobalSmokeTest
,
CanAssignTagAndThenGet
)
TEST_F
(
LogTagManagerNonGlobalSmokeTest
,
CanAssignTagAndThenGet
)
{
{
m_logTagManager
.
assign
(
m_something
.
name
,
&
m_something
);
m_logTagManager
.
assign
(
m_something
.
name
,
&
m_something
);
...
@@ -332,11 +338,11 @@ protected:
...
@@ -332,11 +338,11 @@ protected:
LogTag
tagOurs
;
LogTag
tagOurs
;
protected
:
protected
:
static
const
expr
const
char
*
strSour
=
"sour"
;
static
const
char
*
const
strSour
;
//
= "sour";
static
const
expr
const
char
*
strSop
=
"sop"
;
static
const
char
*
const
strSop
;
//
= "sop";
static
const
expr
const
char
*
strSoursop
=
"soursop"
;
static
const
char
*
const
strSoursop
;
//
= "soursop";
static
const
expr
const
char
*
strSourDotSop
=
"sour.sop"
;
static
const
char
*
const
strSourDotSop
;
//
= "sour.sop";
static
const
expr
const
char
*
strOurs
=
"ours"
;
static
const
char
*
const
strOurs
;
//
= "ours";
public
:
public
:
LogTagManagerSubstrNonConfusionFixture
()
LogTagManagerSubstrNonConfusionFixture
()
...
@@ -384,6 +390,13 @@ public:
...
@@ -384,6 +390,13 @@ public:
}
}
};
};
const
char
*
const
LogTagManagerSubstrNonConfusionFixture
::
strSour
=
"sour"
;
const
char
*
const
LogTagManagerSubstrNonConfusionFixture
::
strSop
=
"sop"
;
const
char
*
const
LogTagManagerSubstrNonConfusionFixture
::
strSoursop
=
"soursop"
;
const
char
*
const
LogTagManagerSubstrNonConfusionFixture
::
strSourDotSop
=
"sour.sop"
;
const
char
*
const
LogTagManagerSubstrNonConfusionFixture
::
strOurs
=
"ours"
;
INSTANTIATE_TEST_CASE_P
(
INSTANTIATE_TEST_CASE_P
(
LogTagManagerSubstrNonConfusionTest
,
LogTagManagerSubstrNonConfusionTest
,
LogTagManagerSubstrNonConfusionFixture
,
LogTagManagerSubstrNonConfusionFixture
,
...
@@ -482,14 +495,14 @@ protected:
...
@@ -482,14 +495,14 @@ protected:
LogTag
m_coconutDotPineapple
;
LogTag
m_coconutDotPineapple
;
protected
:
protected
:
static
const
expr
const
char
*
strApple
=
"apple"
;
static
const
char
*
const
strApple
;
//
= "apple";
static
const
expr
const
char
*
strBanana
=
"banana"
;
static
const
char
*
const
strBanana
;
//
= "banana";
static
const
expr
const
char
*
strCoconut
=
"coconut"
;
static
const
char
*
const
strCoconut
;
//
= "coconut";
static
const
expr
const
char
*
strOrange
=
"orange"
;
static
const
char
*
const
strOrange
;
//
= "orange";
static
const
expr
const
char
*
strPineapple
=
"pineapple"
;
static
const
char
*
const
strPineapple
;
//
= "pineapple";
static
const
expr
const
char
*
strBananaDotOrange
=
"banana.orange"
;
static
const
char
*
const
strBananaDotOrange
;
//
= "banana.orange";
static
const
expr
const
char
*
strBananaDotPineapple
=
"banana.pineapple"
;
static
const
char
*
const
strBananaDotPineapple
;
//
= "banana.pineapple";
static
const
expr
const
char
*
strCoconutDotPineapple
=
"coconut.pineapple"
;
static
const
char
*
const
strCoconutDotPineapple
;
//
= "coconut.pineapple";
public
:
public
:
LogTagManagerNamePartNonConfusionFixture
()
LogTagManagerNamePartNonConfusionFixture
()
...
@@ -542,7 +555,7 @@ protected:
...
@@ -542,7 +555,7 @@ protected:
// Each row ("config") specifies the tag name specifier used to call setLevelByFirstPart().
// Each row ("config") specifies the tag name specifier used to call setLevelByFirstPart().
// Each column ("target") specifies whether an actual tag with the "target"
// Each column ("target") specifies whether an actual tag with the "target"
// name would have its log level changed because of the call to setLevelByFirstPart().
// name would have its log level changed because of the call to setLevelByFirstPart().
static
const
expr
const
bool
expectedResultUsingFirstPart
[
5
][
8
]
=
static
const
bool
expectedResultUsingFirstPart
[
5
][
8
]
=
{
{
/*byFirstPart(apple)*/
{
true
,
false
,
false
,
false
,
false
,
false
,
false
,
false
},
/*byFirstPart(apple)*/
{
true
,
false
,
false
,
false
,
false
,
false
,
false
,
false
},
/*byFirstPart(banana)*/
{
false
,
true
,
false
,
false
,
false
,
true
,
true
,
false
},
/*byFirstPart(banana)*/
{
false
,
true
,
false
,
false
,
false
,
true
,
true
,
false
},
...
@@ -555,7 +568,7 @@ protected:
...
@@ -555,7 +568,7 @@ protected:
// Each row ("config") specifies the tag name specifier used to call setLevelByAnyPart().
// Each row ("config") specifies the tag name specifier used to call setLevelByAnyPart().
// Each column ("target") specifies whether an actual tag with the "target"
// Each column ("target") specifies whether an actual tag with the "target"
// name would have its log level changed because of the call to setLevelByAnyPart().
// name would have its log level changed because of the call to setLevelByAnyPart().
static
const
expr
const
bool
expectedResultUsingAnyPart
[
5
][
8
]
=
static
const
bool
expectedResultUsingAnyPart
[
5
][
8
]
=
{
{
/*byAnyPart(apple)*/
{
true
,
false
,
false
,
false
,
false
,
false
,
false
,
false
},
/*byAnyPart(apple)*/
{
true
,
false
,
false
,
false
,
false
,
false
,
false
,
false
},
/*byAnyPart(banana)*/
{
false
,
true
,
false
,
false
,
false
,
true
,
true
,
false
},
/*byAnyPart(banana)*/
{
false
,
true
,
false
,
false
,
false
,
true
,
true
,
false
},
...
@@ -578,6 +591,16 @@ protected:
...
@@ -578,6 +591,16 @@ protected:
}
}
};
};
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strApple
=
"apple"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strBanana
=
"banana"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strCoconut
=
"coconut"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strOrange
=
"orange"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strPineapple
=
"pineapple"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strBananaDotOrange
=
"banana.orange"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strBananaDotPineapple
=
"banana.pineapple"
;
const
char
*
const
LogTagManagerNamePartNonConfusionFixture
::
strCoconutDotPineapple
=
"coconut.pineapple"
;
INSTANTIATE_TEST_CASE_P
(
INSTANTIATE_TEST_CASE_P
(
LogTagManagerNamePartNonConfusionTest
,
LogTagManagerNamePartNonConfusionTest
,
LogTagManagerNamePartNonConfusionFixture
,
LogTagManagerNamePartNonConfusionFixture
,
...
...
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