class Paludis::Selection::Selection

Selection for an Environment selection.

Public Class Methods

new(*args) click to toggle source
VALUE
    selection_init(int, VALUE *, VALUE self)
    {
        return self;
    }

    template <typename T_>
    struct SelectionNew
    {
        static VALUE
        selection_new(VALUE self, VALUE fg_v)
        {
            Selection * ptr(0);
            try
            {
                FilteredGenerator fg(value_to_filtered_generator(fg_v));
                ptr = new T_(fg);
                VALUE data(Data_Wrap_Struct(self, 0, &Common<Selection>::free, ptr));
                rb_obj_call_init(data, 0, &self);
                return data;
            }
            catch (const std::exception & e)
            {
                delete ptr;
                exception_to_ruby_exception(e);
            }
        }
    };

    /*
     *  call-seq:
     *      to_s -> String
     *
     * Return as String
     */
    FAKE_RDOC_METHOD(selection_to_s)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> SomeArbitraryVersion
     *
     * Create new SomeArbitrartyVersion Selection
     */
    FAKE_RDOC_METHOD(some_arbitrary_version_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> BestVersionOnly
     *
     * Create new BestVersionOnly Selection
     */
    FAKE_RDOC_METHOD(best_version_only_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> BestVersionInEachSlot
     *
     * Create new BestVersionOnly Selection
     */
    FAKE_RDOC_METHOD(best_version_in_each_slot_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> AllVersionsSorted
     *
     * Create new AllVersionsSorted Selection
     */
    FAKE_RDOC_METHOD(all_versions_sorted_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> AllVersionsGroupedBySlot
     *
     * Create new AllVersionsGroupedBySlot Selection
     */
    FAKE_RDOC_METHOD(all_versions_sorted_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> AllVersionsUnsorted
     *
     * Create new AllVersionsUnsorted Selection
     */
    FAKE_RDOC_METHOD(all_versions_sorted_new)

    /*
     * call-seq:
     *     new(FilteredGenerator) -> RequireExactlyOne
     *
     * Create new RequireExactlyOne Selection
     */
    FAKE_RDOC_METHOD(all_versions_sorted_new)

    void do_register_selection()
    {
        /*
         * Document-module: Paludis::Selection
         *
         * Collection of classes to sort and select the results for an
         * Environment selection.
         */
        c_selection_module = rb_define_module_under(c_paludis_module, "Selection");

        /*
         * Document-class: Paludis::Selection::Selection
         *
         * Selection for an Environment selection.
         */
        c_selection = rb_define_class_under(c_selection_module, "Selection", rb_cObject);
        rb_funcall(c_selection, rb_intern("private_class_method"), 1, rb_str_new2("new"));
        rb_define_method(c_selection, "initialize", selection_init, -1);
        rb_define_method(c_selection, "to_s", selection_to_s, 0)

        /*
         * Document-class: Paludis::Selection::SomeArbitraryVersion
         *
         * Select some arbitrary version of some arbitrary package.
         */
        c_selection_some_arbitrary_version = rb_define_class_under(c_selection_module, "SomeArbitraryVersion", c_selection);
        rb_define_singleton_method(c_selection_some_arbitrary_version, "new",                some_arbitrary_version_new, 1)

        /*
         * Document-class: Paludis::Selection::BestVersionOnly
         *
         * Select the best version only of each package.
         */
        c_selection_best_version_only = rb_define_class_under(c_selection_module, "BestVersionOnly", c_selection);
        rb_define_singleton_method(c_selection_best_version_only, "new",                best_version_only_new, 1)

        /*
         * Document-class: Paludis::Selection::BestVersionInEachSlot
         *
         * Select the best version in each slot of each package.
         */
        c_selection_best_version_in_each_slot = rb_define_class_under(c_selection_module, "BestVersionInEachSlot", c_selection);
        rb_define_singleton_method(c_selection_best_version_in_each_slot, "new",                best_version_in_each_slot_new, 1)

        /*
         * Document-class: Paludis::Selection::AllVersionsSorted
         *
         * Select all versions, sorted.
         */
        c_selection_all_versions_sorted = rb_define_class_under(c_selection_module, "AllVersionsSorted", c_selection);
        rb_define_singleton_method(c_selection_all_versions_sorted, "new",                all_versions_sorted_new, 1)

        /*
         * Document-class: Paludis::Selection::AllVersionsGroupedBySlot
         *
         * Select all versions, sorted and grouped by slot.
         */
        c_selection_all_versions_grouped_by_slot = rb_define_class_under(c_selection_module, "AllVersionsGroupedBySlot", c_selection);
        rb_define_singleton_method(c_selection_all_versions_grouped_by_slot, "new",                all_versions_grouped_by_slot, 1)

        /*
         * Document-class: Paludis::Selection::AllVersionsUnsorted
         *
         * Select all versions, in no particular order.
         */
        c_selection_all_versions_unsorted = rb_define_class_under(c_selection_module, "AllVersionsUnsorted", c_selection);
        rb_define_singleton_method(c_selection_all_versions_unsorted, "new",                all_versions_unsorted_new, 1)

        /*
         * Document-class: Paludis::Selection::RequireExactlyOne
         *
         * Require exactly one matching ID.
         */
        c_selection_require_exactly_one = rb_define_class_under(c_selection_module, "RequireExactlyOne", c_selection);
        rb_define_singleton_method(c_selection_require_exactly_one, "new",                require_exactly_one_new, 1)
    }
}