1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: Common Rappture Dictionary Source |
---|
4 | * |
---|
5 | * ====================================================================== |
---|
6 | * AUTHOR: Derrick S. Kearney, Purdue University |
---|
7 | * Copyright (c) 2005 |
---|
8 | * Purdue Research Foundation, West Lafayette, IN |
---|
9 | * ====================================================================== |
---|
10 | */ |
---|
11 | |
---|
12 | #include "RpBindingsDict.h" |
---|
13 | |
---|
14 | RpDict DICT_TEMPLATE_L ObjDict_Lib; |
---|
15 | RpDict DICT_TEMPLATE_U ObjDictUnits; |
---|
16 | |
---|
17 | int |
---|
18 | storeObject_Lib(RpLibrary* objectName) { |
---|
19 | |
---|
20 | int retVal = -1; |
---|
21 | int dictKey = ObjDict_Lib.size() + 1; |
---|
22 | int newEntry = 0; |
---|
23 | |
---|
24 | if (objectName) { |
---|
25 | // dictionary returns a reference to the inserted value |
---|
26 | // no error checking to make sure it was successful in entering |
---|
27 | // the new entry. |
---|
28 | ObjDict_Lib.set(dictKey,objectName, &newEntry); |
---|
29 | } |
---|
30 | |
---|
31 | retVal = dictKey; |
---|
32 | return retVal; |
---|
33 | } |
---|
34 | |
---|
35 | RpLibrary* |
---|
36 | getObject_Lib(int objKey) { |
---|
37 | |
---|
38 | RpLibrary* retVal = *(ObjDict_Lib.find(objKey).getValue()); |
---|
39 | |
---|
40 | if (retVal == *(ObjDict_Lib.getNullEntry().getValue())) { |
---|
41 | retVal = NULL; |
---|
42 | } |
---|
43 | |
---|
44 | return retVal; |
---|
45 | |
---|
46 | } |
---|
47 | |
---|
48 | int |
---|
49 | storeObject_UnitsStr(std::string objectName) { |
---|
50 | |
---|
51 | int retVal = -1; |
---|
52 | int dictNextKey = ObjDictUnits.size() + 1; |
---|
53 | int newEntry = 0; |
---|
54 | |
---|
55 | if (objectName != "") { |
---|
56 | // dictionary returns a reference to the inserted value |
---|
57 | // no error checking to make sure it was successful in entering |
---|
58 | // the new entry. |
---|
59 | ObjDictUnits.set(dictNextKey,objectName, &newEntry); |
---|
60 | } |
---|
61 | |
---|
62 | retVal = dictNextKey; |
---|
63 | return retVal; |
---|
64 | } |
---|
65 | |
---|
66 | RpUnits* |
---|
67 | getObject_UnitsStr(int objKey) { |
---|
68 | |
---|
69 | std::string basisName = *(ObjDictUnits.find(objKey).getValue()); |
---|
70 | |
---|
71 | if (basisName == *(ObjDictUnits.getNullEntry().getValue())) { |
---|
72 | // basisName = ""; |
---|
73 | return NULL; |
---|
74 | } |
---|
75 | |
---|
76 | return RpUnits::find(basisName); |
---|
77 | |
---|
78 | } |
---|