本文整理汇总了C++中Data函数的典型用法代码示例。如果您正苦于以下问题:C++ Data函数的具体用法?C++ Data怎么用?C++ Data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _getCategories
static const char* _getCategories( obj inst, Boolean* readonly) {
iOArchiveBoxData data = Data(inst);
TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "get categories [%s]", wArchiveBox.getcategories(data->ini) );
*readonly = data->readonly;
return wArchiveBox.getcategories(data->ini);
}
示例2: test_sorting_elements_SoA
void test_sorting_elements_SoA()
{
// Generating the test data
std::random_device Rd;
std::mt19937 Gen(Rd());
std::uniform_int_distribution<std::uint32_t> PrimRand(1, 6);
std::uniform_int_distribution<std::uint32_t> FirstRand(0, 1);
std::uniform_int_distribution<std::uint32_t> OffsetRand(1, 6);
std::vector<DrawElementsIndirectCommand> Data(COUNT);
Data[0].primitiveCount = PrimRand(Gen) * 3;
Data[0].instanceCount = 1;
Data[0].firstIndex = FirstRand(Gen) == 0 ? 0 : PrimRand(Gen);
Data[0].baseVertex = 0;
Data[0].baseInstance = 0;
for(std::size_t i = 1; i < Data.size(); ++i)
{
Data[i].primitiveCount = PrimRand(Gen) * 3;
Data[i].instanceCount = 1;
Data[i].firstIndex = Data[i - 1].firstIndex + Data[i - 1].primitiveCount + (std::rand() % 10 ? 0 : OffsetRand(Gen));
Data[i].baseVertex = 0;
Data[i].baseInstance = 0;
}
// Randomize the data
std::uniform_int_distribution<std::uint32_t> DataRand(0, Data.size() - 1);
for(std::size_t i = 0; i < Data.size(); ++i)
{
DrawElementsIndirectCommand Temp;
Temp.primitiveCount = Data[i].primitiveCount;
Temp.instanceCount = Data[i].instanceCount;
Temp.firstIndex = Data[i].firstIndex;
Temp.baseVertex = Data[i].baseVertex;
Temp.baseInstance = Data[i].baseInstance;
std::uint32_t SwapIndex = DataRand(Gen);
Data[i].primitiveCount = Data[SwapIndex].primitiveCount;
Data[i].instanceCount = Data[SwapIndex].instanceCount;
Data[i].firstIndex = Data[SwapIndex].firstIndex;
Data[i].baseVertex = Data[SwapIndex].baseVertex;
Data[i].baseInstance = Data[SwapIndex].baseInstance;
Data[SwapIndex].primitiveCount = Temp.primitiveCount;
Data[SwapIndex].instanceCount = Temp.instanceCount;
Data[SwapIndex].firstIndex = Temp.firstIndex;
Data[SwapIndex].baseVertex = Temp.baseVertex;
Data[SwapIndex].baseInstance = Temp.baseInstance;
}
{
// Actual testing
std::clock_t TimeStart = std::clock();
// Reording the draws
std::sort(Data.begin(), Data.end(), less);
std::clock_t TimeEnd = std::clock();
printf("Repack - sort: %lu ms\n", (TimeEnd - TimeStart) * 1000 / CLOCKS_PER_SEC);
}
// Packing the draws
std::clock_t TimeStart = std::clock();
std::size_t j = 0;
{
for(std::size_t i = 1; i < Data.size(); ++i)
{
if(Data[j].firstIndex + Data[j].primitiveCount == Data[i].firstIndex)
{
Data[j].primitiveCount += Data[i].primitiveCount;
}
else
{
++j;
Data[j].primitiveCount = Data[i].primitiveCount;
Data[j].instanceCount = Data[i].instanceCount;
Data[j].firstIndex = Data[i].firstIndex;
Data[j].baseVertex = Data[i].baseVertex;
Data[j].baseInstance = Data[i].baseInstance;
}
}
std::clock_t TimeEnd = std::clock();
printf("Repack - pack(%lu): %lu ms\n", j, (TimeEnd - TimeStart) * 1000 / CLOCKS_PER_SEC);
}
{
std::clock_t TimeStart = std::clock();
//std::vector<DrawElementsIndirectCommand> Result(j + 1);
//memcpy(&Result[0], &Data[0], Result.size() * sizeof(DrawElementsIndirectCommand));
Data.resize(j + 1);
Data.shrink_to_fit();
std::clock_t TimeEnd = std::clock();
printf("Repack - shrink: %lu ms\n", (TimeEnd - TimeStart) * 1000 / CLOCKS_PER_SEC);
//.........这里部分代码省略.........
示例3: rocs_serial_setSerialMode
void rocs_serial_setSerialMode( iOSerial inst, serial_mode mode ) {
iOSerialData o = Data(inst);
int errno;
#if defined __APPLE__
#else
struct termios tio;
if (!o->directIO) {
tcgetattr( o->sh, &tio );
tio.c_cflag &= ~PARENB;
tio.c_cflag &= ~CSTOPB;
tio.c_cflag &= ~CSIZE;
}
switch (mode) {
case mm:
/* Set Uart register for 38400baud Marklin/Motorola*/
if (o->currserialmode != mm) {
o->currserialmode = mm;
if (o->directIO) {
SystemOp.writePort( o->portbase + 3, 0x80 );
SystemOp.writePort( o->portbase + 0, 0x03 );
SystemOp.writePort( o->portbase + 1, 0x00 );
SystemOp.writePort( o->portbase + 3, 0x01 );
} else {
tio.c_cflag |= CS6;
cfsetospeed( &tio, B38400 );
cfsetispeed( &tio, B38400 );
}
}
break;
case dcc:
/* Set Uart register for 19200baud NMRA DCC */
if (o->currserialmode != dcc) {
o->currserialmode = dcc;
if (o->directIO) {
SystemOp.writePort( o->portbase + 3, 0x80 );
SystemOp.writePort( o->portbase + 0, 0x06 );
SystemOp.writePort( o->portbase + 1, 0x00 );
SystemOp.writePort( o->portbase + 3, 0x03 );
} else {
tio.c_cflag |= CS8;
cfsetospeed( &tio, B19200 );
cfsetispeed( &tio, B19200 );
}
}
break;
case mma:
if (o->currserialmode != mma) {
o->currserialmode = mma;
if (o->directIO) {
SystemOp.writePort( o->portbase + 3, 0x80 );
SystemOp.writePort( o->portbase + 0, 0x01 );
SystemOp.writePort( o->portbase + 1, 0x00 );
SystemOp.writePort( o->portbase + 3, 0x1F );
} else {
tio.c_cflag |= CS8;
tio.c_cflag |= PARENB;
tio.c_cflag |= CSTOPB;
cfsetospeed( &tio, B115200 );
cfsetispeed( &tio, B115200 );
}
break;
}
default: TraceOp.trc( __FILE__, TRCLEVEL_ERROR, __LINE__, 9999, "Error setting Serial mode!");
}
/* set attribute now */
if (!o->directIO && tcsetattr( o->sh, TCSAFLUSH, &tio ) != 0)
TraceOp.terrno( name, TRCLEVEL_WARNING, __LINE__, 9999, errno, "tcsetattr failed!" );
// tcgetattr( o->sh, &tio );
// TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "Current output baud rate is %d\n", (int) cfgetospeed(&tio) );
#endif
}
示例4: lcm_ILI9325_setup
void
lcm_ILI9325_setup(
void
)
{
#define Command(gw_cmd) *pcmd = gw_cmd
#define Data(gw_data) *pdata = gw_data
dispReg_t *pdispReg = (dispReg_t *)(LOGI_ADDR_DISP_REG);
volatile unsigned short *pcmd = (volatile unsigned short *) &pdispReg->dispLcmPgmIo00;
volatile unsigned short *pdata = (volatile unsigned short *) &pdispReg->dispLcmPgmIo10;//dispLcmPgmIo30;
// Start Initial Sequence
Command(0x00E3); Data(0x3008); // Set internal timing
Command(0x00E7); Data(0x0012); // Set internal timing
Command(0x00EF); Data(0x1231); // Set internal timing
Command(0x0001); Data(0x0100); // set SS and SM bit
Command(0x0002); Data(0x0700); // set 1 line inversion
Command(0x0003); Data(0x1018); // set GRAM write direction and BGR=1.
Command(0x0004); Data(0x0000); // Resize register
Command(0x0008); Data(0x0207); // set the back porch and front porch
Command(0x0009); Data(0x0000); // set non-display area refresh cycle ISC[3:0]
Command(0x000A); Data(0x0000); // FMARK function
Command(0x000C); Data(0x0000); // RGB interface setting
Command(0x000D); Data(0x0000); // Frame marker Position
Command(0x000F); Data(0x0000); // RGB interface polarity
// Power On sequence
Command(0x0010); Data(0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Command(0x0011); Data(0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Command(0x0012); Data(0x0000); // VREG1OUT voltage
Command(0x0013); Data(0x0000); // VDV[4:0] for VCOM amplitude
mdelay(10); // Dis-charge capacitor power voltage
Command(0x0010); Data(0x1490); // SAP, BT[3:0], AP, DSTB, SLP, STB
Command(0x0011); Data(0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
mdelay(10); // Delay 50ms
Command(0x0012); Data(0x001D); // Internal reference voltage= Vci;
mdelay(10); // Delay 50ms
Command(0x0013); Data(0x0800); // Set VDV[4:0] for VCOM amplitude
Command(0x0029); Data(0x0045); // Set VCM[5:0] for VCOMH
Command(0x002B); Data(0x000D); // Set Frame Rate
mdelay(10); // Delay 50ms
Command(0x0020); Data(0x0000); // GRAM horizontal Address
Command(0x0021); Data(0x0000); // GRAM Vertical Address
// Adjust the Gamma Curve
Command(0x0030); Data(0x0007);
Command(0x0031); Data(0x0707);
Command(0x0032); Data(0x0006);
Command(0x0035); Data(0x0704);
Command(0x0036); Data(0x1F04);
Command(0x0037); Data(0x0004);
Command(0x0038); Data(0x0000);
Command(0x0039); Data(0x0706);
Command(0x003C); Data(0x0701);
Command(0x003D); Data(0x000F);
// Set GRAM area
Command(0x0050); Data(0x0000); // Horizontal GRAM Start Address
Command(0x0051); Data(0x00EF); // Horizontal GRAM End Address
Command(0x0052); Data(0x0000); // Vertical GRAM Start Address
Command(0x0053); Data(0x013F); // Vertical GRAM Start Address
Command(0x0060); Data(0xA700); // Gate Scan Line
Command(0x0061); Data(0x0001); // NDL,VLE, REV
Command(0x006A); Data(0x0000); // set scrolling line
// Partial Display Control
Command(0x0080); Data(0x0000);
Command(0x0081); Data(0x0000);
Command(0x0082); Data(0x0000);
Command(0x0083); Data(0x0000);
Command(0x0084); Data(0x0000);
Command(0x0085); Data(0x0000);
// Panel Control
Command(0x0090); Data(0x0010);
Command(0x0092); Data(0x0600);
Command(0x0093); Data(0x0003);
Command(0x0095); Data(0x0110);
Command(0x0097); Data(0x0000);
Command(0x0098); Data(0x0000);
Command(0x0007); Data(0x0133); // 262K color and display ON
Command(0x0022);
}
示例5: Data
FString::~FString ()
{
Data()->Release();
}
示例6: CheckIdx
/** Return pointer to the index-th data item - non-const version */
FORCEINLINE T *Data(size_t index)
{
CheckIdx(index);
return (Data() + index);
}
示例7: GetItemIndex
Data GetItemIndex(void) { return (item_index ? Data(item_index) : Data()); }
示例8: __translate
static int __translate( iOSprog sprog, iONode node, char* outa, int* insize ) {
iOSprogData data = Data(sprog);
int repeat = 1;
outa[0] = '\0';
*insize = 0;
/* System command. */
if( StrOp.equals( NodeOp.getName( node ), wSysCmd.name() ) ) {
const char* cmd = wSysCmd.getcmd( node );
if( StrOp.equals( cmd, wSysCmd.stop ) || StrOp.equals( cmd, wSysCmd.ebreak ) ) {
TraceOp.trc( name, TRCLEVEL_MONITOR, __LINE__, 9999, "Power OFF" );
StrOp.fmtb( outa, "-\r" );
data->power = False;
}
else if( StrOp.equals( cmd, wSysCmd.go ) ) {
TraceOp.trc( name, TRCLEVEL_MONITOR, __LINE__, 9999, "Power ON" );
StrOp.fmtb( outa, "+\r" );
data->power = True;
}
}
/* Switch command. */
else if( StrOp.equals( NodeOp.getName( node ), wSwitch.name() ) ) {
int addr = wSwitch.getaddr1( node );
int port = wSwitch.getport1( node );
int gate = wSwitch.getgate1( node );
int fada = 0;
int pada = 0;
int dir = 1;
int action = 1;
int cmdsize = 0;
byte dcc[12];
char cmd[32] = {0};
if( port == 0 ) {
fada = addr;
AddrOp.fromFADA( addr, &addr, &port, &gate );
}
else if( addr == 0 && port > 0 ) {
pada = port;
AddrOp.fromPADA( port, &addr, &port );
}
if( fada == 0 )
fada = AddrOp.toFADA( addr, port, gate );
if( pada == 0 )
pada = AddrOp.toPADA( addr, port );
if( StrOp.equals( wSwitch.getcmd( node ), wSwitch.turnout ) )
dir = 0; /* thrown */
if( wSwitch.issinglegate( node ) ) {
dir = gate;
if( StrOp.equals( wSwitch.getcmd( node ), wSwitch.straight ) )
action = 0;
}
TraceOp.trc( name, TRCLEVEL_MONITOR, __LINE__, 9999,
"turnout %04d %d %-10.10s fada=%04d pada=%04d addr=%d port=%d gate=%d dir=%d action=%d",
addr, port, wSwitch.getcmd( node ), fada, pada, addr, port, gate, dir, action );
cmdsize = accDecoderPkt2(dcc, addr, 1, (port-1)*2+dir);
__byteToStr( cmd, dcc, cmdsize );
StrOp.fmtb( outa, "O %s\r", cmd );
TraceOp.trc( name, TRCLEVEL_BYTE, __LINE__, 9999, "DCC out: %s", outa );
*insize = 3;
repeat = 2;
}
else if( StrOp.equals( NodeOp.getName( node ), wSignal.name() ) ) {
int addr = wSignal.getaddr(node);
int port = wSignal.getport1(node);
int gate = wSignal.getgate1(node);
int aspect = wSignal.getaspect(node);
int fada = 0;
int pada = 0;
int cmdsize = 0;
byte dcc[12];
char cmd[32] = {0};
if( port == 0 ) {
fada = addr;
AddrOp.fromFADA( addr, &addr, &port, &gate );
}
else if( addr == 0 && port > 0 ) {
pada = port;
AddrOp.fromPADA( port, &addr, &port );
}
if( fada == 0 )
fada = AddrOp.toFADA( addr, port, gate );
if( pada == 0 )
pada = AddrOp.toPADA( addr, port );
TraceOp.trc( name, TRCLEVEL_MONITOR, __LINE__, 9999, "signal %04d %d %d fada=%04d pada=%04d aspect=%d",
addr, port, gate, fada, pada, aspect );
//.........这里部分代码省略.........
示例9: _setListener
static Boolean _setListener( obj inst ,obj listenerObj ,const digint_listener listenerFun ) {
iOSprogData data = Data(inst);
data->listenerObj = listenerObj;
data->listenerFun = listenerFun;
return True;
}
示例10: __id
static const char* __id( void* inst ) {
iOSprogData data = Data(inst);
return data->iid;
}
示例11: __event
static void* __event( void* inst, const void* evt ) {
iOSprogData data = Data(inst);
return NULL;
}
示例12: __properties
static void* __properties( void* inst ) {
iOSprogData data = Data(inst);
return data->ini;
}
示例13: main
int main(int argc, char *argv[])
{
//All must bow for the migthy vector of DOOOOM!
vec3 p;
eoInitAll(argc, argv, DATADIR);
//Enable mouse-selection
eoGameEnableMouseSelection(0.2);
eoExec("testbox 1");
//Load the cursor
sprite_base* dcur_sprb = eoSpriteBaseLoad(Data("/data/gfx/","cursor.spr"));
dcur_spr = eoSpriteNew( dcur_sprb, 1, 1 );
sprite_base* hcur_sprb = eoSpriteBaseLoad(Data("/data/gfx/","cursorH.spr"));
hcur_spr = eoSpriteNew( hcur_sprb, 1, 1 );
//Setup the 2D gui context
ingameContext = eoGuiContextCreate();
winHalp = eoGuiAddWindow(ingameContext, 10, 10, 200, 50, "Halp", NULL);
int lblOffset=0, lblInc=13;
eoGuiAddLabel(winHalp, 0, 0, "F1 = Console");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "h = Toggle Halp");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "click = Select Obj");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "u,o = obj move y");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "i,j,k,l = obj move x/z");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "8,9= obj rot around y");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "space =free/lock camera");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "del = delete selected object");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "shift = move slower");
lblOffset+=lblInc;
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "Cmds:");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "-------------");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "quit 1");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "addat /dir/file.obj className");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "add /dir/file.obj className");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "rot x y z");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "pos x y z");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "class [newClassName]");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "save FILENAME.lvl");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "merge FILENAME.lvl");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "pinc [num]");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "rinc [num]");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "testbox [0 or 1]");
eoGuiAddLabel(winHalp, 0, lblOffset+=lblInc, "hitbox [0 or 1]");
winHalp->_size.y +=lblOffset;
winObjInfo = eoGuiAddWindow(ingameContext, eoSetting()->res.x- 160, eoSetting()->res.y - 110, 150,100, "Object Info", NULL );
lblInfoClassName = eoGuiAddLabel( winObjInfo, 0,0, "Class: No Object ");
lblInfoId = eoGuiAddLabel( winObjInfo, 0,10, "Id: No Object ");
lblInfoPos = eoGuiAddLabel( winObjInfo, 0,20, "Pos: No Object ");
lblInfoRot = eoGuiAddLabel( winObjInfo, 0,30, "Rot: No Object ");
hackyPos.x = 0;
hackyPos.y = 2.5;
hackyPos.z = 0;
eoCamPosSet( hackyPos );
hackyPos.x = 0;
hackyPos.y = 0;
hackyPos.z = -10;
eoCamTargetSet( hackyPos );
eoExec( "camfree 1" );
eoFuncAdd( conLoadObj, NULL, "add");
eoFuncAdd( conLoadObjP, NULL, "addat");
eoFuncAdd( conRotObj, NULL, "rot");
eoFuncAdd( conPosObj, NULL, "pos");
eoFuncAdd( conClassObj, NULL, "class");
eoFuncAdd( conMergeLevel, NULL, "merge");
eoFuncAdd( conSaveLevel, NULL, "save");
eoVarAdd(CON_TYPE_VEC3,0, &hackyPos, "_selectedPos");
eoVarAdd(CON_TYPE_VEC3,0, &hackyRot, "_selectedRot");
eoVarAdd(CON_TYPE_FLOAT,0, &rinc, "rinc");
eoVarAdd(CON_TYPE_FLOAT,0, &pinc, "pinc");
//Set active context
eoGuiContextSet(ingameContext);
eoGuiWarpMouse( eoSetting()->res.x/2, eoSetting()->res.y/2 );
//Set camera to somewhere
p.x=14;
p.y=2;
//.........这里部分代码省略.........
示例14: _getCategory
static iONode _getCategory( obj inst ,const char* category ) {
iOArchiveBoxData data = Data(inst);
TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "get category [%s]", category );
return NULL;
}
示例15: Speed
void Speed (int period, int value) { Data (period, 1, value); }