source: trunk/src/core/RpOutcomeCInterface.cc @ 5119

Last change on this file since 5119 was 3362, checked in by ldelgass, 11 years ago

Merge nanovis2 branch to trunk

File size: 2.6 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: C Rappture Outcome Interface Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#include "RpOutcome.h"
15#include "RpOutcomeCInterface.h"
16#include "RpOutcomeCHelper.h"
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23int
24RapptureOutcomeInit(RapptureOutcome* status)
25{
26    if (status == NULL) {
27        return -1;
28    }
29
30    status->_status = NULL;
31
32    return 0;
33}
34
35int
36RapptureOutcomeNew(RapptureOutcome* status)
37{
38    if (status == NULL) {
39        return -1;
40    }
41
42    RapptureOutcomeFree(status);
43    status->_status = (void*) new Rappture::Outcome();
44
45    return 0;
46}
47
48int
49RapptureOutcomeFree(RapptureOutcome* status)
50{
51    if (status->_status != NULL) {
52        delete ((Rappture::Outcome*)status->_status);
53        status->_status = NULL;
54    }
55    return 0;
56}
57
58int
59RpOutcomeToCOutcome(Rappture::Outcome* rpoutcome, RapptureOutcome* status)
60{
61    if (rpoutcome == NULL) {
62        return -1;
63    }
64
65    if (status == NULL) {
66        return -1;
67    }
68
69    RapptureOutcomeFree(status);
70    status->_status = new Rappture::Outcome(*rpoutcome);
71    return 0;
72}
73
74int
75RapptureOutcomeError(  RapptureOutcome* outcome,
76                       const char* errmsg,
77                       int status  )
78{
79    if (outcome == NULL) {
80        return -1;
81    }
82
83    if (outcome->_status == NULL) {
84        return -1;
85    }
86
87    ((Rappture::Outcome*)outcome->_status)->error(errmsg,status);
88    return 0;
89}
90
91int
92RapptureOutcomeClear(RapptureOutcome* status)
93{
94    if (status == NULL) {
95        return -1;
96    }
97
98    if (status->_status == NULL) {
99        return -1;
100    }
101
102    ((Rappture::Outcome*)status->_status)->clear();
103    return 0;
104}
105
106int
107RapptureOutcomeAddContext(RapptureOutcome* status, const char* msg)
108{
109    if (status == NULL) {
110        return -1;
111    }
112
113    if (status->_status == NULL) {
114        return -1;
115    }
116
117    ((Rappture::Outcome*)status->_status)->addContext(msg);
118    return 0;
119}
120
121const char*
122RapptureOutcomeRemark(RapptureOutcome* status)
123{
124    return NULL;
125}
126
127const char*
128RapptureOutcomeContext(RapptureOutcome* status)
129{
130    return NULL;
131}
132
133int
134RapptureOutcomeCheck(RapptureOutcome* status)
135{
136  return (Rappture::Outcome*)status->_status != NULL;
137}
138
139#ifdef __cplusplus
140}
141#endif // ifdef __cplusplus
Note: See TracBrowser for help on using the repository browser.