1Algorithm::Dependency::USsoeurrcCeo(n3t)ributed Perl DocAulmgeonrtiatthimo:n:Dependency::Source(3)
2
3
4
6 Algorithm::Dependency::Source - Implements a source of heirachy items
7
9 The Algorithm::Dependency::Source class provides an abstract parent
10 class for implementing sources for the heirachy data the algorithm will
11 use. For an example of an implementation of this, see
12 Algorithm::Dependency::Source::File, which is bundled with the main
13 Algorithm::Dependency package.
14
16 new @arguments
17 Although you cannot directly use the "new" constructor for
18 "Algorithm::Dependency::Source", it will work the same in all
19 subclasses.
20
21 The constructor takes zero or more subclass specific arguments to
22 define the location of the source of the items, and returns a new
23 object. Alrough it may check that the arguments you passed are valid,
24 the source will usually NOT actually load the items from the source,
25 instead defering the loading until you need to use the items.
26
27 Returns a new object on success, or "undef" on error.
28
29 load
30 The "load" method is the public method used to actually load the items
31 from their storage location into the the source object. The method will
32 automatically called, as needed, in most circumstances. You would
33 generally only want to use "load" manually if you think there may be
34 some uncertainty that the source will load correctly, and want to check
35 it will work.
36
37 Returns true if the items are loaded successfully, or "undef" on error.
38
39 item $name
40 The "item" method fetches and returns the item object specified by the
41 name argument.
42
43 Returns an Algorithm::Dependency::Item object on success, or "undef" if
44 the named item does not exist in the source.
45
46 items
47 The "items" method returns, as a list of objects, all of the items
48 contained in the source. The item objects will be returned in the same
49 order as that in the storage location.
50
51 Returns a list of Algorithm::Dependency::Item objects on success, or
52 "undef" on error.
53
54 missing_dependencies
55 By default, we are leniant with missing dependencies if the item is
56 neved used. For systems where having a missing dependency can be very
57 bad, the "missing_dependencies" method checks all Items to make sure
58 their dependencies exist.
59
60 If there are any missing dependencies, returns a reference to an array
61 of their ids. If there are no missing dependencies, returns 0. Returns
62 "undef" on error.
63
65 "Algorithm::Dependency::Source" itself is a fairly thin module, and it
66 is intended that you will probably need to extend it to be able to
67 extract item data from whatever location you have stored them.
68
69 This is usually a fairly simple two step process.
70
71 Overload the "new" method.
72 Assuming your subclass takes some form or argument on creation, you
73 will need to overload the "new" method to accept the arguments,
74 validate them, and store them in the source object.
75
76 Define the method "_load_item_list".
77 Leaving our parent's "load" method to take care of conflict,
78 errors, and whatever, the "_load_item_list" method is used to
79 simply create a list of Algorithm::Dependency::Item objects from
80 wherever you store the item, and return them as a list.
81
82 Having completed these two things, your subclass should be completed.
83 For an example of the code, have a look at the source for the simple
84 subclass Algorithm::Dependency::Source::File.
85
87 For general comments, contact the author.
88
89 To file a bug against this module, in a way you can keep track of, see
90 the CPAN bug tracking system.
91
92 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency>
93
95 Adam Kennedy <adamk@cpan.org>
96
98 Algorithm::Dependency, Algorithm::Dependency::Source::File
99
101 Copyright 2003 - 2009 Adam Kennedy.
102
103 This program is free software; you can redistribute it and/or modify it
104 under the same terms as Perl itself.
105
106 The full text of the license can be found in the LICENSE file included
107 with this module.
108
109
110
111perl v5.28.0 2009-04-14 Algorithm::Dependency::Source(3)