File indexing completed on 2024-05-19 05:42:11

0001 // ct_lvtmdb_repositoryobject.h                                      -*-C++-*-
0002 
0003 /*
0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk>
0005 // SPDX-License-Identifier: Apache-2.0
0006 //
0007 // Licensed under the Apache License, Version 2.0 (the "License");
0008 // you may not use this file except in compliance with the License.
0009 // You may obtain a copy of the License at
0010 //
0011 //     http://www.apache.org/licenses/LICENSE-2.0
0012 //
0013 // Unless required by applicable law or agreed to in writing, software
0014 // distributed under the License is distributed on an "AS IS" BASIS,
0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 // See the License for the specific language governing permissions and
0017 // limitations under the License.
0018 */
0019 
0020 #ifndef INCLUDED_CT_LVTMDB_REPOSITORYOBJECT
0021 #define INCLUDED_CT_LVTMDB_REPOSITORYOBJECT
0022 
0023 #include <lvtmdb_export.h>
0024 
0025 #include <ct_lvtmdb_databaseobject.h>
0026 
0027 #include <string>
0028 #include <vector>
0029 
0030 namespace Codethink::lvtmdb {
0031 
0032 // Forward Declarations
0033 class PackageObject;
0034 
0035 // ====================
0036 // class RepositoryObject
0037 // ====================
0038 
0039 class LVTMDB_EXPORT RepositoryObject : public DatabaseObject {
0040     // See locking discipline in superclass. That applies here.
0041 
0042   private:
0043     std::vector<PackageObject *> d_children;
0044     std::string d_diskPath;
0045 
0046   public:
0047     // CREATORS
0048     RepositoryObject(std::string qualifiedName, std::string name, std::string path);
0049 
0050     ~RepositoryObject() noexcept override;
0051 
0052     RepositoryObject(RepositoryObject&& other) noexcept;
0053 
0054     RepositoryObject& operator=(RepositoryObject&& other) noexcept;
0055 
0056     // ACCESSORS
0057     [[nodiscard]] const std::vector<PackageObject *>& children() const;
0058     [[nodiscard]] const std::string& diskPath() const;
0059 
0060     // MANIPULATORS
0061     void addChild(PackageObject *pkg);
0062     // pkg->parent() should already point to this
0063     // an exclusive lock on this is required before calling this method
0064 };
0065 
0066 } // namespace Codethink::lvtmdb
0067 
0068 #endif // INCLUDED_CT_LVTMDB_PACKAGEOBJECT