make QueryInterface const

This commit is contained in:
Mathieu Lacage
2007-05-25 10:52:58 +02:00
parent 4358b2fd71
commit cb3ec490a5
2 changed files with 6 additions and 6 deletions

View File

@@ -110,10 +110,10 @@ Object::~Object ()
m_next = 0;
}
Ptr<Object>
Object::DoQueryInterface (InterfaceId iid)
Object::DoQueryInterface (InterfaceId iid) const
{
NS_ASSERT (Check ());
Object *currentObject = this;
const Object *currentObject = this;
do {
NS_ASSERT (currentObject != 0);
InterfaceId cur = currentObject->m_iid;
@@ -123,7 +123,7 @@ Object::DoQueryInterface (InterfaceId iid)
}
if (cur == iid)
{
return currentObject;
return const_cast<Object *> (currentObject);
}
currentObject = currentObject->m_next;
} while (currentObject != this);

View File

@@ -55,14 +55,14 @@ public:
inline void Ref (void) const;
inline void Unref (void) const;
template <typename T>
Ptr<T> QueryInterface (InterfaceId iid);
Ptr<T> QueryInterface (InterfaceId iid) const;
void Dispose (void);
void AddInterface (Ptr<Object> other);
protected:
void SetInterfaceId (InterfaceId iid);
virtual void DoDispose (void);
private:
Ptr<Object> DoQueryInterface (InterfaceId iid);
Ptr<Object> DoQueryInterface (InterfaceId iid) const;
bool Check (void) const;
void MaybeDelete (void) const;
mutable uint32_t m_count;
@@ -92,7 +92,7 @@ Object::Unref (void) const
template <typename T>
Ptr<T>
Object::QueryInterface (InterfaceId iid)
Object::QueryInterface (InterfaceId iid) const
{
Ptr<Object> found = DoQueryInterface (iid);
if (found != 0)