xref: /aoo42x/main/autodoc/source/ary/loc/loc_dir.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include <ary/loc/loc_dir.hxx>
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/loc/loc_file.hxx>
34 #include <sortedids.hxx>
35 #include "locs_le.hxx"
36 
37 
38 namespace ary
39 {
40 namespace loc
41 {
42 
43 struct Directory::Container
44 {
45     typedef SortedIds<Le_Compare>           SortedChildList;
46 
47 	SortedChildList     aSubDirectories;
48 	SortedChildList     aFiles;
49 
50 	                    Container()
51 	                        :   aSubDirectories(),
52 	                            aFiles()
53 	                        {}
54 };
55 
56 
57 
58 
59 Directory::Directory(Le_id i_assignedRoot)
60     :   sLocalName(),
61         nParentDirectory(0),
62         nAssignedRoot(i_assignedRoot),
63 	    aAssignedNode(),
64         pChildren(new Container)
65 {
66     aAssignedNode.Assign_Entity(*this);
67 }
68 
69 Directory::Directory( const String  &   i_localName,
70 					  Le_id             i_parentDirectory )
71     :   sLocalName(i_localName),
72         nParentDirectory(i_parentDirectory),
73         nAssignedRoot(0),
74 	    aAssignedNode(),
75         pChildren(new Container)
76 {
77     aAssignedNode.Assign_Entity(*this);
78 }
79 
80 Directory::~Directory()
81 {
82 }
83 
84 void
85 Directory::Add_Dir(const Directory  &  i_dir)
86 {
87     pChildren->aSubDirectories.Add(i_dir.LeId());
88 }
89 
90 void
91 Directory::Add_File(const File & i_file)
92 {
93     pChildren->aFiles.Add(i_file.LeId());
94 }
95 
96 Le_id
97 Directory::Search_Dir(const String & i_name) const
98 {
99     return pChildren->aSubDirectories.Search(i_name);
100 }
101 
102 Le_id
103 Directory::Search_File(const String & i_name) const
104 {
105     return pChildren->aFiles.Search(i_name);
106 }
107 
108 void
109 Directory::do_Accept(csv::ProcessorIfc & io_processor) const
110 {
111     csv::CheckedCall(io_processor,*this);
112 }
113 
114 ClassId
115 Directory::get_AryClass() const
116 {
117     return class_id;
118 }
119 
120 const String &
121 Directory::inq_LocalName() const
122 {
123     return sLocalName;
124 }
125 
126 Le_id
127 Directory::inq_ParentDirectory() const
128 {
129     return nParentDirectory;
130 }
131 
132 
133 } // namespace loc
134 } // namespace ary
135