Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / UpdateableServerInfo.cpp
blob5009d774fc3eb17d6c08ee085cb8781d9a20f1e5
1 #include "orbsvcs/Log_Macros.h"
2 #include "Locator_Repository.h"
3 #include "UpdateableServerInfo.h"
5 UpdateableServerInfo::UpdateableServerInfo (const Repository_Ptr& repo,
6 const ACE_CString& name,
7 int pid)
8 : repo_(repo),
9 si_(repo->get_active_server (name,pid)),
10 needs_update_(false)
14 UpdateableServerInfo::UpdateableServerInfo (const Repository_Ptr& repo,
15 const Server_Info_Ptr& si,
16 bool reset_start_count)
17 : repo_(repo),
18 si_(si),
19 needs_update_(false)
21 if (reset_start_count)
23 needs_update_ = repo_.get() != 0;
24 si_->active_info ()->start_count_ = 0;
28 UpdateableServerInfo::UpdateableServerInfo (UpdateableServerInfo& other)
29 :repo_ (other.repo_),
30 si_ (other.si_),
31 needs_update_(other.needs_update_)
33 other.needs_update_ = false;
36 UpdateableServerInfo::~UpdateableServerInfo ()
38 update_repo ();
41 void
42 UpdateableServerInfo::server_info (const Server_Info_Ptr& si)
44 this->si_ = si;
47 void
48 UpdateableServerInfo::notify_remote_access
49 (ImplementationRepository::AAM_Status state)
51 repo_->notify_remote_access (this->si_->ping_id (), state);
54 void
55 UpdateableServerInfo::update_repo ()
57 if (!needs_update_)
58 return;
60 needs_update_ = false;
61 int err = repo_->update_server (si_);
62 if (err == 0 && !si_->alt_info_.null ())
64 err = repo_->update_server (si_->alt_info_);
66 if (err != 0)
68 ORBSVCS_ERROR ((LM_ERROR,"(%P|%t) update repo failed err = %d, %p\n",
69 err, "update_server"));
73 const Server_Info*
74 UpdateableServerInfo::operator-> () const
76 return si_.get();
79 const Server_Info&
80 UpdateableServerInfo::operator* () const
82 return *(si_.get());
86 const Server_Info_Ptr&
87 UpdateableServerInfo::edit (bool active)
89 needs_update_ = active && repo_.get() != 0;
90 return si_;
93 bool
94 UpdateableServerInfo::null() const
96 return si_.null();