Example #1
0
GenObject* ObjList::remove(bool delobj)
{
    GenObject *tmp = m_obj;

    if (m_next) {
	ObjList *n = m_next;
	m_next = n->next();
	m_obj = n->get();
	m_delete = n->m_delete;
	n->m_obj = 0;
	n->m_next = 0;
	n->destruct();
    }
    else
	m_obj = 0;

    if (delobj && tmp) {
	XDebug(DebugInfo,"ObjList::remove() deleting %p",tmp);
	// Don't use TelEngine::destruct(): the compiler will call the non-template
	// function (which doesn't reset the pointer)
	tmp->destruct();
	tmp = 0;
    }
    return tmp;
}
Example #2
0
bool HashList::resync()
{
    XDebug(DebugAll,"HashList::resync() [%p]",this);
    bool moved = false;
    for (unsigned int n = 0; n < m_size; n++) {
        ObjList* l = m_lists[n];
        while (l) {
            GenObject* obj = l->get();
            if (obj) {
                unsigned int i = obj->toString().hash() % m_size;
                if (i != n) {
                    bool autoDel = l->autoDelete();
                    m_lists[n]->remove(obj,false);
                    if (!m_lists[i])
                        m_lists[i] = new ObjList;
                    m_lists[i]->append(obj)->setDelete(autoDel);
                    moved = true;
                    continue;
                }
            }
            l = l->next();
        }
    }
    return moved;
}
Example #3
0
GenObject* ObjList::set(const GenObject* obj, bool delold)
{
    if (m_obj == obj)
	return 0;
    GenObject *tmp = m_obj;
    m_obj = const_cast<GenObject*>(obj);
    if (delold && tmp) {
	tmp->destruct();
	return 0;
    }
    return tmp;
}
Example #4
0
ObjList::~ObjList()
{
#ifdef XDEBUG
    Debugger debug("ObjList::~ObjList()"," [%p]",this);
#endif
    if (m_obj) {
	GenObject *tmp = m_obj;
	m_obj = 0;
	if (m_delete) {
	    XDebug(DebugInfo,"ObjList::~ObjList() deleting %p",tmp);
	    tmp->destruct();
	}
    }
    TelEngine::destruct(m_next);
}
Example #5
0
NamedList& NamedList::copyParams(const NamedList& original, ObjList* list, char childSep)
{
    XDebug(DebugInfo,"NamedList::copyParams(%p,%p,'%.1s') [%p]",
	&original,list,&childSep,this);
    for (; list; list = list->next()) {
	GenObject* obj = list->get();
	if (!obj)
	    continue;
	String name = obj->toString();
	name.trimBlanks();
	if (name)
	    copyParam(original,name,childSep);
    }
    return *this;
}
Example #6
0
GenObject* ListIterator::get(unsigned int index) const
{
    if ((index >= m_length) || !m_objects)
	return 0;
    GenObject* obj = m_objects[index];
    if (!obj)
	return 0;
    if (m_objList) {
	if (m_objList->find(obj) && obj->alive())
	    return obj;
    }
    else if (m_hashList) {
	if (m_hashList->find(obj,m_hashes[index]) && obj->alive())
	    return obj;
    }
    return 0;
}
Example #7
0
bool FallBackHandler::received(Message &msg)
{
    switch (m_type)
    {	
	case Answered:
	{ 
	    GenObject* route = s_fallbacklist[msg.getValue("targetid")];
	    s_fallbacklist.remove(route);
	    return false;
	}
	break;
	case Hangup:
	{
	    GenObject* route = s_fallbacklist[msg.getValue("id")];
	    s_fallbacklist.remove(route);
	    return false;
	}
	break;
	case Disconnect:
	{	
	    String reason=msg.getValue("reason");	
	    if (m_stoperror && m_stoperror.matches(reason)) {
		//stop fallback on this error
		GenObject* route = s_fallbacklist[msg.getValue("id")];
		s_fallbacklist.remove(route);
		return false;
	    }

	    FallBackRoute* route = static_cast<FallBackRoute*>(s_fallbacklist[msg.getValue("id")]);
	    if (route) {
		Message* r = route->get();
		if (r) {
		    r->userData(msg.userData());
		    Engine::enqueue(r);
		    return true;
		}
		s_fallbacklist.remove(route);
	    }
	    return false;
	}
	break;
    }
    return false;
}