UniSet  2.6.0
ObjectRepository.h
00001 /*
00002  * Copyright (c) 2015 Pavel Vainerman.
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as
00006  * published by the Free Software Foundation, version 2.1.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00011  * Lesser General Lesser Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00015  */
00016 // --------------------------------------------------------------------------
00021 // --------------------------------------------------------------------------
00022 #ifndef ObjectRepository_H_
00023 #define ObjectRepository_H_
00024 // --------------------------------------------------------------------------
00025 #include <memory>
00026 #include <omniORB4/CORBA.h>
00027 #include <omniORB4/Naming.hh>
00028 #include <string>
00029 #include "UniSetTypes.h"
00030 #include "Exceptions.h"
00031 #include "Configuration.h"
00032 // -----------------------------------------------------------------------------------------
00033 namespace uniset
00034 {
00035 //namespase ORepository
00036 //{
00037 
00045 class ObjectRepository
00046 {
00047     public:
00048 
00049         ObjectRepository( const std::shared_ptr<uniset::Configuration>& conf );
00050         ~ObjectRepository();
00051 
00055 
00056         void registration(const std::string& name, const uniset::ObjectPtr oRef, const std::string& section, bool force = false) const
00057         throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
00058 
00060         void registration(const std::string& fullName, const uniset::ObjectPtr oRef, bool force = false) const
00061         throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
00062 
00064         void unregistration(const std::string& name, const std::string& section) const throw(uniset::ORepFailed, uniset::NameNotFound);
00066         void unregistration(const std::string& fullName) const throw(uniset::ORepFailed, uniset::NameNotFound);
00067         // @}
00068         // end of ORepGroup
00069 
00071         uniset::ObjectPtr resolve(const std::string& name, const std::string& NSName = "NameService")const throw(uniset::ORepFailed, uniset::NameNotFound);
00072 
00074         bool isExist( const uniset::ObjectPtr& oref ) const;
00076         bool isExist( const std::string& fullName ) const;
00077 
00084         enum ObjectType
00085         {
00086             ObjectRef,  
00087             Section     
00088         };
00089 
00091         bool list(const std::string& section, uniset::ListObjectName* ls, size_t how_many = 300)throw(uniset::ORepFailed);
00092 
00094         bool listSections(const std::string& in_section, uniset::ListObjectName* ls, size_t how_many = 300)throw(uniset::ORepFailed);
00095 
00096         // -------------------------------------------------------------------
00098         bool createSection( const std::string& name, const std::string& in_section )throw(uniset::ORepFailed, uniset::InvalidObjectName);
00099 
00101         bool createSectionF(const std::string& fullName)throw(uniset::ORepFailed, uniset::InvalidObjectName);
00102 
00104         bool createRootSection(const std::string& name);
00105 
00107         bool removeSection(const std::string& fullName, bool recursive = false);
00108 
00110         bool renameSection(const std::string& newName, const std::string& fullName);
00111 
00113         void printSection(const std::string& fullName);
00114 
00115         // @}
00116         // end of add to ORepServiceGroup
00117 
00118     protected:
00119 
00120         ObjectRepository();
00121         mutable std::string nsName;
00122         std::shared_ptr<uniset::Configuration> uconf;
00123 
00124         bool list(const std::string& section, uniset::ListObjectName* ls, unsigned int how_many, ObjectType type);
00125 
00127         bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx);
00128 
00129     private:
00130         bool init() const;
00131         mutable CosNaming::NamingContext_var localctx;
00132 };
00133 // -------------------------------------------------------------------------
00134 } // end of uniset namespace
00135 //};
00136 // -----------------------------------------------------------------------------------------
00137 #endif
00138 // -----------------------------------------------------------------------------------------