Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_body.hpp
1/*
2##############################################################################
3# file: ms_body.hpp
4# 'msparser' toolkit
5# Implements a reference counted body (pimpl) idiom
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2014 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11 * @(#)$Source: parser/inc/ms_body.hpp $
12 * @(#)$Revision: f7c430569a82a92eac8833564053b59680ac20a8 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
13 * @(#)$Date: 2021-01-11 13:23:17 +0000 $
14##############################################################################
15 */
16
17#ifndef MS_BODY_HPP
18#define MS_BODY_HPP
19
20
21namespace matrix_science
22{
23
24 //=========================================================================
29 class MS_MASCOTRESFILE_API ms_body
30 {
31 protected:
32 ms_body() : refcount_(0) {}
33 virtual ~ms_body() {}
34 ms_body(const ms_body &) : refcount_(0) {}
35#ifndef SWIG
36 void operator=(const ms_body &) {}
37#endif
38 private:
39 void addRef();
40 bool release(); // true means final release (refcount now zero)
41 long refcount_;
42 friend class ms_handle;
43 };
44
45 class MS_MASCOTRESFILE_API ms_handle
46 {
47 protected:
48 explicit ms_handle(ms_body * bodyPtr);
49 explicit ms_handle(const ms_handle & copy);
50 virtual ~ms_handle()
51 {
52 attachBody(0);
53 };
54#ifndef SWIG
55 const ms_handle & operator=(const ms_handle & copy);
56 ms_body * body();
57 const ms_body * body() const;
58#endif
59 void attachBody(ms_body * newBody);
60 private:
61 ms_body * body_;
62 };
63 // end of tools_group
65 //=========================================================================
66
67} // namespace matrix_science
68
69#endif // MS_BODY_HPP
70
71/*------------------------------- End of File -------------------------------*/