Purge underscored header file barriers
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / interfaces / garbage-collector-interface.h
1 #ifndef DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H
2 #define DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 namespace Dali
22 {
23
24 namespace V8Plugin
25 {
26
27 class BaseWrappedObject;
28
29 /**
30  * @brief Tracks all Dali-wrapped objects that are used by v8.
31  * Required to delete any wrapped objects that are not cleaned up after V8 has shut down.
32  *
33  * Unfortunately the v8 garbage collection may never run while executing a script,
34  * and currently doesn't run on shutdown (for performance reasons with Chrome browser).
35  *
36  * This means we have to manually keep track of all objects, and perform our
37  * own garbage collection on shut down.
38  *
39  * For every object created:
40  * - Store a weak handle to it
41  * - Register a callback to be informed if v8 garbage collector decides it's no longer required.
42  * -- Call back is done using v8 SetWeak(), which states:
43  *    "There is no guarantee as to *when* or even *if* the callback is invoked."
44  *
45  */
46 class GarbageCollectorInterface
47 {
48
49 public:
50
51   /**
52    * Register an object with Dali's garbage collector
53    * @param object a wrapped object
54    */
55   virtual void Register( BaseWrappedObject* object ) = 0;
56
57   /**
58    * Un-register an object with Dali's garbage collector
59    * @param object a wrapped object
60    */
61   virtual void UnRegister( BaseWrappedObject* object )  = 0;
62
63   /**
64    * Delete all
65    */
66   virtual void GarbageCollect() = 0;
67
68 protected:
69
70   /**
71    * Constructor
72    */
73   GarbageCollectorInterface()
74   {
75   }
76
77   /**
78    * virtual destructor
79    */
80   virtual ~GarbageCollectorInterface()
81   {
82   }
83
84   // Undefined copy constructor.
85   GarbageCollectorInterface( const GarbageCollectorInterface& );
86
87   // Undefined assignment operator.
88   GarbageCollectorInterface& operator=( const GarbageCollectorInterface& );
89 };
90
91 } // namespace V8Plugin
92
93 } // namespace Dali
94
95 #endif // DALI_V8PLUGIN_GARBAGE_COLLECTOR_INTERFACE_H