File: simple.cpp

package info (click to toggle)
xplc 0.3.13-12.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,536 kB
  • sloc: sh: 2,739; cpp: 2,697; ansic: 1,127; makefile: 64; perl: 6
file content (43 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (11)
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
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * This file is example code for XPLC (http://xplc.sourceforge.net/),
 * and is put into the public domain.
 */

#include <stdio.h>
#include <xplc/xplc.h>
#include "IExample.h"
#include "simple.h"

/*
 * This is an helper class from the C++ binding. While it is not XPLC
 * itself (despite the name), it makes XPLC itself easier to use in
 * C++.
 *
 * It should live at least as long as you intend to use XPLC, as it
 * keeps it alive.
 *
 * Although this wastes a tiny bit of space, it is allowed to have
 * more than one XPLC helper object in a single process, since XPLC
 * uses reference counting. This is useful for libraries, which can
 * create their own XPLC helper object, and if the main application
 * also uses XPLC, or if another library used by the application uses
 * XPLC (even if the application doesn't!), they will be able to
 * cooperate through XPLC.
 */
XPLC xplc;

int main() {
  xplc.addModuleDirectory("../simple-module");

  xplc_ptr<IExample> example(xplc.get<IExample>(SimpleComponent_CID));

  if (example) {
    example->sayHello();
  } else {
    printf("SimpleComponent not found\n");
  }

  return 0;
}