1 /********************************************************************************
2 *                                                                               *
3 *                                  X - O b j e c t                              *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2020 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify          *
9 * it under the terms of the GNU Lesser General Public License as published by   *
10 * the Free Software Foundation; either version 3 of the License, or             *
11 * (at your option) any later version.                                           *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
16 * GNU Lesser General Public License for more details.                           *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public License      *
19 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
20 ********************************************************************************/
21 #ifndef FXID_H
22 #define FXID_H
23 
24 #ifndef FXOBJECT_H
25 #include "FXObject.h"
26 #endif
27 
28 namespace FX {
29 
30 class FXApp;
31 
32 
33 /// Encapsulates server side resource
34 class FXAPI FXId : public FXObject {
35   FXDECLARE_ABSTRACT(FXId)
36 private:
37   FXApp *app;             // Back link to application object
38   FXptr  data;            // User data
39 protected:
40   FXID   xid;
41 private:
42   FXId(const FXId&);
43   FXId &operator=(const FXId&);
44 protected:
FXId()45   FXId():app((FXApp*)-1L),data(NULL),xid(0){}
FXId(FXApp * a)46   FXId(FXApp* a):app(a),data(NULL),xid(0){}
47 public:
48 
49   /// Get application
getApp()50   FXApp* getApp() const { return app; }
51 
52   /// Get XID handle
id()53   FXID id() const { return xid; }
54 
55   /// Create resource
56   virtual void create();
57 
58   /// Detach resource
59   virtual void detach();
60 
61   /// Destroy resource
62   virtual void destroy();
63 
64   /// Set user data pointer
setUserData(FXptr ptr)65   void setUserData(FXptr ptr){ data=ptr; }
66 
67   /// Get user data pointer
getUserData()68   FXptr getUserData() const { return data; }
69 
70   /// Save object to stream
71   virtual void save(FXStream& store) const;
72 
73   /// Load object from stream
74   virtual void load(FXStream& store);
75 
76   /// Destructor
77   virtual ~FXId();
78   };
79 
80 }
81 
82 #endif
83