Mockups for data facades

This commit is contained in:
Dennis Luxen
2013-09-18 17:49:49 +02:00
parent a08fef172e
commit 2ab04e7e2f
7 changed files with 214 additions and 9 deletions
+2
View File
@@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
//TODO: Umbauen in Private Data Facade
#ifndef NODEINFORMATIONHELPDESK_H_
#define NODEINFORMATIONHELPDESK_H_
+18 -9
View File
@@ -22,13 +22,14 @@ or see http://www.gnu.org/licenses/agpl.txt.
#define STATICGRAPH_H_INCLUDED
#include "../DataStructures/Percent.h"
#include "../DataStructures/SharedMemoryVectorWrapper.h"
#include "../Util/SimpleLogger.h"
#include "../typedefs.h"
#include <algorithm>
#include <vector>
template< typename EdgeDataT>
template< typename EdgeDataT, bool UseSharedMemory = false>
class StaticGraph {
public:
typedef NodeID NodeIterator;
@@ -40,8 +41,9 @@ public:
NodeIterator source;
NodeIterator target;
bool operator<( const InputEdge& right ) const {
if ( source != right.source )
if ( source != right.source ) {
return source < right.source;
}
return target < right.target;
}
};
@@ -82,16 +84,22 @@ public:
}
}
StaticGraph( std::vector<_StrNode> & nodes, std::vector<_StrEdge> & edges) {
StaticGraph(
ShMemVector<_StrNode, UseSharedMemory> & nodes,
ShMemVector<_StrEdge, UseSharedMemory> & edges
) {
_numNodes = nodes.size();
_numEdges = edges.size();
_nodes.swap(nodes);
_edges.swap(edges);
//Add dummy node to end of _nodes array;
_nodes.push_back(_nodes.back());
if( !UseSharedMemory ) {
//Add dummy node to end of _nodes array;
_nodes.push_back(_nodes.back());
} else {
//TODO: Move to graph array construction
}
#ifndef NDEBUG
Percent p(GetNumberOfNodes());
for(unsigned u = 0; u < GetNumberOfNodes(); ++u) {
@@ -176,8 +184,9 @@ public:
EdgeIterator tmp = FindEdge( from, to );
if(UINT_MAX == tmp) {
tmp = FindEdge( to, from );
if(UINT_MAX != tmp)
if(UINT_MAX != tmp) {
result = true;
}
}
return tmp;
}
@@ -187,8 +196,8 @@ private:
NodeIterator _numNodes;
EdgeIterator _numEdges;
std::vector< _StrNode > _nodes;
std::vector< _StrEdge > _edges;
ShMemVector< _StrNode, UseSharedMemory > _nodes;
ShMemVector< _StrEdge, UseSharedMemory > _edges;
};
#endif // STATICGRAPH_H_INCLUDED