OSDN Git Service

Version 5.91
[vbslib/main.git] / GPL_bin_fullset / NaturalDocs / Modules / NaturalDocs / Topics / Type.pm
1 ###############################################################################
2 #
3 #   Package: NaturalDocs::Topics::Type
4 #
5 ###############################################################################
6 #
7 #   A class storing information about a <TopicType>.
8 #
9 ###############################################################################
10
11 # This file is part of Natural Docs, which is Copyright © 2003-2010 Greg Valure
12 # Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
13 # Refer to License.txt for the complete details
14
15 use strict;
16 use integer;
17
18
19 package NaturalDocs::Topics::Type;
20
21 use NaturalDocs::DefineMembers 'NAME',                         'Name()',
22                                                  'PLURAL_NAME',             'PluralName()',      'SetPluralName()',
23                                                  'INDEX',                        'Index()',              'SetIndex()',
24                                                  'SCOPE',                       'Scope()',              'SetScope()',
25                                                  'PAGE_TITLE_IF_FIRST', 'PageTitleIfFirst()', 'SetPageTitleIfFirst()',
26                                                  'BREAK_LISTS',             'BreakLists()',        'SetBreakLists()',
27                                                  'CLASS_HIERARCHY',    'ClassHierarchy()',  'SetClassHierarchy()',
28                                                  'CAN_GROUP_WITH';
29
30 # Dependency: New() depends on the order of these and that there are no parent classes.
31
32 use base 'Exporter';
33 our @EXPORT = ('SCOPE_NORMAL', 'SCOPE_START', 'SCOPE_END', 'SCOPE_ALWAYS_GLOBAL');
34
35 #
36 #   Constants: Members
37 #
38 #   The object is implemented as a blessed arrayref, with the following constants as its indexes.
39 #
40 #   NAME - The topic's name.
41 #   PLURAL_NAME - The topic's plural name.
42 #   INDEX - Whether the topic is indexed.
43 #   SCOPE - The topic's <ScopeType>.
44 #   PAGE_TITLE_IF_FIRST - Whether the topic becomes the page title if it's first in a file.
45 #   BREAK_LISTS - Whether list topics should be broken into individual topics in the output.
46 #   CLASS_HIERARCHY - Whether the topic is part of the class hierarchy.
47 #   CAN_GROUP_WITH - The existence hashref of <TopicTypes> the type can be grouped with.
48 #
49
50
51
52 ###############################################################################
53 # Group: Types
54
55
56 #
57 #   Constants: ScopeType
58 #
59 #   The possible values for <Scope()>.
60 #
61 #   SCOPE_NORMAL - The topic stays in the current scope without affecting it.
62 #   SCOPE_START - The topic starts a scope.
63 #   SCOPE_END - The topic ends a scope, returning it to global.
64 #   SCOPE_ALWAYS_GLOBAL - The topic is always global, but it doesn't affect the current scope.
65 #
66 use constant SCOPE_NORMAL => 1;
67 use constant SCOPE_START => 2;
68 use constant SCOPE_END => 3;
69 use constant SCOPE_ALWAYS_GLOBAL => 4;
70
71
72
73 ###############################################################################
74 # Group: Functions
75
76
77 #
78 #   Function: New
79 #
80 #   Creates and returns a new object.
81 #
82 #   Parameters:
83 #
84 #       name - The topic name.
85 #       pluralName - The topic's plural name.
86 #       index - Whether the topic is indexed.
87 #       scope - The topic's <ScopeType>.
88 #       pageTitleIfFirst - Whether the topic becomes the page title if it's the first one in a file.
89 #       breakLists - Whether list topics should be broken into individual topics in the output.
90 #
91 sub New #(name, pluralName, index, scope, pageTitleIfFirst, breakLists)
92     {
93     my ($self, @params) = @_;
94
95     # Dependency: Depends on the parameter order matching the member order and that there are no parent classes.
96
97     my $object = [ @params ];
98     bless $object, $self;
99
100     return $object;
101     };
102
103
104 #
105 #   Functions: Accessors
106 #
107 #   Name - Returns the topic name.
108 #   PluralName - Returns the topic's plural name.
109 #   SetPluralName - Replaces the topic's plural name.
110 #   Index - Whether the topic is indexed.
111 #   SetIndex - Sets whether the topic is indexed.
112 #   Scope - Returns the topic's <ScopeType>.
113 #   SetScope - Replaces the topic's <ScopeType>.
114 #   PageTitleIfFirst - Returns whether the topic becomes the page title if it's first in the file.
115 #   SetPageTitleIfFirst - Sets whether the topic becomes the page title if it's first in the file.
116 #   BreakLists - Returns whether list topics should be broken into individual topics in the output.
117 #   SetBreakLists - Sets whether list topics should be broken into individual topics in the output.
118 #   ClassHierarchy - Returns whether the topic is part of the class hierarchy.
119 #   SetClassHierarchy - Sets whether the topic is part of the class hierarchy.
120 #
121
122
123 #
124 #   Function: CanGroupWith
125 #
126 #   Returns whether the type can be grouped with the passed <TopicType>.
127 #
128 sub CanGroupWith #(TopicType type) -> bool
129     {
130     my ($self, $type) = @_;
131     return ( defined $self->[CAN_GROUP_WITH] && exists $self->[CAN_GROUP_WITH]->{$type} );
132     };
133
134
135 #
136 #   Function: SetCanGroupWith
137 #
138 #   Sets the list of <TopicTypes> the type can be grouped with.
139 #
140 sub SetCanGroupWith #(TopicType[] types)
141     {
142     my ($self, $types) = @_;
143
144     $self->[CAN_GROUP_WITH] = { };
145
146     foreach my $type (@$types)
147         {  $self->[CAN_GROUP_WITH]->{$type} = 1;  };
148     };
149
150
151
152 1;