src: split storage types into data and type

* this shortens the signature of many methods and allows to pass a single object as reference instead of passing multiple references and values
This commit is contained in:
mlangkabel
2017-11-19 01:31:50 +01:00
parent 66b278b1c9
commit 343caebcf6
39 changed files with 1182 additions and 899 deletions
@@ -174,9 +174,9 @@ void SharedIntermediateStorage::setStorageOccurrences(const std::vector<StorageO
}
}
std::vector<StorageComponentAccess> SharedIntermediateStorage::getStorageComponentAccesses() const
std::vector<StorageComponentAccessData> SharedIntermediateStorage::getStorageComponentAccesses() const
{
std::vector<StorageComponentAccess> result;
std::vector<StorageComponentAccessData> result;
for (unsigned int i = 0; i < m_storageComponentAccesses.size(); i++)
{
@@ -186,7 +186,7 @@ std::vector<StorageComponentAccess> SharedIntermediateStorage::getStorageCompone
return result;
}
void SharedIntermediateStorage::setStorageComponentAccesses(const std::vector<StorageComponentAccess>& storageComponentAccesses)
void SharedIntermediateStorage::setStorageComponentAccesses(const std::vector<StorageComponentAccessData>& storageComponentAccesses)
{
m_storageComponentAccesses.clear();
@@ -196,9 +196,9 @@ void SharedIntermediateStorage::setStorageComponentAccesses(const std::vector<St
}
}
std::vector<StorageCommentLocation> SharedIntermediateStorage::getStorageCommentLocations() const
std::vector<StorageCommentLocationData> SharedIntermediateStorage::getStorageCommentLocations() const
{
std::vector<StorageCommentLocation> result;
std::vector<StorageCommentLocationData> result;
for (unsigned int i = 0; i < m_storageCommentLocations.size(); i++)
{
@@ -208,7 +208,7 @@ std::vector<StorageCommentLocation> SharedIntermediateStorage::getStorageComment
return result;
}
void SharedIntermediateStorage::setStorageCommentLocations(const std::vector<StorageCommentLocation>& commentLocations)
void SharedIntermediateStorage::setStorageCommentLocations(const std::vector<StorageCommentLocationData>& commentLocations)
{
m_storageCommentLocations.clear();
@@ -218,9 +218,9 @@ void SharedIntermediateStorage::setStorageCommentLocations(const std::vector<Sto
}
}
std::vector<StorageError> SharedIntermediateStorage::getStorageErrors() const
std::vector<StorageErrorData> SharedIntermediateStorage::getStorageErrors() const
{
std::vector<StorageError> result;
std::vector<StorageErrorData> result;
for (unsigned int i = 0; i < m_storageErrors.size(); i++)
{
@@ -230,7 +230,7 @@ std::vector<StorageError> SharedIntermediateStorage::getStorageErrors() const
return result;
}
void SharedIntermediateStorage::setStorageErrors(const std::vector<StorageError>& errors)
void SharedIntermediateStorage::setStorageErrors(const std::vector<StorageErrorData>& errors)
{
m_storageErrors.clear();
@@ -1,7 +1,6 @@
#ifndef SHARED_INTERMEDIATE_STORAGE_H
#define SHARED_INTERMEDIATE_STORAGE_H
#include "data/storage/StorageTypes.h"
#include "data/indexer/interprocess/shared_types/SharedStorageTypes.h"
#include "utility/interprocess/SharedMemory.h"
@@ -32,14 +31,14 @@ public:
std::vector<StorageOccurrence> getStorageOccurrences() const;
void setStorageOccurrences(const std::vector<StorageOccurrence>& storageOccurences);
std::vector<StorageComponentAccess> getStorageComponentAccesses() const;
void setStorageComponentAccesses(const std::vector<StorageComponentAccess>& storageComponentAccesses);
std::vector<StorageComponentAccessData> getStorageComponentAccesses() const;
void setStorageComponentAccesses(const std::vector<StorageComponentAccessData>& storageComponentAccesses);
std::vector<StorageCommentLocation> getStorageCommentLocations() const;
void setStorageCommentLocations(const std::vector<StorageCommentLocation>& commentLocations);
std::vector<StorageCommentLocationData> getStorageCommentLocations() const;
void setStorageCommentLocations(const std::vector<StorageCommentLocationData>& commentLocations);
std::vector<StorageError> getStorageErrors() const;
void setStorageErrors(const std::vector<StorageError>& errors);
std::vector<StorageErrorData> getStorageErrors() const;
void setStorageErrors(const std::vector<StorageErrorData>& errors);
Id getNextId() const;
void setNextId(const Id nextId);
@@ -48,13 +47,13 @@ private:
SharedMemory::Vector<SharedStorageFile> m_storageFiles;
SharedMemory::Vector<SharedStorageSymbol> m_storageSymbols;
SharedMemory::Vector<SharedStorageOccurrence> m_storageOccurrences;
SharedMemory::Vector<SharedStorageComponentAccess> m_storageComponentAccesses;
SharedMemory::Vector<SharedStorageCommentLocation> m_storageCommentLocations;
SharedMemory::Vector<SharedStorageComponentAccessData> m_storageComponentAccesses;
SharedMemory::Vector<SharedStorageCommentLocationData> m_storageCommentLocations;
SharedMemory::Vector<SharedStorageNode> m_storageNodes;
SharedMemory::Vector<SharedStorageEdge> m_storageEdges;
SharedMemory::Vector<SharedStorageLocalSymbol> m_storageLocalSymbols;
SharedMemory::Vector<SharedStorageSourceLocation> m_storageSourceLocations;
SharedMemory::Vector<SharedStorageError> m_storageErrors;
SharedMemory::Vector<SharedStorageErrorData> m_storageErrors;
SharedMemory::Allocator* m_allocator;
@@ -1,6 +1,16 @@
#ifndef SHARED_STORAGE_TYPES_H
#define SHARED_STORAGE_TYPES_H
#include "data/storage/type/StorageCommentLocation.h"
#include "data/storage/type/StorageComponentAccess.h"
#include "data/storage/type/StorageEdge.h"
#include "data/storage/type/StorageError.h"
#include "data/storage/type/StorageFile.h"
#include "data/storage/type/StorageLocalSymbol.h"
#include "data/storage/type/StorageNode.h"
#include "data/storage/type/StorageOccurrence.h"
#include "data/storage/type/StorageSourceLocation.h"
#include "data/storage/type/StorageSymbol.h"
#include "utility/types.h"
#include "utility/interprocess/SharedMemory.h"
@@ -25,8 +35,8 @@ CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageEdge, SharedStorageEdge )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageSymbol, SharedStorageSymbol )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageSourceLocation, SharedStorageSourceLocation )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageOccurrence, SharedStorageOccurrence )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageComponentAccess, SharedStorageComponentAccess )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageCommentLocation, SharedStorageCommentLocation )
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageComponentAccessData, SharedStorageComponentAccessData)
CONVERT_STORAGE_TYPE_TO_SHARED_TYPE( StorageCommentLocationData, SharedStorageCommentLocationData)
struct SharedStorageNode
@@ -103,10 +113,9 @@ inline StorageLocalSymbol fromShared(const SharedStorageLocalSymbol& symbol)
}
struct SharedStorageError
struct SharedStorageErrorData
{
SharedStorageError(
Id id,
SharedStorageErrorData(
const std::string& message,
const std::string& commandline,
const std::string& filePath,
@@ -116,8 +125,7 @@ struct SharedStorageError
bool indexed,
SharedMemory::Allocator* allocator
)
: id(id)
, message(message.c_str(), allocator)
: message(message.c_str(), allocator)
, commandline(commandline.c_str(), allocator)
, filePath(filePath.c_str(), allocator)
, lineNumber(lineNumber)
@@ -126,7 +134,6 @@ struct SharedStorageError
, indexed(indexed)
{}
Id id;
SharedMemory::String message;
SharedMemory::String commandline;
@@ -138,17 +145,17 @@ struct SharedStorageError
bool indexed;
};
inline SharedStorageError toShared(const StorageError& error, SharedMemory::Allocator* allocator)
inline SharedStorageErrorData toShared(const StorageErrorData& error, SharedMemory::Allocator* allocator)
{
return SharedStorageError(
error.id, error.message, error.commandline, error.filePath.str(),
return SharedStorageErrorData(
error.message, error.commandline, error.filePath.str(),
error.lineNumber, error.columnNumber, error.fatal, error.indexed, allocator);
}
inline StorageError fromShared(const SharedStorageError& error)
inline StorageErrorData fromShared(const SharedStorageErrorData& error)
{
return StorageError(
error.id, error.message.c_str(), error.commandline.c_str(), FilePath(error.filePath.c_str()),
return StorageErrorData(
error.message.c_str(), error.commandline.c_str(), FilePath(error.filePath.c_str()),
error.lineNumber, error.columnNumber, error.fatal, error.indexed);
}