aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/service/svcenum.cpp
blob: f921965411de2386caf2093eac702d624c083ca8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <precomp.h>

//<?#include "<class data="implementationheader"/>"
#include "svcenum.h"
//?>


#include <api/service/services.h>
#include <api/service/waservicefactory.h>
#include <bfc/bfc_assert.h>

SvcEnum::SvcEnum() : type(WaSvc::NONE), factory(NULL) {
  reset();
}

void *SvcEnum::_getNext(int global_lock) {
	if (WASABI_API_SVC == NULL) return NULL;
	for (;;) {
		factory = WASABI_API_SVC->service_enumService(type, pos++);
		if (factory == NULL) return NULL;
		void *s = factory->getInterface(FALSE);// get but don't lock
		if (s)
		{
			if (_testService(s)) {
				if (global_lock)
					WASABI_API_SVC->service_lock(factory, s);	// lock in sys tables
				return s;
			}
			factory->releaseInterface(s);
		}
	}
}

void SvcEnum::reset() {
	pos = 0;
	factory = NULL;
}

int SvcEnum::release(void *ptr) {
  return WASABI_API_SVC->service_release(ptr);
}

waServiceFactory *SvcEnum::getLastFactory() {
  return factory;
}