0024927: Getting rid of "Persistent" functionality -- Code
[occt.git] / src / PMMgt / PMMgt_InsertDelete.tcl
1 # Copyright (c) 1999-2014 OPEN CASCADE SAS
2 #
3 # This file is part of Open CASCADE Technology software library.
4 #
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License version 2.1 as published
7 # by the Free Software Foundation, with special exception defined in the file
8 # OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 # distribution for complete text of the license and disclaimer of any warranty.
10 #
11 # Alternatively, this file may be used under the terms of Open CASCADE
12 # commercial license or contractual agreement.
13
14 proc PMMgt_InsertDelete:AdmFileType {} {
15     return "dbadmfile";
16 }
17
18 proc PMMgt_InsertDelete:OutputDirTypeName {} {
19     return "dbtmpfile";
20 }
21
22
23 proc PMMgt_InsertDelete:HandleInputFile { ID } { 
24
25     scan $ID "%\[^:\]:%\[^:\]:%\[^:\]"  unit type name
26
27     switch $name {
28         Handle_PMMgt_PManaged.hxx  {return 1;} 
29         default {
30             return 0;
31         }
32     }
33 }
34 proc PMMgt_InsertDelete:AddDelete {name func} {
35     set status 0
36     set dbmsprof [wokprofile -b]
37     if {$dbmsprof != "DFLT"} {
38         set status [catch { exec grep  -s "^$func" $name >& /dev/null}]
39         if {$status != 0} { 
40             set status [catch {exec sed -e "s?public:?$func?" <$name >${name}.new}]
41             msgprint -i -c "PMMgt_InsertDelete:Execute" "mv ${name}.new  $name"
42             set status [catch {exec mv ${name}.new  $name}]
43             if {$status == 0} {
44                 set status [catch {exec chmod 664 $name}]
45             }
46         }
47     }
48
49     return $status
50 }
51
52 proc PMMgt_InsertDelete:Execute { unit args } {
53     
54     msgprint -i -c "PMMgt_InsertDelete:Execute" "Insert virtual void delete() in Handle"
55     set dbmsprof [wokprofile -b]
56
57     foreach file  $args {
58         scan $file "%\[^:\]:%\[^:\]:%\[^:\]"  Unit type name
59
60         if {$name == "Handle_PMMgt_PManaged.hxx"} {
61             set vistarget [woklocate -p PMMgt:pubinclude:$name [wokinfo -N $unit]]
62             set target    [wokinfo -p pubinclude:$name $unit]
63             set status [PMMgt_InsertDelete:AddDelete $vistarget "public: Standard_EXPORT void Delete();"]
64         }
65     }
66
67     return 0;
68 }