Commit graph

51 commits

Author SHA1 Message Date
16abe82cde LocationQuery: fix a segfault due to ill guided conversion path 2017-10-27 05:12:28 +02:00
5dfd135595 Library: remove redundant checks from IterAdapter implementation
Explicitly assuming that those functions are called solely from IterAdapter
and that they are implemented in a typical standard style, we're able to elide
two redundant calls to the checkPoint() function. Since checkPoint typically performs
some non-trivial checks, this has the potential of a significant performance improvement

- we check (and throw ITER_EXHAUST) anyway from operator++, so we know that pos is valid
- the iterate() function ensures checkPoint is invoked right after iterNext,
  and thus the typical standard implementation of iterNext need not do the same
2017-10-01 03:25:33 +02:00
937ad64596 DiffMessage: now uniformly plays the role of MutationMessage (closes #1066) 2017-08-13 07:25:32 +02:00
2a26cef010 remove leftovers of first diff-applicator implementation
...obsoleted by new generic implementation
2016-09-08 18:30:27 +02:00
840d9e4397 make Rec::Mutator as such diff mutable
this adds kind of an extension point to diff::Record<GenNode>::Mutator,
which is then actually defined (implemented) within the diff framework.

This allows the TreeDiffTraits automatically to use this function
to get a TreeMutator for a given Rec::Mutator. Which in turn allows
the generic version of DiffApplicator automatically to attach and
bind to a Record<GenNode>

together this allows us to ditch the explicit specialisation
and dedicated, hand-written implementation of DiffApplication
to GenNode in favour of using the TreeMutator and friends.
2016-09-05 02:25:07 +02:00
c791763890 implement builder setup for Rec<GenNode>
this compiles just fine.
But we still need to define the concrete closures
to make it work with the actual contents of GenNode
2016-08-31 18:40:09 +02:00
57b105bbc5 fix a re-entrance problem
initially, even the diff applicator was meant to be a
"throwaway" object. But then, on writing some tests,
it seemed natural to allow re-using a single applicator,
after having attached it to some target.

With that change, I failed to care for the garbage
left back in the "old" sequence after applying one diff;
since in the typical usage sequence, the first use builds
content from scratch, this problem starts to show up only
with the third usage, where the garbage left from the input
of the second usage appears at the begin of the "new sequence"

Solution is to throw away that garbage explicitly on re-entrance
2016-06-10 02:48:22 +02:00
16086caf42 explicit error message
...turns out that inclusion of format-string.hpp
is almost irrelevant, since diff/record.hpp already
includes even format-util.hpp
2016-05-28 01:49:03 +02:00
3f8946c157 better naming of Record::Mutator content moving operation
while the original name, 'replace', conveys the intention,
this more standard name 'swap' reveals what is done
and thus opens a wider array of possible usage
2016-03-03 22:58:33 +01:00
44785859ea convenience shortcut to simplify command invocation via Bus 2016-02-13 22:55:57 +01:00
3f22150ab3 back to topic: get all the arguments of command binding logged
...when the Test-Nexus processes a command binding message.
In the real system of course we do not want to log every bind message.

The challenge here is the fact that command binding as such
is opaque, and the types of the data within the bind message
are opaque as well. Finally I settled on the compromise
to log them as strings, but only the DataCap part;
most value types applicable within GenNode
have a string representation to match.
2016-02-05 15:55:22 +01:00
ae7912dc99 refactoring: move new library helpers into final destination 2016-01-28 15:19:09 +01:00
f743784bc9 add accessor for Nth child to our Record type 2016-01-23 17:10:44 +01:00
334f542897 clean-up(#985): remove code superseded by this rework
now finally able to remove most of the cruft from format-util.hpp
and get rid of the infamous util::str
2016-01-09 02:05:23 +01:00
5874b1b4dc change lib::Record string representation to handle empty parts better
...no need to enclose empty sections when there are no
attributes or no children. Makes test code way more readable.



TestEventLog_test PASS as far as implemented
2015-12-05 03:57:11 +01:00
289bc7114c implement mutation of the current element (_THIS_)
while implementing this, I've discovered a conceptual error:
we allow to accept attributes, even when we've already entered
the child scope. This means that we can not predictable get back
at the "last" (i.e. the currently touched) element, because this
might be such an attribute. So a really correct implementation
would have to memorise the "current" element, which is really
tricky, given the various ways of touching elements in our
diff language.

In the end I've decided to ignore this problem (maybe a better
solution would have been to disallow those "late" attributes?)
My reasoning is that attributes are unlikely to be full records,
rather just values, and values are never mutated. (but note
that it is definitively possible to have an record as attribute!)
2015-11-01 03:29:35 +01:00
bc072ab336 Generic Record: change semantics of the "match" operation for objects
in the first version, I defined equality to just compare the IDs
But that didn't seem right, or what one would expect by the concept
of equality (this is a long standing discussion with persistent
object-relationally mapped data).

So I changed the semantics of equaility to be "deep".
As this means possiblty to visit a whole tree depth-first,
it seems reasonable to provide the shallow "identity-comparison" likewise.
And the most reaonable choice is to use the "matches(object)" API
for that, since, in case of objects, the matches was defined
as full equality, which now seems redundant.

Thus: from now on: obj.matches(otherObj)
means they share the same IDs
2015-10-30 21:44:43 +01:00
1101ce7210 implement opening a nested child scope for diff application 2015-10-30 04:45:22 +01:00
2882d78755 implementation: simplest case (insert element)
...so now the stage is set. We can reimplement
the handling of the list diff cases here in the context
of tree diff application. The additional twist of course
being the distinction between attribute and child scope
2015-10-24 03:15:35 +02:00
2b619d6622 implement RecordContentMutator - unit test pass 2015-10-24 01:49:07 +02:00
aa46940daa indicate how RecordContentMutator will be used 2015-10-23 21:08:33 +02:00
5cbdcc0f22 stub ContentMutator implementation 2015-10-23 20:55:02 +02:00
eabeee3b7b decide on the implementation approach for tree diff application
this boils down to the two alternatives
 - manipulate the target data structure
 - build an altered copy

since our goal is to handle large tree structures efficiently,
the decision was cast in favour of data manipulation
2015-10-23 00:40:02 +02:00
08e7e3df15 prefer more readable bool operator spelling
especially the '!' for negation is sometimes too terse
and easily overlooked.
2015-09-25 03:12:04 +02:00
8e8a67e6df test fixes up to (not including) the iteration scope bracketing
...since for the latter I'll actually chose quite another
approach, based on the HierarchyOrientationIndicator
2015-09-17 19:39:34 +02:00
b0368a6d2b full unit test coverage of equality
horay!
seems like madness?
well -- found and squashed a bug: equality on RecordRef
implicitly converted to GenNode(RecordRef), which always
generates new (distinct) IDs and so never succeeds. What
we really want is equality test on the references
2015-08-29 21:27:33 +02:00
a05c9f81a6 Segfault: one move to much
the temporary was destroyed before moving it out.
2015-08-29 01:46:24 +02:00
a56226f297 Record "object" representation now finished and passes Test 2015-08-17 22:13:36 +02:00
0bff4f21d5 Record References: fix copy and assignment handling
not entirely sure about the design, but lets try this approach:
they can be "cloned" and likewise move-assigned, but we do not
allow the regular assignment, because this would enable to use
references like pointers (what we deliberately do not want)
2015-08-17 20:56:40 +02:00
7650b36f1e Generic Record: finish implementation of Mutator
especially setting (changing) attributes turned out to be tricky,
since in case of a GenNode this would mean to re-bind the hash ID;
we can not possibly do that properly without knowing the type of the payload,
and by design this payload type is opaque (erased).

As resort, I changed the semantics of the assign operation:
now it rather builds a new payload element, with a given initialiser.
In case of the strings, this ends up being the same operation,
while in case of GenNode, this is now something entirely different:
we can now build a new GenNode "in place" of the old one, and both
will have the same symbolic ID (attribute key). Incidentally,
our Variant implementation will reject such a re-building operatinon
when this means to change the (opaque) payload type.

in addition, I created a new API function on the Mutator,
allowing to move-in a complete attribute object. Actually this
new function became the working implementation. This way, it is
still possible to emplace a new attribute efficiently (consider
this to be a whole object graph!). But only, if the key (ID)
embedded in the attribute object is already what is the intended
key for this attribute. This way, we elegantly circumvent the
problem of having to re-bind a hash ID without knowing the type seed
2015-08-17 20:31:07 +02:00
46bfc0638f Generic Record: settle type handling
initially, the intention was to inject the type as a magic attribute.
But this turned out to make the implementation brittle, asymmetric
and either quite demanding, or inefficient.

The only sane approach would be to introduce a third collection,
the metadata attributes. Then it would be possible to handle these
automatically, but expose them through the iterator.

In the end I decided against it, just the type attribute
allone does not justify that effort. So now the type is an
special magic field and kept apart from any object data.
2015-08-17 06:34:51 +02:00
0cde55a67f Generic Record: finish basic implementation 2015-08-17 03:59:53 +02:00
657f0031f4 Generic Record: reorganise type configuration
this solves the problem how to deal with value access
- for the simple default (string) implementation,
  we use a 'key = val' syntax and thus have to split strings,
  which means we need to return contents by value
- for the actual relevant use case we have GenNode entries,
  which may recursively hold further Records. For dealing
  with diff messages over this data struture, its a good
  idea to allow for const& value access (otherwise we'd
  end up copying large subtrees for trivial operaions)
2015-08-17 02:40:57 +02:00
61b6868bff pick up work where I left one month ago
OMG, what was all this about?
OK... this cant possibly work this way.
At least we need to trim after splitting the attributes.
But this is not enough, we want the value, which implies
to make the type flexible (since we cant return a const& to
a substring extracted on-the-fly)
2015-08-17 01:22:01 +02:00
430107fcd8 draft impl of Record<string>
this specialisation of the Record template is provided as
default implementation for simple unit tests
2015-08-16 01:35:31 +02:00
f565ae4639 weird warning turns out to be GCC 4.7.2 Bug 56402
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56402

The lambda definition captures the this pointer,
but the ctor of the lamda does not initialise this capture.

In our case, we're lucky, as we don't use the "this" pointer;
otherwise, we'd get a crash a runtime.

Fixed since GCC-4.7.3  --> it's *really* time to upgrade to Debian/Jessie
2015-08-16 01:35:31 +02:00
00dc968d7b implement generic attribute access in Record type 2015-08-16 01:35:30 +02:00
bfb7bbd2f5 implement Record: operator string() for diagnostics 2015-08-16 01:35:30 +02:00
5b0d58518e WIP: stub GenNode ref 2015-08-16 01:35:30 +02:00
ee6d044e33 WIP: implement the node builder API 2015-08-16 01:35:30 +02:00
d14c502ea9 WIP: decision about the builder sequence
after sleeping a night over this, it seems obvios
that we do not want to start the build proces "implicitly",
starting from a Record<GenNode>. Rather, we always want
the user to plant a dedicated Mutator object, which then
can remain noncopyable and is passed by reference through
the whole builder chain. Movin innards of *this object*
are moved away a the end of the chain does not pose much risk.
2015-08-16 01:35:30 +02:00
d92878876a WIP: attempt to define the object builder invocation chain
TODO still unresolved issues with the bootstrap.
Looks like we shall not initiate from the basic Rec(),
but reather require an explicit construction.
2015-08-16 01:35:30 +02:00
8c78af2adc bool conversion for record references (see also #477)
I decided to allow for an 'unbound' reference to allow
default construction of elements involving record references.

I am aware of the implications, but I place the focus
on the value nature of GenNode elements; the RecordRef
was introduced only as a means to cary out diff comparisons
and similar computations.
2015-08-16 01:35:30 +02:00
1810d00690 WIP: but with a notable difference to std::ref
..it can be default created, which represents the
"bottom", invalid state
2015-08-16 01:35:29 +02:00
b81419ad63 WIP: decide to implement the record ref as simple referenc wrapper 2015-08-16 01:35:29 +02:00
cecb5db972 settle on an approach for handling attributes
Initially, I considered to build an index table like
collection of ordered attributes. But since our actual
use case is Record<GenNode>, this was ruled out in favour
of just a vector<GenNode>, where the keys are embedded
right within the nameID-Field of GenNode.

A decisive factor was the observation, that this design
is basically forced to encode the attribute keys somehow
into the attribute values, because otherwise the whole
collection like initialisation and iteration would break
down. Thus, a fully generic implementation is not possible,
and a pseudo generic implementation just for the purpose of
writing unit tests would be overkill.

Basically this decision means that Record requires an
explicit specialisation to implement the attribute-key
binding for each value type to use.
2015-08-16 01:35:29 +02:00
e664ea552f stub the Record::Mutator implementation
passes compiler again
2015-08-16 01:35:28 +02:00
28c27243c8 WIP: const correctnes: Record is conceived as immutable
...and so should be all the exposed iterators.
Thanks, dear C++ compiler for spotting this subtle mismatch!
2015-08-16 01:35:28 +02:00
96e10faa84 WIP: first round of stubbing for diff::Record 2015-08-16 01:35:28 +02:00
b91734b0a6 WIP: first draft -- properties of an external symbolic record type
This Record type is intended to play a role in the
diff description / exchange of GUI data structures.
2015-08-16 01:35:28 +02:00