1 /*                                                                            */
2 /* CDDL HEADER START                                                          */
3 /*                                                                            */
4 /* The contents of this file are subject to the terms of the Common           */
5 /* Development and Distribution License Version 1.0 (the "License").          */
6 /*                                                                            */
7 /* You can obtain a copy of the license at                                    */
8 /* http://www.opensource.org/licenses/CDDL-1.0.  See the License for the      */
9 /* specific language governing permissions and limitations under the License. */
10 /*                                                                            */
11 /* When distributing Covered Code, include this CDDL HEADER in each file and  */
12 /* include the License file in a prominent location with the name             */
13 /* LICENSE.CDDL.                                                              */
14 /* If applicable, add the following below this CDDL HEADER, with the fields   */
15 /* enclosed by brackets "[]" replaced with your own identifying information:  */
16 /*                                                                            */
17 /* Portions Copyright (c) [yyyy] [name of copyright owner].                   */
18 /* All rights reserved.                                                       */
19 /*                                                                            */
20 /* CDDL HEADER END                                                            */
21 /*                                                                            */
22 
23 /*                                                                            */
24 /* Copyright (c) 2016--2020, Regents of the University of Minnesota.          */
25 /* All rights reserved.                                                       */
26 /*                                                                            */
27 /* Contributors:                                                              */
28 /*    Ryan S. Elliott                                                         */
29 /*                                                                            */
30 
31 /*                                                                            */
32 /* Release: This file is part of the kim-api-2.2.1 package.                   */
33 /*                                                                            */
34 
35 
36 #include <string>
37 
38 #ifndef KIM_LOG_VERBOSITY_HPP_
39 #include "KIM_LogVerbosity.hpp"
40 #endif
41 extern "C" {
42 #ifndef KIM_LOG_VERBOSITY_H_
43 #include "KIM_LogVerbosity.h"
44 #endif
45 }  // extern "C"
46 
47 #ifndef KIM_SUPPORT_STATUS_HPP_
48 #include "KIM_SupportStatus.hpp"
49 #endif
50 extern "C" {
51 #ifndef KIM_SUPPORT_STATUS_H_
52 #include "KIM_SupportStatus.h"
53 #endif
54 }  // extern "C"
55 
56 #ifndef KIM_COMPUTE_ARGUMENT_NAME_HPP_
57 #include "KIM_ComputeArgumentName.hpp"
58 #endif
59 extern "C" {
60 #ifndef KIM_COMPUTE_ARGUMENT_NAME_H_
61 #include "KIM_ComputeArgumentName.h"
62 #endif
63 }  // extern "C"
64 
65 #ifndef KIM_COMPUTE_CALLBACK_NAME_HPP_
66 #include "KIM_ComputeCallbackName.hpp"
67 #endif
68 extern "C" {
69 #ifndef KIM_COMPUTE_CALLBACK_NAME_H_
70 #include "KIM_ComputeCallbackName.h"
71 #endif
72 }  // extern "C"
73 
74 #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_HPP_
75 #include "KIM_ModelComputeArgumentsCreate.hpp"
76 #endif
77 extern "C" {
78 #ifndef KIM_MODEL_COMPUTE_ARGUMENTS_CREATE_H_
79 #include "KIM_ModelComputeArgumentsCreate.h"
80 #endif
81 }  // extern "C"
82 
83 
84 struct KIM_ModelComputeArgumentsCreate
85 {
86   void * p;
87 };
88 
89 #define CONVERT_POINTER                                           \
90   KIM::ModelComputeArgumentsCreate * pModelComputeArgumentsCreate \
91       = reinterpret_cast<KIM::ModelComputeArgumentsCreate *>(     \
92           modelComputeArgumentsCreate->p)
93 
94 namespace
95 {
makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity)96 KIM::LogVerbosity makeLogVerbosityCpp(KIM_LogVerbosity const logVerbosity)
97 {
98   return KIM::LogVerbosity(logVerbosity.logVerbosityID);
99 }
100 
makeSupportStatusCpp(KIM_SupportStatus const supportStatus)101 KIM::SupportStatus makeSupportStatusCpp(KIM_SupportStatus const supportStatus)
102 {
103   return KIM::SupportStatus(supportStatus.supportStatusID);
104 }
105 
106 KIM::ComputeArgumentName
makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName)107 makeComputeArgumentNameCpp(KIM_ComputeArgumentName const computeArgumentName)
108 {
109   return KIM::ComputeArgumentName(computeArgumentName.computeArgumentNameID);
110 }
111 
112 KIM::ComputeCallbackName
makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName)113 makeComputeCallbackNameCpp(KIM_ComputeCallbackName const computeCallbackName)
114 {
115   return KIM::ComputeCallbackName(computeCallbackName.computeCallbackNameID);
116 }
117 }  // namespace
118 
119 extern "C" {
KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus(KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,KIM_ComputeArgumentName const computeArgumentName,KIM_SupportStatus const supportStatus)120 int KIM_ModelComputeArgumentsCreate_SetArgumentSupportStatus(
121     KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,
122     KIM_ComputeArgumentName const computeArgumentName,
123     KIM_SupportStatus const supportStatus)
124 {
125   CONVERT_POINTER;
126 
127   return pModelComputeArgumentsCreate->SetArgumentSupportStatus(
128       makeComputeArgumentNameCpp(computeArgumentName),
129       makeSupportStatusCpp(supportStatus));
130 }
131 
KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus(KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,KIM_ComputeCallbackName const computeCallbackName,KIM_SupportStatus const supportStatus)132 int KIM_ModelComputeArgumentsCreate_SetCallbackSupportStatus(
133     KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,
134     KIM_ComputeCallbackName const computeCallbackName,
135     KIM_SupportStatus const supportStatus)
136 {
137   CONVERT_POINTER;
138 
139   return pModelComputeArgumentsCreate->SetCallbackSupportStatus(
140       makeComputeCallbackNameCpp(computeCallbackName),
141       makeSupportStatusCpp(supportStatus));
142 }
143 
KIM_ModelComputeArgumentsCreate_SetModelBufferPointer(KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,void * const ptr)144 void KIM_ModelComputeArgumentsCreate_SetModelBufferPointer(
145     KIM_ModelComputeArgumentsCreate * const modelComputeArgumentsCreate,
146     void * const ptr)
147 {
148   CONVERT_POINTER;
149 
150   pModelComputeArgumentsCreate->SetModelBufferPointer(ptr);
151 }
152 
153 
KIM_ModelComputeArgumentsCreate_LogEntry(KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate,KIM_LogVerbosity const logVerbosity,char const * const message,int const lineNumber,char const * const fileName)154 void KIM_ModelComputeArgumentsCreate_LogEntry(
155     KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate,
156     KIM_LogVerbosity const logVerbosity,
157     char const * const message,
158     int const lineNumber,
159     char const * const fileName)
160 {
161   CONVERT_POINTER;
162 
163   pModelComputeArgumentsCreate->LogEntry(
164       makeLogVerbosityCpp(logVerbosity), message, lineNumber, fileName);
165 }
166 
KIM_ModelComputeArgumentsCreate_ToString(KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate)167 char const * KIM_ModelComputeArgumentsCreate_ToString(
168     KIM_ModelComputeArgumentsCreate const * const modelComputeArgumentsCreate)
169 {
170   CONVERT_POINTER;
171 
172   return pModelComputeArgumentsCreate->ToString().c_str();
173 }
174 
175 }  // extern "C"
176