[Aptitude-devel] aptitude-qt VCS usage and code review

Piotr Galiszewski piotr at galiszewski.pl
Mon Jul 19 19:51:08 UTC 2010


2010/7/19 Daniel Burrows <dburrows at debian.org>:
> On Sun, Jul 18, 2010 at 12:37:22AM +0200, Piotr Galiszewski <piotr at galiszewski.pl> was heard to say:
>> 2010/7/16 Piotr Galiszewski <piotr at galiszewski.pl>:
>> > 2010/7/16 Daniel Burrows <dburrows at debian.org>:
>> >> On Fri, Jul 16, 2010 at 01:10:43PM +0200, Piotr Galiszewski <piotr at galiszewski.pl> was heard to say:
>> [snip]
>> >>  You shouldn't have to implement anything or borrow code from generic/.
>> >> All you need to do is hand a string to the parse routine, catch any
>> >> errors you get back, and the pass the matcher to the match routine.
>> >> For input handling, there's a controller/view pair named "search_input"
>> >> that will do the parsing for you, so you just operate at the level of
>> >> search expressions.
>> >>
>> >
>> > Thanks I will have a look on it
>> >
>>
>> Unfortunately, I can't use matcher in my case. I have to write
>> analogous code, which will match package objects on my view
>
>  Why doesn't this work?
>
> using aptitude::matching::get_match;
> using aptitude::matching::pattern;
> using aptitude::matching::search_info;
> using cwidget::util::ref_ptr;
>
> class aptitude_match_filter : public package_filter
> {
>  ref_ptr<pattern> p;
>  ref_ptr<search_cache> search_info;
>
> public:
>  aptitude_match_filter(const ref_ptr<pattern> &_p)
>    : p(_p),
>      search_info(search_info::create())
>  {
>  }
>
>  bool matches(package_ptr pkg)
>  {
>    return get_match(p, pkg.get_pkg(), search_info,
>                     *apt_cache_file, *apt_package_records).get() != NULL;
>  }
> };
>

Yes this will work. I only thought that it will be faster to use
cached members of package objects than using pkgIterator. It could be
measured, so I will try above code after finishing status_widget
implementation. Without docs, it should be ready today

>  Daniel
>
-- 
Regards
Piotr Galiszewski



More information about the Aptitude-devel mailing list