File: main_win.cpp

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (75 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (3)
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
// NOLINTBEGIN(*)

//+=============================================================================
//
// file :               main.cpp
//
// description :        C++ source for a TANGO device server main.
//			The main rule is to initialise (and create) the Tango
//			system and to create the DServerClass singleton.
//			The main should be the same for every Tango device server.
//
// project :            TANGO
//
// author(s) :          A.Gotz + E.Taurel
//
//
//
// copyleft :           European Synchrotron Radiation Facility
//                      BP 220, Grenoble 38043
//                      FRANCE
//
//-=============================================================================

#include <tango/tango.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg;
    Tango::Util *tg;
    try
    {
        //
        // Initialise the device server
        //
        tg = Tango::Util::init(hInstance, nCmdShow);

        //
        // Create the device server singleton which will create everything
        //
        tg->server_init(true);
        //
        // Run the endless loop
        //

        cout << "Ready to accept request" << std::endl;
        tg->server_run();
    }
    catch(std::bad_alloc)
    {
        MessageBox((HWND) NULL, "Memory error", "Command line", MB_ICONSTOP);
        return (FALSE);
    }
    catch(Tango::DevFailed &e)
    {
        MessageBox((HWND) NULL, e.errors[0].desc.in(), "Command line", MB_ICONSTOP);
        return (FALSE);
    }
    catch(CORBA::Exception &)
    {
        MessageBox((HWND) NULL, "CORBA Exception", "Command line", MB_ICONSTOP);
        return (FALSE);
    }

    while(GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    delete tg;

    return msg.wParam;
}

// NOLINTEND(*)