summaryrefslogtreecommitdiff
path: root/db/introspect.cpp
blob: 34db42a143dc774b62ed91c42d76c4742ad9be63 (plain)
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
// introspect.cpp 

#include "stdafx.h"
#include "introspect.h"
#include "../util/builder.h"
#include "../util/goodies.h"
#include "pdfile.h"
#include "jsobj.h"
#include "pdfile.h"

typedef map<string,Cursor*> StringToCursor;
StringToCursor *specialNamespaces;

auto_ptr<Cursor> getSpecialCursor(const char *ns) {
	StringToCursor::iterator it = specialNamespaces->find(ns);
	return auto_ptr<Cursor>
		(it == specialNamespaces->end() ? 
		0 : it->second->clone());
}

void SingleResultObjCursor::reg(const char *as) {
	if( specialNamespaces == 0 )
		specialNamespaces = new StringToCursor();
	if( specialNamespaces->count(as) == 0 ) {
		(*specialNamespaces)[as] = this;
	}
}

void profile(const char *str,
			 int millis)
{
	JSObjBuilder b;
	b.appendDate("ts", jsTime());
	b.append("info", str);
	b.append("millis", (double) millis);
	JSObj p = b.done();
	theDataFileMgr.insert(client->profileName.c_str(), 
		p.objdata(), p.objsize(), true);
}