Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54967 - /trunk/storage/libstorage/src/Graph.cc
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Fri, 23 Jan 2009 20:18:36 -0000
  • Message-id: <E1LQSU8-0007oD-LH@xxxxxxxxxxxxxxxx>
Author: aschnell
Date: Fri Jan 23 21:18:36 2009
New Revision: 54967

URL: http://svn.opensuse.org/viewcvs/yast?rev=54967&view=rev
Log:
- added attributes for nodes and edges

Modified:
trunk/storage/libstorage/src/Graph.cc

Modified: trunk/storage/libstorage/src/Graph.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Graph.cc?rev=54967&r1=54966&r2=54967&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Graph.cc (original)
+++ trunk/storage/libstorage/src/Graph.cc Fri Jan 23 21:18:36 2009
@@ -1,6 +1,6 @@
/*
- Textdomain "storage"
-*/
+ * Author: Arvin Schnell <aschnell@xxxxxxx>
+ */


#include <string>
@@ -20,28 +20,30 @@
enum Rank { RANK_NONE, RANK_DISK, RANK_PARTITION, RANK_MD, RANK_LVMVG,
RANK_LVMLV,
RANK_MOUNTPOINT };
typedef array<Rank, 6> Ranks;
- const Ranks ranks = { { RANK_DISK, RANK_PARTITION, RANK_MD, RANK_LVMVG,
- RANK_LVMLV, RANK_MOUNTPOINT } };
+ const Ranks ranks = { { RANK_DISK, RANK_PARTITION, RANK_MD, RANK_LVMVG,
RANK_LVMLV,
+ RANK_MOUNTPOINT } };

struct Node
{
- Node(const string& id, Rank rank, const string& label)
- : id(id), rank(rank), label(label)
+ Node(const string& id, Rank rank, const string& label, const string&
attributes = "")
+ : id(id), rank(rank), label(label), attributes(attributes)
{}

- const string id;
- const Rank rank;
- const string label;
+ string id;
+ Rank rank;
+ string label;
+ string attributes;
};

struct Edge
{
- Edge(const string& node1, const string& node2)
- : node1(node1), node2(node2)
+ Edge(const string& id1, const string& id2, const string& attributes =
"")
+ : id1(id1), id2(id2), attributes(attributes)
{}

- const string node1;
- const string node2;
+ string id1;
+ string id2;
+ string attributes;
};

string dotQuote(const string& str)
@@ -51,12 +53,18 @@

std::ostream& operator<<(std::ostream& s, const Node& node)
{
- return s << dotQuote(node.id) << " [label=" << dotQuote(node.label) <<
"];";
+ s << dotQuote(node.id) << " [label=" << dotQuote(node.label);
+ if (!node.attributes.empty())
+ s << ", " << node.attributes;
+ return s << "];";
}

std::ostream& operator<<(std::ostream& s, const Edge& edge)
{
- return s << dotQuote(edge.node1) << " -> " << dotQuote(edge.node2) <<
";";
+ s << dotQuote(edge.id1) << " -> " << dotQuote(edge.id2);
+ if (!edge.attributes.empty())
+ s << " [" << edge.attributes << "]";
+ return s << ";";
}
}

@@ -100,7 +108,7 @@

if (!i2->v.usedByDevice.empty())
{
- edges.push_back(Edge(partition_node.id, "device:" +
i2->v.usedByDevice));
+ edges.push_back(Edge(partition_node.id, "device:" +
i2->v.usedByDevice, "color=green"));
}

if (!i2->v.mount.empty())
@@ -108,7 +116,7 @@
Node mountpoint_node("mountpoint:" + i2->v.mount,
RANK_MOUNTPOINT, i2->v.mount);
nodes.push_back(mountpoint_node);

- edges.push_back(Edge(partition_node.id,
mountpoint_node.id));
+ edges.push_back(Edge(partition_node.id,
mountpoint_node.id, "color=blue"));
}
}

@@ -147,7 +155,7 @@

for (deque<MdInfo>::iterator i2 = mds.begin(); i2 != mds.end();
++i2)
{
- Node md_node("device:" + i2->v.device, RANK_MD,
i2->v.device);
+ Node md_node("device:" + i2->v.device, RANK_MD,
i2->v.device, "color=red, fillcolor=yellow");
nodes.push_back(md_node);

if (!i2->v.usedByDevice.empty())
@@ -196,7 +204,6 @@
}
out << endl;

-
for (list<Edge>::const_iterator edge = edges.begin(); edge != edges.end();
++edge)
out << " " << (*edge) << endl;


--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages