|
Boost Users : |
Subject: Re: [Boost-users] [multi_index] Problem of scope with the replace in static data structure
From: joaquin_at_[hidden]
Date: 2009-02-11 04:44:57
Rodrigo Dias Ferreira escribió:
>> 2. If the answer to 1 is no, can you post the debug console
>> output of your program?
>>
> The output of this part of the code (I will mark the part
> inside the function commitChanges();:
> ///////////begin commitChanges();/////////////////////////////
> DEBUG_at_commitChanges:before replacing:_git Name: COI:0351-123-4555
> Node version was not found!
> DEBUG_at_commitChanges:after replacing:_git Name: COI:0351-123-4555
> Found it: Name: Node:0351-123-4569 Timestamp: 1234340512
> Found it: Name: Node:0351-123-4569 Timestamp: 1234340521
> ///////////end commitChanges();/////////////////////////////
> Commit was successful!
> Retrieving the graph with commit:
> Node version was not found!
>
[...]
Nothing illuminating here... BTW, the code you ran to produce this
output cannot be the
same you posted before, as the traces are incompatible --the sentence
"Retrieving the
graph with commit:" appears nowhere in the code.
>> 3. You're copying values of the type Graph. How's this type defined?
>> Has it proper copy semantics?
>>
> Yes, I think so:
> class Graph {
> ...
> public:
>
> // TODO: Really constructors
> /// Default Constructor
> Graph() {
> _rangeBegin = 0;
> _rangeEnd = 0;
> }
> /// Copy constructors
> Graph(const Graph &g) : _rangeBegin(g._rangeBegin),
> _rangeEnd(g._rangeEnd),
> _nodeRep(g._nodeRep), _nodeNameRep(g._nodeNameRep),
> _nodeTimeStampView(g._nodeTimeStampView),
> _localPropRep(g._localPropRep),
> _globalPropRep(g._globalPropRep){}
> ...
> }
>
It's hard to know whether you got copy semantics right without knowing
the types
of _rangeBegin, _rangeEnd and the rest of Graph data members, but this
has prompted
me to suspect that maybe there's something wrong with the handler type
Graph_h (which
I assume is some sort of ref-counted reference to Graph, right?). Can
you please
test the following? In your //Test of the commit section, rather than
reuse graph_h please
use a different variable to do the after-commitChanges check:
//Test of the commit
if (graph_h.commitChanges())
cout << "Commit was successful!\n";
else
cout << "Commitretr was unsuccessful!\n";
// Debug
//Graph_h graph_h;
//NodeIterator nodeIt;
//Node_h node_h;
graphIt it = DynamicGraphs::_graphRep.find("COI:0351-123-4555");
Graph_h graph_h2 = Graph_h(it); // WE DON'T REUSE graph_h
//propertystream_h propS;
propS = graph_h2->lookupLocalProp("name");
p_h = propS.next();
cout << "DEBUG_at_main:right after the commit:_git " << p_h.value() <<endl;
nodeIt = graph_h2->nodeIterator("Node:0351-123-4569");
if (!nodeIt)
cout << "Node version was not found!"<<endl;
else //Works for both: one match and range lookup
while (!nodeIt.end()){
node_h = nodeIt.next();
cout << "Found it: " << *node_h;
}
//Debug
Does this make any difference?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net