Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xData_1d_x.cc File Reference
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include "xData.h"

Go to the source code of this file.

Functions

int xData_init_1d_x (statusMessageReporting *smr, xData_element *element)
 
int xData_is_1d_x (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_1d_x (statusMessageReporting *smr, xData_element *element, int setMsg)
 
int xData_1d_x_copyData (statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes, double *d)
 
double * xData_1d_x_allocateCopyData (statusMessageReporting *smr, xData_element *element)
 
int xData_1d_x_free_copyData (statusMessageReporting *smr, void *data)
 

Function Documentation

◆ xData_1d_x_allocateCopyData()

double * xData_1d_x_allocateCopyData ( statusMessageReporting smr,
xData_element element 
)

Definition at line 105 of file xData_1d_x.cc.

105 {
106
107 xData_Int i, n;
108 xDataType *xDT = &(element->xDataTypeInfo);
109 double *p, *data;
110
111 if( !xData_isElement_1d_x( smr, element, 1 ) ) return( NULL );
112 n = xDT->end - xDT->start;
113 p = (double *) xDT->data;
114 //if( ( data = xData_malloc2( smr, n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
115 if( ( data = (double*) xData_malloc2( smr, n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
116 for( i = 0; i < n; i++, p++ ) data[i] = *p;
117 return( data );
118}
xData_Int end
Definition: xData.h:162
xData_Int start
Definition: xData.h:162
void * data
Definition: xData.h:163
xDataType xDataTypeInfo
Definition: xData.h:187
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
int xData_Int
Definition: xData.h:50
int xData_isElement_1d_x(statusMessageReporting *smr, xData_element *element, int setMsg)
Definition: xData_1d_x.cc:77

◆ xData_1d_x_copyData()

int xData_1d_x_copyData ( statusMessageReporting smr,
xData_element element,
xData_Int  nAllocatedBytes,
double *  d 
)

Definition at line 84 of file xData_1d_x.cc.

84 {
85
86 xData_Int i, n;
87 xDataType *xDT = &(element->xDataTypeInfo);
88 double *p;
89
90 if( !xData_isElement_1d_x( smr, element, 1 ) ) return( 1 );
91 n = xDT->end - xDT->start;
92 //if( n * sizeof( double ) > nAllocatedBytes ) {
93 if( n * sizeof( double ) > (size_t) nAllocatedBytes ) {
94 void *smrUser = xData_get_smrUserInterfaceFromElement( element );
95 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "allocated memory = %lld to small, need %lld", nAllocatedBytes, n );
96 return( 1 );
97 }
98 p = (double *) xDT->data;
99 for( i = 0; i < n; i++, d++, p++ ) *d = *p;
100 return( 0 );
101}
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
Definition: xData.cc:952

Referenced by tpia_misc_getEqualProbableBins().

◆ xData_1d_x_free_copyData()

int xData_1d_x_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 122 of file xData_1d_x.cc.

122 {
123
124 xData_free( smr, data );
125 return( 0 );
126}
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

◆ xData_init_1d_x()

int xData_init_1d_x ( statusMessageReporting smr,
xData_element element 
)

Definition at line 54 of file xData_1d_x.cc.

54 {
55
56 xDataType *xDT = &(element->xDataTypeInfo);
57
60 xDT->element = element;
61 xDT->toData = toData;
62 xDT->toString = toString;
63 xDT->release = release;
64 xDT->data = NULL;
65 return( xData_xDataTypeConvertAttributes( smr, element ) );
66}
xData_element * element
Definition: xData.h:157
enum xData_xDataType status
Definition: xData.h:155
xDT_releaseFunction release
Definition: xData.h:160
const char * typeString
Definition: xData.h:156
xDT_toStringFunction toString
Definition: xData.h:159
xDT_toDataFunction toData
Definition: xData.h:158
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
Definition: xData.cc:668
char const *const xData_oned_x_ID
Definition: xData.h:71
@ xData_xDataType_Ok
Definition: xData.h:81

◆ xData_is_1d_x()

int xData_is_1d_x ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 70 of file xData_1d_x.cc.

70 {
71
72 return( xData_is_xDataType( smr, xDT, xData_oned_x_ID, setMsg ) );
73}
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
Definition: xData.cc:900

Referenced by xData_isElement_1d_x().

◆ xData_isElement_1d_x()

int xData_isElement_1d_x ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 77 of file xData_1d_x.cc.

77 {
78
79 return( xData_is_1d_x( smr, &(element->xDataTypeInfo), setMsg ) );
80}
int xData_is_1d_x(statusMessageReporting *smr, xDataType *xDT, int setMsg)
Definition: xData_1d_x.cc:70

Referenced by xData_1d_x_allocateCopyData(), and xData_1d_x_copyData().