source: trunk/FACT++/dim/src/dimcpp.cxx@ 19713

Last change on this file since 19713 was 15282, checked in by tbretz, 12 years ago
Updated to v20r7.
File size: 1.9 KB
Line 
1#include <assert.h>
2#include <signal.h>
3#include <stdio.h>
4#include <stdlib.h>
5#ifdef __VMS
6#include <starlet.h>
7#endif
8
9#define DIMLIB
10#include <dim_core.hxx>
11#include <dim.hxx>
12
13int DimCore::inCallback = 0;
14int DimUtil::itsBufferSize = 0;
15char *DimUtil::itsBuffer = (char *)0;
16
17extern "C" {
18static void timer_user_routine(void *tp)
19{
20 DimTimer *t = (DimTimer *)tp;
21 DimCore::inCallback = 1;
22 t->firedFlag = 1;
23 t->runningFlag = 0;
24 t->timerHandler();
25 DimCore::inCallback = 0;
26}
27}
28
29int DimTimer::start(int time)
30{
31 if(runningFlag)
32 return 0;
33 runningFlag = 1;
34 firedFlag = 0;
35 dtq_start_timer(time, timer_user_routine, this);
36 return 1;
37}
38
39int DimTimer::stop()
40{
41 firedFlag = 0;
42 runningFlag = 0;
43 return dtq_stop_timer(this);
44}
45
46DimTimer::DimTimer()
47{
48 firedFlag = 0;
49 runningFlag = 0;
50}
51
52DimTimer::DimTimer(int time)
53{
54 firedFlag = 0;
55 runningFlag = 0;
56 start(time);
57}
58
59DimTimer::~DimTimer()
60{
61 if(runningFlag)
62 stop();
63}
64
65// Threads
66
67extern "C" {
68static void thread_user_routine(void *tp)
69{
70 DimThread *t = (DimThread *)tp;
71// DimCore::inCallback = 1;
72// t->firedFlag = 1;
73// t->runningFlag = 0;
74 t->threadHandler();
75 t->itsId = 0;
76// DimCore::inCallback = 0;
77}
78}
79
80DimThread::DimThread()
81{
82// start();
83 itsId = 0;
84}
85
86DimThread::~DimThread()
87{
88// if(itsId)
89// stop();
90}
91
92int DimThread::start()
93{
94 if(!itsId)
95 {
96 itsId = (long)dim_start_thread(thread_user_routine, this);
97 return 1;
98 }
99 return 0;
100}
101/*
102int DimThread::stop()
103{
104 int ret = dim_stop_thread(itsId);
105 itsId = 0;
106 return ret;
107}
108*/
109
110DimUtil::DimUtil()
111{
112}
113
114DimUtil::~DimUtil()
115{
116}
117
118char *DimUtil::getEnvVar(char *name)
119{
120 int size;
121
122 size = dim_get_env_var(name, 0, 0);
123 if(!size)
124 return (char *)0;
125 if((itsBufferSize < size ) && (itsBufferSize != 0))
126 {
127 delete[] itsBuffer;
128 itsBufferSize = 0;
129 }
130 if(!itsBufferSize)
131 {
132 itsBuffer = new char[size];
133 itsBufferSize = size;
134 }
135 dim_get_env_var(name, itsBuffer, itsBufferSize);
136 return itsBuffer;
137}
Note: See TracBrowser for help on using the repository browser.