Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakub Janák
tss
Commits
dc4b57c9
Commit
dc4b57c9
authored
3 months ago
by
Jakub Janák
Browse files
Options
Downloads
Patches
Plain Diff
partially refactored the file manager read_dot_file method
parent
157944ef
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
files/file_manager.cpp
+23
-10
23 additions, 10 deletions
files/file_manager.cpp
files/file_manager.hpp
+4
-0
4 additions, 0 deletions
files/file_manager.hpp
with
27 additions
and
10 deletions
files/file_manager.cpp
+
23
−
10
View file @
dc4b57c9
...
...
@@ -13,25 +13,26 @@ const std::string file_manager::INSTANCES_PATH = "../files/instances";
const
std
::
string
file_manager
::
RESULTS_PATH
=
"../files/results"
;
// TODO: refactor the read dot file
std
::
unique_ptr
<
ts_instance
>
file_manager
::
read_dot_file
(
const
std
::
string
&
file_name
)
{
// graphviz context
GVC_t
*
gvc
=
gvContext
();
bool
file_manager
::
load_graph
(
const
std
::
string
&
file_name
,
GVC_t
*
gvc
,
Agraph_t
*&
graph
,
std
::
unique_ptr
<
ts_instance
>
&
value1
)
{
// Open the .dot file
FILE
*
file
=
fopen
(
file_name
.
c_str
(),
"r"
);
// error opening the file
if
(
!
file
)
{
std
::
cout
<<
"Error opening file: "
<<
file_name
<<
" in: "
<<
INSTANCES_PATH
<<
std
::
endl
;
return
nullptr
;
value1
=
nullptr
;
return
true
;
}
//
Parse the .dot file into a graph (digraph)
Agraph_t
*
graph
=
agread
(
file
,
nullptr
);
//
done a reading file
graph
=
agread
(
file
,
nullptr
);
fclose
(
file
);
// graph isn't parsed
if
(
!
graph
)
{
std
::
cout
<<
"Error reading DOT file: "
<<
file_name
<<
std
::
endl
;
return
nullptr
;
value1
=
nullptr
;
return
true
;
}
// Check if the graph is a digraph
...
...
@@ -39,8 +40,20 @@ std::unique_ptr<ts_instance> file_manager::read_dot_file(const std::string &file
std
::
cout
<<
"The graph in the file is not a directed graph (digraph)."
<<
std
::
endl
;
agclose
(
graph
);
gvFreeContext
(
gvc
);
return
nullptr
;
value1
=
nullptr
;
return
true
;
}
return
false
;
}
// TODO: refactor the read dot file
std
::
unique_ptr
<
ts_instance
>
file_manager
::
read_dot_file
(
const
std
::
string
&
file_name
)
{
// graphviz context
GVC_t
*
gvc
=
gvContext
();
Agraph_t
*
graph
;
std
::
unique_ptr
<
ts_instance
>
value1
;
if
(
load_graph
(
file_name
,
gvc
,
graph
,
value1
))
return
value1
;
// graph variables
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
node
>
>
nodesMap
;
...
...
This diff is collapsed.
Click to expand it.
files/file_manager.hpp
+
4
−
0
View file @
dc4b57c9
#ifndef FILEMANAGER_H
#define FILEMANAGER_H
#include
<cgraph.h>
#include
<gvcext.h>
#include
<string>
#include
<__filesystem/directory_entry.h>
...
...
@@ -12,6 +14,8 @@ public:
static
const
std
::
string
RESULTS_PATH
;
static
bool
load_graph
(
const
std
::
string
&
file_name
,
GVC_t
*
gvc
,
Agraph_t
*&
graph
,
std
::
unique_ptr
<
ts_instance
>
&
value1
);
static
std
::
unique_ptr
<
ts_instance
>
read_dot_file
(
const
std
::
string
&
file_name
);
static
std
::
vector
<
std
::
filesystem
::
directory_entry
>
get_dot_instances
(
const
std
::
string
&
directory_path
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment