Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roccom_c.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: roccom_c.C,v 1.19 2008/12/06 08:43:25 mtcampbe Exp $
24 
30 /* Author: Xiangmin Jiao */
31 
32 #include "Roccom_base.h"
33 #include "roccom_assertion.h"
34 #include <cstdarg>
35 
36 // Include C++ implementation
37 #define C_ONLY
38 #include "roccom_c.h"
39 #include "roccom_c++.h"
40 
41 USE_COM_NAME_SPACE
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 // Blocking function calls
48 void COM_call_function( const int wf, int argc, ...) {
49  COM_assertion_msg( argc <= Function::MAX_NUMARG, "Too many arguments") ;
50 
51  int i;
52  void *args[Function::MAX_NUMARG];
53  va_list ap;
54 
55  va_start( ap, argc);
56  for ( i=0; i<argc; ++i) {
57  args[i] = va_arg( ap, void*);
58  }
59  va_end( ap);
60  COM_get_roccom()->call_function( wf, argc, args);
61 }
62 
63 // Non-blocking function calls
64 void COM_icall_function( const int wf, int argc, ...) {
65  COM_assertion_msg( argc <= Function::MAX_NUMARG, "Too many arguments") ;
66 
67  int i;
68  void *args[Function::MAX_NUMARG];
69  va_list ap;
70 
71  va_start( ap, argc);
72  for ( i=0; i<argc-1; ++i) {
73  args[i] = va_arg( ap, void*);
74  }
75  int *status = va_arg( ap, int *);
76  va_end( ap);
77  COM_get_roccom()->icall_function( wf, argc, args, status);
78 }
79 
80 void COM_get_attribute( const char *wa_str, char *loc,
81  int *type, int *size, char *u_str, int u_len)
82 {
83  std::string unit;
84  COM_get_roccom()->get_attribute( wa_str, loc, type, size, &unit);
85  if ( u_str && u_len) {
86  int len=unit.size(), n=std::min(len, int(u_len));
87  std::copy( unit.c_str(), unit.c_str()+n, u_str);
88  std::fill_n( u_str+1+n, std::max(0,int(u_len-len)), 0);
89  }
90 }
91 
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 
98 
99 
100 
101 
Contains the wrapper routines for C++ binding of Roccom API.
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
Definition: roccom_c++.h:269
#define COM_assertion_msg(EX, msg)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
This file contains the C wrapper for Roccom_base.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
blockLoc i
Definition: read.cpp:79
This file contains a set of routines for error assertion.
const NT & n
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
void COM_icall_function(const int wf, int argc,...)
Definition: roccom_c.C:64
Contains declaration of the base class for Roccom implementations.