ZeusBase-Library  2.0.4
Naming.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch)
3  *****************************************************************************
4  * Project : Zeus Base Library
5  * Module : Naming
6  * Package : Zeus.ZeusBase.Remote
7  * Author : Benjamin Hadorn
8  * Date : 27.12.2011
9  * System : Zeus-Framework
10  *****************************************************************************
11  * Licence: *
12  * This library is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU Lesser General Public License as *
14  * published by the Free Software Foundation; either version *
15  * 2.1 of the License, or (at your option) any later version. *
16  * *
17  * This library is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU Lesser General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU Lesser General Public *
23  * License along with this library; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
25  *****************************************************************************/
26 
27 /*****************************************************************************
28  * Changes:
29  * 27.12.2011 bha: created zeus 2.0
30  *****************************************************************************/
31 
32 #ifndef NamingH
33 #define NamingH
34 
35 
40 
42 
44 #define Naming TNaming::getInstance()
45 
46 class TCriticalSection;
47 class TXMLStream;
48 
49 /***************************************************************************/
60 /***************************************************************************/
62 {
63  public:
64  static TNaming& getInstance();
65  static Retval createNewInstance(TNaming*& rpObject);
66 
67  Retval connect(const TString& rAddress, Uint uiPort);
68  void disconnect();
69  Retval getLocalContext(INamedContext*& rpContext);
70  void setDelegationInterface(INaming* pIface);
71 
72  //Methods of INaming
73  virtual bool MQUALIFIER hasRemoteContext() const;
74  virtual bool MQUALIFIER isConnected() const;
75  virtual void MQUALIFIER releaseLocalContext();
76 
77  //Methods of INaming
78  virtual Retval MQUALIFIER bind(const IString& rName, const IRemoteObject& rObject);
79  virtual Retval MQUALIFIER rebind(const IString& rName, const IRemoteObject& rObject);
80  virtual Retval MQUALIFIER unbind(const IString& rName);
81  virtual Retval MQUALIFIER lookup(const IString& rQuery, IRemoteObject*& rpObject);
82  virtual Retval MQUALIFIER lookupObjects(const IString& rQuery, IRemoteObjectList& rObjects);
83  virtual Retval MQUALIFIER lookupAny(const IString& rQuery, IRemoteObject*& rpObject);
84 
85  virtual Retval MQUALIFIER getObjectNames(const IString& rQuery, IStringList& rNames);
86 
87 
88  //Methods of IZUnknown
90 
91  protected:
92  void createLocalContext();
93  bool checkAndCreateLocalContext();
94 
96  //Compiler problem on older version from microsoft
97  #ifdef _MSC_VER
98  public:
99  #endif
100 
102  TNaming();
103  virtual ~TNaming();
104 
105  private:
107  static TAutoPtr<TNaming> m_ptrNaming;
109  TCriticalSection& m_rLock;
111  TAutoPtr<INaming> m_ptrDelegationInterface;
113  TAutoPtr<INamedContext> m_ptrRemoteContext;
115  TAutoPtr<INamedContext> m_ptrLocalContext;
117  TXMLStream* m_pLocalXMLData;
118 };
119 
120 //INLINE METHDOS
121 /***************************************************************************/
125 /***************************************************************************/
126 inline /*static*/ TNaming& TNaming::getInstance()
127 {
128  return *m_ptrNaming;
129 }
130 
131 /***************************************************************************/
134 /***************************************************************************/
135 inline bool TNaming::checkAndCreateLocalContext()
136 {
137  if (m_ptrLocalContext == NULL)
138  {
139  createLocalContext();
140  }
141  return (m_ptrLocalContext != NULL);
142 }
143 
144 /***************************************************************************/
147 /***************************************************************************/
148 inline bool MQUALIFIER TNaming::hasRemoteContext() const
149 {
150  bool bRetval = false;
151  if (m_ptrDelegationInterface != NULL)
152  {
153  bRetval = m_ptrDelegationInterface->hasRemoteContext();
154  }
155  else
156  {
157  bRetval = (m_ptrRemoteContext != NULL);
158  }
159  return bRetval;
160 }
161 
162 /***************************************************************************/
165 /***************************************************************************/
166 inline bool MQUALIFIER TNaming::isConnected() const
167 {
168  bool bRetval = false;
169  if (m_ptrDelegationInterface != NULL)
170  {
171  bRetval = m_ptrDelegationInterface->isConnected();
172  }
173  else
174  {
175  bRetval = false; //TODO
176  }
177  return bRetval;
178 }
179 
180 
182 
183 #endif
Definition: ZObject.h:57
#define END_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:96
#define zeusbase_class
Definition: PlatformDefines.hpp:165
#define IRemoteObjectList
Definition: IRemoteObject.hpp:43
#define MQUALIFIER
Definition: LinuxPlatform.hpp:64
Definition: IList.hpp:57
#define BEGIN_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:95
Definition: INamedContext.hpp:51
Definition: XMLStream.h:49
Definition: String.h:113
Definition: Naming.h:61
Definition: IRemoteObject.hpp:52
Definition: CriticalSection.h:52
Definition: AutoPtr.hpp:274
Definition: INaming.hpp:48
#define MEMORY_MANAGER_DECL
Definition: IZUnknownImplHelper.hpp:44
Definition: IString.hpp:48


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Tue Sep 13 2016 22:30:46