Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
6bc71edd
Commit
6bc71edd
authored
Mar 31, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLI command dump order change
parent
bed51374
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
7 deletions
+88
-7
src/app/cli_cmd.cpp
src/app/cli_cmd.cpp
+9
-7
src/utils/common.cpp
src/utils/common.cpp
+2
-0
src/utils/ordered_map.cpp
src/utils/ordered_map.cpp
+9
-0
src/utils/ordered_map.hpp
src/utils/ordered_map.hpp
+68
-0
No files found.
src/app/cli_cmd.cpp
View file @
6bc71edd
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include <utils/common.hpp>
#include <utils/common.hpp>
#include <utils/constants.hpp>
#include <utils/constants.hpp>
#include <utils/options.hpp>
#include <utils/options.hpp>
#include <utils/ordered_map.hpp>
#define CMD_ERR(x) \
#define CMD_ERR(x) \
{ \
{ \
...
@@ -44,16 +45,17 @@ class OptionsHandler : public opt::IOptionsHandler
...
@@ -44,16 +45,17 @@ class OptionsHandler : public opt::IOptionsHandler
}
}
};
};
static
std
::
string
DumpCommands
(
const
std
::
m
ap
<
std
::
string
,
std
::
string
>
&
descTable
)
static
std
::
string
DumpCommands
(
const
OrderedM
ap
<
std
::
string
,
std
::
string
>
&
descTable
)
{
{
size_t
maxLength
=
0
;
size_t
maxLength
=
0
;
for
(
auto
&
item
:
descTable
)
for
(
auto
&
item
:
descTable
)
maxLength
=
std
::
max
(
maxLength
,
item
.
first
.
size
());
maxLength
=
std
::
max
(
maxLength
,
item
.
size
());
std
::
stringstream
ss
{};
std
::
stringstream
ss
{};
for
(
auto
&
item
:
descTable
)
for
(
auto
&
item
:
descTable
)
ss
<<
item
.
first
<<
std
::
string
(
maxLength
-
item
.
first
.
size
(),
' '
)
<<
" | "
<<
item
.
second
<<
"
\n
"
;
ss
<<
item
<<
std
::
string
(
maxLength
-
item
.
size
(),
' '
)
<<
" | "
<<
descTable
[
item
]
<<
"
\n
"
;
std
::
string
output
=
ss
.
str
();
std
::
string
output
=
ss
.
str
();
utils
::
Trim
(
output
);
utils
::
Trim
(
output
);
return
output
;
return
output
;
}
}
...
@@ -61,7 +63,7 @@ static std::string DumpCommands(const std::map<std::string, std::string> &descTa
...
@@ -61,7 +63,7 @@ static std::string DumpCommands(const std::map<std::string, std::string> &descTa
namespace
app
namespace
app
{
{
static
std
::
m
ap
<
std
::
string
,
std
::
string
>
g_gnbCmdToDescription
=
{
static
OrderedM
ap
<
std
::
string
,
std
::
string
>
g_gnbCmdToDescription
=
{
{
"status"
,
"Show some status information about the gNB"
},
{
"status"
,
"Show some status information about the gNB"
},
{
"info"
,
"Show some information about the gNB"
},
{
"info"
,
"Show some information about the gNB"
},
{
"amf-list"
,
"List all AMFs associated with the gNB"
},
{
"amf-list"
,
"List all AMFs associated with the gNB"
},
...
@@ -70,15 +72,15 @@ static std::map<std::string, std::string> g_gnbCmdToDescription = {
...
@@ -70,15 +72,15 @@ static std::map<std::string, std::string> g_gnbCmdToDescription = {
{
"ue-count"
,
"Print the total number of UEs connected the this gNB"
},
{
"ue-count"
,
"Print the total number of UEs connected the this gNB"
},
};
};
static
std
::
m
ap
<
std
::
string
,
std
::
string
>
g_gnbCmdToUsage
=
{
static
OrderedM
ap
<
std
::
string
,
std
::
string
>
g_gnbCmdToUsage
=
{
{
"status"
,
""
},
{
"info"
,
""
},
{
"amf-list"
,
""
},
{
"amf-info"
,
"<amf-id>"
},
{
"ue-list"
,
""
},
{
"ue-count"
,
""
},
{
"status"
,
""
},
{
"info"
,
""
},
{
"amf-list"
,
""
},
{
"amf-info"
,
"<amf-id>"
},
{
"ue-list"
,
""
},
{
"ue-count"
,
""
},
};
};
static
std
::
m
ap
<
std
::
string
,
bool
>
g_gnbCmdToHelpIfEmpty
=
{{
"status"
,
false
},
{
"info"
,
false
},
static
OrderedM
ap
<
std
::
string
,
bool
>
g_gnbCmdToHelpIfEmpty
=
{{
"status"
,
false
},
{
"info"
,
false
},
{
"amf-list"
,
false
},
{
"amf-info"
,
true
},
{
"amf-list"
,
false
},
{
"amf-info"
,
true
},
{
"ue-list"
,
false
},
{
"ue-count"
,
false
}};
{
"ue-list"
,
false
},
{
"ue-count"
,
false
}};
static
std
::
m
ap
<
std
::
string
,
std
::
string
>
g_ueCmdToDescription
=
{
static
OrderedM
ap
<
std
::
string
,
std
::
string
>
g_ueCmdToDescription
=
{
{
"info"
,
"Show some information about the UE"
},
{
"info"
,
"Show some information about the UE"
},
{
"status"
,
"Show some status information about the UE"
},
{
"status"
,
"Show some status information about the UE"
},
{
"timers"
,
"Dump current status of the timers in the UE"
},
{
"timers"
,
"Dump current status of the timers in the UE"
},
...
...
src/utils/common.cpp
View file @
6bc71edd
...
@@ -306,6 +306,8 @@ bool utils::IsNumeric(const std::string &str)
...
@@ -306,6 +306,8 @@ bool utils::IsNumeric(const std::string &str)
void
utils
::
Trim
(
std
::
string
&
s
)
void
utils
::
Trim
(
std
::
string
&
s
)
{
{
if
(
s
.
length
()
==
0
)
return
;
s
.
erase
(
s
.
begin
(),
std
::
find_if
(
s
.
begin
(),
s
.
end
(),
[](
unsigned
char
ch
)
{
return
!
std
::
isspace
(
ch
);
}));
s
.
erase
(
s
.
begin
(),
std
::
find_if
(
s
.
begin
(),
s
.
end
(),
[](
unsigned
char
ch
)
{
return
!
std
::
isspace
(
ch
);
}));
s
.
erase
(
std
::
find_if
(
s
.
rbegin
(),
s
.
rend
(),
[](
unsigned
char
ch
)
{
return
!
std
::
isspace
(
ch
);
}).
base
(),
s
.
end
());
s
.
erase
(
std
::
find_if
(
s
.
rbegin
(),
s
.
rend
(),
[](
unsigned
char
ch
)
{
return
!
std
::
isspace
(
ch
);
}).
base
(),
s
.
end
());
}
}
...
...
src/utils/ordered_map.cpp
0 → 100644
View file @
6bc71edd
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "ordered_map.hpp"
src/utils/ordered_map.hpp
0 → 100644
View file @
6bc71edd
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include <initializer_list>
#include <unordered_map>
#include <utility>
#include <vector>
template
<
typename
TKey
,
typename
TValue
>
class
OrderedMap
{
private:
std
::
unordered_map
<
TKey
,
TValue
>
m_map
{};
std
::
vector
<
TKey
>
m_keyOrder
{};
public:
OrderedMap
()
=
default
;
OrderedMap
(
std
::
initializer_list
<
std
::
pair
<
TKey
,
TValue
>>
initList
)
{
for
(
auto
&
pair
:
initList
)
{
if
(
!
m_map
.
count
(
pair
.
first
))
m_keyOrder
.
push_back
(
pair
.
first
);
m_map
[
pair
.
first
]
=
pair
.
second
;
}
}
inline
auto
count
(
const
TKey
&
key
)
{
return
m_map
.
count
(
key
);
}
inline
TValue
&
operator
[](
const
TKey
&
key
)
{
return
m_map
.
at
(
key
);
}
inline
const
TValue
&
operator
[](
const
TKey
&
key
)
const
{
return
m_map
.
at
(
key
);
}
inline
typename
std
::
vector
<
TKey
>::
iterator
begin
()
{
return
m_keyOrder
.
begin
();
}
inline
typename
std
::
vector
<
TKey
>::
const_iterator
begin
()
const
{
return
m_keyOrder
.
begin
();
}
inline
typename
std
::
vector
<
TKey
>::
iterator
end
()
{
return
m_keyOrder
.
end
();
}
inline
typename
std
::
vector
<
TKey
>::
const_iterator
end
()
const
{
return
m_keyOrder
.
end
();
}
};
\ No newline at end of file
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