-
Notifications
You must be signed in to change notification settings - Fork 0
/
Environs.Cpp.cpp
156 lines (122 loc) · 4.38 KB
/
Environs.Cpp.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
* Environs CLI implementation common
* ------------------------------------------------------------------
* Copyright (c) Chi-Tai Dang
*
* @author Chi-Tai Dang
* @version 1.0
* @remarks
*
* This file is part of the Environs framework developed at the
* Lab for Human Centered Multimedia of the University of Augsburg.
* http://hcm-lab.de/environs
*
* Environ is free software; you can redistribute it and/or modify
* it under the terms of the Eclipse Public License v1.0.
* A copy of the license may be obtained at:
* http://www.eclipse.org/org/documents/epl-v10.html
* --------------------------------------------------------------------
*/
#include "stdafx.h"
#ifndef CLI_CPP
#include "Environs.h"
#include "Environs.Lib.h"
#include "Environs.Observer.h"
#include "Environs.Release.h"
#include "Environs.Native.h"
#include "Core/Kernel.h"
using namespace std;
using namespace environs::API;
#define CLASS_NAME "Environs.Cpp . . . . . ."
namespace environs
{
void EnvironsDisposer ( lib::IEnvironsDispose * obj )
{
if ( obj ) ((lib::IEnvironsDispose *) obj)->Release ();
}
namespace lib
{
class FactoryProxy
{
public:
static Environs * Create ()
{
return new Environs ();
}
static void SetHandle ( Environs * inst, int hInst )
{
inst->SetInstance ( hInst );
}
};
/// C function exported by the library
ENVIRONSAPI LIBEXPORT void * CallConv ENVIRONS_CreateInstance1 ( int crt )
{
CVerb ( ENVIRONS_TOSTRING ( ENVIRONS_CreateInstance1 ) );
#ifdef _WIN32
if ( crt != ENVIRONS_BUILD_CRT ) {
CWarnArg ( ENVIRONS_TOSTRING ( ENVIRONS_CreateInstance1 ) ": Different versions of CRT [exe = %i] != [%i = lib]", crt, ENVIRONS_BUILD_CRT );
//return 0;
}
#endif
int hEnvirons = environs::API::CreateEnvironsN ();
if ( hEnvirons <= 0 )
return 0;
Environs * api = FactoryProxy::Create ();
if ( api != nill ) {
FactoryProxy::SetHandle ( api, hEnvirons );
if ( api->Init () ) {
if ( api->Retain () )
return (void *) api;
}
delete api;
}
environs::API::DisposeN ( hEnvirons );
return nill;
}
#ifdef USE_ENVIRONS_LOG_POINTERS
ENVIRONSAPI LIBEXPORT void ENVIRONS_GetLogMethods1 ( void ** outLog, void ** outLogArg )
{
if ( !outLog || !outLogArg )
return;
*outLog = (void *) COutLog;
*outLogArg = (void *) COutArgLog;
}
#endif
#ifdef _WIN32
ENVIRONSAPI LIBEXPORT void PreDispose ( )
{
environs::API::PreDisposeN ();
}
#endif
bool Environs::InitPlatform ()
{
if ( !allocated )
{
environsObservers = make_shared < vct ( lib::IIEnvironsObserver * ) > (); // spv ( lib::IIEnvironsObserver * ) (new vector < lib::IIEnvironsObserver * >);
if ( !environsObservers )
return false;
environsObserversForMessages = make_shared < vct ( lib::IIEnvironsMessageObserver * ) > (); //spv ( lib::IIEnvironsMessageObserver * ) (new vector < lib::IIEnvironsMessageObserver * >);
if ( !environsObserversForMessages )
return false;
environsObserversForData = make_shared < vct ( lib::IIEnvironsDataObserver * ) > (); // spv ( lib::IIEnvironsDataObserver * ) (new vector < lib::IIEnvironsDataObserver * >);
if ( !environsObserversForData )
return false;
environsObserversForSensor = make_shared < vct ( lib::IIEnvironsSensorObserver * ) > (); //spv ( lib::IIEnvironsSensorDataObserver * ) (new vector < lib::IIEnvironsSensorDataObserver * >);
if ( !environsObserversForSensor )
return false;
listAllObservers = make_shared < vector < lib::IIListObserver * > > ();
if ( !listAllObservers )
return false;
listNearbyObservers = make_shared < vector < lib::IIListObserver * > > ();
if ( !listNearbyObservers )
return false;
listMediatorObservers = make_shared < vector < lib::IIListObserver * > > ();
if ( !listMediatorObservers )
return false;
}
SetCallbacksN ( hEnvirons, 0, (void *) BridgeForUdpData, (void *) BridgeForMessage, (void *) BridgeForMessageExt, (void *) BridgeForNotify, (void *) BridgeForNotifyExt, (void *) BridgeForData, (void *) BridgeForStatusMessage );
return true;
}
}
}
#endif