source: trunk/src/core/RpOutcome.h @ 1018

Last change on this file since 1018 was 1018, checked in by gah, 16 years ago

Massive changes: New directory/file layout

File size: 1.6 KB
Line 
1/*
2 * ======================================================================
3 *  Rappture::Outcome
4 *
5 *  AUTHOR:  Michael McLennan, Purdue University
6 *  Copyright (c) 2004-2007  Purdue Research Foundation
7 * ----------------------------------------------------------------------
8 *  See the file "license.terms" for information on usage and
9 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 * ======================================================================
11 */
12#ifndef RAPPTURE_OUTCOME_H
13#define RAPPTURE_OUTCOME_H
14
15#include <string>
16#include <RpPtr.h>
17
18namespace Rappture {
19
20/**
21 *  This object represents the result of any Rappture call.  It acts
22 *  like a boolean, so it can be tested for success/failure.  But
23 *  it can also contain information about failure, including a trace
24 *  back of messages indicating the cause.
25 */
26class Outcome {
27public:
28    Outcome(const char* errmsg=NULL);
29    Outcome(const Outcome& status);
30    Outcome& operator=(const Outcome& status);
31    virtual ~Outcome();
32
33    virtual Outcome& error(const char* errmsg, int status=1);
34    virtual Outcome& clear();
35
36    virtual operator int() const;
37    virtual int operator!() const;
38    virtual Outcome& operator&=(Outcome status);  // pass-by-value to avoid temp
39
40    virtual std::string remark() const;
41    virtual Outcome& addContext(const char *rem);
42    virtual std::string context() const;
43
44private:
45    /// overall pass/fail status
46    int _status;
47
48    /// error message
49    Ptr<std::string>_remarkPtr;
50
51    /// stack trace
52    Ptr<std::string>_contextPtr;
53};
54
55} // namespace Rappture
56
57#endif
Note: See TracBrowser for help on using the repository browser.