More yateclass related cleanups.
git-svn-id: http://yate.null.ro/svn/yate/trunk@280 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
d35d4d6b4a
commit
047382865b
|
@ -9,8 +9,7 @@ DEFS :=
|
|||
INCLUDES := -I@top_srcdir@ -I../.. -I@srcdir@
|
||||
CFLAGS := -O2 @MODULE_CPPFLAGS@ @INLINE_FLAGS@
|
||||
LDFLAGS:= -L.. -lyate
|
||||
INCFILES := @top_srcdir@/yatengine.h @top_srcdir@/yatephone.h \
|
||||
@srcdir@/ysip.h @srcdir@/util.h
|
||||
INCFILES := @top_srcdir@/yateclass.h @srcdir@/ysip.h @srcdir@/util.h
|
||||
|
||||
PROGS=
|
||||
LIBS = libysip.a
|
||||
|
|
|
@ -562,11 +562,10 @@ void Driver::statusParams(String& str)
|
|||
|
||||
void Driver::statusChannels(String& str)
|
||||
{
|
||||
ObjList* l = &m_chans;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList* l = m_chans.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
Channel* c = static_cast<Channel*>(l->get());
|
||||
if (c)
|
||||
str.append(c->id(),",") << "=" << c->status() << "|" << c->address();
|
||||
str.append(c->id(),",") << "=" << c->status() << "|" << c->address();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,11 +200,9 @@ bool Configuration::save() const
|
|||
return false;
|
||||
FILE *f = ::fopen(c_str(),"w");
|
||||
if (f) {
|
||||
ObjList *ol = const_cast<ObjList *>(&m_sections);
|
||||
for (;ol;ol=ol->next()) {
|
||||
ObjList *ol = m_sections.skipNull();
|
||||
for (;ol;ol=ol->skipNext()) {
|
||||
NamedList *nl = static_cast<NamedList *>(ol->get());
|
||||
if (!nl)
|
||||
continue;
|
||||
::fprintf(f,"[%s]\n",nl->c_str());
|
||||
unsigned int n = nl->length();
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
|
|
|
@ -159,11 +159,10 @@ void DataSource::Forward(const DataBlock& data, unsigned long timeDelta)
|
|||
}
|
||||
Lock lock(m_mutex);
|
||||
ref();
|
||||
ObjList *l = &m_consumers;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList *l = m_consumers.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
DataConsumer *c = static_cast<DataConsumer *>(l->get());
|
||||
if (c)
|
||||
c->Consume(data,timeDelta);
|
||||
c->Consume(data,timeDelta);
|
||||
}
|
||||
m_timestamp += timeDelta;
|
||||
deref();
|
||||
|
@ -414,17 +413,15 @@ String DataTranslator::srcFormats(const String& dFormat)
|
|||
{
|
||||
String s;
|
||||
s_mutex.lock();
|
||||
ObjList *l = &s_factories;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList *l = s_factories.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
TranslatorFactory *f = static_cast<TranslatorFactory *>(l->get());
|
||||
if (f) {
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if (dFormat == caps->dest->name) {
|
||||
if (!s.null())
|
||||
s << " ";
|
||||
s << caps->src->name << "@" << caps->cost;
|
||||
}
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if (dFormat == caps->dest->name) {
|
||||
if (!s.null())
|
||||
s << " ";
|
||||
s << caps->src->name << "@" << caps->cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -436,17 +433,15 @@ String DataTranslator::destFormats(const String& sFormat)
|
|||
{
|
||||
String s;
|
||||
s_mutex.lock();
|
||||
ObjList *l = &s_factories;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList *l = s_factories.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
TranslatorFactory *f = static_cast<TranslatorFactory *>(l->get());
|
||||
if (f) {
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if (sFormat == caps->src->name) {
|
||||
if (!s.null())
|
||||
s << " ";
|
||||
s << caps->dest->name << "@" << caps->cost;
|
||||
}
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if (sFormat == caps->src->name) {
|
||||
if (!s.null())
|
||||
s << " ";
|
||||
s << caps->dest->name << "@" << caps->cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -458,16 +453,14 @@ int DataTranslator::cost(const String& sFormat, const String& dFormat)
|
|||
{
|
||||
int c = -1;
|
||||
s_mutex.lock();
|
||||
ObjList *l = &s_factories;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList *l = s_factories.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
TranslatorFactory *f = static_cast<TranslatorFactory *>(l->get());
|
||||
if (f) {
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if ((c == -1) || (c > caps->cost)) {
|
||||
if ((sFormat == caps->src->name) && (dFormat == caps->dest->name))
|
||||
c = caps->cost;
|
||||
}
|
||||
const TranslatorCaps *caps = f->getCapabilities();
|
||||
for (; caps && caps->src && caps->dest; caps++) {
|
||||
if ((c == -1) || (c > caps->cost)) {
|
||||
if ((sFormat == caps->src->name) && (dFormat == caps->dest->name))
|
||||
c = caps->cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -485,14 +478,12 @@ DataTranslator* DataTranslator::create(const String& sFormat, const String& dFor
|
|||
DataTranslator *trans = 0;
|
||||
|
||||
s_mutex.lock();
|
||||
ObjList *l = &s_factories;
|
||||
for (; l; l=l->next()) {
|
||||
ObjList *l = s_factories.skipNull();
|
||||
for (; l; l=l->skipNext()) {
|
||||
TranslatorFactory *f = static_cast<TranslatorFactory *>(l->get());
|
||||
if (f) {
|
||||
trans = f->create(sFormat,dFormat);
|
||||
if (trans)
|
||||
break;
|
||||
}
|
||||
trans = f->create(sFormat,dFormat);
|
||||
if (trans)
|
||||
break;
|
||||
}
|
||||
s_mutex.unlock();
|
||||
|
||||
|
|
|
@ -268,18 +268,16 @@ int Engine::run()
|
|||
while (s_haltcode == -1) {
|
||||
if (s_cmds) {
|
||||
Output("Executing initial commands");
|
||||
for (ObjList* c = s_cmds; c; c=c->next()) {
|
||||
for (ObjList* c = s_cmds->skipNull(); c; c=c->skipNext()) {
|
||||
String* s = static_cast<String*>(c->get());
|
||||
if (s) {
|
||||
Message m("engine.command");
|
||||
m.addParam("line",*s);
|
||||
if (dispatch(m)) {
|
||||
if (m.retValue())
|
||||
Output("%s",m.retValue().c_str());
|
||||
}
|
||||
else
|
||||
Debug(DebugWarn,"Unrecognized command '%s'",s->c_str());
|
||||
Message m("engine.command");
|
||||
m.addParam("line",*s);
|
||||
if (dispatch(m)) {
|
||||
if (m.retValue())
|
||||
Output("%s",m.retValue().c_str());
|
||||
}
|
||||
else
|
||||
Debug(DebugWarn,"Unrecognized command '%s'",s->c_str());
|
||||
}
|
||||
s_cmds->destruct();
|
||||
s_cmds = 0;
|
||||
|
@ -451,21 +449,20 @@ void Engine::initPlugins()
|
|||
Debug(DebugInfo,"Engine::initPlugins()");
|
||||
#endif
|
||||
dispatch("engine.init");
|
||||
ObjList *l = &plugins;
|
||||
for (; l; l = l->next()) {
|
||||
ObjList *l = plugins.skipNull();
|
||||
for (; l; l = l->skipNext()) {
|
||||
Plugin *p = static_cast<Plugin *>(l->get());
|
||||
if (p)
|
||||
p->initialize();
|
||||
p->initialize();
|
||||
}
|
||||
}
|
||||
|
||||
int Engine::usedPlugins()
|
||||
{
|
||||
int used = 0;
|
||||
ObjList *l = &plugins;
|
||||
for (; l; l = l->next()) {
|
||||
ObjList *l = plugins.skipNull();
|
||||
for (; l; l = l->skipNext()) {
|
||||
Plugin *p = static_cast<Plugin *>(l->get());
|
||||
if (p && p->isBusy())
|
||||
if (p->isBusy())
|
||||
used++;
|
||||
}
|
||||
return used;
|
||||
|
|
|
@ -86,10 +86,10 @@ NamedList& NamedList::clearParam(const String& name)
|
|||
NamedString* NamedList::getParam(const String& name) const
|
||||
{
|
||||
XDebug(DebugInfo,"NamedList::getParam(\"%s\")",name.c_str());
|
||||
const ObjList *p = &m_params;
|
||||
for (;p;p=p->next()) {
|
||||
const ObjList *p = m_params.skipNull();
|
||||
for (;p;p=p->skipNext()) {
|
||||
NamedString *s = static_cast<NamedString *>(p->get());
|
||||
if (s && (s->name() == name))
|
||||
if (s->name() == name)
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -78,6 +78,25 @@ ObjList* ObjList::last() const
|
|||
return const_cast<ObjList*>(n);
|
||||
}
|
||||
|
||||
ObjList* ObjList::skipNull() const
|
||||
{
|
||||
const ObjList *n = this;
|
||||
while (n && !n->get())
|
||||
n = n->next();
|
||||
return const_cast<ObjList*>(n);
|
||||
}
|
||||
|
||||
ObjList* ObjList::skipNext() const
|
||||
{
|
||||
const ObjList *n = this;
|
||||
while (n) {
|
||||
n = n->next();
|
||||
if (n && n->get())
|
||||
break;
|
||||
}
|
||||
return const_cast<ObjList*>(n);
|
||||
}
|
||||
|
||||
ObjList* ObjList::operator+(int index) const
|
||||
{
|
||||
if (index < 0)
|
||||
|
@ -107,11 +126,11 @@ ObjList* ObjList::find(const GenObject* obj) const
|
|||
ObjList* ObjList::find(const String& str) const
|
||||
{
|
||||
XDebug(DebugAll,"ObjList::find(\"%s\") [%p]",str.c_str(),this);
|
||||
const ObjList *n = this;
|
||||
const ObjList *n = skipNull();
|
||||
while (n) {
|
||||
if (n->get() && str.matches(n->get()->toString()))
|
||||
if (str.matches(n->get()->toString()))
|
||||
break;
|
||||
n = n->next();
|
||||
n = n->skipNext();
|
||||
}
|
||||
XDebug(DebugInfo,"ObjList::find returning %p",n);
|
||||
return const_cast<ObjList*>(n);
|
||||
|
|
12
yateclass.h
12
yateclass.h
|
@ -607,6 +607,18 @@ public:
|
|||
*/
|
||||
ObjList* last() const;
|
||||
|
||||
/**
|
||||
* Skip over NULL holding items in the list
|
||||
* @return Pointer to the first non NULL holding item in list or NULL
|
||||
*/
|
||||
ObjList* skipNull() const;
|
||||
|
||||
/**
|
||||
* Advance in the list skipping over NULL holding items
|
||||
* @return Pointer to the next non NULL holding item in list or NULL
|
||||
*/
|
||||
ObjList* skipNext() const;
|
||||
|
||||
/**
|
||||
* Pointer-like indexing operator
|
||||
* @param index Index of the list item to retrive
|
||||
|
|
Loading…
Reference in New Issue