Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zipr Toolchain
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Open Source Software
Zipr Toolchain
Commits
3a95c8ef
Commit
3a95c8ef
authored
6 years ago
by
Matthew McGill
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring
Former-commit-id: 12c1163de790ed7611be9642046bc122a4a50d06
parent
3480b045
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libIRDB/include/core/IRDB_Objects.hpp
+5
-2
5 additions, 2 deletions
libIRDB/include/core/IRDB_Objects.hpp
libIRDB/src/core/IRDB_Objects.cpp
+22
-18
22 additions, 18 deletions
libIRDB/src/core/IRDB_Objects.cpp
with
27 additions
and
20 deletions
libIRDB/include/core/IRDB_Objects.hpp
+
5
−
2
View file @
3a95c8ef
...
@@ -50,8 +50,11 @@ class IRDBObjects_t
...
@@ -50,8 +50,11 @@ class IRDBObjects_t
// type aliases of maps. maps allow speed of finding needed files, file IRs
// type aliases of maps. maps allow speed of finding needed files, file IRs
// and/or variants that have already been read from the DB
// and/or variants that have already been read from the DB
using
IdToVariantMap_t
=
std
::
map
<
db_id_t
,
const
std
::
shared_ptr
<
VariantID_t
>>
;
using
IdToVariantMap_t
=
std
::
map
<
db_id_t
,
const
std
::
shared_ptr
<
VariantID_t
>>
;
struct
FileIRInfo_t
using
FileIRInfo_t
=
std
::
pair
<
File_t
*
const
,
std
::
shared_ptr
<
FileIR_t
>>
;
{
File_t
*
const
file
;
std
::
shared_ptr
<
FileIR_t
>
fileIR
;
};
using
IdToFileIRInfoMap_t
=
std
::
map
<
db_id_t
,
FileIRInfo_t
>
;
using
IdToFileIRInfoMap_t
=
std
::
map
<
db_id_t
,
FileIRInfo_t
>
;
IdToVariantMap_t
variant_map
;
IdToVariantMap_t
variant_map
;
...
...
This diff is collapsed.
Click to expand it.
libIRDB/src/core/IRDB_Objects.cpp
+
22
−
18
View file @
3a95c8ef
...
@@ -28,21 +28,23 @@ shared_ptr<FileIR_t> IRDBObjects_t::addFileIR(db_id_t variant_id, db_id_t file_i
...
@@ -28,21 +28,23 @@ shared_ptr<FileIR_t> IRDBObjects_t::addFileIR(db_id_t variant_id, db_id_t file_i
return
null_fileIR
;
return
null_fileIR
;
}
}
else
else
{
{
if
(
it
->
second
.
second
==
NULL
)
File_t
*
const
&
the_file
=
(
it
->
second
).
file
;
shared_ptr
<
FileIR_t
>
&
the_fileIR
=
(
it
->
second
).
fileIR
;
if
(
the_fileIR
==
NULL
)
{
{
File_t
*
const
the_file
=
it
->
second
.
first
;
assert
(
the_file
!=
NULL
);
assert
(
the_file
!=
NULL
);
assert
(
variant_map
.
find
(
variant_id
)
!=
variant_map
.
end
());
assert
(
variant_map
.
find
(
variant_id
)
!=
variant_map
.
end
());
VariantID_t
&
the_variant
=
*
(
variant_map
.
at
(
variant_id
).
get
());
VariantID_t
&
the_variant
=
*
(
variant_map
.
at
(
variant_id
).
get
());
it
->
second
.
second
=
make_shared
<
FileIR_t
>
(
the_variant
,
the_file
);
the_fileIR
=
make_shared
<
FileIR_t
>
(
the_variant
,
the_file
);
assert
(
it
->
second
.
second
!=
NULL
);
assert
(
the_fileIR
!=
NULL
);
}
}
// make sure static variable is set in the calling module -- IMPORTANT
// make sure static variable is set in the calling module -- IMPORTANT
(
it
->
second
.
second
)
->
SetArchitecture
();
the_fileIR
->
SetArchitecture
();
return
it
->
second
.
second
;
return
the_fileIR
;
}
}
}
}
...
@@ -53,15 +55,16 @@ int IRDBObjects_t::writeBackFileIR(db_id_t file_id)
...
@@ -53,15 +55,16 @@ int IRDBObjects_t::writeBackFileIR(db_id_t file_id)
if
(
it
!=
file_IR_map
.
end
())
if
(
it
!=
file_IR_map
.
end
())
{
{
File_t
*
const
the_file
=
it
->
second
.
fi
rst
;
File_t
*
const
&
the_file
=
(
it
->
second
)
.
fi
le
;
assert
(
the_file
!=
NULL
);
assert
(
the_file
!=
NULL
);
try
try
{
{
cout
<<
"Writing changes for "
<<
the_file
->
GetURL
()
<<
endl
;
cout
<<
"Writing changes for "
<<
the_file
->
GetURL
()
<<
endl
;
// make sure static variable is set in the calling module -- IMPORTANT
// make sure static variable is set in the calling module -- IMPORTANT
(
it
->
second
.
second
)
->
SetArchitecture
();
shared_ptr
<
FileIR_t
>
&
the_fileIR
=
(
it
->
second
).
fileIR
;
(
it
->
second
.
second
)
->
WriteToDB
();
the_fileIR
->
SetArchitecture
();
the_fileIR
->
WriteToDB
();
}
}
catch
(
DatabaseError_t
pnide
)
catch
(
DatabaseError_t
pnide
)
{
{
...
@@ -89,10 +92,11 @@ void IRDBObjects_t::deleteFileIR(db_id_t file_id)
...
@@ -89,10 +92,11 @@ void IRDBObjects_t::deleteFileIR(db_id_t file_id)
if
(
it
!=
file_IR_map
.
end
())
if
(
it
!=
file_IR_map
.
end
())
{
{
if
(
it
->
second
.
second
!=
NULL
)
shared_ptr
<
FileIR_t
>
&
the_fileIR
=
(
it
->
second
).
fileIR
;
if
(
the_fileIR
!=
NULL
)
{
{
assert
(
it
->
second
.
second
.
use_count
()
<=
2
);
assert
(
the_fileIR
.
use_count
()
<=
2
);
(
it
->
second
.
second
)
.
reset
();
the_fileIR
.
reset
();
}
}
}
}
}
}
...
@@ -143,8 +147,8 @@ shared_ptr<VariantID_t> IRDBObjects_t::addVariant(db_id_t variant_id)
...
@@ -143,8 +147,8 @@ shared_ptr<VariantID_t> IRDBObjects_t::addVariant(db_id_t variant_id)
File_t
*
const
curr_file
=
*
it
;
File_t
*
const
curr_file
=
*
it
;
shared_ptr
<
FileIR_t
>
curr_file_IR
;
shared_ptr
<
FileIR_t
>
curr_file_IR
;
auto
file_IR_pair
=
make_pair
(
curr_file
,
curr_file_IR
)
;
FileIRInfo_t
file_IR_info
=
{
curr_file
,
curr_file_IR
}
;
auto
file_map_pair
=
make_pair
((
*
it
)
->
GetBaseID
(),
file_IR_
pair
);
auto
file_map_pair
=
make_pair
((
*
it
)
->
GetBaseID
(),
file_IR_
info
);
file_IR_map
.
insert
(
file_map_pair
);
file_IR_map
.
insert
(
file_map_pair
);
}
}
...
@@ -161,8 +165,8 @@ bool IRDBObjects_t::filesBeingShared(const shared_ptr<VariantID_t>& the_variant)
...
@@ -161,8 +165,8 @@ bool IRDBObjects_t::filesBeingShared(const shared_ptr<VariantID_t>& the_variant)
)
)
{
{
assert
(
file_IR_map
.
find
((
*
file_it
)
->
GetBaseID
())
!=
file_IR_map
.
end
());
assert
(
file_IR_map
.
find
((
*
file_it
)
->
GetBaseID
())
!=
file_IR_map
.
end
());
const
pair
<
File_t
*
,
shared_ptr
<
FileIR_t
>>
file_IR_
pair
=
file_IR_map
.
at
((
*
file_it
)
->
GetBaseID
());
const
auto
file_IR_
info
=
file_IR_map
.
at
((
*
file_it
)
->
GetBaseID
());
if
(
file_IR_
pair
.
second
.
use_count
()
>
2
)
if
(
file_IR_
info
.
fileIR
.
use_count
()
>
2
)
{
{
return
true
;
return
true
;
}
}
...
@@ -239,7 +243,7 @@ int IRDBObjects_t::writeBackAll(void)
...
@@ -239,7 +243,7 @@ int IRDBObjects_t::writeBackAll(void)
++
file_it
++
file_it
)
)
{
{
const
int
result
=
IRDBObjects_t
::
writeBackFileIR
((
file_it
->
second
.
fi
rst
)
->
GetBaseID
());
const
int
result
=
IRDBObjects_t
::
writeBackFileIR
((
file_it
->
second
.
fi
le
)
->
GetBaseID
());
if
(
result
!=
0
)
if
(
result
!=
0
)
{
{
ret_status
=
-
1
;
ret_status
=
-
1
;
...
...
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