hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
92a5c7f2a916af5dad02a0129e148cf91381964f
21,312
cpp
C++
src/S2LP.cpp
cparata/S2-LP
620eb9026749425bd8bf8cd8929711aae8f831fd
[ "BSD-3-Clause" ]
4
2020-06-10T00:10:36.000Z
2021-07-04T16:12:41.000Z
src/S2LP.cpp
cparata/S2-LP
620eb9026749425bd8bf8cd8929711aae8f831fd
[ "BSD-3-Clause" ]
3
2021-04-16T15:50:28.000Z
2021-09-15T14:59:51.000Z
src/S2LP.cpp
cparata/S2-LP
620eb9026749425bd8bf8cd8929711aae8f831fd
[ "BSD-3-Clause" ]
5
2020-03-25T09:39:02.000Z
2022-03-09T18:48:10.000Z
/** ****************************************************************************** * @file S2LP.cpp * @author SRA * @version V1.0.0 * @date March 2020 * @brief Implementation of a S2-LP sub-1GHz transceiver. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "S2LP.h" /* Defines -------------------------------------------------------------------*/ #define HEADER_WRITE_MASK 0x00 /*!< Write mask for header byte*/ #define HEADER_READ_MASK 0x01 /*!< Read mask for header byte*/ #define HEADER_ADDRESS_MASK 0x00 /*!< Address mask for header byte*/ #define HEADER_COMMAND_MASK 0x80 /*!< Command mask for header byte*/ #define S2LP_CMD_SIZE 2 #define BUILT_HEADER(add_comm, w_r) (add_comm | w_r) /*!< macro to build the header byte*/ #define WRITE_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) /*!< macro to build the write header byte*/ #define READ_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK) /*!< macro to build the read header byte*/ #define COMMAND_HEADER BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) /*!< macro to build the command header byte*/ #define LINEAR_FIFO_ADDRESS 0xFF /*!< Linear FIFO address*/ /* Class Implementation ------------------------------------------------------*/ /** Constructor * @param spi object of the instance of the spi peripheral * @param csn the spi chip select pin * @param sdn the shutdown pin * @param irqn the pin to receive IRQ event * @param frequency the base carrier frequency in Hz * @param xtalFrequency the crystal oscillator frequency * @param paInfo information about external power amplifier * @param irq_gpio the S2-LP gpio used to receive the IRQ events * @param my_addr address of the device * @param multicast_addr multicast address * @param broadcast_addr broadcast address */ S2LP::S2LP(SPIClass *spi, int csn, int sdn, int irqn, uint32_t frequency, uint32_t xtalFrequency, PAInfo_t paInfo, S2LPGpioPin irq_gpio, uint8_t my_addr, uint8_t multicast_addr, uint8_t broadcast_addr) : dev_spi(spi), csn_pin(csn), sdn_pin(sdn), irq_pin(irqn), lFrequencyBase(frequency), s_lXtalFrequency(xtalFrequency), s_paInfo(paInfo), irq_gpio_selected(irq_gpio), my_address(my_addr), multicast_address(multicast_addr), broadcast_address(broadcast_addr) { Callback<void()>::func = std::bind(&S2LP::S2LPIrqHandler, this); irq_handler = static_cast<S2LPEventHandler>(Callback<void()>::callback); memset((void *)&g_xStatus, 0, sizeof(S2LPStatus)); s_cWMbusSubmode = WMBUS_SUBMODE_NOT_CONFIGURED; current_event_callback = NULL; nr_of_irq_disabled = 0; xTxDoneFlag = RESET; memset((void *)vectcRxBuff, 0, FIFO_SIZE*sizeof(uint8_t)); memset((void *)vectcTxBuff, 0, FIFO_SIZE*sizeof(uint8_t)); cRxData = 0; is_waiting_for_read = false; is_bypass_enabled = false; } /** * @brief Initialize the S2-LP library. * @param None. * @retval None. */ void S2LP::begin(void) { pinMode(csn_pin, OUTPUT); digitalWrite(csn_pin, HIGH); pinMode(sdn_pin, OUTPUT); /* Shutdown the S2-LP */ digitalWrite(sdn_pin, HIGH); delay(1); digitalWrite(sdn_pin, LOW); delay(1); /* S2-LP soft reset */ S2LPCmdStrobeSres(); SGpioInit xGpioIRQ={ irq_gpio_selected, S2LP_GPIO_MODE_DIGITAL_OUTPUT_LP, S2LP_GPIO_DIG_OUT_IRQ }; S2LPGpioInit(&xGpioIRQ); SRadioInit xRadioInit = { lFrequencyBase, /* base carrier frequency */ MOD_2FSK, /* modulation type */ 38400, /* data rate */ 20000, /* frequency deviation */ 100000 /* bandwidth */ }; S2LPRadioInit(&xRadioInit); S2LPRadioSetMaxPALevel(S_DISABLE); if(s_paInfo.paRfRangeExtender == RANGE_EXT_NONE) { S2LPRadioSetPALeveldBm(7, 12); } else { /* in case we are using a board with external PA, the S2LPRadioSetPALeveldBm will be not functioning because the output power is affected by the amplification of this external component. Set the raw register. */ /* For example, paLevelValue=0x25 will give about 19dBm on a STEVAL FKI-915V1 */ S2LPSpiWriteRegisters(PA_POWER8_ADDR, 1, &s_paInfo.paLevelValue); if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SE2435L) { S2LPGpioInit(&s_paInfo.paSignalCSD_S2LP); S2LPGpioInit(&s_paInfo.paSignalCPS_S2LP); S2LPGpioInit(&s_paInfo.paSignalCTX_S2LP); } else if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { pinMode(s_paInfo.paSignalCSD_MCU, OUTPUT); pinMode(s_paInfo.paSignalCPS_MCU, OUTPUT); pinMode(s_paInfo.paSignalCTX_MCU, OUTPUT); } } S2LPRadioSetPALevelMaxIndex(7); PktBasicInit xBasicInit={ 16, /* Preamble length */ 32, /* Sync length */ 0x88888888, /* Sync word */ S_ENABLE, /* Variable length */ S_DISABLE, /* Extended length field */ PKT_CRC_MODE_8BITS, /* CRC mode */ S_ENABLE, /* Enable address */ S_DISABLE, /* Enable FEC */ S_ENABLE /* Enable Whitening */ }; S2LPPktBasicInit(&xBasicInit); PktBasicAddressesInit xAddressInit={ S_ENABLE, /* Filtering my address */ my_address, /* My address */ S_ENABLE, /* Filtering multicast address */ multicast_address, /* Multicast address */ S_ENABLE, /* Filtering broadcast address */ broadcast_address /* broadcast address */ }; S2LPPktBasicAddressesInit(&xAddressInit); SCsmaInit xCsmaInit={ S_ENABLE, /* Persistent mode enable/disable */ CSMA_PERIOD_64TBIT, /* CS Period */ 3, /* CS Timeout */ 5, /* Max number of backoffs */ 0xFA21, /* BU counter seed */ 32 /* CU prescaler */ }; S2LPCsmaInit(&xCsmaInit); S2LPPacketHandlerSetRxPersistentMode(S_ENABLE); SRssiInit xSRssiInit = { .cRssiFlt = 14, .xRssiMode = RSSI_STATIC_MODE, .cRssiThreshdBm = -60, }; S2LPRadioRssiInit(&xSRssiInit); S2LPManagementRcoCalibration(); /* Enable PQI */ S2LPRadioSetPqiCheck(0x00); S2LPRadioSetPqiCheck(S_ENABLE); /* S2LP IRQs enable */ S2LPGpioIrqDeInit(NULL); S2LPGpioIrqConfig(RX_DATA_READY,S_ENABLE); S2LPGpioIrqConfig(TX_DATA_SENT , S_ENABLE); /* clear FIFO if needed */ S2LPCmdStrobeFlushRxFifo(); /* Set infinite Timeout */ S2LPTimerSetRxTimerCounter(0); S2LPTimerSetRxTimerStopCondition(ANY_ABOVE_THRESHOLD); /* IRQ registers blanking */ S2LPGpioIrqClearStatus(); uint8_t tmp = 0x90; S2LPSpiWriteRegisters(0x76, 1, &tmp); if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { FEM_Operation_SKY66420(FEM_RX); } /* Go to RX state */ S2LPCmdStrobeCommand(CMD_RX); attachInterrupt(irq_pin, irq_handler, FALLING); } /** * @brief DeInitialize the S2-LP library. * @param None. * @retval None. */ void S2LP::end(void) { /* Shutdown the S2-LP */ digitalWrite(sdn_pin, HIGH); delay(1); digitalWrite(sdn_pin, LOW); delay(1); /* S2-LP soft reset */ S2LPCmdStrobeSres(); /* Detach S2-LP IRQ */ detachInterrupt(irq_pin); /* Reset CSN pin */ pinMode(csn_pin, INPUT); /* Reset SDN pin */ pinMode(sdn_pin, INPUT); /* Reset CSD, CPS and CTX if it is needed */ if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { pinMode(s_paInfo.paSignalCSD_MCU, INPUT); pinMode(s_paInfo.paSignalCPS_MCU, INPUT); pinMode(s_paInfo.paSignalCTX_MCU, INPUT); } /* Reset all internal variables */ memset((void *)&g_xStatus, 0, sizeof(S2LPStatus)); s_cWMbusSubmode = WMBUS_SUBMODE_NOT_CONFIGURED; current_event_callback = NULL; nr_of_irq_disabled = 0; xTxDoneFlag = RESET; memset((void *)vectcRxBuff, 0, FIFO_SIZE*sizeof(uint8_t)); memset((void *)vectcTxBuff, 0, FIFO_SIZE*sizeof(uint8_t)); cRxData = 0; is_waiting_for_read = false; is_bypass_enabled = false; } /** * @brief Attach the callback for Receive event. * @param func the Receive callback. * @retval None. */ void S2LP::attachS2LPReceive(S2LPEventHandler func) { current_event_callback = func; } /** * @brief Send the payload packet. * @param payload pointer to the data to be sent. * @param payload_len length in bytes of the payload data. * @param dest_addr destination address. * @param use_csma_ca should CSMA/CA be enabled for transmission. * @retval zero in case of success, non-zero error code otherwise. * @note the maximum payload size allowed is 128 bytes */ uint8_t S2LP::send(uint8_t *payload, uint8_t payload_len, uint8_t dest_addr, bool use_csma_ca) { uint32_t start_time; uint32_t current_time; if(payload_len > FIFO_SIZE) { return 1; } disableS2LPIrq(); /* Go to Ready mode */ if(S2LPSetReadyState()) { enableS2LPIrq(); return 1; } S2LPPktBasicSetPayloadLength(payload_len); S2LPSetRxSourceReferenceAddress(dest_addr); if(use_csma_ca) { S2LPCsma(S_ENABLE); } /* Flush TX FIFO */ S2LPCmdStrobeCommand(CMD_FLUSHTXFIFO); memcpy(vectcTxBuff, payload, payload_len); S2LPSpiWriteFifo(payload_len, vectcTxBuff); /* IRQ registers blanking */ S2LPGpioIrqClearStatus(); enableS2LPIrq(); uint8_t tmp=0x9C; S2LPSpiWriteRegisters(0x76,1,&tmp); if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { FEM_Operation_SKY66420(FEM_TX); } S2LPCmdStrobeCommand(CMD_TX); start_time = millis(); /* wait for TX done */ do { current_time = millis(); } while(!xTxDoneFlag && (current_time - start_time) <= 1000); if(use_csma_ca) { S2LPCsma(S_DISABLE); } if(!is_waiting_for_read) { uint8_t tmp = 0x90; S2LPSpiWriteRegisters(0x76, 1, &tmp); if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { FEM_Operation_SKY66420(FEM_RX); } /* Return to RX state */ S2LPCmdStrobeCommand(CMD_RX); } disableS2LPIrq(); /* Timeout case */ if(!xTxDoneFlag) { enableS2LPIrq(); return 1; } xTxDoneFlag = RESET; enableS2LPIrq(); return 0; } /** * @brief Get the payload size of the received packet. * @param None. * @retval the payload size of the received packet. */ uint8_t S2LP::getRecvPayloadLen(void) { return cRxData; } /** * @brief Read the payload packet. * @param payload pointer to the data to be sent. * @param payload_len length in bytes of the payload data. * @retval the number of read bytes. * @note the maximum payload size allowed is 128 bytes */ uint8_t S2LP::read(uint8_t *payload, uint8_t payload_len) { uint8_t ret_val = cRxData; disableS2LPIrq(); if(payload_len < cRxData) { enableS2LPIrq(); return 0; } memcpy(payload, vectcRxBuff, cRxData); cRxData = 0; is_waiting_for_read = false; uint8_t tmp = 0x90; S2LPSpiWriteRegisters(0x76, 1, &tmp); if(s_paInfo.paRfRangeExtender == RANGE_EXT_SKYWORKS_SKY66420) { FEM_Operation_SKY66420(FEM_RX); } /* Return to RX state */ S2LPCmdStrobeCommand(CMD_RX); enableS2LPIrq(); return ret_val; } /** * @brief Sets the channel number. * @param cChannel the channel number. * @retval None. */ void S2LP::setRadioChannel(uint8_t cChannel) { return S2LPRadioSetChannel(cChannel); } /** * @brief Returns the actual channel number. * @param None. * @retval uint8_t Actual channel number. */ uint8_t S2LP::getRadioChannel(void) { return S2LPRadioGetChannel(); } /** * @brief Set the channel space factor in channel space register. * The channel spacing step is computed as F_Xo/32768. * @param fChannelSpace the channel space expressed in Hz. * @retval None. */ void S2LP::setRadioChannelSpace(uint32_t lChannelSpace) { return S2LPRadioSetChannelSpace(lChannelSpace); } /** * @brief Return the channel space register. * @param None. * @retval uint32_t Channel space. The channel space is: CS = channel_space_factor x XtalFrequency/2^15 * where channel_space_factor is the CHSPACE register value. */ uint32_t S2LP::getRadioChannelSpace(void) { return S2LPRadioGetChannelSpace(); } /** * @brief Set the Ready state. * @param None. * @retval zero in case of success, non-zero error code otherwise. */ uint8_t S2LP::S2LPSetReadyState(void) { uint8_t ret_val = 0; uint32_t start_time; uint32_t current_time; S2LPCmdStrobeCommand(CMD_SABORT); start_time = millis(); do { S2LPRefreshStatus(); current_time = millis(); } while(g_xStatus.MC_STATE != MC_STATE_READY && (current_time - start_time) <= 1000); if((current_time - start_time) > 1000) { ret_val = 1; } return ret_val; } S2LPCutType S2LP::S2LPManagementGetCut(void) { uint8_t tmp; /* Read Cut version from S2LP register */ S2LPSpiReadRegisters(0xF1, 1, &tmp); return (S2LPCutType)tmp; } /** * @brief IRQ Handler. * @param None. * @retval None. */ void S2LP::S2LPIrqHandler(void) { S2LPIrqs xIrqStatus; /* Get the IRQ status */ S2LPGpioIrqGetStatus(&xIrqStatus); /* Check the SPIRIT TX_DATA_SENT IRQ flag */ if(xIrqStatus.IRQ_TX_DATA_SENT) { /* set the tx_done_flag to manage the event in the send() */ xTxDoneFlag = SET; } /* Check the S2LP RX_DATA_READY IRQ flag */ if(xIrqStatus.IRQ_RX_DATA_READY) { /* Get the RX FIFO size */ cRxData = S2LPFifoReadNumberBytesRxFifo(); /* Read the RX FIFO */ S2LPSpiReadFifo(cRxData, vectcRxBuff); /* Flush the RX FIFO */ S2LPCmdStrobeFlushRxFifo(); is_waiting_for_read = true; /* Call application callback */ if(current_event_callback) { current_event_callback(); } } } /** * @brief Disable the S2LP interrupts. * @param None. * @retval None. */ void S2LP::disableS2LPIrq(void) { if(nr_of_irq_disabled == 0) { detachInterrupt(irq_pin); } nr_of_irq_disabled++; } /** * @brief Enable the S2LP interrupts. * @param None. * @retval None. */ void S2LP::enableS2LPIrq(void) { if(nr_of_irq_disabled > 0) { nr_of_irq_disabled--; if(nr_of_irq_disabled == 0) { attachInterrupt(irq_pin, irq_handler, FALLING); } } } /** * @brief Commands for external PA of type SKY66420. * @param operation the command to be executed. * @retval None. */ void S2LP::FEM_Operation_SKY66420(FEM_OperationType operation) { switch (operation) { case FEM_SHUTDOWN: { /* Puts CSD high to turn on PA */ digitalWrite(s_paInfo.paSignalCSD_MCU, LOW); /* Puts CTX high to go in TX state DON'T CARE */ digitalWrite(s_paInfo.paSignalCTX_MCU, HIGH); /* No Bypass mode select DON'T CARE */ digitalWrite(s_paInfo.paSignalCPS_MCU, HIGH); break; } case FEM_TX_BYPASS: { /* Puts CSD high to turn on PA */ digitalWrite(s_paInfo.paSignalCSD_MCU, HIGH); /* Puts CTX high to go in TX state */ digitalWrite(s_paInfo.paSignalCTX_MCU, HIGH); /* Bypass mode select */ digitalWrite(s_paInfo.paSignalCPS_MCU, LOW); break; } case FEM_TX: { /* Puts CSD high to turn on PA */ digitalWrite(s_paInfo.paSignalCSD_MCU, HIGH); /* Puts CTX high to go in TX state */ digitalWrite(s_paInfo.paSignalCTX_MCU, HIGH); /* No Bypass mode select DON'T CARE */ digitalWrite(s_paInfo.paSignalCPS_MCU, HIGH); break; } case FEM_RX: { /* Puts CSD high to turn on PA */ digitalWrite(s_paInfo.paSignalCSD_MCU, HIGH); /* Puts CTX low */ digitalWrite(s_paInfo.paSignalCTX_MCU, LOW); /* Check Bypass mode */ if (is_bypass_enabled) { digitalWrite(s_paInfo.paSignalCPS_MCU, LOW); } else { digitalWrite(s_paInfo.paSignalCPS_MCU, HIGH); } break; } default: /* Error */ break; } } /** * @brief Write single or multiple registers. * @param cRegAddress: base register's address to be write * @param cNbBytes: number of registers and bytes to be write * @param pcBuffer: pointer to the buffer of values have to be written into registers * @retval Device status */ S2LPStatus S2LP::S2LPSpiWriteRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer ) { uint8_t header[S2LP_CMD_SIZE]={WRITE_HEADER,cRegAddress}; S2LPStatus status; SpiSendRecv( header, pcBuffer, cNbBytes ); ((uint8_t*)&status)[1]=header[0]; ((uint8_t*)&status)[0]=header[1]; return status; } /** * @brief Read single or multiple registers. * @param cRegAddress: base register's address to be read * @param cNbBytes: number of registers and bytes to be read * @param pcBuffer: pointer to the buffer of registers' values read * @retval Device status */ S2LPStatus S2LP::S2LPSpiReadRegisters(uint8_t cRegAddress, uint8_t cNbBytes, uint8_t* pcBuffer ) { uint8_t header[S2LP_CMD_SIZE]={READ_HEADER,cRegAddress}; S2LPStatus status; SpiSendRecv( header, pcBuffer, cNbBytes ); ((uint8_t*)&status)[1]=header[0]; ((uint8_t*)&status)[0]=header[1]; return status; } /** * @brief Send a command * @param cCommandCode: command code to be sent * @retval Device status */ S2LPStatus S2LP::S2LPSpiCommandStrobes(uint8_t cCommandCode) { uint8_t header[S2LP_CMD_SIZE]={COMMAND_HEADER,cCommandCode}; S2LPStatus status; SpiSendRecv( header, NULL, 0 ); ((uint8_t*)&status)[1]=header[0]; ((uint8_t*)&status)[0]=header[1]; return status; } /** * @brief Write data into TX FIFO. * @param cNbBytes: number of bytes to be written into TX FIFO * @param pcBuffer: pointer to data to write * @retval Device status */ S2LPStatus S2LP::S2LPSpiWriteFifo(uint8_t cNbBytes, uint8_t* pcBuffer) { uint8_t header[S2LP_CMD_SIZE]={WRITE_HEADER,LINEAR_FIFO_ADDRESS}; S2LPStatus status; SpiSendRecv( header, pcBuffer, cNbBytes ); ((uint8_t*)&status)[1]=header[0]; ((uint8_t*)&status)[0]=header[1]; return status; } /** * @brief Read data from RX FIFO. * @param cNbBytes: number of bytes to read from RX FIFO * @param pcBuffer: pointer to data read from RX FIFO * @retval Device status */ S2LPStatus S2LP::S2LPSpiReadFifo(uint8_t cNbBytes, uint8_t* pcBuffer) { uint8_t header[S2LP_CMD_SIZE]={READ_HEADER,LINEAR_FIFO_ADDRESS}; S2LPStatus status; SpiSendRecv( header, pcBuffer, cNbBytes ); ((uint8_t*)&status)[1]=header[0]; ((uint8_t*)&status)[0]=header[1]; return status; } /** * @brief Basic SPI function to send/receive data. * @param pcHeader: pointer to header to be sent * @param pcBuffer: pointer to data to be sent/received * @param cNbBytes: number of bytes to send/receive * @retval Device status */ void S2LP::SpiSendRecv(uint8_t *pcHeader, uint8_t *pcBuffer, uint16_t cNbBytes) { disableS2LPIrq(); dev_spi->beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); digitalWrite(csn_pin, LOW); dev_spi->transfer(pcHeader, S2LP_CMD_SIZE); if(cNbBytes) { dev_spi->transfer(pcBuffer, cNbBytes); } digitalWrite(csn_pin, HIGH); enableS2LPIrq(); } /** * @brief Management of RCO calibration. * @param None. * @retval None. */ void S2LP::S2LPManagementRcoCalibration(void) { uint8_t tmp[2],tmp2; S2LPSpiReadRegisters(0x6D, 1, &tmp2); tmp2 |= 0x01; S2LPSpiWriteRegisters(0x6D, 1, &tmp2); S2LPSpiCommandStrobes(0x63); delay(100); S2LPSpiCommandStrobes(0x62); do { S2LPSpiReadRegisters(0x8D, 1, tmp); } while((tmp[0]&0x10)==0); S2LPSpiReadRegisters(0x94, 2, tmp); S2LPSpiReadRegisters(0x6F, 1, &tmp2); tmp[1]=(tmp[1]&0x80)|(tmp2&0x7F); S2LPSpiWriteRegisters(0x6E, 2, tmp); S2LPSpiReadRegisters(0x6D, 1, &tmp2); tmp2 &= 0xFE; S2LPSpiWriteRegisters(0x6D, 1, &tmp2); }
25.801453
457
0.680133
cparata
92ae06733548a7f8dd9a19cf96c8f449bd64a0c3
35,275
cpp
C++
Parser/src/parser.cpp
nuua-io/Nuua
d74bec22d09d25f2bc0ced8d7c9a154ff84a874d
[ "MIT" ]
43
2018-11-17T02:08:09.000Z
2022-03-03T14:50:02.000Z
Parser/src/parser.cpp
nuua-io/Nuua
d74bec22d09d25f2bc0ced8d7c9a154ff84a874d
[ "MIT" ]
2
2019-08-07T03:16:51.000Z
2021-05-17T03:05:08.000Z
Parser/src/parser.cpp
nuua-io/Nuua
d74bec22d09d25f2bc0ced8d7c9a154ff84a874d
[ "MIT" ]
3
2019-01-07T18:43:35.000Z
2021-07-21T12:12:23.000Z
/** * |-------------| * | Nuua Parser | * |-------------| * * Copyright 2019 Erik Campobadal <soc@erik.cat> * https://nuua.io */ #include "../include/parser.hpp" #include "../../Lexer/include/lexer.hpp" #include "../../Logger/include/logger.hpp" #include <filesystem> #include <algorithm> #define CURRENT() (*(this->current)) #define PREVIOUS() (*(this->current - 1)) #define CHECK(token) (this->current->type == token) #define CHECK_AT(token, n) ((this->current + n)->type == token) #define NEXT() (this->current++) #define ADVANCE(n) (this->current += n) #define IS_AT_END() (CHECK(TOKEN_EOF)) #define LOOKAHEAD(n) (*(this->current + n)) #define LINE() (this->current->line) #define COL() (this->current->column) #define PLINE() ((this->current - 1)->line) #define PCOL() ((this->current - 1)->column) #define ADD_LOG(msg) logger->add_entity(this->file, LINE(), COL(), msg) #define ADD_PREV_LOG(msg) logger->add_entity(this->file, PLINE(), PCOL(), msg) #define ADD_LOG_PAR(line, col, msg) logger->add_entity(this->file, line, col, msg) #define EXPECT_NEW_LINE() if (!this->match_any({{ TOKEN_NEW_LINE, TOKEN_EOF }})) { \ ADD_LOG("Expected a new line or EOF but got '" + CURRENT().to_string() + "'."); exit(logger->crash()); } #define NEW_NODE(type, ...) (std::make_shared<type>(this->file, PLINE(), PCOL(), __VA_ARGS__)) // Stores the parsing file stack, to avoid // cyclic imports. static std::vector<const std::string *> file_stack; #define PREVENT_CYCLIC(file_ptr) \ { \ if (std::find(file_stack.begin(), file_stack.end(), file_ptr) != file_stack.end()) { \ ADD_LOG("Cyclic import detected. Can't use '" + *file_ptr + "'. Cyclic imports are not available in nuua."); \ exit(logger->crash()); \ } \ } // Stores the relation between a file_name and the // parsed Abstract Syntax Tree and the pointer to the // original long lived file name string. // Acts as a temporal cache to avoid re-parsing a file. static std::unordered_map< std::string, std::pair< std::shared_ptr<std::vector<std::shared_ptr<Statement>>>, std::shared_ptr<const std::string> > > parsed_files; Token *Parser::consume(const TokenType type, const std::string &message) { if (this->current->type == type) return NEXT(); ADD_LOG(message); exit(logger->crash()); } bool Parser::match(const TokenType token) { if (CHECK(token)) { if (token != TOKEN_EOF) NEXT(); return true; } return false; } bool Parser::match_any(const std::vector<TokenType> &tokens) { for (const TokenType &token : tokens) { if (CHECK(token)) { if (token != TOKEN_EOF) NEXT(); return true; } } return false; } /* GRAMMAR RULES */ /* primary -> "false" | "true" | INTEGER | FLOAT | STRING | IDENTIFIER | LIST | DICTIONARY | OBJECT | "(" expression ")" */ std::shared_ptr<Expression> Parser::primary() { if (this->match(TOKEN_FALSE)) return NEW_NODE(Boolean, false); if (this->match(TOKEN_TRUE)) return NEW_NODE(Boolean, true); if (this->match(TOKEN_INTEGER)) return NEW_NODE(Integer, std::stoll(PREVIOUS().to_string())); if (this->match(TOKEN_FLOAT)) return NEW_NODE(Float, std::stof(PREVIOUS().to_string())); if (this->match(TOKEN_STRING)) return NEW_NODE(String, PREVIOUS().to_string()); if (this->match(TOKEN_IDENTIFIER)) { const std::string name = PREVIOUS().to_string(); // It can be an object. if (this->match(TOKEN_BANG)) { // It's an object. this->consume(TOKEN_LEFT_BRACE, "Expected '{' at the start of the object creation."); std::unordered_map<std::string, std::shared_ptr<Expression>> arguments; this->object_arguments(arguments); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' at the end of the object creation."); return NEW_NODE(Object, name, arguments); } return NEW_NODE(Variable, name); } if (this->match(TOKEN_LEFT_SQUARE)) { std::vector<std::shared_ptr<Expression> > values; if (this->match(TOKEN_RIGHT_SQUARE)) return NEW_NODE(List, values); for (;;) { if (IS_AT_END()) { ADD_LOG("Unfinished list, Expecting ']' after the last list element."); exit(logger->crash()); } values.push_back(std::move(expression())); if (this->match(TOKEN_RIGHT_SQUARE)) break; this->consume(TOKEN_COMMA, "Expected ',' after a list element"); } return NEW_NODE(List, values); } if (this->match(TOKEN_LEFT_BRACE)) { std::unordered_map<std::string, std::shared_ptr<Expression>> values; std::vector<std::string> keys; if (this->match(TOKEN_RIGHT_BRACE)) return NEW_NODE(Dictionary, values, keys); for (;;) { if (IS_AT_END()) { ADD_LOG("Unfinished dictionary, Expecting '}' after the last dictionary element."); exit(logger->crash()); } std::shared_ptr<Expression> key = this->expression(); if (key->rule != RULE_VARIABLE) { ADD_LOG("Expected an identifier as a key"); exit(logger->crash()); } this->consume(TOKEN_COLON, "Expected ':' after dictionary key"); std::string name = std::static_pointer_cast<Variable>(key)->name; values[name] = this->expression(); keys.push_back(name); if (this->match(TOKEN_RIGHT_BRACE)) break; this->consume(TOKEN_COMMA, "Expected ',' after dictionary element"); } return NEW_NODE(Dictionary, values, keys); } if (this->match(TOKEN_LEFT_PAREN)) { std::shared_ptr<Expression> value = this->expression(); this->consume(TOKEN_RIGHT_PAREN, "Expected ')' after a group expression"); return NEW_NODE(Group, value); } /* if (this->match(TOKEN_STICK)) { std::vector<std::shared_ptr<Statement> > parameters = this->parameters(); if (!this->match(TOKEN_STICK)) { parameters = this->parameters(); this->consume(TOKEN_STICK, "Expected '|' after the closure parameters"); } std::string return_type; if (this->match(TOKEN_COLON)) return_type = this->type(false); std::vector<std::shared_ptr<Statement> > body; if (this->match(TOKEN_RIGHT_ARROW)) { body.push_back(NEW_NODE(Return, this->expression())); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { body.push_back(this->statement(false)); } else if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); body = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after closure body."); } else { ADD_LOG("Unknown token found after closure. Expected '->', '=>' or '{'."); exit(logger->crash()); } return NEW_NODE(Closure, parameters, return_type, body); } */ ADD_LOG("Expected an expression but got '" + CURRENT().to_string() + "'"); exit(logger->crash()); } /* unary_postfix -> primary unary_p*; unary_p -> "[" expression "]" | slice | "(" arguments? ")" | '.' IDENTIFIER; slice -> "[" expression? ":" expression? (":" expression?)? "]" arguments -> expression ("," expression)*; */ std::shared_ptr<Expression> Parser::unary_postfix() { std::shared_ptr<Expression> result = this->primary(); while (this->match_any({{ TOKEN_LEFT_SQUARE, TOKEN_LEFT_PAREN, TOKEN_DOT }})) { Token op = PREVIOUS(); switch (op.type) { case TOKEN_LEFT_SQUARE: { std::shared_ptr<Expression> start = std::shared_ptr<Expression>(); std::shared_ptr<Expression> end = std::shared_ptr<Expression>(); std::shared_ptr<Expression> step = std::shared_ptr<Expression>(); if (this->match(TOKEN_COLON)) goto parser_is_slice1; start = this->expression(); if (this->match(TOKEN_COLON)) { // It's a Slice, not an access and the start index is already calculated. parser_is_slice1: if (this->match(TOKEN_RIGHT_SQUARE)) goto parser_finish_slice; if (this->match(TOKEN_COLON)) goto parser_get_slice_step; end = this->expression(); if (this->match(TOKEN_RIGHT_SQUARE)) goto parser_finish_slice; this->consume(TOKEN_COLON, "Expected ':' or ']' after slice end index"); parser_get_slice_step: if (this->match(TOKEN_RIGHT_SQUARE)) goto parser_finish_slice; step = this->expression(); this->consume(TOKEN_RIGHT_SQUARE, "Expected ']' after a slice step"); parser_finish_slice: result = NEW_NODE(Slice, result, start, end, step); break; } this->consume(TOKEN_RIGHT_SQUARE, "Expected ']' after the access index"); result = NEW_NODE(Access, result, start); break; } case TOKEN_LEFT_PAREN: { std::vector<std::shared_ptr<Expression>> arguments = this->arguments(); this->consume(TOKEN_RIGHT_PAREN, "Expected ')' after function arguments."); result = NEW_NODE(Call, result, arguments); break; } case TOKEN_DOT: { std::string prop = this->consume(TOKEN_IDENTIFIER, "Expected an identifier after '.' in an access to an object property.")->to_string(); result = NEW_NODE(Property, result, prop); break; } default: { ADD_LOG("Invalid unary postfix operator"); exit(logger->crash()); }; } } return result; } /* unary_prefix -> ("!" | "+" | "-") unary_prefix | unary_postfix; */ std::shared_ptr<Expression> Parser::unary_prefix() { if (this->match_any({{ TOKEN_BANG, TOKEN_PLUS, TOKEN_MINUS }})) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->unary_prefix(); return NEW_NODE(Unary, op, expr); } return this->unary_postfix(); } /* cast -> unary_prefix ("as" type)*; */ std::shared_ptr<Expression> Parser::cast() { std::shared_ptr<Expression> result = this->unary_prefix(); while (this->match(TOKEN_AS)) { std::shared_ptr<Type> type = this->type(); result = NEW_NODE(Cast, result, type); } return result; } /* multiplication -> cast (("/" | "*") cast)*; */ std::shared_ptr<Expression> Parser::multiplication() { std::shared_ptr<Expression> result = this->cast(); while (this->match_any({{ TOKEN_SLASH, TOKEN_STAR /* , TOKEN_PERCENT */ }})) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->cast(); result = NEW_NODE(Binary, result, op, expr); } return result; } /* addition -> multiplication (("-" | "+") multiplication)*; */ std::shared_ptr<Expression> Parser::addition() { std::shared_ptr<Expression> result = this->multiplication(); while (this->match_any({{ TOKEN_MINUS, TOKEN_PLUS }})) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->multiplication(); result = NEW_NODE(Binary, result, op, expr); } return result; } /* comparison -> addition ((">" | ">=" | "<" | "<=") addition)*; */ std::shared_ptr<Expression> Parser::comparison() { std::shared_ptr<Expression> result = this->addition(); while (this->match_any({{ TOKEN_HIGHER, TOKEN_HIGHER_EQUAL, TOKEN_LOWER, TOKEN_LOWER_EQUAL }})) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->addition(); result = NEW_NODE(Binary, result, op, expr); } return result; } /* equality -> comparison (("!=" | "==") comparison)*; */ std::shared_ptr<Expression> Parser::equality() { std::shared_ptr<Expression> result = this->comparison(); while (this->match_any({{ TOKEN_BANG_EQUAL, TOKEN_EQUAL_EQUAL }})) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->comparison(); result = NEW_NODE(Binary, result, op, expr); } return result; } /* logical_and -> equality ("and" equality)*; */ std::shared_ptr<Expression> Parser::logical_and() { std::shared_ptr<Expression> result = this->equality(); while (this->match(TOKEN_AND)) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->equality(); result = NEW_NODE(Logical, result, op, expr); } return result; } /* logical_or -> logical_and ("or" logical_and)*; */ std::shared_ptr<Expression> Parser::logical_or() { std::shared_ptr<Expression> result = this->logical_and(); while (this->match(TOKEN_OR)) { Token op = PREVIOUS(); std::shared_ptr<Expression> expr = this->logical_and(); result = NEW_NODE(Logical, result, op, expr); } return result; } /* range -> logical_or ((".." | "...") logical_or)*; */ std::shared_ptr<Expression> Parser::range() { std::shared_ptr<Expression> result = this->logical_or(); while (this->match_any({{ TOKEN_DOUBLE_DOT, TOKEN_TRIPLE_DOT }})) { const bool inclusive = PREVIOUS().type == TOKEN_DOUBLE_DOT ? false : true; std::shared_ptr<Expression> right = this->expression(); result = NEW_NODE(Range, result, right, inclusive); } return result; } /* assignment -> range ("=" range)*; */ std::shared_ptr<Expression> Parser::assignment() { std::shared_ptr<Expression> result = this->range(); while (this->match(TOKEN_EQUAL)) { std::shared_ptr<Expression> expr = this->range(); result = NEW_NODE(Assign, result, expr); } return result; } /* expression -> assignment; */ std::shared_ptr<Expression> Parser::expression() { return this->assignment(); } /* variable_declaration -> IDENTIFIER ":" ("=" expression)?; */ std::shared_ptr<Statement> Parser::variable_declaration() { std::string variable = this->consume(TOKEN_IDENTIFIER, "Expected an identifier in a declaration statement")->to_string(); this->consume(TOKEN_COLON, "Expected ':' after identifier in a declaration statement"); std::shared_ptr<Type> type = this->type(); std::shared_ptr<Expression> initializer; if (this->match(TOKEN_EQUAL)) initializer = this->expression(); if (!type && !initializer) { ADD_LOG("A variable without type and initializer can't be declared. At least one is expected."); exit(logger->crash()); } return NEW_NODE(Declaration, variable, type, initializer); } /* expression_statement -> expression; */ std::shared_ptr<Statement> Parser::expression_statement() { std::shared_ptr<Expression> expr = this->expression(); return NEW_NODE(ExpressionStatement, expr); } /* use_declaration -> "use" STRING | "use" IDENTIFIER ("," IDENTIFIER)* "from" STRING; */ std::shared_ptr<Statement> Parser::use_declaration() { std::vector<std::string> targets; std::string module; if (CHECK(TOKEN_IDENTIFIER)) { targets.push_back(this->consume(TOKEN_IDENTIFIER, "Expected an identifier after 'use'")->to_string()); // The message is redundant. while (this->match(TOKEN_COMMA)) targets.push_back(this->consume(TOKEN_IDENTIFIER, "Expected an identifier after ','")->to_string()); this->consume(TOKEN_FROM, "Expected 'from' after the import target"); module = this->consume(TOKEN_STRING, "Expected an identifier after 'from'")->to_string(); } else { module = this->consume(TOKEN_STRING, "Expected an identifier or 'string' after 'use'")->to_string(); } Parser::format_path(module, this->file); std::shared_ptr<Use> use; // Parse the contents of the target. if (parsed_files.find(module) == parsed_files.end()) { use = NEW_NODE(Use, targets, std::make_shared<std::string>(module)); PREVENT_CYCLIC(use->module.get()); use->code = std::make_shared<std::vector<std::shared_ptr<Statement>>>(); Parser(use->module).parse(use->code); } else { use = NEW_NODE(Use, targets, parsed_files[module].second); PREVENT_CYCLIC(use->module.get()); use->code = parsed_files[module].first; } return use; } /* export_declaration -> "export" top_level_declaration */ std::shared_ptr<Statement> Parser::export_declaration() { std::shared_ptr<Statement> stmt = this->top_level_declaration(false); if (stmt->rule == RULE_EXPORT) { ADD_LOG("Can't export an export. Does that even make sense?."); exit(logger->crash()); } // printf("CURRENT: %s\n", CURRENT().to_string().c_str()); return NEW_NODE(Export, stmt); } /* fun_declaration -> "fun" IDENTIFIER "(" parameters? ")" (":" type)? ("->" expression "\n" | "=>" statement | "{" "\n" statement* "}" "\n"); parameters -> variable_declaration ("," variable_declaration)*; */ std::shared_ptr<Statement> Parser::fun_declaration() { std::string name = this->consume(TOKEN_IDENTIFIER, "Expected an identifier (function name) after 'fun'.")->to_string(); this->consume(TOKEN_LEFT_PAREN, "Expected '(' after the function name."); std::vector<std::shared_ptr<Declaration>> parameters; if (!this->match(TOKEN_RIGHT_PAREN)) { this->parameters(&parameters); this->consume(TOKEN_RIGHT_PAREN, "Expected ')' after the function parameters"); } std::shared_ptr<Type> return_type; if (this->match(TOKEN_COLON)) return_type = this->type(false); std::vector<std::shared_ptr<Statement> > body; if (this->match(TOKEN_RIGHT_ARROW)) { body.push_back(std::move(NEW_NODE(Return, this->expression()))); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { body.push_back(std::move(this->statement(false))); } else if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); body = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after function body."); } else { ADD_LOG("Unknown token found after function. Expected '->', '=>' or '{'."); exit(logger->crash()); } return std::make_shared<Function>(NEW_NODE(FunctionValue, name, parameters, return_type, body)); } /* print_statement -> "print" expression; */ std::shared_ptr<Statement> Parser::print_statement() { std::shared_ptr<Expression> expr = this->expression(); return NEW_NODE(Print, expr); } /* if_statement -> "if" expression ("=>" statement | "{" "\n" statement* "}"); */ std::shared_ptr<Statement> Parser::if_statement() { std::shared_ptr<Expression> condition = this->expression(); std::vector<std::shared_ptr<Statement> > then_branch, else_branch; // Then branch if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); then_branch = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'if' body."); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { then_branch.push_back(std::move(this->statement(false))); } else { ADD_LOG("Expected '{' or '=>' after 'if' condition."); exit(logger->crash()); } // Else branch if (this->match(TOKEN_ELIF)) { else_branch.push_back(std::move(this->if_statement())); } else if (CHECK(TOKEN_NEW_LINE) && CHECK_AT(TOKEN_ELIF, 1)) { ADVANCE(2); // Consume the two tokens. else_branch.push_back(std::move(this->if_statement())); } else if (this->match(TOKEN_ELSE)) { if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); else_branch = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'else' body."); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { else_branch.push_back(std::move(this->statement(false))); } else { ADD_LOG("Expected '{' or '=>' after 'else'."); exit(logger->crash()); } } else if (CHECK(TOKEN_NEW_LINE) && CHECK_AT(TOKEN_ELSE, 1)) { ADVANCE(2); // Consume the two tokens. if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); else_branch = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'else' body."); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { else_branch.push_back(std::move(this->statement(false))); } else { ADD_LOG("Expected '{' or '=>' after 'else'."); exit(logger->crash()); } } return NEW_NODE(If, condition, then_branch, else_branch); } std::shared_ptr<Statement> Parser::while_statement() { std::shared_ptr<Expression> condition = this->expression(); std::vector<std::shared_ptr<Statement> > body; if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); body = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'while' body."); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { body.push_back(std::move(this->statement(false))); } else { ADD_LOG("Expected '{' or '=>' after 'while' condition."); exit(logger->crash()); } return NEW_NODE(While, condition, body); } /* for_statement -> "for" IDENTIFIER ("," IDENTIFIER)? "in" expression ("=>" statement | "{" "\n" statement* "}" "\n"); */ std::shared_ptr<Statement> Parser::for_statement() { std::string index, variable = this->consume(TOKEN_IDENTIFIER, "Expected identifier after 'for'")->to_string(); if (this->match(TOKEN_COMMA)) { index = this->consume(TOKEN_IDENTIFIER, "Expected identifier as the optional second identifier in 'for'")->to_string(); } this->consume(TOKEN_IN, "Expected 'in' after 'for' identifier/s."); std::shared_ptr<Expression> iterator = this->expression(); std::vector<std::shared_ptr<Statement> > body; if (this->match(TOKEN_LEFT_BRACE)) { EXPECT_NEW_LINE(); body = this->body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'for' body."); } else if (this->match(TOKEN_BIG_RIGHT_ARROW)) { body.push_back(std::move(this->statement(false))); } else { ADD_LOG("Expected '{' or '=>' after 'for' iterator."); exit(logger->crash()); } return NEW_NODE(For, variable, index, iterator, body); } /* return_statement -> "return" expression?; */ std::shared_ptr<Statement> Parser::return_statement() { if (CHECK(TOKEN_NEW_LINE) || CHECK(TOKEN_EOF)) { return NEW_NODE(Return, nullptr); } std::shared_ptr<Expression> expr = this->expression(); return NEW_NODE(Return, expr); } std::shared_ptr<Statement> Parser::delete_statement() { std::shared_ptr<Expression> expr = this->expression(); return NEW_NODE(Delete, expr); } std::shared_ptr<Statement> Parser::class_statement() { std::string name = this->consume(TOKEN_IDENTIFIER, "Expected identifier after 'class'.")->to_string(); this->consume(TOKEN_LEFT_BRACE, "Expected '{' after 'class' name."); std::vector<std::shared_ptr<Statement> > body = this->class_body(); this->consume(TOKEN_RIGHT_BRACE, "Expected '}' after 'class' body."); return NEW_NODE(Class, name, body); } /* statement -> variable_declaration "\n"? | if_statement "\n" | while_statement "\n" | for_statement "\n" | return_statement "\n" | delete_statement "\n" | print_statement "\n" | expression_statement "\n"?; */ std::shared_ptr<Statement> Parser::statement(bool new_line) { std::shared_ptr<Statement> result; // Remove blank lines while (this->match(TOKEN_NEW_LINE)); // Save the current line / column. line_t line = LINE(); column_t column = COL(); // Check what type of statement we're parsing. if (CHECK(TOKEN_IDENTIFIER) && LOOKAHEAD(1).type == TOKEN_COLON) { ADD_LOG("Parsing variable declaration"); result = this->variable_declaration(); } else if (this->match(TOKEN_IF)) { ADD_PREV_LOG("Parsing if declaration"); result = this->if_statement(); } else if (this->match(TOKEN_WHILE)) { ADD_PREV_LOG("Parsing while statement"); result = this->while_statement(); } else if (this->match(TOKEN_FOR)) { ADD_PREV_LOG("Parsing for statement"); result = this->for_statement(); } else if (this->match(TOKEN_RETURN)) { ADD_PREV_LOG("Parsing return statement"); result = this->return_statement(); } else if (this->match(TOKEN_DELETE)) { ADD_PREV_LOG("Parsing delete statement"); result = this->delete_statement(); } else if (this->match(TOKEN_PRINT)) { ADD_PREV_LOG("Parsing print statement"); result = this->print_statement(); } else { ADD_LOG("Parsing expression"); result = this->expression_statement(); } if (new_line) EXPECT_NEW_LINE(); logger->pop_entity(); // Set the line / column to overwrite the ones in the node. result->line = line; result->column = column; return result; } /* top_level_declaration -> use_declaration "\n" | export_declaration "\n" | class_declaration "\n" | fun_declaration "\n"; */ std::shared_ptr<Statement> Parser::top_level_declaration(const bool expect_new_line) { std::shared_ptr<Statement> result; // Save the current line / column. line_t line = LINE(); column_t column = COL(); if (this->match(TOKEN_USE)) { ADD_PREV_LOG("Parsing 'use' declaration"); result = this->use_declaration(); } else if (this->match(TOKEN_EXPORT)) { ADD_PREV_LOG("Parsing 'export' declaration"); result = this->export_declaration(); } else if (this->match(TOKEN_CLASS)) { ADD_PREV_LOG("Parsing 'class' declaration"); result = this->class_statement(); } else if (this->match(TOKEN_FUN)) { ADD_PREV_LOG("Parsing 'fun' declaration"); result = this->fun_declaration(); // Set the line / column to overwrite the ones in the node. // MUST BE SET ON THE INNER VALUE std::static_pointer_cast<Function>(result)->value->line = line; std::static_pointer_cast<Function>(result)->value->column = column; } else { //printf("CURRENT: %zu\n", CURRENT().); ADD_LOG("Unknown top level declaration. Expected 'use', 'export', 'class' or 'fun'. But got '" + CURRENT().to_type_string() + "'"); exit(logger->crash()); } if (expect_new_line) EXPECT_NEW_LINE(); logger->pop_entity(); // Set the line / column to overwrite the ones in the node. result->line = line; result->column = column; return result; } std::shared_ptr<Statement> Parser::class_body_declaration() { std::shared_ptr<Statement> result; // Remove blank lines while (this->match(TOKEN_NEW_LINE)); // Save the current line / column. line_t line = LINE(); column_t column = COL(); if (CHECK(TOKEN_IDENTIFIER) && LOOKAHEAD(1).type == TOKEN_COLON) { ADD_LOG("Parsing variable declaration"); result = this->variable_declaration(); } else if (this->match(TOKEN_FUN)) { ADD_PREV_LOG("Parsing 'fun' declaration"); result = this->fun_declaration(); // Set the line / column to overwrite the ones in the node. // MUST BE SET ON THE INNER VALUE std::static_pointer_cast<Function>(result)->value->line = line; std::static_pointer_cast<Function>(result)->value->column = column; } else { ADD_LOG("Invalid class block declaration. Expected 'fun' or variable declaration. But got '" + CURRENT().to_string() + "'"); exit(logger->crash()); } EXPECT_NEW_LINE(); logger->pop_entity(); // Set the line / column to overwrite the ones in the node. result->line = line; result->column = column; return result; } void Parser::parameters(std::vector<std::shared_ptr<Declaration>> *dest) { if (!CHECK(TOKEN_RIGHT_PAREN)) { do { std::shared_ptr<Statement> parameter = this->statement(false); if (parameter->rule != RULE_DECLARATION) { ADD_LOG_PAR(parameter->line, parameter->column, "Invalid argument when defining the function. Expected a variable declaration."); exit(logger->crash()); } // Disallow parameter initializors. std::shared_ptr<Declaration> dec = std::static_pointer_cast<Declaration>(parameter); if (dec->initializer) { ADD_LOG_PAR(dec->initializer->line, dec->initializer->column, "Function parameters are not allowed to have initializers."); exit(logger->crash()); } dest->push_back(std::move(dec)); } while (this->match(TOKEN_COMMA)); } } void Parser::object_arguments(std::unordered_map<std::string, std::shared_ptr<Expression>> &arguments) { if (!CHECK(TOKEN_RIGHT_BRACE)) { do { std::string key = this->consume(TOKEN_IDENTIFIER, "Expected an identifier to set the object argument")->to_string(); this->consume(TOKEN_COLON, "Expected ':' after the argument identifier"); arguments[key] = std::move(this->expression()); } while (this->match(TOKEN_COMMA)); } } std::vector<std::shared_ptr<Expression>> Parser::arguments() { std::vector<std::shared_ptr<Expression>> arguments; if (!CHECK(TOKEN_RIGHT_PAREN)) { do arguments.push_back(std::move(this->expression())); while (this->match(TOKEN_COMMA)); } return arguments; } std::vector<std::shared_ptr<Statement>> Parser::body() { std::vector<std::shared_ptr<Statement>> body; while (!IS_AT_END()) { // Remove blank lines. while (this->match(TOKEN_NEW_LINE)); if (IS_AT_END()) { ADD_LOG("Unterminated body. Must use '}' to terminate the body."); exit(logger->crash()); } // Check if the body ended. if (CHECK(TOKEN_RIGHT_BRACE)) break; // Push a new statement into the body. body.push_back(std::move(this->statement())); } return body; } std::vector<std::shared_ptr<Statement> > Parser::class_body() { std::vector<std::shared_ptr<Statement> > body; while (!IS_AT_END() && !CHECK(TOKEN_RIGHT_BRACE)) { body.push_back(std::move(this->class_body_declaration())); } return body; } /* type -> "[" type "]" | "{" type "}" | "(" type ("," type)* ("->" type)? ")" | IDENTIFIER; */ std::shared_ptr<Type> Parser::type(bool optional) { if (this->match(TOKEN_LEFT_SQUARE)) { // List type. std::shared_ptr<Type> inner_type = this->type(); std::shared_ptr<Type> type = std::make_shared<Type>(VALUE_LIST, inner_type); this->consume(TOKEN_RIGHT_SQUARE, "A list type needs to end with ']'"); return type; } else if (this->match(TOKEN_LEFT_BRACE)) { // Dict type. std::shared_ptr<Type> inner_type = this->type(); std::shared_ptr<Type> type = std::make_shared<Type>(VALUE_DICT, inner_type); this->consume(TOKEN_RIGHT_BRACE, "A dictionary type needs to end with '}'"); return type; } else if (this->match(TOKEN_LEFT_PAREN)) { // Function type. if (this->match(TOKEN_RIGHT_PAREN)) { // Empty function (no paramenters or return type) return std::make_shared<Type>(VALUE_FUN); } else if (this->match(TOKEN_RIGHT_ARROW)) { // Function without arguments and only a return type. std::shared_ptr<Type> type = this->type(); this->consume(TOKEN_RIGHT_PAREN, "A function type needs to end with ')'"); return std::make_shared<Type>(VALUE_FUN, type); } // The function have arguments (+ return)? std::shared_ptr<Type> type = std::make_shared<Type>(VALUE_FUN); // Add the parameters. do type->parameters.push_back(std::move(this->type())); while (this->match(TOKEN_COMMA)); // Add the return type if needed. if (this->match(TOKEN_RIGHT_ARROW)) type->inner_type = this->type(); this->consume(TOKEN_RIGHT_PAREN, "A function type needs to end with ')'"); return type; } else if (CHECK(TOKEN_IDENTIFIER)) { // Other types (native + custom). std::string type = this->consume(TOKEN_IDENTIFIER, "Expected an identifier as a type.")->to_string(); return std::make_shared<Type>(type); } else if (optional && (CHECK(TOKEN_NEW_LINE) || CHECK(TOKEN_EQUAL))) return std::shared_ptr<Type>(); ADD_LOG("Unknown type token expected."); exit(logger->crash()); } /* program -> top_level_declaration*; */ void Parser::parse(std::shared_ptr<std::vector<std::shared_ptr<Statement>>> &code) { // Add the file we are going to parse to the file_stack. file_stack.push_back(this->file.get()); // Prepare the token list. std::unique_ptr<std::vector<Token>> tokens = std::make_unique<std::vector<Token>>(); Lexer lexer = Lexer(this->file); // Scan the tokens. lexer.scan(tokens); if (logger->show_tokens) Token::debug_tokens(*tokens); this->current = &tokens->front(); while (!IS_AT_END()) { // Remove blank lines while (this->match(TOKEN_NEW_LINE)); if (IS_AT_END()) break; // Add the TLD. code->push_back(std::move(this->top_level_declaration())); } // Check the code size to avoid empty files. if (code->size() == 0) { logger->add_entity(this->file, 0, 0, "Empty file detected, you might need to check the file or make sure it's not empty."); exit(logger->crash()); } parsed_files[*this->file] = std::make_pair(code, this->file); } Parser::Parser(const char *file) { std::string source = std::string(file); Parser::format_path(source); this->file = std::move(std::make_shared<const std::string>(std::string(source))); } void Parser::format_path(std::string &path, const std::shared_ptr<const std::string> &parent) { // Add the final .nu if needed. if (path.length() <= 3 || path.substr(path.length() - 3) != ".nu") path.append(".nu"); // Join the parent if needed. std::filesystem::path f; // Path if local file if (parent) f = std::filesystem::path(*parent).remove_filename().append(path); else f = path; // Cehck if path exists if (!std::filesystem::exists(std::filesystem::absolute(f))) { // Check if path exists on std lib. f = std::filesystem::path(logger->executable_path).remove_filename().append("Lib").append(path); if (!std::filesystem::exists(std::filesystem::absolute(f))) { // Well... No module exists with that name. logger->add_entity(std::shared_ptr<const std::string>(), 0, 0, "Module " + path + " not found in any path."); exit(logger->crash()); } } path = std::filesystem::absolute(f).string(); } #undef CURRENT #undef PREVIOUS #undef CHECK #undef CHECK_AT #undef NEXT #undef ADVANCE #undef IS_AT_END #undef LOOKAHEAD #undef LINE #undef COL #undef PLINE #undef PCOL #undef ADD_LOG #undef ADD_LOG_PAR #undef ADD_PREV_LOG #undef EXPECT_NEW_LINE #undef NEW_NODE
36.744792
152
0.619731
nuua-io
92aed95a9b30612cc232672044221fd85a6aafac
507
cpp
C++
ITP1/q31.cpp
felixny/AizuOnline
8ff399d60077e08961845502d4a99244da580cd2
[ "MIT" ]
null
null
null
ITP1/q31.cpp
felixny/AizuOnline
8ff399d60077e08961845502d4a99244da580cd2
[ "MIT" ]
null
null
null
ITP1/q31.cpp
felixny/AizuOnline
8ff399d60077e08961845502d4a99244da580cd2
[ "MIT" ]
null
null
null
// ITP1_9_C #include <iostream> #include <string> using namespace std; int main() { string taro; string hanako; int n; int pointH = 0; int pointT = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> taro >> hanako; if (taro > hanako) { pointT += 3; } else if (taro < hanako) { pointH += 3; } else if (taro == hanako) { pointT += 1; pointH += 1; } } cout << pointT << " " << pointH << endl; return 0; } /* 3 cat dog fish fish lion tiger */
14.485714
42
0.506903
felixny
92aefa42e0b83866da1087676db09d5e1193f50d
3,598
cc
C++
system_manager.cc
rockchip-linux/LibIPCProtocol
6fe4cb96c761253f4002db1f3be71b24dc946cd2
[ "BSD-3-Clause" ]
1
2021-06-28T00:25:02.000Z
2021-06-28T00:25:02.000Z
system_manager.cc
rockchip-linux/LibIPCProtocol
6fe4cb96c761253f4002db1f3be71b24dc946cd2
[ "BSD-3-Clause" ]
null
null
null
system_manager.cc
rockchip-linux/LibIPCProtocol
6fe4cb96c761253f4002db1f3be71b24dc946cd2
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2020 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <assert.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string> #include <unistd.h> #include <glib.h> #include <dbus-c++/dbus.h> #include "json-c/json.h" #include "system_manager.h" #include "system_manager_proxy.h" #include "dbus_connection.h" #include "libipcpro_log_control.h" extern int ipc_pro_log_ctl; #define SYSTEMMANAGER_DBUSSEND_1(FUNC) \ dbus_mutex_lock(); \ try { \ DBus::Connection conn = get_dbus_conn(); \ DBusSystemManager* system_manager_proxy_ = new DBusSystemManager(conn, SYSTEM_MANAGER_PATH, SYSTEM_MANAGER, SYSTEM_MANAGER_INTERFACE); \ system_manager_proxy_->FUNC(); \ delete system_manager_proxy_; \ } catch (DBus::Error err) { \ ipc_pro_log_ctl && printf("DBus::Error - %s\n", err.what()); \ } \ dbus_mutex_unlock(); \ return NULL; #define SYSTEMMANAGER_DBUSSEND_2(FUNC) \ char *ret = NULL; \ dbus_mutex_lock(); \ try { \ DBus::Connection conn = get_dbus_conn(); \ DBusSystemManager* system_manager_proxy_ = new DBusSystemManager(conn, SYSTEM_MANAGER_PATH, SYSTEM_MANAGER, SYSTEM_MANAGER_INTERFACE); \ auto config = system_manager_proxy_->FUNC(json); \ ret = g_strdup(config.c_str()); \ delete system_manager_proxy_; \ } catch (DBus::Error err) { \ ipc_pro_log_ctl && printf("DBus::Error - %s\n", err.what()); \ } \ dbus_mutex_unlock(); \ return ret; char *dbus_system_reboot(void) { SYSTEMMANAGER_DBUSSEND_1(Reboot); } char *dbus_system_factory_reset(void) { SYSTEMMANAGER_DBUSSEND_1(FactoryReset); } char *dbus_system_export_db(char *json) { SYSTEMMANAGER_DBUSSEND_2(ExportDB); } char *dbus_system_import_db(char *json) { SYSTEMMANAGER_DBUSSEND_2(ImportDB); } char *dbus_system_export_log(char *json) { SYSTEMMANAGER_DBUSSEND_2(ExportLog); } char *dbus_system_upgrade(char *json) { SYSTEMMANAGER_DBUSSEND_2(Upgrade); } extern "C" char *system_reboot(void) { return dbus_system_reboot(); } extern "C" char *system_factory_reset(void) { return dbus_system_factory_reset(); } extern "C" char *system_export_db(const char *path) { char *ret = NULL; json_object *j_cfg = json_object_new_object(); json_object_object_add(j_cfg, "sPath", json_object_new_string(path)); ret = dbus_system_export_db((char *)json_object_to_json_string(j_cfg)); json_object_put(j_cfg); return ret; } extern "C" char *system_import_db(const char *path) { char *ret = NULL; json_object *j_cfg = json_object_new_object(); json_object_object_add(j_cfg, "sPath", json_object_new_string(path)); ret = dbus_system_import_db((char *)json_object_to_json_string(j_cfg)); json_object_put(j_cfg); return ret; } extern "C" char *system_export_log(const char *path) { char *ret = NULL; json_object *j_cfg = json_object_new_object(); json_object_object_add(j_cfg, "sPath", json_object_new_string(path)); ret = dbus_system_export_log((char *)json_object_to_json_string(j_cfg)); json_object_put(j_cfg); return ret; } extern "C" char *system_upgrade(const char *path) { char *ret = NULL; json_object *j_cfg = json_object_new_object(); json_object_object_add(j_cfg, "sPath", json_object_new_string(path)); ret = dbus_system_upgrade((char *)json_object_to_json_string(j_cfg)); json_object_put(j_cfg); return ret; }
26.455882
144
0.708727
rockchip-linux
92b24e1febd4e548b6c726b55d2d7e972f5f219b
8,994
cpp
C++
libpvguiqt/src/PVLayerStackModel.cpp
inendi-inspector/inspector
9b9a00222d8a73cb0817ca56790ee9155db61cc4
[ "MIT" ]
null
null
null
libpvguiqt/src/PVLayerStackModel.cpp
inendi-inspector/inspector
9b9a00222d8a73cb0817ca56790ee9155db61cc4
[ "MIT" ]
null
null
null
libpvguiqt/src/PVLayerStackModel.cpp
inendi-inspector/inspector
9b9a00222d8a73cb0817ca56790ee9155db61cc4
[ "MIT" ]
null
null
null
// // MIT License // // © ESI Group, 2015 // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #include <inendi/PVLayerStack.h> #include <inendi/PVView.h> #include <pvguiqt/PVCustomQtRoles.h> #include <pvguiqt/PVLayerStackModel.h> /****************************************************************************** * * PVGuiQt::PVLayerStackModel::PVLayerStackModel * *****************************************************************************/ PVGuiQt::PVLayerStackModel::PVLayerStackModel(Inendi::PVView& lib_view, QObject* parent) : QAbstractTableModel(parent) , _lib_view(lib_view) , select_brush(QColor(255, 240, 200)) , unselect_brush(QColor(180, 180, 180)) { PVLOG_DEBUG("PVGuiQt::PVLayerStackModel::%s : Creating object\n", __FUNCTION__); select_font.setBold(true); lib_view._layer_stack_about_to_refresh.connect( sigc::mem_fun(this, &PVGuiQt::PVLayerStackModel::layer_stack_about_to_be_refreshed)); lib_view._layer_stack_refreshed.connect( sigc::mem_fun(this, &PVGuiQt::PVLayerStackModel::layer_stack_refreshed)); } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::columnCount * *****************************************************************************/ int PVGuiQt::PVLayerStackModel::columnCount(const QModelIndex& /*index*/) const { return 3; } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::data * *****************************************************************************/ QVariant PVGuiQt::PVLayerStackModel::data(const QModelIndex& index, int role) const { // AG: the two following lines are kept for the sake of history... /* We prepare a direct acces to the total number of layers */ // int layer_count = lib_layer_stack().get_layer_count(); // AG: this comment is also kept for history :) /* We create and store the true index of the layer in the lib */ int lib_index = lib_index_from_model_index(index.row()); switch (role) { case Qt::DecorationRole: switch (index.column()) { case 0: if (lib_layer_stack().get_layer_n(lib_index).get_visible()) { return QPixmap(":/layer-active.png"); } else { return QPixmap(":/layer-inactive.png"); } break; } break; case (Qt::BackgroundRole): if (lib_layer_stack().get_selected_layer_index() == lib_index) { return QBrush(QColor(205, 139, 204)); } break; case (Qt::DisplayRole): switch (index.column()) { case 1: return lib_layer_stack().get_layer_n(lib_index).get_name(); case 2: return QString("%L3").arg( lib_layer_stack().get_layer_n(lib_index).get_selectable_count()); } break; case (Qt::EditRole): switch (index.column()) { case 1: return lib_layer_stack().get_layer_n(lib_index).get_name(); } break; case (Qt::TextAlignmentRole): switch (index.column()) { case 0: return (Qt::AlignCenter + Qt::AlignVCenter); case 2: return (Qt::AlignRight + Qt::AlignVCenter); default: return (Qt::AlignLeft + Qt::AlignVCenter); } break; case (Qt::ToolTipRole): switch (index.column()) { case 1: return lib_layer_stack().get_layer_n(lib_index).get_name(); break; } break; case (PVCustomQtRoles::UnderlyingObject): { QVariant ret; ret.setValue<void*>((void*)&lib_layer_stack().get_layer_n(lib_index)); return ret; } } return QVariant(); } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::flags * *****************************************************************************/ Qt::ItemFlags PVGuiQt::PVLayerStackModel::flags(const QModelIndex& index) const { switch (index.column()) { case 0: // return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; return Qt::ItemIsEditable | Qt::ItemIsEnabled; default: return (Qt::ItemIsEditable | Qt::ItemIsEnabled); } } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::headerData * *****************************************************************************/ QVariant PVGuiQt::PVLayerStackModel::headerData(int /*section*/, Qt::Orientation /*orientation*/, int role) const { // FIXME : this should not be used : delegate... switch (role) { case (Qt::SizeHintRole): return QSize(37, 37); break; } return QVariant(); } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::rowCount * *****************************************************************************/ int PVGuiQt::PVLayerStackModel::rowCount(const QModelIndex& /*index*/) const { return lib_layer_stack().get_layer_count(); } /****************************************************************************** * * PVGuiQt::PVLayerStackModel::setData * *****************************************************************************/ bool PVGuiQt::PVLayerStackModel::setData(const QModelIndex& index, const QVariant& value, int role) { int layer_count = lib_layer_stack().get_layer_count(); /* We create and store the true index of the layer in the lib */ int lib_index = layer_count - 1 - index.row(); switch (role) { case (Qt::EditRole): switch (index.column()) { case 0: lib_view().toggle_layer_stack_layer_n_visible_state(lib_index); lib_view().process_layer_stack(); return true; case 1: lib_view().set_layer_stack_layer_n_name(lib_index, value.toString()); return true; default: return QAbstractTableModel::setData(index, value, role); } default: return QAbstractTableModel::setData(index, value, role); } return false; } void PVGuiQt::PVLayerStackModel::layer_stack_about_to_be_refreshed() { beginResetModel(); } void PVGuiQt::PVLayerStackModel::reset_layer_colors(const int idx) { Inendi::PVLayerStack& layerstack = lib_layer_stack(); Inendi::PVLayer& layer = layerstack.get_layer_n(lib_index_from_model_index(idx)); layer.reset_to_default_color(); lib_view().process_layer_stack(); } void PVGuiQt::PVLayerStackModel::show_this_layer_only(const int idx) { Inendi::PVLayerStack& layerstack = lib_layer_stack(); int layer_idx = lib_index_from_model_index(idx); Inendi::PVLayer& layer = layerstack.get_layer_n(layer_idx); layer.set_visible(true); // in case, it isn't visible for (int i = 0; i < layerstack.get_layer_count(); i++) { if (i != layer_idx) { Inendi::PVLayer& layer = layerstack.get_layer_n(i); layer.set_visible(false); } } lib_view().process_layer_stack(); } void PVGuiQt::PVLayerStackModel::layer_stack_refreshed() { endResetModel(); } void PVGuiQt::PVLayerStackModel::add_new_layer(QString name) { _lib_view.add_new_layer(name); Inendi::PVLayer& layer = lib_layer_stack().get_layer_n(rowCount() - 1); layer.reset_to_full_and_default_color(); lib_view().process_layer_stack(); } void PVGuiQt::PVLayerStackModel::move_selected_layer_up() { beginResetModel(); lib_view().move_selected_layer_up(); lib_view().process_layer_stack(); endResetModel(); } void PVGuiQt::PVLayerStackModel::move_selected_layer_down() { beginResetModel(); lib_view().move_selected_layer_down(); lib_view().process_layer_stack(); endResetModel(); } void PVGuiQt::PVLayerStackModel::delete_selected_layer() { if (lib_layer_stack().get_selected_layer().is_locked()) { return; } _lib_view.delete_selected_layer(); lib_view().process_layer_stack(); } void PVGuiQt::PVLayerStackModel::duplicate_selected_layer(const QString& name) { beginResetModel(); lib_view().duplicate_selected_layer(name); lib_view().process_layer_stack(); endResetModel(); } void PVGuiQt::PVLayerStackModel::delete_layer_n(const int idx) { assert(idx < rowCount()); if (lib_layer_stack().get_layer_n(idx).is_locked()) { return; } _lib_view.delete_layer_n(idx); lib_view().process_layer_stack(); }
28.919614
99
0.632199
inendi-inspector
92b39e8022390f7662723c15701eda42b756749c
552
hpp
C++
mspp/mspp/Utils/IterableUtils.hpp
shailist/ms-
4f40dd670bdd442c26abcc1642f748775381bb3c
[ "Unlicense" ]
null
null
null
mspp/mspp/Utils/IterableUtils.hpp
shailist/ms-
4f40dd670bdd442c26abcc1642f748775381bb3c
[ "Unlicense" ]
null
null
null
mspp/mspp/Utils/IterableUtils.hpp
shailist/ms-
4f40dd670bdd442c26abcc1642f748775381bb3c
[ "Unlicense" ]
null
null
null
#pragma once namespace IterableUtils { template <typename TIterable> inline constexpr bool starts_with(const TIterable& iterable, const TIterable& sub_iterable) { auto iterable_iter = iterable.cbegin(); auto sub_iterable_iter = sub_iterable.cbegin(); for (;; ++iterable_iter, ++sub_iterable_iter) { if ((iterable.cend() == iterable_iter) || (sub_iterable.cend() == sub_iterable_iter)) { break; } if(*iterable_iter != *sub_iterable_iter) { return false; } } return sub_iterable.cend() == sub_iterable_iter; } }
24
92
0.697464
shailist
92b791d0a438f2e5837ccd1f36103314f392b407
109
cpp
C++
examples/libsimdpp/main.cpp
PhoebeWangintw/hunter
67fadbe7388254c8626b2130c0afb0a5f1817e47
[ "BSD-2-Clause" ]
2
2019-05-28T06:24:08.000Z
2021-08-10T17:10:35.000Z
examples/libsimdpp/main.cpp
PhoebeWangintw/hunter
67fadbe7388254c8626b2130c0afb0a5f1817e47
[ "BSD-2-Clause" ]
null
null
null
examples/libsimdpp/main.cpp
PhoebeWangintw/hunter
67fadbe7388254c8626b2130c0afb0a5f1817e47
[ "BSD-2-Clause" ]
1
2020-03-02T16:07:55.000Z
2020-03-02T16:07:55.000Z
#include <simdpp/simd.h> int main() { simdpp::uint8<32> a; simdpp::uint8<32> b; auto c = a + b; }
18.166667
24
0.550459
PhoebeWangintw
92bc0e770e74ab566c2ad501f1c0cc77c0caf138
6,443
cpp
C++
test/system-level/dca/dca_sp_DCA+_mpi_test.cpp
gonidelis/DCA
b219350a335b96c85b74de9a88bd00d4f37f0ce2
[ "BSD-3-Clause" ]
null
null
null
test/system-level/dca/dca_sp_DCA+_mpi_test.cpp
gonidelis/DCA
b219350a335b96c85b74de9a88bd00d4f37f0ce2
[ "BSD-3-Clause" ]
11
2020-04-22T14:50:27.000Z
2021-09-10T05:43:51.000Z
test/system-level/dca/dca_sp_DCA+_mpi_test.cpp
weilewei/DCA
b219350a335b96c85b74de9a88bd00d4f37f0ce2
[ "BSD-3-Clause" ]
1
2019-09-22T16:33:19.000Z
2019-09-22T16:33:19.000Z
// Copyright (C) 2018 ETH Zurich // Copyright (C) 2018 UT-Battelle, LLC // All rights reserved. // // See LICENSE for terms of usage. // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Author: Urs R. Haehner (haehneru@itp.phys.ethz.ch) // Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch) // // No-change test for a concurrent (using MPI) DCA+ calculation using the CT-AUX cluster solver. // It runs a simulation of a tight-binding model on 2D square lattice. This also tests the // checkpointing between DCA iterations. #include <iostream> #include <string> #include "gtest/gtest.h" #include "dca/config/cmake_options.hpp" #include "dca/function/domains.hpp" #include "dca/function/function.hpp" #include "dca/function/util/difference.hpp" #include "dca/io/filesystem.hpp" #include "dca/io/hdf5/hdf5_reader.hpp" #include "dca/io/json/json_reader.hpp" #include "dca/function/util/difference.hpp" #include "dca/math/random/std_random_wrapper.hpp" #include "dca/parallel/no_threading/no_threading.hpp" #include "dca/phys/dca_data/dca_data.hpp" #include "dca/phys/dca_loop/dca_loop.hpp" #include "dca/phys/dca_step/cluster_solver/ctaux/ctaux_cluster_solver.hpp" #include "dca/phys/domains/cluster/cluster_domain.hpp" #include "dca/phys/domains/cluster/symmetries/point_groups/2d/2d_square.hpp" #include "dca/phys/models/analytic_hamiltonians/square_lattice.hpp" #include "dca/phys/models/tight_binding_model.hpp" #include "dca/phys/parameters/parameters.hpp" #include "dca/profiling/null_profiler.hpp" #include "dca/testing/dca_mpi_test_environment.hpp" #include "dca/testing/minimalist_printer.hpp" #include "dca/util/git_version.hpp" #include "dca/util/modules.hpp" constexpr bool update_baseline = false; dca::testing::DcaMpiTestEnvironment* dca_test_env; TEST(dca_sp_DCAplus_mpi, Self_energy) { using RngType = dca::math::random::StdRandomWrapper<std::mt19937_64>; using DcaPointGroupType = dca::phys::domains::D4; using LatticeType = dca::phys::models::square_lattice<DcaPointGroupType>; using ModelType = dca::phys::models::TightBindingModel<LatticeType>; using Threading = dca::parallel::NoThreading; using ParametersType = dca::phys::params::Parameters<dca::testing::DcaMpiTestEnvironment::ConcurrencyType, Threading, dca::profiling::NullProfiler, ModelType, RngType, dca::phys::solver::CT_AUX>; using DcaDataType = dca::phys::DcaData<ParametersType>; using ClusterSolverType = dca::phys::solver::CtauxClusterSolver<dca::linalg::CPU, ParametersType, DcaDataType>; // The DistType parameter should be covered by the default in dca_loop.hpp // but it doesn't work for gcc 8.3.0 on cray. using DcaLoopType = dca::phys::DcaLoop<ParametersType, DcaDataType, ClusterSolverType, dca::DistType::NONE>; auto& concurrency = dca_test_env->concurrency; dca::util::SignalHandler::init(concurrency.id() == concurrency.first()); if (concurrency.id() == concurrency.first()) { // Copy initial state from an aborted run. filesystem::copy_file( DCA_SOURCE_DIR "/test/system-level/dca/data.dca_sp_DCA+_mpi_test.hdf5.tmp", "./data.dca_sp_DCA+_mpi_test.hdf5.tmp", filesystem::copy_options::overwrite_existing); dca::util::GitVersion::print(); dca::util::Modules::print(); dca::config::CMakeOptions::print(); std::cout << "\n" << "********************************************************************************\n" << "********** DCA(+) Calculation **********\n" << "********************************************************************************\n" << "\n" << "Start time : " << dca::util::print_time() << "\n" << "\n" << "MPI-world set up: " << dca_test_env->concurrency.number_of_processors() << " processes." << "\n" << std::endl; } ParametersType parameters(dca::util::GitVersion::string(), dca_test_env->concurrency); parameters.read_input_and_broadcast<dca::io::JSONReader>(dca_test_env->input_file_name); parameters.update_model(); parameters.update_domains(); DcaDataType dca_data(parameters); dca_data.initialize(); DcaLoopType dca_loop(parameters, dca_data, dca_test_env->concurrency); dca_loop.initialize(); dca_loop.execute(); dca_loop.finalize(); if (!update_baseline) { if (dca_test_env->concurrency.id() == dca_test_env->concurrency.first()) { std::cout << "\nProcessor " << dca_test_env->concurrency.id() << " is checking data " << std::endl; // Read self-energy from check_data file. DcaDataType::SpGreensFunction Sigma_check("Self_Energy"); dca::io::HDF5Reader reader; reader.open_file(DCA_SOURCE_DIR "/test/system-level/dca/check_data.dca_sp_DCA+_mpi_test.hdf5"); reader.open_group("functions"); reader.execute(Sigma_check); reader.close_file(); // Compare the computed self-energy with the expected result. auto diff = dca::func::util::difference(Sigma_check, dca_data.Sigma); EXPECT_NEAR(0, diff.l2, 1.e-9); std::cout << "\nProcessor " << dca_test_env->concurrency.id() << " is writing data." << std::endl; dca_loop.write(); std::cout << "\nFinish time: " << dca::util::print_time() << "\n" << std::endl; } } else { if (concurrency.id() == concurrency.first()) { dca::io::HDF5Writer writer; writer.open_file(DCA_SOURCE_DIR "/test/system-level/dca/check_data.dca_sp_DCA+_mpi_test.hdf5"); writer.open_group("functions"); writer.execute(dca_data.Sigma); writer.close_file(); } } } int main(int argc, char** argv) { int result = 0; ::testing::InitGoogleTest(&argc, argv); dca::parallel::MPIConcurrency concurrency(argc, argv); dca_test_env = new dca::testing::DcaMpiTestEnvironment( concurrency, DCA_SOURCE_DIR "/test/system-level/dca/input.dca_sp_DCA+_mpi_test.json"); ::testing::AddGlobalTestEnvironment(dca_test_env); ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners(); if (dca_test_env->concurrency.id() != 0) { delete listeners.Release(listeners.default_result_printer()); listeners.Append(new dca::testing::MinimalistPrinter); } result = RUN_ALL_TESTS(); return result; }
39.771605
100
0.670185
gonidelis
92c9d75b665ccc72165d44f9e3120a4264fcaf40
1,065
cpp
C++
C++/airplane-seat-assignment-probability.cpp
jaiskid/LeetCode-Solutions
a8075fd69087c5463f02d74e6cea2488fdd4efd1
[ "MIT" ]
3,269
2018-10-12T01:29:40.000Z
2022-03-31T17:58:41.000Z
C++/airplane-seat-assignment-probability.cpp
jaiskid/LeetCode-Solutions
a8075fd69087c5463f02d74e6cea2488fdd4efd1
[ "MIT" ]
53
2018-12-16T22:54:20.000Z
2022-02-25T08:31:20.000Z
C++/airplane-seat-assignment-probability.cpp
jaiskid/LeetCode-Solutions
a8075fd69087c5463f02d74e6cea2488fdd4efd1
[ "MIT" ]
1,236
2018-10-12T02:51:40.000Z
2022-03-30T13:30:37.000Z
// Time: O(1) // Space: O(1) class Solution { public: double nthPersonGetsNthSeat(int n) { // p(k) = 1 * (prob that 1th passenger takes his own seat) + // 0 * (prob that 1th passenger takes kth one's seat) + // 1 * (prob that 1th passenger takes the others' seat) * // (prob that the first k-1 passengers get a seat // which is not kth one's seat) // = 1/k + p(k-1)*(k-2)/k // // p(1) = 1 // p(2) = 1/2 + p(1) * (2-2)/2 = 1/2 // p(3) = 1/3 + p(2) * (3-2)/3 = 1/3 + 1/2 * (3-2)/3 = 1/2 // ... // p(n) = 1/n + 1/2 * (n-2)/n = (2+n-2)/(2n) = 1/2 return n != 1 ? 0.5 : 1.0; } }; // Time: O(n) // Space: O(1) class Solution2 { public: double nthPersonGetsNthSeat(int n) { vector<double> dp(2); dp[0] = 1.0; // zero-indexed for (int i = 2; i <= n; ++i) { dp[(i - 1) % 2] = 1.0 / i + dp[(i - 2) % 2] * (i - 2) / i; } return dp[(n - 1) % 2]; } };
29.583333
73
0.406573
jaiskid
92d34bdc75e8f726ba72e0f207e4bbd8dadb960e
5,907
cpp
C++
arduino/stepper_servo_i2c/src/stepper_servo_controller.cpp
naturetwo/plantnotplant
be9e941e517080e175e292c782fefef9c8b17ce5
[ "Apache-2.0" ]
1
2019-03-30T12:36:34.000Z
2019-03-30T12:36:34.000Z
arduino/stepper_servo_i2c/src/stepper_servo_controller.cpp
naturetwo/plantnotplant
be9e941e517080e175e292c782fefef9c8b17ce5
[ "Apache-2.0" ]
null
null
null
arduino/stepper_servo_i2c/src/stepper_servo_controller.cpp
naturetwo/plantnotplant
be9e941e517080e175e292c782fefef9c8b17ce5
[ "Apache-2.0" ]
null
null
null
// Arduino Motor Controller // Marcus Jones 24FEB2019 // // Commands // f: Stepper forward 1 rotation // b: Stepper backward 1 rotation // 1: Servo posion 1 // 2: Servo posion 2 // 3: Servo posion 3 // // Serial API: #include <Arduino.h> #include <Servo.h> #include <Wire.h> #include <Adafruit_NeoPixel.h> // I2C settings int i2c_address = 0x09; // LED Settings const int PIN_LED = 12; void blink(int cnt, int delay); int BLINK_WAIT = 500; // NEO Pixel settings const int PIN_NEOPIXEL = 10; const int NUMPIXELS = 16; // Parameter 3 = pixel type flags, add together as needed: // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) Adafruit_NeoPixel neoRing = Adafruit_NeoPixel(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); void colorWipe(uint32_t c, uint8_t wait); // Servo settings // Servo accepts write(int), where int is 0 - 360 [degrees] Servo servo1; const int PIN_SERVO = 13; int position = 0; // Variable to store position const int DELAY_SERVO = 10; // Delay in ms // Stepper settings // Stepper accepts const int PIN_STEP = 4; const int PIN_DIRECTION = 3; const int PIN_EN = 2; const int STEPS_ROTATE = 200; const int STEP_SPEED = 500; // Delay in [ms] void stepper_rotate(float rotations); // Serial I2C settings void receiveEvent(int howMany); char str[50]; // For sprintf void setup() { // LED pinMode(PIN_LED, OUTPUT); digitalWrite(PIN_LED, LOW); // NEOpixel neoRing.begin(); neoRing.setBrightness(60); // Lower brightness and save eyeballs! neoRing.show(); // Initialize all pixels to 'off // Stepper pins setup pinMode(PIN_STEP, OUTPUT); pinMode(PIN_DIRECTION, OUTPUT); pinMode(PIN_EN, OUTPUT); digitalWrite(PIN_EN, LOW); // Servo pins setup servo1.attach(PIN_SERVO); servo1.write(180); // Serial setup Serial.begin(9600); // I2C setup Wire.begin(i2c_address); // join i2c bus with address #8 Wire.onReceive(receiveEvent); // register event } void loop() { delay(100); } void blink(int cnt, int wait){ for (int i=0; i<=cnt; i++){ digitalWrite(PIN_LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(wait); // wait for a second digitalWrite(PIN_LED, LOW); // turn the LED off by making the voltage LOW delay(wait); // wait for a second; } } // function that executes whenever data is received from master // this function is registered as an event, see setup() // Execute a motor command AND print to serial for debugging void receiveEvent(int howMany) { while (Wire.available()) { // loop through all but the last char c = Wire.read(); // receive byte as a character // Handle the recieved bytes switch (c) { // LED Control case 'X': sprintf(str, "%c : LED ON\n", char(c)); Serial.print(str); digitalWrite(PIN_LED, HIGH); break; case 'x': sprintf(str, "%c : LED OFF\n", char(c)); Serial.print(str); digitalWrite(PIN_LED, LOW); break; // Stepper control case 'f': sprintf(str, "%c : Stepper forward\n", char(c)); Serial.print(str); stepper_rotate(1); blink(3,BLINK_WAIT); break; case 'b': sprintf(str, "%c : Stepper backward\n", char(c)); Serial.print(str); stepper_rotate(-1); blink(3,BLINK_WAIT); break; // Servo control case '1': sprintf(str, "%c : Servo position 1\n", char(c)); Serial.print(str); servo1.write(2); // Just above 0 to prevent motor chatter blink(3,BLINK_WAIT); break; case '2': sprintf(str, "%c : Servo position 2\n", char(c)); Serial.print(str); servo1.write(90); blink(3,BLINK_WAIT); break; case '3': sprintf(str, "%c : Servo position 3\n", char(c)); Serial.print(str); servo1.write(180); blink(3,BLINK_WAIT); break; // Neopixel Control case 'P': sprintf(str, "%c : NEOPIXEL ON\n", char(c)); Serial.print(str); colorWipe(neoRing.Color(255, 155, 50), 25); // Orange blink(3,BLINK_WAIT); break; case 'p': sprintf(str, "%c : NEOPIXEL ON\n", char(c)); Serial.print(str); colorWipe(neoRing.Color(0, 0, 0), 25); // Black blink(3,BLINK_WAIT); break; // case 'w': // sprintf(str, "%c : wait 500 ms!", char(c)); // Serial.print(str); // delay(500); // break; // case 'W': // sprintf(str, "%c : wait 1000 ms!", char(c)); // Serial.print(str); // delay(1000); // break; default: sprintf(str, "%c : Unrecognized byte!\n", char(c)); Serial.print(str); blink(10,BLINK_WAIT); break; } // End case-switch } } void stepper_rotate(float rotations) { // Smoothly rotate specified rotations // Accepts a signed floating point number // Fractional rotations possible // Get the direction from the sign if (rotations < 0) { // Backwards digitalWrite(PIN_DIRECTION, LOW); } else { // Forwards digitalWrite(PIN_DIRECTION, HIGH); } // Get the required steps int steps = abs(rotations) * STEPS_ROTATE; // Rotate for (int x = 0; x < steps; x++) { digitalWrite(PIN_STEP, HIGH); delayMicroseconds(STEP_SPEED); digitalWrite(PIN_STEP, LOW); delayMicroseconds(STEP_SPEED); } } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { // Iterate over each pixel for (uint16_t i = 0; i < neoRing.numPixels(); i++) { neoRing.setPixelColor(i, c); neoRing.show(); delay(wait); } }
24.510373
93
0.619096
naturetwo
92d4d92a67fa67b0f562791ff39593ec02bb289d
1,239
hpp
C++
engine/runtime/rendering/generator/cylinder_mesh.hpp
ValtoForks/EtherealEngine
ab769803dcd71a61c2805afd259959b62fcdc1ff
[ "BSD-2-Clause" ]
791
2016-11-04T14:13:41.000Z
2022-03-20T20:47:31.000Z
engine/runtime/rendering/generator/cylinder_mesh.hpp
ValtoForks/EtherealEngine
ab769803dcd71a61c2805afd259959b62fcdc1ff
[ "BSD-2-Clause" ]
28
2016-12-01T05:59:30.000Z
2021-03-20T09:49:26.000Z
engine/runtime/rendering/generator/cylinder_mesh.hpp
ValtoForks/EtherealEngine
ab769803dcd71a61c2805afd259959b62fcdc1ff
[ "BSD-2-Clause" ]
151
2016-12-21T09:44:43.000Z
2022-03-31T13:42:18.000Z
#ifndef GENERATOR_CYLINDERMESH_HPP #define GENERATOR_CYLINDERMESH_HPP #include "axis_swap_mesh.hpp" #include "lathe_mesh.hpp" #include "line_shape.hpp" #include "uv_flip_mesh.hpp" namespace generator { /// Cylinder centered at origin aligned along the z-axis. /// @image html CylinderMesh.svg class cylinder_mesh_t { private: using impl_t = axis_swap_mesh_t<lathe_mesh_t<line_shape_t>>; impl_t axis_swap_mesh_; public: /// @param radius Radius of the cylinder along the xy-plane. /// @param size Half of the length of the cylinder along the z-axis. /// @param slices Subdivisions around the z-axis. /// @param segments Subdivisions along the z-axis. /// @param start Counterclockwise angle around the z-axis relative to the x-axis. /// @param sweep Counterclockwise angle around the z-axis. cylinder_mesh_t(double radius = 1.0, double size = 1.0, int slices = 32, int segments = 8, double start = 0.0, double sweep = gml::radians(360.0)); using triangles_t = typename impl_t::triangles_t; triangles_t triangles() const noexcept { return axis_swap_mesh_.triangles(); } using vertices_t = typename impl_t::vertices_t; vertices_t vertices() const noexcept { return axis_swap_mesh_.vertices(); } }; } #endif
26.361702
91
0.749798
ValtoForks
92d6b42a0a5f924cedd60817659ac6fe420ca030
1,318
cpp
C++
sxaccelerate/src/graph/SxGProps.cpp
ashtonmv/sphinx_vdw
5896fee0d92c06e883b72725cb859d732b8b801f
[ "Apache-2.0" ]
1
2020-02-29T03:26:32.000Z
2020-02-29T03:26:32.000Z
sxaccelerate/src/graph/SxGProps.cpp
ashtonmv/sphinx_vdw
5896fee0d92c06e883b72725cb859d732b8b801f
[ "Apache-2.0" ]
null
null
null
sxaccelerate/src/graph/SxGProps.cpp
ashtonmv/sphinx_vdw
5896fee0d92c06e883b72725cb859d732b8b801f
[ "Apache-2.0" ]
null
null
null
// --------------------------------------------------------------------------- // // The general purpose cross platform C/C++ framework // // S x A c c e l e r a t e // // Home: https://www.sxlib.de // License: Apache 2 // Authors: see src/AUTHORS // // --------------------------------------------------------------------------- #include <SxGProps.h> size_t sxHash (const SxGProps &in) { return SxHashFunction::hash (in.getId ()); } SxGProps::SxGProps () : id(-1) { } SxGProps::SxGProps (ssize_t id_) : id(id_) {} ssize_t SxGProps::getId () const { return id; } SxVariant &SxGProps::getProperty (const SxString &key) { if(props.containsKey (key)) return props(key); else SX_CHECK (false, key); } const SxVariant &SxGProps::getProperty (const SxString &key) const { if(props.containsKey (key)) return props(key); else SX_CHECK (false, key); } const SxMap<SxString,SxVariant> & SxGProps::getProperties () const { return props; } bool SxGProps::operator== (const SxGProps &n1) const { return id == n1.id; } bool SxGProps::hasProperty (const SxString &key) const { return this->props.containsKey (key); } SxGProps::operator ssize_t() const { return id; }
22.338983
78
0.528073
ashtonmv
92d7507a777de4cbc7b66ae86ec2ac23ffd7d06f
3,013
cpp
C++
src/gui/tb/tb_str.cpp
sstanfield/hexGame
99edad55703846992d3f64ad4cf9d146d57ca625
[ "Zlib" ]
null
null
null
src/gui/tb/tb_str.cpp
sstanfield/hexGame
99edad55703846992d3f64ad4cf9d146d57ca625
[ "Zlib" ]
null
null
null
src/gui/tb/tb_str.cpp
sstanfield/hexGame
99edad55703846992d3f64ad4cf9d146d57ca625
[ "Zlib" ]
null
null
null
// ================================================================================ // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås == // == See tb_core.h for more information. == // ================================================================================ #include "tb_str.h" #include <stdlib.h> #include <ctype.h> #include <stdarg.h> #include <stdio.h> #include <assert.h> namespace tb { static const char *empty = ""; inline void safe_delete(char *&str) { if (str != empty && str) free(str); str = const_cast<char*>(empty); } const char *stristr(const char *arg1, const char *arg2) { const char *a, *b; for(;*arg1;arg1++) { a = arg1; b = arg2; while (toupper(*a++) == toupper(*b++)) if (!*b) return arg1; } return nullptr; } // == TBStr ========================================================== TBStr::TBStr() : TBStrC(empty) { } TBStr::TBStr(const char* str) : TBStrC(str == empty ? empty : strdup(str)) { if (!s) s = const_cast<char*>(empty); } TBStr::TBStr(const TBStr &str) : TBStrC(str.s == empty ? empty : strdup(str.s)) { if (!s) s = const_cast<char*>(empty); } TBStr::TBStr(const char* str, int len) : TBStrC(empty) { Set(str, len); } TBStr::~TBStr() { safe_delete(s); } bool TBStr::Set(const char* str, int len) { safe_delete(s); if (len == TB_ALL_TO_TERMINATION) len = strlen(str); if (char *new_s = (char *) malloc(len + 1)) { s = new_s; memcpy(s, str, len); s[len] = 0; return true; } return false; } bool TBStr::SetFormatted(const char* format, ...) { safe_delete(s); if (!format) return true; va_list ap; int max_len = 64; char *new_s = nullptr; while (true) { if (char *tris_try_new_s = (char *) realloc(new_s, max_len)) { new_s = tris_try_new_s; va_start(ap, format); int ret = vsnprintf(new_s, max_len, format, ap); va_end(ap); if (ret > max_len) // Needed size is known (+2 for termination and avoid ambiguity) max_len = ret + 2; else if (ret == -1 || ret >= max_len - 1) // Handle some buggy vsnprintf implementations. max_len *= 2; else // Everything fit for sure { s = new_s; return true; } } else { // Out of memory free(new_s); break; } } return false; } void TBStr::Clear() { safe_delete(s); } void TBStr::Remove(int ofs, int len) { assert(ofs >= 0 && (ofs + len <= (int)strlen(s))); if (!len) return; char *dst = s + ofs; char *src = s + ofs + len; while (*src != 0) *(dst++) = *(src++); *dst = *src; } bool TBStr::Insert(int ofs, const char *ins, int ins_len) { int len1 = strlen(s); if (ins_len == TB_ALL_TO_TERMINATION) ins_len = strlen(ins); int newlen = len1 + ins_len; if (char *news = (char *) malloc(newlen + 1)) { memcpy(&news[0], s, ofs); memcpy(&news[ofs], ins, ins_len); memcpy(&news[ofs + ins_len], &s[ofs], len1 - ofs); news[newlen] = 0; safe_delete(s); s = news; return true; } return false; } } // namespace tb
18.83125
92
0.545636
sstanfield
92df5776c2237871b6299ff2eb1599fa24b05845
695
cpp
C++
Coding/CodeChef/Other/MANRECT.cpp
dhvanilp/Data-Structures-and-Algorithms
d9c04e424ef2d2a73dc8afda7ace4cc294c05420
[ "MIT" ]
null
null
null
Coding/CodeChef/Other/MANRECT.cpp
dhvanilp/Data-Structures-and-Algorithms
d9c04e424ef2d2a73dc8afda7ace4cc294c05420
[ "MIT" ]
null
null
null
Coding/CodeChef/Other/MANRECT.cpp
dhvanilp/Data-Structures-and-Algorithms
d9c04e424ef2d2a73dc8afda7ace4cc294c05420
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; #define alpha 1000000000 int main(){ int t; cin>>t; while(t--){ long long int k1,k2,k3,k4; cout<<"Q 0 0\n"<<flush; cin>>k1; cout<<"Q 1000000000 1000000000\n"<<flush; cin>>k2; cout<<"Q 1000000000 0\n"<<flush; cin>>k3; cout<<"Q 0 1000000000\n"<<flush; cin>>k4; long long int a,b,c,d; cout<<"Q 0 "<<(k1-k4+alpha)/2<<"\n"<<flush; cin>>a; b=k1-a; d=alpha*1LL+a-k4; c=2*alpha*1LL-d-k2; cout<<"A "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"<<flush; int temp; cin>>temp; } return 0; }
21.71875
59
0.443165
dhvanilp
92df58be4ba43f7498c6a5f73940bc99d8ac1b5a
975
cpp
C++
cpp1st/week05/byongmin/03.atomic.cpp
th4inquiry/PentaDevs
aa379d24494a485ad5e7fdcc385c6ccfb02cf307
[ "Apache-2.0" ]
2
2022-03-10T10:18:23.000Z
2022-03-16T15:37:22.000Z
cpp1st/week05/byongmin/03.atomic.cpp
th4inquiry/PentaDevs
aa379d24494a485ad5e7fdcc385c6ccfb02cf307
[ "Apache-2.0" ]
8
2022-03-09T16:14:47.000Z
2022-03-28T15:35:17.000Z
cpp1st/week05/byongmin/03.atomic.cpp
th4inquiry/PentaDevs
aa379d24494a485ad5e7fdcc385c6ccfb02cf307
[ "Apache-2.0" ]
4
2022-03-08T00:22:29.000Z
2022-03-12T13:22:43.000Z
#include <iostream> #include <thread> #include <vector> #include <atomic> using namespace std; void increment(int& counter) { for (int i=0; i<10000; ++i) { ++counter; this_thread::sleep_for(chrono::microseconds(1)); } } void incrementAtomic(atomic<int>& counter) { for (int i=0; i<10000; ++i) { ++counter; this_thread::sleep_for(chrono::microseconds(1)); } } int main() { int counter{0}; atomic<int> counterAtomic{0}; vector<thread> threads; vector<thread> threadsAtomic; for (int i=0; i<10; ++i) { threads.emplace_back(thread{increment, ref(counter)}); threadsAtomic.emplace_back(thread{incrementAtomic, ref(counterAtomic)}); } for (auto& t : threads) { t.join(); } for (auto& t : threadsAtomic) { t.join(); } cout << "conter : " << counter << endl; cout << "conterAtomic : " << counterAtomic << endl; return 0; }
18.396226
80
0.575385
th4inquiry
92e0f90428a0a6b4eeec4d42b63b8feabd42c22e
2,202
hpp
C++
src/sdl/error.hpp
degarashi/revenant
9e671320a5c8790f6bdd1b14934f81c37819f7b3
[ "MIT" ]
null
null
null
src/sdl/error.hpp
degarashi/revenant
9e671320a5c8790f6bdd1b14934f81c37819f7b3
[ "MIT" ]
null
null
null
src/sdl/error.hpp
degarashi/revenant
9e671320a5c8790f6bdd1b14934f81c37819f7b3
[ "MIT" ]
null
null
null
#pragma once #include "lubee/src/error_chk.hpp" namespace rev { namespace detail { struct SDLErrorI { static const char* Get(); static void Reset(); static const char *const c_apiName; }; struct IMGErrorI { static const char* Get(); static void Reset(); static const char *const c_apiName; }; } template <class I> struct ErrorT { std::string _errMsg; const char* errorDesc() { const char* err = I::Get(); if(*err != '\0') { _errMsg = err; I::Reset(); return _errMsg.c_str(); } return nullptr; } void reset() const { I::Reset(); } const char* getAPIName() const { return I::c_apiName; } }; using SDLError = ErrorT<detail::SDLErrorI>; using IMGError = ErrorT<detail::IMGErrorI>; } #define SDLEC_Base(flag, act, ...) EChk_polling##flag<::lubee::err::act>(::rev::SDLError(), SOURCEPOS, __VA_ARGS__) #define SDLEC_Base0(flag, act) EChk_polling##flag<::lubee::err::act>(::rev::SDLError(), SOURCEPOS) #define SDLAssert(...) SDLEC_Base(_a, Trap, __VA_ARGS__) #define SDLWarn(...) SDLEC_Base(_a, Warn, __VA_ARGS__) #define SDLAssert0() SDLEC_Base0(_a, Trap) #define SDLWarn0() SDLEC_Base0(_a, Warn) #define D_SDLAssert(...) SDLEC_Base(_d, Trap, __VA_ARGS__) #define D_SDLWarn(...) SDLEC_Base(_d, Warn, __VA_ARGS__) #define D_SDLAssert0() SDLEC_Base0(_d, Trap) #define D_SDLWarn0() SDLEC_Base0(_d, Warn) #define SDLThrow(typ, ...) SDLEC_Base(_a, Throw<typ>, __VA_ARGS__) #define IMGEC_Base(flag, act, ...) EChk_polling##flag<::lubee::err::act>(::rev::IMGError(), SOURCEPOS, __VA_ARGS__) #define IMGEC_Base0(flag, act) EChk_polling##flag<::lubee::err::act>(::rev::IMGError(), SOURCEPOS) #define IMGAssert(...) IMGEC_Base(_a, Trap, __VA_ARGS__) #define IMGWarn(...) IMGEC_Base(_a, Warn, __VA_ARGS__) #define IMGAssert0() IMGEC_Base0(_a, Trap) #define IMGWarn0() IMGEC_Base0(_a, Warn) #define D_IMGAssert(...) IMGEC_Base(_d, Trap, __VA_ARGS__) #define D_IMGWarn(...) IMGEC_Base(_d, Warn, __VA_ARGS__) #define D_IMGAssert0() IMGEC_Base0(_d, Trap) #define D_IMGWarn0() IMGEC_Base0(_d, Warn) #define IMGThrow(typ, ...) IMGEC_Base(_a, Throw<typ>, __VA_ARGS__)
33.876923
116
0.669846
degarashi
2bb450124612e631b02f7d839b2f37920171d2fc
6,043
cpp
C++
Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1EasingSplines.cpp
polarpathgames/Polar-Path
cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6
[ "MIT" ]
9
2019-03-05T07:26:04.000Z
2019-10-09T15:57:45.000Z
Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1EasingSplines.cpp
polarpathgames/Polar-Path
cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6
[ "MIT" ]
114
2019-03-10T09:35:12.000Z
2019-06-10T21:39:12.000Z
Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1EasingSplines.cpp
polarpathgames/Polar-Path
cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6
[ "MIT" ]
3
2019-02-25T16:12:40.000Z
2019-11-19T20:48:06.000Z
#include "p2Defs.h" #include "p2Log.h" #include "App.h" #include "m1Input.h" #include "m1Textures.h" #include "m1Render.h" #include "m1MenuManager.h" #include "m1Window.h" #include "m1Map.h" #include "m1EasingSplines.h" #include <string> #include "p2Log.h" #include "Brofiler/Brofiler.h" m1EasingSplines::m1EasingSplines() : m1Module() { name.assign("easingsplines"); } // Destructor m1EasingSplines::~m1EasingSplines() { } // Called each loop iteration bool m1EasingSplines::Update(float dt) { BROFILER_CATEGORY("UpdateEasingSplines", Profiler::Color::Purple); std::list<EaseSplineInfo*>::iterator item = easing_splines.begin(); for (; item != easing_splines.end(); ++item) { if (*item != nullptr) { if (!(*item)->Update(dt)) { delete(*item); (*item) = nullptr; } } } easing_splines.remove(nullptr); return true; } // Called before quitting bool m1EasingSplines::CleanUp() { LOG("Freeing scene"); std::list<EaseSplineInfo*>::iterator item = easing_splines.begin(); for (; item != easing_splines.end(); ++item) { if (*item != nullptr) { delete(*item); (*item) = nullptr; } } easing_splines.clear(); return true; } EaseSplineInfo* m1EasingSplines::CreateSpline(int * position, const int target_position, const float time_to_travel, TypeSpline type, std::function<void()> fn) { std::list <EaseSplineInfo*>::iterator item = easing_splines.begin(); for (; item != easing_splines.end(); ++item) { if ((*item) != nullptr && (*item)->position == position) { (*item)->to_delete = true; break; } } EaseSplineInfo* info = DBG_NEW EaseSplineInfo(position, target_position, time_to_travel, type, fn); if (info != nullptr) easing_splines.push_back(info); else LOG("Could not create the Spline..."); return info; } bool EaseSplineInfo::Update(float dt) { bool ret = true; float time_passed = SDL_GetTicks() - time_started; if (time_passed < time_to_travel && !to_delete) { switch (type) { case EASE: { *position = ease_function.Ease(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_OUT_QUINT: { *position = ease_function.EaseOutQuint(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_IN_OUT_BACK: { *position = ease_function.EaseInOutBack(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_IN_BACK: { *position = ease_function.EaseInBack(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_OUT_BACK: { *position = ease_function.EaseOutBack(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_IN_CUBIC: { *position = ease_function.EaseInCubic(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_OUT_CUBIC: { *position = ease_function.EaseOutCubic(time_passed, initial_position, distance_to_travel, time_to_travel); } break; case EASE_OUT_BOUNCE: { *position = ease_function.EaseOutBounce(time_passed, initial_position, distance_to_travel, time_to_travel); } break; default: break; } } else { if (fn != nullptr) this->fn(); to_delete = true; ret = false; } return ret; } int EaseFunctions::EaseOutQuint(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { return distance_to_travel * ((time_passed = time_passed / time_to_travel - 1)*time_passed*time_passed*time_passed*time_passed + 1) + initial_position; } int EaseFunctions::Ease(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { return distance_to_travel * (time_passed / time_to_travel) + initial_position; } int EaseFunctions::EaseInOutBack(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { float s = 1.70158f; if ((time_passed /= time_to_travel / 2) < 1) { return distance_to_travel / 2 * (time_passed*time_passed*(((s *= (1.525f)) + 1)*time_passed - s)) + initial_position; } else { float postFix = time_passed -= 2; return distance_to_travel / 2 * ((postFix)*time_passed*(((s *= (1.525f)) + 1)*time_passed + s) + 2) + initial_position; } } int EaseFunctions::EaseInBack(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { float s = 2.70158f; float postFix = time_passed /= time_to_travel; return distance_to_travel * (postFix)*time_passed*((s + 1)*time_passed - s) + initial_position; } int EaseFunctions::EaseOutBack(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { float s = 1.10158f; return distance_to_travel * ((time_passed = time_passed / time_to_travel - 1)*time_passed*((s + 1)*time_passed + s) + 1) + initial_position; } int EaseFunctions::EaseInCubic(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { return distance_to_travel * (time_passed /= time_to_travel)*time_passed*time_passed + initial_position; } int EaseFunctions::EaseOutCubic(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { return distance_to_travel * ((time_passed = time_passed / time_to_travel - 1)*time_passed*time_passed + 1) + initial_position; } int EaseFunctions::EaseOutBounce(float time_passed, int initial_position, int distance_to_travel, float time_to_travel) { if ((time_passed /= time_to_travel) < (1 / 2.75f)) { return distance_to_travel * (7.5625f*time_passed*time_passed) + initial_position; } else if (time_passed < (2 / 2.75f)) { float postFix = time_passed -= (1.5f / 2.75f); return distance_to_travel * (7.5625f*(postFix)*time_passed + .75f) + initial_position; } else if (time_passed < (2.5 / 2.75)) { float postFix = time_passed -= (2.25f / 2.75f); return distance_to_travel * (7.5625f*(postFix)*time_passed + .9375f) + initial_position; } else { float postFix = time_passed -= (2.625f / 2.75f); return distance_to_travel * (7.5625f*(postFix)*time_passed + .984375f) + initial_position; } }
29.915842
159
0.730101
polarpathgames
2bb5086b377f9557b71a737d06db2a6d5f33517b
71
cpp
C++
Src/App.cpp
Kataglyphis/GraphicsEngineVulkan
5c66d5761419a6a1b1a6a0628d391d29f03fb0ad
[ "BSD-3-Clause" ]
null
null
null
Src/App.cpp
Kataglyphis/GraphicsEngineVulkan
5c66d5761419a6a1b1a6a0628d391d29f03fb0ad
[ "BSD-3-Clause" ]
null
null
null
Src/App.cpp
Kataglyphis/GraphicsEngineVulkan
5c66d5761419a6a1b1a6a0628d391d29f03fb0ad
[ "BSD-3-Clause" ]
null
null
null
#include "App.h" App::App() { } void App::run() { } App::~App() { }
5.071429
16
0.464789
Kataglyphis
2bb62a640cf30baf34c8397376008da560128338
1,209
cpp
C++
src/test.weapon.cpp
prinsij/RogueReborn
20e6ba4d2e61a47283747ba207a758e604fa89d9
[ "BSD-3-Clause" ]
null
null
null
src/test.weapon.cpp
prinsij/RogueReborn
20e6ba4d2e61a47283747ba207a758e604fa89d9
[ "BSD-3-Clause" ]
null
null
null
src/test.weapon.cpp
prinsij/RogueReborn
20e6ba4d2e61a47283747ba207a758e604fa89d9
[ "BSD-3-Clause" ]
null
null
null
/** * @file test.weapon.cpp * @author Team Rogue++ * @date December 08, 2016 * * @brief Member definitions for the WeaponTest class */ #include <exception> #include <iostream> #include <string> #include <vector> #include "include/playerchar.h" #include "include/weapon.h" #include "test.testable.h" /** * @brief Tests the Weapon class. */ class WeaponTest : public Testable { public: WeaponTest(){} void test(){ comment("Commencing Weapon tests..."); try { Weapon weaponCon = Weapon(Coord(0,0)); assert(true, "Created Weapon (1)"); Weapon weaponCon2 = Weapon(Coord(0,0), Item::FLOOR, 0); assert(true, "Created Weapon (2)"); } catch (const std::exception& e) { assert(false, "Failure creating Potion"); } Weapon weapon = Weapon(Coord(0,0), Item::FLOOR, 5); weapon.setEnchantments(-1, -2); assert (weapon.isIdentified(), "Weapon Identification Test"); assert (weapon.hasEffect(Item::CURSED), "Weapon Curse Test"); assert (weapon.getName().find("/") != std::string::npos, "Get Weapon Name"); assert (weapon.getEnchantments() == std::make_pair<int, int>(-1, -2), "Get Weapon Enchantments"); comment("Finished Weapon tests."); } };
25.1875
100
0.652605
prinsij
2bbfffebeab6997db4591b2bad5db24d4f641254
5,814
cpp
C++
cpp/sec.cpp
Ypig/vergil
1fedad4a6afbd108530959275e959c4bf5ed0990
[ "MIT" ]
74
2019-10-03T07:22:47.000Z
2022-03-15T11:54:45.000Z
cpp/sec.cpp
Ypig/vergil
1fedad4a6afbd108530959275e959c4bf5ed0990
[ "MIT" ]
null
null
null
cpp/sec.cpp
Ypig/vergil
1fedad4a6afbd108530959275e959c4bf5ed0990
[ "MIT" ]
34
2019-10-05T05:08:26.000Z
2022-02-14T03:36:01.000Z
#include "sec.h" namespace tokza{ SEC_ELE::SEC_ELE() { this->head = 0; this->end = 0; this->file_hash = 0; this->mem_hash = 0; return; } SEC_ELE::~SEC_ELE() { this->head = 0; this->end = 0; this->file_hash = 0; this->mem_hash = 0; return; } SEC::SEC(CONFHANDLE& confhandle__, MDBASE& mdbase__):confhandle(confhandle__),mdbase(mdbase__) { this->flag = false; this->is_hook = 0; this->dec_conf = confhandle.get_dec_conf(); if(nullptr==dec_conf){ LOGD("FUNC::FUNC(),fail.\n"); FAIL_EXIT; } return; } SEC::~SEC() { flag = false; is_hook = 0; dec_conf = nullptr; return; } bool SEC::init() { vector<u32> vec; bool ret = this->confhandle.get_type_vec(CONF_TYPE::TYPE_SEC_ELE,vec); if(!ret){ LOGD("SEC::init(),fail.\n"); return false; } // 举例 @@type##@@head##@@end##@@filehash##(段信息) STR_UTILS su; for(auto& idx:vec){ char* dec = su.get_decconf_by_idx(this->dec_conf,idx); char* p1 = su.getpart(dec,1); char* p2 = su.getpart(dec,2); char* p3 = su.getpart(dec,3); char* p4 = su.getpart(dec,4); if (NULL == p1 || NULL == p2 || NULL == p3 || NULL == p4) { LOGD("SEC::init(),fail.\n"); return false; } SEC_TYPE sec_type = (SEC_TYPE)(su.str2num(p1)); u32 head = (u32)(su.str2num(p2)); u32 end = (u32)(su.str2num(p3)); u32 filehash = (u32)(su.str2num(p4)); if(SEC_TYPE::TYPE_DYNSYM ==sec_type){ sub_init(this->LOAD1.dynsym,head,end,filehash); } else if(SEC_TYPE::TYPE_DYNSTR ==sec_type){ sub_init(this->LOAD1.dynstr,head,end,filehash); } else if(SEC_TYPE::TYPE_HASH ==sec_type){ sub_init(this->LOAD1.hash,head,end,filehash); } else if(SEC_TYPE::TYPE_RELDYN ==sec_type){ sub_init(this->LOAD1.reldyn,head,end,filehash); } else if(SEC_TYPE::TYPE_RELPLT ==sec_type){ sub_init(this->LOAD1.relplt,head,end,filehash); } else if(SEC_TYPE::TYPE_PLT ==sec_type){ sub_init(this->LOAD1.plt,head,end,filehash); } else if(SEC_TYPE::TYPE_ARMEXTAB ==sec_type){ sub_init(this->LOAD1.arm_extab,head,end,filehash); } else if(SEC_TYPE::TYPE_ARMEXIDX ==sec_type){ sub_init(this->LOAD1.arm_exidx,head,end,filehash); } else if(SEC_TYPE::TYPE_RODATA ==sec_type){ sub_init(this->LOAD1.rodata,head,end,filehash); } else if(SEC_TYPE::TYPE_FINIARRAY ==sec_type){ sub_init(this->LOAD2.fini_array,head,end,filehash); } else if(SEC_TYPE::TYPE_INITARRAY ==sec_type){ sub_init(this->LOAD2.init_array,head,end,filehash); } else if(SEC_TYPE::TYPE_DYNAMIC ==sec_type){ sub_init(this->LOAD2.dynamic,head,end,filehash); }else{ LOGD("SEC::init(),fail.\n"); return false; }//ifelse }//for return true; } void SEC::sub_init(SEC_ELE& ele, u32 head, u32 end, u32 file_hash) { ele.head = head; ele.end = end; ele.file_hash =file_hash; return; } void SEC::get_memhash() { u32 base = this->mdbase.get_self(); sub_getmemhash(this->LOAD1.dynsym,base); sub_getmemhash(this->LOAD1.dynstr,base); sub_getmemhash(this->LOAD1.hash,base); sub_getmemhash(this->LOAD1.reldyn,base); sub_getmemhash(this->LOAD1.relplt,base); sub_getmemhash(this->LOAD1.plt,base); sub_getmemhash(this->LOAD1.arm_extab,base); sub_getmemhash(this->LOAD1.arm_exidx,base); sub_getmemhash(this->LOAD1.rodata,base); sub_getmemhashload2(this->LOAD2.fini_array,base); sub_getmemhashload2(this->LOAD2.init_array,base); sub_getmemhash(this->LOAD2.dynamic,base); return; } void SEC::sub_getmemhash(SEC_ELE& ele,u32 base) { ele.mem_hash = str_utils.membkdrhash_half(base,ele.head,ele.end); if(ele.mem_hash != ele.file_hash){ this->is_hook += IS_HOOK; LOGD("SEC::sub_getmemhash(),find sec hook.\n"); } return; } void SEC::sub_getmemhashload2(SEC_ELE& ele, u32 base) { if(ele.end <= ele.head){ ele.mem_hash = 0; return; } MEM mem; u8* addr = (u8*)(ele.head + base); u32 size = (ele.end - ele.head); u32* buf = (u32*)(mem.get(size)); u32 count = size / 4; memcpy(buf, addr, size); for (u32 k = 0; k < count; k++) { if (0 == buf[k]) continue; else buf[k] = buf[k] - base; }//for ele.mem_hash = str_utils.membkdrhash_half( 0, (u32)buf,(u32)buf + size ); if(ele.mem_hash != ele.file_hash){ this->is_hook += IS_HOOK; LOGD("SEC::sub_getmemhashload2(),find sec hook.\n"); } return; } bool SEC::check() { // 初始化 if(!this->flag){ if(!init()){ FAIL_EXIT; } this->flag = true; } // 实时计算内存hash,与预设对比后返回结果 this->is_hook = 0; get_memhash(); if( 0!=this->is_hook ){ return true; }else{ return false; } } }
31.597826
100
0.5086
Ypig
2bc2a35da628b06dec5d795ffe1a5575b375f772
3,052
cpp
C++
src/Picasso_InputParser.cpp
streeve/picasso
8e546ede7729dbb0462f5a856d06530f7cbf912c
[ "BSD-3-Clause" ]
3
2021-02-17T14:59:09.000Z
2021-09-29T23:29:52.000Z
src/Picasso_InputParser.cpp
streeve/picasso
8e546ede7729dbb0462f5a856d06530f7cbf912c
[ "BSD-3-Clause" ]
48
2021-02-17T17:24:12.000Z
2022-03-18T14:12:02.000Z
src/Picasso_InputParser.cpp
streeve/picasso
8e546ede7729dbb0462f5a856d06530f7cbf912c
[ "BSD-3-Clause" ]
5
2021-02-17T14:39:58.000Z
2021-10-05T18:42:21.000Z
/**************************************************************************** * Copyright (c) 2021 by the Picasso authors * * All rights reserved. * * * * This file is part of the Picasso library. Picasso is distributed under a * * BSD 3-clause license. For the licensing terms see the LICENSE file in * * the top-level directory. * * * * SPDX-License-Identifier: BSD-3-Clause * ****************************************************************************/ #include <Picasso_InputParser.hpp> #include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/xml_parser.hpp> namespace Picasso { //---------------------------------------------------------------------------// //! Input argument constructor. InputParser::InputParser( int argc, char* argv[] ) { // Get the filename from the input. bool found_arg = false; std::string filename; for ( int n = 0; n < argc - 1; ++n ) { if ( 0 == std::strcmp( argv[n], "--picasso-input-json" ) ) { filename = std::string( argv[n + 1] ); found_arg = true; parse( filename, "json" ); break; } else if ( 0 == std::strcmp( argv[n], "--picasso-input-xml" ) ) { filename = std::string( argv[n + 1] ); found_arg = true; parse( filename, "xml" ); break; } } // Check that we found the filename. if ( !found_arg ) throw std::runtime_error( "No Picasso input file specified: --picasso-input-*type* [file name] is required.\ Where *type* can be json or xml" ); } //---------------------------------------------------------------------------// //! Filename constructor. InputParser::InputParser( const std::string& filename, const std::string& type ) { parse( filename, type ); } //---------------------------------------------------------------------------// //! Get the ptree. const boost::property_tree::ptree& InputParser::propertyTree() const { return _ptree; } //---------------------------------------------------------------------------// // Parse the field. void InputParser::parse( const std::string& filename, const std::string& type ) { // Get the filename from the input. if ( 0 == type.compare( "json" ) ) { boost::property_tree::read_json( filename, _ptree ); } else if ( 0 == type.compare( "xml" ) ) { boost::property_tree::read_xml( filename, _ptree ); } else // Check that we found the filename. { throw std::runtime_error( "Only json or xml inputs supported" ); } } //---------------------------------------------------------------------------// } // end namespace Picasso
34.681818
94
0.424967
streeve
2bc3612efa6deba48d73001ac47174f596347899
5,617
hpp
C++
lib/generated/definitions/mask/mask_neon.hpp
db-tu-dresden/TVL
051261d49f993ce5c70629526038a6f7717055ef
[ "Apache-2.0" ]
2
2022-03-21T23:17:32.000Z
2022-03-22T19:56:17.000Z
lib/generated/definitions/mask/mask_neon.hpp
db-tu-dresden/TVL
051261d49f993ce5c70629526038a6f7717055ef
[ "Apache-2.0" ]
1
2022-03-31T11:56:21.000Z
2022-03-31T11:56:21.000Z
lib/generated/definitions/mask/mask_neon.hpp
db-tu-dresden/TVL
051261d49f993ce5c70629526038a6f7717055ef
[ "Apache-2.0" ]
1
2022-03-23T08:38:49.000Z
2022-03-23T08:38:49.000Z
/*==========================================================================* * This file is part of the TVL - a template SIMD library. * * * * Copyright 2022 TVL-Team, Database Research Group TU Dresden * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * *==========================================================================*/ /* * @file lib/generated/definitions/mask/mask_neon.hpp * @date 30.03.2022 * @brief Mask related primitives. Implementation for neon */ #ifndef TUD_D2RG_TVL_LIB_GENERATED_DEFINITIONS_MASK_MASK_NEON_HPP #define TUD_D2RG_TVL_LIB_GENERATED_DEFINITIONS_MASK_MASK_NEON_HPP #include "../../declarations/mask.hpp" namespace tvl { namespace details { /** * @brief: Template specialization of implementation for "to_integral". * @details: * Target Extension: neon. * Data Type: int64_t * Extension Flags: ['neon'] */ template<ImplementationDegreeOfFreedom Idof> struct to_integral_impl<simd<int64_t, neon>, Idof> { using Vec = simd< int64_t, neon >; static constexpr bool native_supported() { return false; } [[nodiscard]] TVL_NO_NATIVE_SUPPORT_WARNING TVL_FORCE_INLINE static typename Vec::base_type apply( typename Vec::mask_type vec_mask ) { static_assert( !std::is_same_v< Idof, native >, "The primitive to_integral is not supported by your hardware natively while it is forced by using native" ); return ( ( vec_mask[ 1 ] >> 62 ) & 0b10 ) | ( vec_mask[ 0 ] >> 63 ); } }; } // end of namespace details for template specialization of to_integral_impl for neon using int64_t. namespace details { /** * @brief: Template specialization of implementation for "get_msb". * @details: * Target Extension: neon. * Data Type: int64_t * Extension Flags: ['neon'] */ template<ImplementationDegreeOfFreedom Idof> struct get_msb_impl<simd<int64_t, neon>, Idof> { using Vec = simd< int64_t, neon >; static constexpr bool native_supported() { return false; } [[nodiscard]] TVL_NO_NATIVE_SUPPORT_WARNING TVL_FORCE_INLINE static typename Vec::base_type apply( typename Vec::register_type vec ) { static_assert( !std::is_same_v< Idof, native >, "The primitive get_msb is not supported by your hardware natively while it is forced by using native" ); return ( ( vec[ 1 ] >> 62 ) & 0b10 ) | ( vec[ 0 ] >> 63 ); } }; } // end of namespace details for template specialization of get_msb_impl for neon using int64_t. namespace details { /** * @brief: Template specialization of implementation for "to_vector". * @details: * Target Extension: neon. * Data Type: int64_t * Extension Flags: ['neon'] */ template<ImplementationDegreeOfFreedom Idof> struct to_vector_impl<simd<int64_t, neon>, Idof> { using Vec = simd< int64_t, neon >; static constexpr bool native_supported() { return true; } [[nodiscard]] TVL_FORCE_INLINE static typename Vec::register_type apply( typename Vec::mask_type mask ) { return vreinterpretq_s64_u64( mask ); //mask is a vector already. } }; } // end of namespace details for template specialization of to_vector_impl for neon using int64_t. namespace details { /** * @brief: Template specialization of implementation for "mask_reduce". * @details: * Target Extension: neon. * Data Type: int64_t * Extension Flags: ['neon'] */ template<ImplementationDegreeOfFreedom Idof> struct mask_reduce_impl<simd<int64_t, neon>, Idof> { using Vec = simd< int64_t, neon >; static constexpr bool native_supported() { return true; } [[nodiscard]] TVL_FORCE_INLINE static typename Vec::base_type apply( typename Vec::base_type mask ) { return mask & 0x3; } }; } // end of namespace details for template specialization of mask_reduce_impl for neon using int64_t. } // end of namespace tvl #endif //TUD_D2RG_TVL_LIB_GENERATED_DEFINITIONS_MASK_MASK_NEON_HPP
45.666667
171
0.541926
db-tu-dresden
2bc61916cabd98ca28e8a5e61c37a6f44c5753e7
223
hpp
C++
examples/glfw_opengl_es_renderer/parameters_persistency.hpp
vladimir-voinea/vr
0af18898ee512a0f94be7609e19753b92da03775
[ "MIT" ]
null
null
null
examples/glfw_opengl_es_renderer/parameters_persistency.hpp
vladimir-voinea/vr
0af18898ee512a0f94be7609e19753b92da03775
[ "MIT" ]
null
null
null
examples/glfw_opengl_es_renderer/parameters_persistency.hpp
vladimir-voinea/vr
0af18898ee512a0f94be7609e19753b92da03775
[ "MIT" ]
null
null
null
#pragma once #include <parameters.hpp> bool have_parameters_file(const std::string& path); parameters load_parameters(const std::string& path); void save_parameters(const std::string& path, const parameters& parameters);
27.875
76
0.793722
vladimir-voinea
2bc813b8772e1619ff3e931dcb0e15fe35b54154
1,051
hpp
C++
nd-coursework/books/cpp/C++Templates/traits/ifthenelse.hpp
crdrisko/nd-grad
f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44
[ "MIT" ]
1
2020-09-26T12:38:55.000Z
2020-09-26T12:38:55.000Z
nd-coursework/books/cpp/C++Templates/traits/ifthenelse.hpp
crdrisko/nd-research
f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44
[ "MIT" ]
null
null
null
nd-coursework/books/cpp/C++Templates/traits/ifthenelse.hpp
crdrisko/nd-research
f1765e4f24d7a4b1b3a76c64eb8d88bcca0eaa44
[ "MIT" ]
null
null
null
// Copyright (c) 2017 by Addison-Wesley, David Vandevoorde, Nicolai M. Josuttis, and Douglas Gregor. All rights reserved. // See the LICENSE file in the project root for more information. // // Name: ifthenelse.hpp // Author: crdrisko // Date: 08/31/2020-20:09:37 // Description: Selecting between two type parameters based on the value of a Boolean value, based on std::conditional<> #ifndef IFTHENELSE_HPP #define IFTHENELSE_HPP // primary template: yield the second argument by default and rely on // a partial specialization to yield the third argument // if COND is false template<bool COND, typename TrueType, typename FalseType> struct IfThenElseT { using Type = TrueType; }; // partial specialization: false yields third argument template<typename TrueType, typename FalseType> struct IfThenElseT<false, TrueType, FalseType> { using Type = FalseType; }; template<bool COND, typename TrueType, typename FalseType> using IfThenElse = typename IfThenElseT<COND, TrueType, FalseType>::Type; #endif
32.84375
121
0.743102
crdrisko
2bc9ec327d7cfd0dfd9eeed6bd82811f3b4a6b20
692
cpp
C++
HDU-Code/2009 Multi-University Training Contest 1/H.cpp
PrayStarJirachi/Exercise-Code
801a5926eccc971ab2182e5e99e3a0746bd6a7f0
[ "MIT" ]
null
null
null
HDU-Code/2009 Multi-University Training Contest 1/H.cpp
PrayStarJirachi/Exercise-Code
801a5926eccc971ab2182e5e99e3a0746bd6a7f0
[ "MIT" ]
null
null
null
HDU-Code/2009 Multi-University Training Contest 1/H.cpp
PrayStarJirachi/Exercise-Code
801a5926eccc971ab2182e5e99e3a0746bd6a7f0
[ "MIT" ]
null
null
null
#include <cstdio> #include <algorithm> #ifdef WIN32 #define LL "%I64d" #else #define LL "%lld" #endif const int MAXN = 3000001; const int Maxdata = 3000000; int g, p[MAXN]; long long phi[MAXN]; bool vis[MAXN]; int main() { phi[1] = 1; for (int i = 2; i <= Maxdata; i++) { if (!vis[i]) phi[p[++g] = i] = i - 1; for (int j = 1; i * p[j] <= Maxdata && j <= g; j++) { vis[i * p[j]] = true; if (i % p[j] == 0) { phi[i * p[j]] = phi[i] * p[j]; break; } else phi[i * p[j]] = phi[i] * phi[p[j]]; } } for (int i = 2; i <= Maxdata; i++) phi[i] += phi[i - 1]; int l, r; while (scanf("%d%d", &l, &r) == 2) { printf(LL "\n", phi[r] - phi[l - 1]); } return 0; }
18.210526
55
0.482659
PrayStarJirachi
2bca3bb76da31998ae094bb5e148962887c7bb02
523
cpp
C++
Code/Engine/Math/Vector3.cpp
ntaylorbishop/Copycat
c02f2881f0700a33a2630fd18bc409177d80b8cd
[ "MIT" ]
2
2017-10-02T03:18:55.000Z
2018-11-21T16:30:36.000Z
Code/Engine/Math/Vector3.cpp
ntaylorbishop/Copycat
c02f2881f0700a33a2630fd18bc409177d80b8cd
[ "MIT" ]
null
null
null
Code/Engine/Math/Vector3.cpp
ntaylorbishop/Copycat
c02f2881f0700a33a2630fd18bc409177d80b8cd
[ "MIT" ]
null
null
null
#include "Engine/Math/Vector3.hpp" #define STATIC //Do-nothing to indicate static STATIC const Vector3 Vector3::ZERO(0.f, 0.f, 0.f); STATIC const Vector3 Vector3::ONE(1.f, 1.f, 1.f); STATIC const Vector3 Vector3::UNIT_VECTOR_X(1.f, 0.f, 0.f); STATIC const Vector3 Vector3::UNIT_VECTOR_Y(0.f, 1.f, 0.f); STATIC const Vector3 Vector3::UNIT_VECTOR_Z(0.f, 0.f, 1.f); STATIC const Vector3 Vector3::RIGHT( 1.f, 0.f, 0.f); STATIC const Vector3 Vector3::UP( 0.f, 1.f, 0.f); STATIC const Vector3 Vector3::FORWARD( 0.f, 0.f, 1.f);
43.583333
59
0.711281
ntaylorbishop
2bcec88dace2a7a2c87a113d27636a436387ef60
619
cc
C++
public/test/cc/test_main.cc
room77/77up
736806fbf52a5e722e8e57ef5c248823b067175d
[ "MIT" ]
3
2015-05-18T14:52:47.000Z
2018-11-12T07:51:00.000Z
public/test/cc/test_main.cc
room77/77up
736806fbf52a5e722e8e57ef5c248823b067175d
[ "MIT" ]
null
null
null
public/test/cc/test_main.cc
room77/77up
736806fbf52a5e722e8e57ef5c248823b067175d
[ "MIT" ]
3
2015-08-04T05:58:18.000Z
2018-11-12T07:51:01.000Z
// Copyright 2012 Room77 Inc. All Rights Reserved. // Author: pramodg@room77.com (Pramod Gupta) // // The default main file that can be used to run unit tests. #include "util/init/main.h" #include "test/cc/test_main.h" extern string gFlag_init_include; int main(int argc, char** argv) { // Init the google mock framework. // This in turn inits the google test framework. testing::InitGoogleMock(&argc, argv); // Only include test inits. gFlag_init_include = "test"; // Init R77. r77::R77Init(argc, argv); int status = RUN_ALL_TESTS(); // Shutdown R77. r77::R77Shutdown(); return status; }
21.344828
60
0.694669
room77
2bcf80363a8770c67fcdb4a0143ead4f672fdaad
8,810
cc
C++
c_src/sst_file_manager.cc
k32/erlang-rocksdb
54657d3a44a09bd4357f07ecfa54b327c1033a17
[ "Apache-2.0" ]
2
2022-03-10T08:21:57.000Z
2022-03-10T14:09:33.000Z
c_src/sst_file_manager.cc
tsutsu/erlang-rocksdb
5b1b66d06539dcb5891c12e5d5ff7a16a3ef3824
[ "Apache-2.0" ]
null
null
null
c_src/sst_file_manager.cc
tsutsu/erlang-rocksdb
5b1b66d06539dcb5891c12e5d5ff7a16a3ef3824
[ "Apache-2.0" ]
1
2021-12-31T06:13:02.000Z
2021-12-31T06:13:02.000Z
// Copyright (c) 2018-2020 Benoit Chesneau // // This file is provided to you under the Apache License, // Version 2.0 (the "License"); you may not use this file // except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. // #include <array> #include <string> #include "rocksdb/sst_file_manager.h" #include "atoms.h" #include "env.h" #include "sst_file_manager.h" #include "util.h" namespace erocksdb { ErlNifResourceType * SstFileManager::m_SstFileManager_RESOURCE(NULL); void SstFileManager::CreateSstFileManagerType( ErlNifEnv * env) { ErlNifResourceFlags flags = (ErlNifResourceFlags)(ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER); m_SstFileManager_RESOURCE = enif_open_resource_type(env, NULL, "erocksdb_SstFileManager", &SstFileManager::SstFileManagerResourceCleanup, flags, NULL); return; } // SstFileManager::CreateSstFileManagerType void SstFileManager::SstFileManagerResourceCleanup(ErlNifEnv * /*env*/, void * arg) { SstFileManager* mgr_ptr = (SstFileManager *)arg; mgr_ptr->~SstFileManager(); mgr_ptr = nullptr; return; } // SstFileManager::SstFileManagerResourceCleanup SstFileManager * SstFileManager::CreateSstFileManagerResource(std::shared_ptr<rocksdb::SstFileManager> mgr) { SstFileManager * ret_ptr; void * alloc_ptr; alloc_ptr=enif_alloc_resource(m_SstFileManager_RESOURCE, sizeof(SstFileManager)); ret_ptr=new (alloc_ptr) SstFileManager(mgr); return(ret_ptr); } SstFileManager * SstFileManager::RetrieveSstFileManagerResource(ErlNifEnv * Env, const ERL_NIF_TERM & term) { SstFileManager * ret_ptr; if (!enif_get_resource(Env, term, m_SstFileManager_RESOURCE, (void **)&ret_ptr)) return NULL; return ret_ptr; } SstFileManager::SstFileManager(std::shared_ptr<rocksdb::SstFileManager> Mgr) : mgr_(Mgr) {} SstFileManager::~SstFileManager() { if(mgr_) { mgr_ = nullptr; } return; } std::shared_ptr<rocksdb::SstFileManager> SstFileManager::sst_file_manager() { auto m = mgr_; return m; } ERL_NIF_TERM NewSstFileManager( ErlNifEnv* env, int /*argc*/, const ERL_NIF_TERM argv[]) { erocksdb::ManagedEnv* env_ptr = erocksdb::ManagedEnv::RetrieveEnvResource(env,argv[0]); if(NULL==env_ptr) return enif_make_badarg(env); ErlNifUInt64 rate_bytes_per_sec = 0; double max_trash_db_ratio = 0.25; ErlNifUInt64 bytes_max_delete_chunk = 64 * 1024 * 1024; ERL_NIF_TERM head, tail; const ERL_NIF_TERM* option; int arity; tail = argv[1]; while(enif_get_list_cell(env, tail, &head, &tail)) { if (enif_get_tuple(env, head, &arity, &option) && 2 == arity) { if(option[0] == erocksdb::ATOM_DELETE_RATE_BYTES_PER_SEC) { if(!enif_get_uint64(env, option[1], &rate_bytes_per_sec)) return enif_make_badarg(env); } else if(option[0] == erocksdb::ATOM_MAX_TRASH_DB_RATIO) { if(!enif_get_double(env, option[1], &max_trash_db_ratio)) return enif_make_badarg(env); } else if(option[0] == erocksdb::ATOM_BYTES_MAX_DELETE_CHUNK) { if(!enif_get_uint64(env, option[1], &bytes_max_delete_chunk)) return enif_make_badarg(env); } else { return enif_make_badarg(env); } } else { return enif_make_badarg(env); } } rocksdb::Status status; rocksdb::SstFileManager* mgr = rocksdb::NewSstFileManager( (rocksdb::Env*)env_ptr->env(), nullptr, "", /* trash_dir, deprecated */ rate_bytes_per_sec, true, /* delete_existing_trash, deprecate */ &status, max_trash_db_ratio, bytes_max_delete_chunk ); if(!status.ok()) return error_tuple(env, ATOM_ERROR, status); std::shared_ptr<rocksdb::SstFileManager> sptr_sst_file_manager(mgr); auto mgr_ptr = SstFileManager::CreateSstFileManagerResource(sptr_sst_file_manager); // create a resource reference to send erlang ERL_NIF_TERM result = enif_make_resource(env, mgr_ptr); // clear the automatic reference from enif_alloc_resource in EnvObject enif_release_resource(mgr_ptr); sptr_sst_file_manager.reset(); sptr_sst_file_manager = nullptr; return enif_make_tuple2(env, ATOM_OK, result); } ERL_NIF_TERM ReleaseSstFileManager(ErlNifEnv* env, int /*argc*/, const ERL_NIF_TERM argv[]) { SstFileManager* mgr_ptr; std::shared_ptr<rocksdb::SstFileManager> mgr; mgr_ptr = erocksdb::SstFileManager::RetrieveSstFileManagerResource(env, argv[0]); if(nullptr==mgr_ptr) return ATOM_OK; mgr = mgr_ptr->sst_file_manager(); mgr.reset(); mgr = nullptr; mgr_ptr = nullptr; return ATOM_OK; } ERL_NIF_TERM SstFileManagerFlag(ErlNifEnv* env, int /*argc*/, const ERL_NIF_TERM argv[]) { SstFileManager* mgr_ptr; mgr_ptr = erocksdb::SstFileManager::RetrieveSstFileManagerResource(env, argv[0]); if(nullptr==mgr_ptr) return enif_make_badarg(env); ErlNifUInt64 ival; double dval; if(argv[1] == erocksdb::ATOM_MAX_ALLOWED_SPACE_USAGE) { if(!enif_get_uint64(env, argv[2], &ival)) return enif_make_badarg(env); mgr_ptr->sst_file_manager()->SetMaxAllowedSpaceUsage(ival); } else if (argv[1] == erocksdb::ATOM_COMPACTION_BUFFER_SIZE) { if(!enif_get_uint64(env, argv[2], &ival)) return enif_make_badarg(env); mgr_ptr->sst_file_manager()->SetCompactionBufferSize(ival); } else if (argv[1] == erocksdb::ATOM_DELETE_RATE_BYTES_PER_SEC) { if(!enif_get_uint64(env, argv[2], &ival)) return enif_make_badarg(env); mgr_ptr->sst_file_manager()->SetDeleteRateBytesPerSecond(ival); } else if (argv[1] == erocksdb::ATOM_MAX_TRASH_DB_RATIO) { if(!enif_get_double(env, argv[2], &dval)) return enif_make_badarg(env); mgr_ptr->sst_file_manager()->SetMaxTrashDBRatio(dval); } else { return enif_make_badarg(env); } return ATOM_OK; } ERL_NIF_TERM sst_file_manager_info_1( ErlNifEnv *env, SstFileManager* mgr_ptr, ERL_NIF_TERM item) { if (item == erocksdb::ATOM_TOTAL_SIZE) { return enif_make_uint64(env, mgr_ptr->sst_file_manager()->GetTotalSize()); } else if (item == erocksdb::ATOM_DELETE_RATE_BYTES_PER_SEC) { return enif_make_uint64(env, mgr_ptr->sst_file_manager()->GetDeleteRateBytesPerSecond()); } else if (item == erocksdb::ATOM_MAX_TRASH_DB_RATIO) { return enif_make_double(env, mgr_ptr->sst_file_manager()->GetMaxTrashDBRatio()); } else if (item == erocksdb::ATOM_TOTAL_TRASH_SIZE) { return enif_make_uint64(env, mgr_ptr->sst_file_manager()->GetTotalTrashSize()); } else if (item == erocksdb::ATOM_IS_MAX_ALLOWED_SPACE_REACHED) { if(mgr_ptr->sst_file_manager()->IsMaxAllowedSpaceReached()) return ATOM_TRUE; return ATOM_FALSE; } else if (item == erocksdb::ATOM_MAX_ALLOWED_SPACE_REACHED_INCLUDING_COMPACTIONS) { if(mgr_ptr->sst_file_manager()->IsMaxAllowedSpaceReachedIncludingCompactions()) return ATOM_TRUE; return ATOM_FALSE; } else { return enif_make_badarg(env); } } ERL_NIF_TERM SstFileManagerInfo(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { SstFileManager* mgr_ptr; mgr_ptr = erocksdb::SstFileManager::RetrieveSstFileManagerResource(env, argv[0]); if(nullptr==mgr_ptr) return enif_make_badarg(env); if(argc > 1) return sst_file_manager_info_1(env, mgr_ptr, argv[1]); std::array<ERL_NIF_TERM, 6> items = { erocksdb::ATOM_MAX_ALLOWED_SPACE_REACHED_INCLUDING_COMPACTIONS, erocksdb::ATOM_IS_MAX_ALLOWED_SPACE_REACHED, erocksdb::ATOM_TOTAL_TRASH_SIZE, erocksdb::ATOM_MAX_TRASH_DB_RATIO, erocksdb::ATOM_DELETE_RATE_BYTES_PER_SEC, erocksdb::ATOM_TOTAL_SIZE }; ERL_NIF_TERM info = enif_make_list(env, 0); for(const auto& item : items) { info = enif_make_list_cell( env, enif_make_tuple2(env, item, sst_file_manager_info_1(env, mgr_ptr, item)), info); } return info; } }
32.996255
97
0.673099
k32
2bde43f65ef5fa046d20c5ad721e68d5144cad57
707
cpp
C++
biblioteka/src/model/Service.cpp
aantczakpiotr/OOP-final-project
9559e797f4b98e88a6a97ef39ea6a8a4b67808b2
[ "MIT" ]
null
null
null
biblioteka/src/model/Service.cpp
aantczakpiotr/OOP-final-project
9559e797f4b98e88a6a97ef39ea6a8a4b67808b2
[ "MIT" ]
null
null
null
biblioteka/src/model/Service.cpp
aantczakpiotr/OOP-final-project
9559e797f4b98e88a6a97ef39ea6a8a4b67808b2
[ "MIT" ]
null
null
null
#include <sstream> #include "Service.hpp" #include "ItemException.hpp" Service::Service(double price, int durationInDays) : Item(price), durationInDays(durationInDays) { if (durationInDays < 0) { throw ItemException("Duration cannot be set to 0 or negative, provided: " + std::to_string(durationInDays)); } } int Service::getDurationInDays() const { return durationInDays; } std::string Service::itemInfo() { std::ostringstream stringStream; stringStream << ", duration: " << durationInDays << " days"; return Item::itemInfo() + stringStream.str(); } double Service::getPrice() const { return Item::getPrice() * durationInDays; } Service::~Service() = default;
25.25
116
0.69024
aantczakpiotr
2bde4f01591cbba2ad10e2ae236f67e3c7091b19
7,407
cpp
C++
sample/src/DX12/PSDownsampler.cpp
ColleenKeegan/FidelityFX-SPD
7c796c6d9fa6a9439e3610478148cfd742d97daf
[ "MIT" ]
92
2020-05-11T18:33:09.000Z
2022-03-28T14:17:36.000Z
sample/src/DX12/PSDownsampler.cpp
adv-sw/FidelityFX-SPD
254099a5111dbcbd9b02f629a55991789ec5a9d0
[ "MIT" ]
4
2020-06-03T19:05:47.000Z
2021-03-23T17:38:42.000Z
sample/src/DX12/PSDownsampler.cpp
adv-sw/FidelityFX-SPD
254099a5111dbcbd9b02f629a55991789ec5a9d0
[ "MIT" ]
17
2020-08-18T04:12:37.000Z
2022-03-29T23:27:20.000Z
// SPDSample // // Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #include "stdafx.h" #include "base/Device.h" #include "base/DynamicBufferRing.h" #include "base/StaticBufferPool.h" #include "base/UploadHeap.h" #include "base/Texture.h" #include "base/Imgui.h" #include "base/Helper.h" #include "PSDownsampler.h" namespace CAULDRON_DX12 { void PSDownsampler::OnCreate( Device *pDevice, UploadHeap *pUploadHeap, ResourceViewHeaps *pResourceViewHeaps, DynamicBufferRing *pConstantBufferRing, StaticBufferPool *pStaticBufferPool ) { m_pDevice = pDevice; m_pStaticBufferPool = pStaticBufferPool; m_pResourceViewHeaps = pResourceViewHeaps; m_pConstantBufferRing = pConstantBufferRing; // Use helper class to create the fullscreen pass // D3D12_STATIC_SAMPLER_DESC SamplerDesc = {}; SamplerDesc.Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; SamplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; SamplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; SamplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; SamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; SamplerDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; SamplerDesc.MinLOD = 0.0f; SamplerDesc.MaxLOD = D3D12_FLOAT32_MAX; SamplerDesc.MipLODBias = 0; SamplerDesc.MaxAnisotropy = 1; SamplerDesc.ShaderRegister = 0; SamplerDesc.RegisterSpace = 0; SamplerDesc.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; m_cubeTexture.InitFromFile(pDevice, pUploadHeap, "..\\media\\envmaps\\papermill\\specular.dds", true, 1.0f, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET); pUploadHeap->FlushAndFinish(); m_downsample.OnCreate(pDevice, "PSDownsampler.hlsl", m_pResourceViewHeaps, m_pStaticBufferPool, 1, 1, &SamplerDesc, m_cubeTexture.GetFormat()); // Allocate descriptors for the mip chain // for (uint32_t slice = 0; slice < m_cubeTexture.GetArraySize(); slice++) { for (uint32_t i = 0; i < m_cubeTexture.GetMipCount() - 1; i++) { m_pResourceViewHeaps->AllocCBV_SRV_UAVDescriptor(1, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_SRV); m_pResourceViewHeaps->AllocRTVDescriptor(1, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_RTV); m_cubeTexture.CreateSRV(0, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_SRV, i, 1, slice); m_cubeTexture.CreateRTV(0, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_RTV, i + 1, 1, slice); } } for (uint32_t slice = 0; slice < m_cubeTexture.GetArraySize(); slice++) { for (uint32_t mip = 0; mip < m_cubeTexture.GetMipCount(); mip++) { m_pResourceViewHeaps->AllocCBV_SRV_UAVDescriptor(1, &m_imGUISRV[slice * m_cubeTexture.GetMipCount() + mip]); m_cubeTexture.CreateSRV(0, &m_imGUISRV[slice * m_cubeTexture.GetMipCount() + mip], mip, 1, slice); } } } void PSDownsampler::OnDestroy() { m_cubeTexture.OnDestroy(); m_downsample.OnDestroy(); } void PSDownsampler::Draw(ID3D12GraphicsCommandList *pCommandList) { UserMarker marker(pCommandList, "PSDownsampler"); // downsample // for (uint32_t slice = 0; slice < m_cubeTexture.GetArraySize(); slice++) { for (uint32_t i = 0; i < m_cubeTexture.GetMipCount() - 1; i++) { pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_cubeTexture.GetResource(), D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET, slice * m_cubeTexture.GetMipCount() + i + 1)); pCommandList->OMSetRenderTargets(1, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_RTV.GetCPU(), true, NULL); SetViewportAndScissor(pCommandList, 0, 0, m_cubeTexture.GetWidth() >> (i + 1), m_cubeTexture.GetHeight() >> (i + 1)); cbDownsample* data; D3D12_GPU_VIRTUAL_ADDRESS constantBuffer; m_pConstantBufferRing->AllocConstantBuffer(sizeof(cbDownsample), (void**)&data, &constantBuffer); data->outWidth = (float)(m_cubeTexture.GetWidth() >> (i + 1)); data->outHeight = (float)(m_cubeTexture.GetHeight() >> (i + 1)); data->invWidth = 1.0f / (float)(m_cubeTexture.GetWidth() >> i); data->invHeight = 1.0f / (float)(m_cubeTexture.GetHeight() >> i); data->slice = slice; m_downsample.Draw(pCommandList, 1, &m_mip[slice * (m_cubeTexture.GetMipCount() - 1) + i].m_SRV, constantBuffer); pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_cubeTexture.GetResource(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, slice * m_cubeTexture.GetMipCount() + i + 1)); } } } void PSDownsampler::GUI(int *pSlice) { bool opened = true; std::string header = "Downsample"; ImGui::Begin(header.c_str(), &opened); if (ImGui::CollapsingHeader("PS", ImGuiTreeNodeFlags_DefaultOpen)) { const char* sliceItemNames[] = { "Slice 0", "Slice 1", "Slice 2", "Slice 3", "Slice 4", "Slice 5" }; ImGui::Combo("Slice of Cube Texture", pSlice, sliceItemNames, _countof(sliceItemNames)); for (uint32_t i = 0; i < m_cubeTexture.GetMipCount(); i++) { ImGui::Image((ImTextureID)&m_imGUISRV[*pSlice * m_cubeTexture.GetMipCount() + i], ImVec2(static_cast<float>(512 >> i), static_cast<float>(512 >> i))); } } ImGui::End(); } }
44.620482
166
0.63575
ColleenKeegan
2be7a2698e1649e99974b65d08258edd176c0c86
13,006
cpp
C++
src/films/transientfilm.cpp
klein-j/transient_pbrt
71d1e3223521a985c93afc5a2e21833afe9f24d7
[ "BSD-2-Clause" ]
null
null
null
src/films/transientfilm.cpp
klein-j/transient_pbrt
71d1e3223521a985c93afc5a2e21833afe9f24d7
[ "BSD-2-Clause" ]
null
null
null
src/films/transientfilm.cpp
klein-j/transient_pbrt
71d1e3223521a985c93afc5a2e21833afe9f24d7
[ "BSD-2-Clause" ]
null
null
null
#include "transientfilm.h" #include "paramset.h" #include "imageio.h" #include "stats.h" #include "TransientImage.hpp" #include "util.h" #include <array> #include <fstream> #include <sstream> namespace pbrt { TransientFileMetaData g_TFMD; STAT_MEMORY_COUNTER("Memory/Film pixels", filmPixelMemory); TransientSampleCache::TransientSample* begin(TransientSampleCache& c) { return &c.cache[0]; } TransientSampleCache::TransientSample* end(TransientSampleCache& c) { return &c.cache[0]+c.size(); } // Film Method Definitions TransientFilm::TransientFilm(const Point3i &resolution, Float tmin, Float tmax, const Bounds2f &cropWindow, std::unique_ptr<Filter> filt, Float diagonal, const std::string &filename, Float maxSampleLuminance) : fullResolution(resolution), tmin(tmin), tmax(tmax), diagonal(diagonal * .001), filter(std::move(filt)), filename(filename), maxSampleLuminance(maxSampleLuminance) { // Compute film image bounds croppedPixelBounds = Bounds2i(Point2i(std::ceil(fullResolution.x * cropWindow.pMin.x), std::ceil(fullResolution.y * cropWindow.pMin.y)), Point2i(std::ceil(fullResolution.x * cropWindow.pMax.x), std::ceil(fullResolution.y * cropWindow.pMax.y))); LOG(INFO) << "Created film with full resolution " << resolution << ". Crop window of " << cropWindow << " -> croppedPixelBounds " << croppedPixelBounds; // Allocate film image storage pixelIntensities.resize(croppedPixelBounds.Area() * fullResolution.z); pixelWeights.resize(croppedPixelBounds.Area()); filmPixelMemory += croppedPixelBounds.Area() * fullResolution.z * sizeof(Float); // the intensities filmPixelMemory += croppedPixelBounds.Area() * sizeof(Float); // the weights // Precompute filter weight table int offset = 0; for(int y = 0; y < filterTableWidth; ++y) { for(int x = 0; x < filterTableWidth; ++x, ++offset) { Point2f p; p.x = (x + 0.5f) * filter->radius.x / filterTableWidth; p.y = (y + 0.5f) * filter->radius.y / filterTableWidth; filterTable[offset] = filter->Evaluate(p); } } } Bounds2i TransientFilm::GetSampleBounds() const { Bounds2f floatBounds(Floor(Point2f(croppedPixelBounds.pMin) + Vector2f(0.5f, 0.5f) - filter->radius), Ceil(Point2f(croppedPixelBounds.pMax) - Vector2f(0.5f, 0.5f) + filter->radius)); return (Bounds2i)floatBounds; } Bounds2f TransientFilm::GetPhysicalExtent() const { Float aspect = (Float)fullResolution.y / (Float)fullResolution.x; Float x = std::sqrt(diagonal * diagonal / (1 + aspect * aspect)); Float y = aspect * x; return Bounds2f(Point2f(-x / 2, -y / 2), Point2f(x / 2, y / 2)); } std::unique_ptr<TransientFilmTile> TransientFilm::GetFilmTile(const Bounds2i &sampleBounds) { // Bound image pixels that samples in _sampleBounds_ contribute to Vector2f halfPixel = Vector2f(0.5f, 0.5f); Bounds2f floatBounds = (Bounds2f)sampleBounds; Point2i p0 = (Point2i)Ceil(floatBounds.pMin - halfPixel - filter->radius); Point2i p1 = (Point2i)Floor(floatBounds.pMax - halfPixel + filter->radius) + Point2i(1, 1); Bounds2i tilePixelBounds = Intersect(Bounds2i(p0, p1), croppedPixelBounds); return std::unique_ptr<TransientFilmTile>(new TransientFilmTile( tilePixelBounds, fullResolution.z, tmin, tmax, filter->radius, filterTable, filterTableWidth, maxSampleLuminance)); } void TransientFilm::MergeFilmTile(std::unique_ptr<TransientFilmTile> tile) { ProfilePhase p(Prof::MergeFilmTile); VLOG(1) << "Merging film tile " << tile->pixelBounds; std::lock_guard<std::mutex> lock(mutex); for(Point2i pixel : tile->GetPixelBounds()) { // iterate over temporal dimension of pixels for(auto t=0; t<fullResolution.z; ++t) { // Merge _pixel_ into _Film::pixels_ const auto& tilePixel = tile->GetPixel({pixel.x, pixel.y, t}); auto mergePixel = GetPixel({pixel.x, pixel.y, t}); *mergePixel.intensity += *tilePixel.intensity; *mergePixel.filterWeightSum += *tilePixel.filterWeightSum; } } } void TransientFilm::WriteImage() { g_TFMD.RenderEndTime = std::chrono::system_clock::now(); // Convert image to RGB and compute final pixel values LOG(INFO) << "Converting image to RGB and computing final weighted pixel values"; // Write RGB image LOG(INFO) << "Writing image " << filename << " with bounds " << croppedPixelBounds; LibTransientImage::T01 outputImage; outputImage.header.numBins = fullResolution.z; outputImage.header.uResolution = (croppedPixelBounds.pMax-croppedPixelBounds.pMin).x; outputImage.header.vResolution = (croppedPixelBounds.pMax-croppedPixelBounds.pMin).y; outputImage.header.tmin = tmin; outputImage.header.tmax = tmax; outputImage.data.resize(croppedPixelBounds.Area() * fullResolution.z); int offset = 0; for(Point2i p : croppedPixelBounds) { for(auto t=0; t<fullResolution.z; ++t) { auto pp = Point3i(p.x, p.y, t); // this is not quite right: if different samples fall in different times bins, the total amount is higher than if they fall into the same one // we have to add weights of all time bins and divide each bin by the total amount. // but how would this be changed, if we wanted also temporal sampling? outputImage.data[offset] = *GetPixel(pp).intensity / *GetPixel(pp).filterWeightSum; ++offset; } } // add meta information: std::stringstream imageProperties; imageProperties << "\n\n\n" << "{\n" << " \"File\": {\n" << " \"MetadataVersion\": \"TransientRenderer\"\n" << " },\n" << " \n" << " \"RenderParameters\": {\n" << " \"Renderer\": \"TransientRenderer\",\n" << " \"InputFile\": \"" << g_TFMD.RenderInputFile << "\",\n" << " \"BlenderExport\": {\n" << " \"Filename\": \"" << g_TFMD.BlenderFilename << "\",\n" << " \"CurrentFrame\": " << g_TFMD.BlenderCurrentFrame << ",\n" << " \"ExportTime\": \"" << g_TFMD.ExportTime << "\"\n" << " },\n" << " \"StartTime\": \"" << FormatTime(g_TFMD.RenderStartTime) << "\",\n" << " \"EndTime\": \"" << FormatTime(g_TFMD.RenderEndTime) << "\",\n" << " \"TotalSeconds\": \"" << std::chrono::duration_cast<std::chrono::seconds>(g_TFMD.RenderEndTime-g_TFMD.RenderStartTime).count() << "\",\n" << " \"Samples\": \"" << g_TFMD.RenderSamples <<"\",\n" << " \"Cores\": \"" << g_TFMD.RenderCores <<"\"\n" << " }\n" << "}" << std::endl; outputImage.imageProperties = imageProperties.str(); outputImage.WriteFile(filename); } TransientPixelRef TransientFilm::GetPixel(const Point3i &p) { CHECK(InsideExclusive(Point2i(p.x, p.y), croppedPixelBounds)); int width = croppedPixelBounds.pMax.x - croppedPixelBounds.pMin.x; int pixelOffset = (p.x - croppedPixelBounds.pMin.x) + (p.y - croppedPixelBounds.pMin.y) * width; return {&pixelIntensities[pixelOffset*fullResolution.z + p.z], &pixelWeights[pixelOffset]}; } std::unique_ptr<TransientFilm> CreateTransientFilm(const ParamSet &params, std::unique_ptr<Filter> filter) { // Intentionally use FindOneString() rather than FindOneFilename() here // so that the rendered image is left in the working directory, rather // than the directory the scene file lives in. std::string filename = params.FindOneString("filename", ""); if(PbrtOptions.imageFile != "") { if(filename != "") { Warning( "Output filename supplied in scene description file, \"%s\", ignored " "due to filename provided on command line, \"%s\".", filename.c_str(), PbrtOptions.imageFile.c_str()); } filename = PbrtOptions.imageFile; } if(filename == "") filename = "pbrt.exr"; int xres = params.FindOneInt("xresolution", 256); int yres = params.FindOneInt("yresolution", 256); int tres = params.FindOneInt("tresolution", 32); if(PbrtOptions.quickRender) xres = std::max(1, xres / 4); if(PbrtOptions.quickRender) yres = std::max(1, yres / 4); if(PbrtOptions.quickRender) tres = std::max(1, tres / 4); Bounds2f crop(Point2f(0, 0), Point2f(1, 1)); int cwi; const Float *cr = params.FindFloat("cropwindow", &cwi); if(cr && cwi == 4) { crop.pMin.x = Clamp(std::min(cr[0], cr[1]), 0.f, 1.f); crop.pMax.x = Clamp(std::max(cr[0], cr[1]), 0.f, 1.f); crop.pMin.y = Clamp(std::min(cr[2], cr[3]), 0.f, 1.f); crop.pMax.y = Clamp(std::max(cr[2], cr[3]), 0.f, 1.f); } else if(cr) Error("%d values supplied for \"cropwindow\". Expected 4.", cwi); Float tmin = params.FindOneFloat("t_min", 0); Float tmax = params.FindOneFloat("t_max", 100); Float diagonal = params.FindOneFloat("diagonal", 35.); Float maxSampleLuminance = params.FindOneFloat("maxsampleluminance", Infinity); return std::make_unique<TransientFilm>(Point3i(xres, yres, tres), tmin, tmax, crop, std::move(filter), diagonal, filename, maxSampleLuminance); } // ------------------ Transient Film Tile ------------------------------ TransientFilmTile::TransientFilmTile(const Bounds2i &pixelBounds, unsigned int tresolution, Float tmin, Float tmax, const Vector2f &filterRadius, const Float *filterTable, int filterTableSize, Float maxSampleLuminance) : pixelBounds(pixelBounds), tresolution(tresolution), tmin(tmin), tmax(tmax), invBinSize(static_cast<Float>(tresolution)/(tmax-tmin)), filterRadius(filterRadius), invFilterRadius(1 / filterRadius.x, 1 / filterRadius.y), filterTable(filterTable), filterTableSize(filterTableSize), maxSampleLuminance(maxSampleLuminance) { pixelIntensities = std::vector<Float>(std::max(0, pixelBounds.Area()) * tresolution); pixelWeights = std::vector<Float>(std::max(0, pixelBounds.Area())); } void TransientFilmTile::AddSample(const Point2f &pFilm, TransientSampleCache& sample, Float sampleWeight) { ProfilePhase _(Prof::AddFilmSample); //if(L > maxSampleLuminance) // L = maxSampleLuminance; // Compute sample's raster bounds Point2f pFilmDiscrete = pFilm - Vector2f(0.5f, 0.5f); Point2i p0 = (Point2i)Ceil(pFilmDiscrete - filterRadius); Point2i p1 = (Point2i)Floor(pFilmDiscrete + filterRadius) + Point2i(1, 1); p0 = Max(p0, pixelBounds.pMin); p1 = Min(p1, pixelBounds.pMax); // Precompute $x$ and $y$ filter table offsets int *ifx = ALLOCA(int, p1.x - p0.x); for(int x = p0.x; x < p1.x; ++x) { Float fx = std::abs((x - pFilmDiscrete.x) * invFilterRadius.x * filterTableSize); ifx[x - p0.x] = std::min((int)std::floor(fx), filterTableSize - 1); } int *ify = ALLOCA(int, p1.y - p0.y); for(int y = p0.y; y < p1.y; ++y) { Float fy = std::abs((y - pFilmDiscrete.y) * invFilterRadius.y * filterTableSize); ify[y - p0.y] = std::min((int)std::floor(fy), filterTableSize - 1); } /* normally the weight is stored for each pixel separately and at the end, the sample sum is divided by the sum of the weights. As we have importance sampling in the temporal dimension, we store the pixel weight only for the spatial dimensions. Thus the weights of filtering the temporal dimension is immediately applied and no denominator must be stored. */ for(int y = p0.y; y < p1.y; ++y) { for(int x = p0.x; x < p1.x; ++x) { // Evaluate filter value at $(x,y)$ pixel int offset = ify[y - p0.y] * filterTableSize + ifx[x - p0.x]; Float filterWeight = filterTable[offset]; // now loop over all the sub samples for(auto& s : sample) { auto T = s.second; auto L = s.first; // same for temporal dimension auto timeBin = (T-tmin) * invBinSize; if(timeBin >= tresolution || timeBin < 0) continue; //skip these samples auto tDiscrete = timeBin - 0.5; auto t0 = static_cast<int>( ceil(tDiscrete-filterRadius.x)); auto t1 = static_cast<int>(floor(tDiscrete+filterRadius.x) + 1); t0 = std::max<int>(t0, 0); t1 = std::min<int>(t1, tresolution); // precompute temporal filter table offsets int *ift = ALLOCA(int, t1-t0); Float temporalFilterTotalWeight = 0; for(int t=t0; t<t1; ++t) { Float ft = std::abs((t - tDiscrete) * invFilterRadius.x * filterTableSize); auto offset = filterTableSize*static_cast<int>(filterTableSize/2); // to get the middle row of the filter ift[t - t0] = std::min((int)std::floor(ft), filterTableSize - 1) + offset; temporalFilterTotalWeight += filterTable[ift[t - t0]]; } auto temporalFilterTotalWeightInv = 1.0 / temporalFilterTotalWeight; for(int t=t0; t<t1; ++t) { // Update pixel values with filtered sample contribution auto pixel = GetPixel({x, y, t}); *pixel.intensity += L.y() * sampleWeight * filterWeight * filterTable[ift[t-t0]] * temporalFilterTotalWeightInv * invBinSize; } } auto pixel = GetPixel({x, y, 0}); // filter weight sum is the same for all pixels with the same x,y *pixel.filterWeightSum += filterWeight; } } } TransientPixelRef TransientFilmTile::GetPixel(const Point3i &p) { CHECK(InsideExclusive(Point2i(p.x, p.y), pixelBounds)); int width = pixelBounds.pMax.x - pixelBounds.pMin.x; int pixelOffset = (p.x - pixelBounds.pMin.x) + (p.y - pixelBounds.pMin.y) * width; return {&pixelIntensities[pixelOffset*tresolution + p.z], &pixelWeights[pixelOffset]}; } Bounds2i TransientFilmTile::GetPixelBounds() const{ return pixelBounds; } } // namespace pbrt
35.438692
145
0.687913
klein-j
2be8412cad95ef11e957aae696128ee2d30153b3
1,902
hpp
C++
aplibs/include/anumlst.hpp
pgul/fastlst
ce07baa06b0063f4c9e1374f24e67e1316ee5af4
[ "BSD-3-Clause" ]
2
2018-01-14T02:49:46.000Z
2021-04-11T11:29:11.000Z
aplibs/include/anumlst.hpp
pgul/fastlst
ce07baa06b0063f4c9e1374f24e67e1316ee5af4
[ "BSD-3-Clause" ]
null
null
null
aplibs/include/anumlst.hpp
pgul/fastlst
ce07baa06b0063f4c9e1374f24e67e1316ee5af4
[ "BSD-3-Clause" ]
1
2018-01-10T19:44:14.000Z
2018-01-10T19:44:14.000Z
/*****************************************************************************/ /* */ /* (C) Copyright 1995-1997 Alberto Pasquale */ /* */ /* A L L R I G H T S R E S E R V E D */ /* */ /*****************************************************************************/ /* */ /* This source code is NOT in the public domain and it CANNOT be used or */ /* distributed without written permission from the author. */ /* */ /*****************************************************************************/ /* */ /* How to contact the author: Alberto Pasquale of 2:332/504@fidonet */ /* Viale Verdi 106 */ /* 41100 Modena */ /* Italy */ /* */ /*****************************************************************************/ // AnumLst.hpp #include <limits.h> struct _anumlist; typedef unsigned int uint; typedef unsigned short word; class ANumLst { private: uint narea; _anumlist *anlhead, *anlcur; _anumlist **anlnext; public: ANumLst (); ~ANumLst (); void Add (word anum); word Get (int first = 0); // USHRT_MAX for no more areas };
46.390244
79
0.241325
pgul
2be86c24de1ed945b238c56ad33487081ad16110
1,722
cpp
C++
test/matrix.cpp
NiklasDallmann/math
e0610b20911923c35660a1c566008cb823e17da8
[ "Apache-2.0" ]
null
null
null
test/matrix.cpp
NiklasDallmann/math
e0610b20911923c35660a1c566008cb823e17da8
[ "Apache-2.0" ]
null
null
null
test/matrix.cpp
NiklasDallmann/math
e0610b20911923c35660a1c566008cb823e17da8
[ "Apache-2.0" ]
null
null
null
#include <chrono> #include <cmath> #include <cstdlib> #include <iostream> #include <memory> #include <matrix.hpp> #include "test.hpp" using namespace nd::math; constexpr std::size_t matrixOrder = 512u; using MatrixType = Matrix<float, matrixOrder, matrixOrder>; int main(int, char **) { { constexpr std::size_t iterations = 5u; const std::unique_ptr<MatrixType> matrix0 = std::make_unique<MatrixType>(traits::initialization::zero); const std::unique_ptr<MatrixType> matrix1 = std::make_unique<MatrixType>(traits::initialization::identity); std::unique_ptr<MatrixType> matrix2 = std::make_unique<MatrixType>(traits::initialization::zero); std::chrono::duration<double> actualDuration; benchmark(iterations, actualDuration, [&matrix0, &matrix1, &matrix2]() { mul(*matrix2, *matrix0, *matrix1); }); const double seconds = std::chrono::duration_cast<std::chrono::milliseconds>(actualDuration).count() / 1000.0; const double flop = std::pow(double(matrixOrder), 3.0); const double gflops = (double(iterations) / seconds * flop / 1.0E9); std::cout << iterations << " runs performed " << std::to_string(seconds) << " s " << std::to_string(gflops) << " GFLOPS\n"; } { const Matrix3x3_f matrix{traits::initialization::identity}; std::cout << static_cast<Matrix4x4_f>(matrix) << "\n"; } { const Vector3_f v{traits::initialization::zero}; const float s = 1.0f; std::cout << Vector4_f{s, v} << "\n"; std::cout << ColumnVector4_f{s, v.transposed()} << "\n"; } { const Matrix4x4_f m = {{1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f}}; std::cout << m << "\n"; } return EXIT_SUCCESS; }
27.774194
125
0.660859
NiklasDallmann
2be8d16505f271a9d0b742a1236714b95aa58b61
2,097
cpp
C++
ListProcessing/Polynomial.cpp
Mohitmauryagit/datastructures
df61f3f5b592dc4fe0b9d6a966b87f3348328e0a
[ "MIT" ]
8
2021-08-12T08:09:37.000Z
2021-12-30T10:45:54.000Z
ListProcessing/Polynomial.cpp
Mohitmauryagit/datastructures
df61f3f5b592dc4fe0b9d6a966b87f3348328e0a
[ "MIT" ]
7
2021-06-09T05:13:23.000Z
2022-01-24T04:47:59.000Z
ListProcessing/Polynomial.cpp
Mohitmauryagit/datastructures
df61f3f5b592dc4fe0b9d6a966b87f3348328e0a
[ "MIT" ]
4
2021-11-07T07:09:58.000Z
2022-02-08T11:43:56.000Z
#include<iostream> using namespace std; typedef struct mynode{ int coef; int pow; mynode* next; } node; void insert(node** head, int val,int pow) { if((*head)==NULL) { node* newnode=(node*)malloc(sizeof(node)); newnode->coef=val; newnode->pow=pow; newnode->next=NULL; (*head)=newnode; return; } insert(&((*head)->next),val,pow); } void showPol(node* temp) //shows polynomial { while(temp!=NULL) { cout<<temp->coef<<"x^"<<temp->pow; temp= temp->next; if(temp!=NULL) { cout<<" + "; } } cout<<endl; } void addPol(node**hd3,node* hd2, node* hd1)//add two polynomial { node* temp= (*hd3); while(hd2!=NULL) { insert(hd3,hd1->coef + hd2 ->coef, hd2->pow); hd1 = hd1->next; hd2 = hd2->next; } } void mult(int *c, int *p, int c1, int p1, int c2, int p2) { *c=c1*c2; *p= p1+p2; } void multPol(node** hd3, node* hd2, node* hd1) { node* temp= (*hd3); int a[4]={0}; while(hd2!=NULL) { node* temp=hd1; int c,p; while (temp!=NULL) { mult(&c,&p,temp->coef,temp->pow, hd2->coef, hd2->pow); cout<<c<<" "<<p<<" "; a[p]=a[p]+c; cout<<a[p]<<endl; temp=temp->next; } hd2=hd2->next; } for(int i=0; i<=4-1; i++) { insert(hd3,a[i],i); } } int main() { node* hd1=NULL; node* hd2=NULL; int c1[]={1,2,3}; int size= sizeof(c1)/sizeof(int); int c2[]={25,7,5}; int count1=0; for(int i=0; i<=size-1; i++) { insert(&hd1,c1[i],i); insert(&hd2,c2[i],i); } cout<<"*********************************ADDITION*****************"<<endl; showPol(hd1); cout<<"+"<<endl; showPol(hd2); cout<<"_______________________"<<endl; node* hd3=NULL; addPol(&hd3,hd1,hd2); showPol(hd3); node* hd4=NULL; multPol(&hd4,hd1,hd2); // node* a = mult(25,0,hd1); // showPol(a); showPol(hd4); return 0; }
18.723214
76
0.469242
Mohitmauryagit
2bf39d78e830470d56455008ab83f5ef908b0e73
412
cpp
C++
149.cpp
jonathanxqs/lintcode
148435aff0a83ac5d77a7ccbd5d0caaea3140a62
[ "MIT" ]
1
2016-06-21T16:29:37.000Z
2016-06-21T16:29:37.000Z
149.cpp
jonathanxqs/lintcode
148435aff0a83ac5d77a7ccbd5d0caaea3140a62
[ "MIT" ]
null
null
null
149.cpp
jonathanxqs/lintcode
148435aff0a83ac5d77a7ccbd5d0caaea3140a62
[ "MIT" ]
null
null
null
class Solution { public: /** * @param prices: Given an integer array * @return: Maximum profit */ int maxProfit(vector<int> &prices) { // write your code here int min=INT_MAX,rt_profit=0; for (auto const s:prices){ if (s-min>rt_profit) rt_profit=s-min; if (s<min) min=s; } return rt_profit; } }; // Total Runtime: 36 ms
17.913043
46
0.541262
jonathanxqs
92009eca9ebe617f308bc971789fb3abb0dc8664
3,129
cc
C++
toolkit/gl_font.cc
teenylasers/eggshell
7d1239eb1b143b11b5ccd1029d9bacdd601c8e4e
[ "ICU", "OpenSSL" ]
null
null
null
toolkit/gl_font.cc
teenylasers/eggshell
7d1239eb1b143b11b5ccd1029d9bacdd601c8e4e
[ "ICU", "OpenSSL" ]
null
null
null
toolkit/gl_font.cc
teenylasers/eggshell
7d1239eb1b143b11b5ccd1029d9bacdd601c8e4e
[ "ICU", "OpenSSL" ]
null
null
null
// Copyright (C) 2014-2020 Russell Smith. // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation, either version 3 of the License, or (at your option) // any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details. #define GL_FONT_IMPLEMENTATION #include "gl_font.h" #include "error.h" #include "gl_utils.h" #include "shaders.h" #include <vector> #include <stdint.h> struct StringToDraw { std::string s; const Font *font; double x, y; float red, green, blue; TextAlignment halign, valign; }; static std::vector<StringToDraw> strings; void DrawString(const char *s, double x, double y, const Font *font, float red, float green, float blue, TextAlignment halign, TextAlignment valign) { if (!s || !s[0]) { return; } strings.resize(strings.size() + 1); strings.back().s = s; strings.back().font = font; strings.back().x = x; strings.back().y = y; strings.back().red = red; strings.back().green = green; strings.back().blue = blue; strings.back().halign = halign; strings.back().valign = valign; } void DrawStringM(const char *s, double x, double y, double z, const Eigen::Matrix4d &T, const Font *font, float red, float green, float blue, TextAlignment halign, TextAlignment valign) { GLint viewport[4]; GL(GetIntegerv)(GL_VIEWPORT, viewport); Eigen::Vector3d win; gl::Project(x, y, z, T, viewport, &win); DrawString(s, win[0], win[1], font, red, green, blue, halign, valign); } //*************************************************************************** // Qt implementation #ifdef QT_CORE_LIB #include <QPainter> #include <QWidget> #include <QFont> void RenderDrawStrings(QWidget *win) { double scale = win->devicePixelRatio(); QPainter painter(win); for (int i = 0; i < strings.size(); i++) { StringToDraw &s = strings[i]; // Convert from opengl pixel coordinates to Qt window coordinates. double x = s.x / scale; double y = win->height() - s.y / scale; // Measure and align the text. double w = s.font->fm->size(0, s.s.c_str()).width(); double h = s.font->fm->height(); double ascent = s.font->fm->ascent(); double descent = s.font->fm->descent(); y = -y; // Since Y coordinates increase going up in AlignText AlignText(w, h, descent, s.halign, s.valign, false, &x, &y); y = -y; // Draw the text. painter.setPen(QColor(s.red, s.green, s.blue, 255)); painter.setFont(*s.font->font); painter.drawText(QPointF(x, y + ascent - 1), s.s.c_str()); } strings.clear(); } void DrawStringGetSize(const char *s, const Font *font, double *width, double *height) { *width = font->fm->size(0, s).width(); *height = font->fm->height(); } #endif // QT_CORE_LIB
30.086538
78
0.63311
teenylasers
92039f8f242ee91aadb4765a2252cee259355645
6,918
cpp
C++
lua_cpp_experiment/lua_cpp_experiment/main.cpp
baransrc/lua-cpp-experiment
d8d31d41e4399f19a6b04699baa7f604a3babecc
[ "MIT" ]
2
2022-02-14T19:21:05.000Z
2022-02-21T01:28:55.000Z
lua_cpp_experiment/lua_cpp_experiment/main.cpp
baransrc/lua-cpp-experiment
d8d31d41e4399f19a6b04699baa7f604a3babecc
[ "MIT" ]
null
null
null
lua_cpp_experiment/lua_cpp_experiment/main.cpp
baransrc/lua-cpp-experiment
d8d31d41e4399f19a6b04699baa7f604a3babecc
[ "MIT" ]
null
null
null
#include <iostream> #include "entity_component.h" #include "lua_helper.h" #include "script.h" //bool check_lua(lua_State* L, int result) //{ // if (result != 0) // { // std::string error_message = lua_tostring(L, -1); // std::cout << error_message << std::endl; // // return false; // } // // return true; //} // //void vanilla_lua_test() //{ // // Create lua state: // lua_State* L = luaL_newstate(); // // // Load all lua libraries: // luaL_openlibs(L); // // if (!check_lua(L, luaL_dofile(L, "experiment.lua"))) // { // // Close and free lua_State L: // lua_close(L); // // return; // } // // std::cout << "Hello World from CPP" << std::endl; // // // Try getting the "box" called print_test on the // // top of the stack: // lua_getglobal(L, "print_test"); // // // Check if top of the stack is a function: // // NOTE: In lua we have indexed stack, and the top // // of the stack is -1. // if (lua_isfunction(L, -1)) // { // // Run the function and if there is a problem // // log the error message given by lua: // if (check_lua(L, lua_pcall(L, 0, 0, 0))) // { // std::cout << "This works my dude" << std::endl; // } // } // // // Close and free lua_State L: // lua_close(L); //} int main() { sol::state lua(sol::c_call<decltype(&print_panic), &print_panic>); // Enable base libraries: lua.open_libraries ( sol::lib::base, sol::lib::package, sol::lib::debug, sol::lib::string, sol::lib::io, sol::lib::coroutine, sol::lib::os, sol::lib::table, sol::lib::math ); sol::load_result settings_load_result = lua.load_file("settings.lua"); // If the loaded script has errors, display it: if (!settings_load_result.valid()) { sol::error error = settings_load_result; std::cerr << "Failed to load settings: " << error.what() << std::endl; system("pause"); return 0; } // Run the settings script: settings_load_result(); // TODO: Get these runtime, and relative to working directory. std::string project_path = lua["project_path"]; std::string script_file_name = lua["script_file_name"]; std::string lua_path = lua["lua_path"]; std::string zbs_lib_path = lua["zbs_lib_path"]; std::string path = ""; path += "package.path = "; path += "\""; path += "./?.lua;"; path += zbs_lib_path + "/lualibs/?/?.lua;"; path += zbs_lib_path + "/lualibs/?.lua;"; path += project_path + "/lua-cpp-experiment/scripts/?.lua;"; path += "\""; path += "..package.path"; std::string c_path = ""; c_path += "package.cpath = "; c_path += "\""; // TODO: Get these runtime, and relative to working directory. c_path += lua_path + "/luaJIT/lib/?.dll;"; c_path += lua_path + "/lua_socket/bin/?.dll;"; c_path += lua_path + "/lua_socket/bin/clibs/?.dll;"; c_path += lua_path + "/lua_socket/bin/clibs/mime/?.dll;"; c_path += lua_path + "/lua_socket/bin/clibs/socket/?.dll;"; c_path += zbs_lib_path + "/bin/?.dll;"; c_path += zbs_lib_path + "/bin/clibs/?.dll"; c_path += "\""; c_path += "..package.cpath"; // Add lua file and dll file checkup paths to the script: // We don't need to check if these files are valid since // we statically run these from code instead of loading it // from file. lua.do_string(c_path); lua.do_string(path); Entity* entity = new Entity(); LuaScript script_1(script_file_name, entity); LuaScript script_2("experiment2.lua", entity); sol::safe_function execute_function = script_1.GetAsTable()["execute"]; //sol::load_result load_result = lua.load_file(script_file_name); //// If the loaded script has errors, display it: //if (!load_result.valid()) //{ // sol::error error = load_result; // std::cerr << "Failed to load " << script_file_name << " " << error.what() << std::endl; // system("pause"); // return 0; //} //// Run the script: //load_result(); //// Create Entity namespace: //sol::table this_namespace = lua["hachiko"].get_or_create<sol::table>(); //// Add entity and components to lua: //component_type_to_lua(this_namespace); //component_to_lua(this_namespace); //component_x_to_lua(this_namespace); //component_y_to_lua(this_namespace); //entity_to_lua(this_namespace); //// Create an entity: //Entity* entity = new Entity(); //// Add the api to interact with entity to namespace: //this_namespace.set("entity", entity); //// Run the execute method of the script: //sol::table experiment_table = lua["experiment"]; //sol::protected_function_result script_result = experiment_table["execute"](); //// If an error comes up, print to the screen and halt the //// execution: //if (!script_result.valid()) //{ // sol::error error = script_result; // std::cout << "[ERROR-LUA]: " << error.what() << std::endl; // std::cin.ignore(); // return 0; //} //// Test if script really changed entity: //std::cout << std::endl << "------------" << std::endl; //std::cout << "Result from CPP: " << entity->GetComponent<ComponentY>()->GetYValue() << std::endl; //// Create another lua state: //sol::state another_lua; // //// Enable libraries for that lua state: //another_lua.open_libraries //( // sol::lib::base, // sol::lib::package, // sol::lib::debug, // sol::lib::string, // sol::lib::io, // sol::lib::coroutine, // sol::lib::os, // sol::lib::table, // sol::lib::math //); //another_lua.do_string(c_path); //another_lua.do_string(path); //sol::table another_namespace = another_lua["hachiko"].get_or_create<sol::table>(); //// Add entity and components to lua: //component_type_to_lua(another_namespace); //component_to_lua(another_namespace); //component_x_to_lua(another_namespace); //component_y_to_lua(another_namespace); //entity_to_lua(another_namespace); //std::string table_name = "experiment"; //sol::table experiment_script_table = lua[table_name]; //sol::table other_script_table = another_lua["ExperimentScript"].get_or_create<sol::table>(); //std::cout << "Adding the experiment script table member functions to another script which runs the functions from experiment.lua" << std::endl; //for (const auto& entry : experiment_script_table) //{ // const sol::object& current_object = entry.second; // if (!current_object.is<sol::function>()) // { // continue; // } // const std::string& function_name = entry.first.as<std::string>(); // std::cout << "Adding: " << function_name << std::endl; // sol::function function = experiment_script_table[function_name]; // other_script_table.set_function(function_name, function); //} //// another_lua["ExperimentScript"].set(other_script_table); //sol::protected_function_result result = another_lua.do_string("ExperimentScript:call_from_another_script(888, \"please work\")"); //if (!result.valid()) //{ // sol::error error = result; // std::cout << "[ERROR-LUA]: " << error.what() << std::endl; // std::cin.ignore(); // return 0; //} //std::string name = lua["experiment"]["name"]; //std::cout << name << std::endl; std::cin.ignore(); return 0; }
26.918288
146
0.651923
baransrc
920604f22fdeefe4691f3ad2deef1ac4a64b5b9d
227
cpp
C++
1_DSAA_code/TestIntCell.cpp
amdfansheng/alogrithm
b2e1dd4094b766895dda8c8fc2cbb2e37e6aa22d
[ "MIT" ]
7
2018-07-22T14:29:58.000Z
2021-05-03T04:40:13.000Z
1_DSAA_code/TestIntCell.cpp
amdfansheng/alogrithm
b2e1dd4094b766895dda8c8fc2cbb2e37e6aa22d
[ "MIT" ]
null
null
null
1_DSAA_code/TestIntCell.cpp
amdfansheng/alogrithm
b2e1dd4094b766895dda8c8fc2cbb2e37e6aa22d
[ "MIT" ]
5
2019-02-13T14:50:51.000Z
2020-07-24T09:05:22.000Z
#include <iostream> #include "IntCell.h" using namespace std; int main( ) { IntCell m; // Or, IntCell m( 0 ); but not IntCell m( ); m.write( 5 ); cout << "Cell contents: " << m.read( ) << endl; return 0; }
16.214286
61
0.555066
amdfansheng
920c4481b54b5bd0acae7b8003cc8c11870f4970
843
cpp
C++
tests/cthread/test_cthread_wait_n_fail2.cpp
hachetman/systemc-compiler
0cc81ace03336d752c0146340ff5763a20e3cefd
[ "Apache-2.0" ]
86
2020-10-23T15:59:47.000Z
2022-03-28T18:51:19.000Z
tests/cthread/test_cthread_wait_n_fail2.cpp
hachetman/systemc-compiler
0cc81ace03336d752c0146340ff5763a20e3cefd
[ "Apache-2.0" ]
18
2020-12-14T13:11:26.000Z
2022-03-14T05:34:20.000Z
tests/cthread/test_cthread_wait_n_fail2.cpp
hachetman/systemc-compiler
0cc81ace03336d752c0146340ff5763a20e3cefd
[ "Apache-2.0" ]
17
2020-10-29T16:19:43.000Z
2022-03-11T09:51:05.000Z
/****************************************************************************** * Copyright (c) 2020, Intel Corporation. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception. * *****************************************************************************/ #include <systemc.h> // wait(N) where N is not constant, changed at next loop iteration, failed SC_MODULE(test_mod) { sc_signal<bool> clk{"clk"}; sc_signal<bool> rstn{"rstn"}; SC_CTOR(test_mod) { SC_CTHREAD(wait_n_inf, clk); async_reset_signal_is(rstn, false); } void wait_n_inf() { sc_uint<10> n = 1; wait(); while (1) { wait(n); n++; } } }; int sc_main(int argc, char **argv) { test_mod tmod{"tmod"}; sc_start(); return 0; }
21.615385
79
0.457888
hachetman
920dae05d475699885703980679dfb55d99c2d7c
13,990
cpp
C++
src/terminal/RenderBufferBuilder.cpp
herrhotzenplotz/contour
f6e58671fd94b44d88a76941bcf9c88a585a3550
[ "Apache-2.0" ]
null
null
null
src/terminal/RenderBufferBuilder.cpp
herrhotzenplotz/contour
f6e58671fd94b44d88a76941bcf9c88a585a3550
[ "Apache-2.0" ]
null
null
null
src/terminal/RenderBufferBuilder.cpp
herrhotzenplotz/contour
f6e58671fd94b44d88a76941bcf9c88a585a3550
[ "Apache-2.0" ]
null
null
null
#include <terminal/Color.h> #include <terminal/ColorPalette.h> #include <terminal/RenderBufferBuilder.h> #include <tuple> using namespace std; namespace terminal { namespace { constexpr RGBColor makeRGBColor(RGBColor fg, RGBColor bg, CellRGBColor cellColor) noexcept { if (holds_alternative<CellForegroundColor>(cellColor)) return fg; if (holds_alternative<CellBackgroundColor>(cellColor)) return bg; return get<RGBColor>(cellColor); } constexpr RGBColor average(RGBColor a, RGBColor b) noexcept { return RGBColor(static_cast<uint8_t>((a.red + b.red) / 2), static_cast<uint8_t>((a.green + b.green) / 2), static_cast<uint8_t>((a.blue + b.blue) / 2)); } tuple<RGBColor, RGBColor> makeColors(ColorPalette const& _colorPalette, CellFlags _cellFlags, bool _reverseVideo, Color foregroundColor, Color backgroundColor, bool _selected, bool _isCursor) { auto const [fg, bg] = makeColors(_colorPalette, _cellFlags, _reverseVideo, foregroundColor, backgroundColor); if (!_selected && !_isCursor) return tuple { fg, bg }; auto const [selectionFg, selectionBg] = [](auto fg, auto bg, bool selected, ColorPalette const& colors) -> tuple<RGBColor, RGBColor> { auto const a = colors.selectionForeground.value_or(bg); auto const b = colors.selectionBackground.value_or(fg); if (selected) return tuple { a, b }; else return tuple { b, a }; }(fg, bg, _selected, _colorPalette); if (!_isCursor) return tuple { selectionFg, selectionBg }; auto const cursorFg = makeRGBColor(selectionFg, selectionBg, _colorPalette.cursor.textOverrideColor); auto const cursorBg = makeRGBColor(selectionFg, selectionBg, _colorPalette.cursor.color); if (_selected) return tuple { average(selectionFg, cursorFg), average(selectionFg, cursorFg) }; return tuple { cursorFg, cursorBg }; } } // namespace template <typename Cell> RenderBufferBuilder<Cell>::RenderBufferBuilder(Terminal const& _terminal, RenderBuffer& _output): output { _output }, terminal { _terminal }, cursorPosition { _terminal.inputHandler().mode() == ViMode::Insert ? _terminal.realCursorPosition() : _terminal.state().viCommands.cursorPosition } { output.clear(); output.frameID = _terminal.lastFrameID(); output.cursor = renderCursor(); } template <typename Cell> optional<RenderCursor> RenderBufferBuilder<Cell>::renderCursor() const { if (!terminal.cursorCurrentlyVisible() || !terminal.viewport().isLineVisible(cursorPosition.line)) return nullopt; // TODO: check if CursorStyle has changed, and update render context accordingly. auto constexpr InactiveCursorShape = CursorShape::Rectangle; // TODO configurable auto const shape = terminal.state().focused ? terminal.cursorShape() : InactiveCursorShape; auto const cursorScreenPosition = CellLocation { cursorPosition.line + boxed_cast<LineOffset>(terminal.viewport().scrollOffset()), cursorPosition.column }; auto const cellWidth = terminal.currentScreen().cellWithAt(cursorPosition); return RenderCursor { cursorScreenPosition, shape, cellWidth }; } template <typename Cell> RenderCell RenderBufferBuilder<Cell>::makeRenderCellExplicit(ColorPalette const& _colorPalette, char32_t codepoint, CellFlags flags, RGBColor fg, RGBColor bg, Color ul, LineOffset _line, ColumnOffset _column) { RenderCell renderCell; renderCell.backgroundColor = bg; renderCell.foregroundColor = fg; renderCell.decorationColor = getUnderlineColor(_colorPalette, flags, fg, ul); renderCell.position.line = _line; renderCell.position.column = _column; renderCell.flags = flags; renderCell.width = 1; if (codepoint) renderCell.codepoints.push_back(codepoint); return renderCell; } template <typename Cell> RenderCell RenderBufferBuilder<Cell>::makeRenderCell(ColorPalette const& _colorPalette, HyperlinkStorage const& _hyperlinks, Cell const& screenCell, RGBColor fg, RGBColor bg, LineOffset _line, ColumnOffset _column) { RenderCell renderCell; renderCell.backgroundColor = bg; renderCell.foregroundColor = fg; renderCell.decorationColor = screenCell.getUnderlineColor(_colorPalette, fg); renderCell.position.line = _line; renderCell.position.column = _column; renderCell.flags = screenCell.styles(); renderCell.width = screenCell.width(); if (screenCell.codepointCount() != 0) { for (size_t i = 0; i < screenCell.codepointCount(); ++i) renderCell.codepoints.push_back(screenCell.codepoint(i)); } renderCell.image = screenCell.imageFragment(); if (auto href = _hyperlinks.hyperlinkById(screenCell.hyperlink())) { auto const& color = href->state == HyperlinkState::Hover ? _colorPalette.hyperlinkDecoration.hover : _colorPalette.hyperlinkDecoration.normal; // TODO(decoration): Move property into Terminal. auto const decoration = href->state == HyperlinkState::Hover ? CellFlags::Underline // TODO: decorationRenderer_.hyperlinkHover() : CellFlags::DottedUnderline; // TODO: decorationRenderer_.hyperlinkNormal(); renderCell.flags |= decoration; // toCellStyle(decoration); renderCell.decorationColor = color; } return renderCell; } template <typename Cell> std::tuple<RGBColor, RGBColor> RenderBufferBuilder<Cell>::makeColorsForCell(CellLocation gridPosition, CellFlags cellFlags, Color foregroundColor, Color backgroundColor) { auto const hasCursor = gridPosition == cursorPosition; // clang-format off bool const paintCursor = (hasCursor || (prevHasCursor && prevWidth == 2)) && output.cursor.has_value() && output.cursor->shape == CursorShape::Block; // clang-format on auto const selected = terminal.isSelected(CellLocation { gridPosition.line, gridPosition.column }); return makeColors(terminal.colorPalette(), cellFlags, reverseVideo, foregroundColor, backgroundColor, selected, paintCursor); } template <typename Cell> void RenderBufferBuilder<Cell>::renderTrivialLine(TriviallyStyledLineBuffer const& lineBuffer, LineOffset lineOffset) { // fmt::print("Rendering trivial line {:2} 0..{}/{}: \"{}\"\n", // lineOffset.value, // lineBuffer.text.size(), // lineBuffer.displayWidth, // lineBuffer.text.view()); auto const frontIndex = output.screen.size(); auto const textMargin = min(boxed_cast<ColumnOffset>(terminal.pageSize().columns), ColumnOffset::cast_from(lineBuffer.text.size())); auto const pageColumnsEnd = boxed_cast<ColumnOffset>(terminal.pageSize().columns); for (auto columnOffset = ColumnOffset(0); columnOffset < textMargin; ++columnOffset) { auto const pos = CellLocation { lineOffset, columnOffset }; auto const gridPosition = terminal.viewport().translateScreenToGridCoordinate(pos); auto const [fg, bg] = makeColorsForCell(gridPosition, lineBuffer.attributes.styles, lineBuffer.attributes.foregroundColor, lineBuffer.attributes.backgroundColor); auto const codepoint = static_cast<char32_t>(lineBuffer.text[unbox<size_t>(columnOffset)]); lineNr = lineOffset; prevWidth = 0; prevHasCursor = false; output.screen.emplace_back(makeRenderCellExplicit(terminal.colorPalette(), codepoint, lineBuffer.attributes.styles, fg, bg, lineBuffer.attributes.underlineColor, lineOffset, columnOffset)); } for (auto columnOffset = textMargin; columnOffset < pageColumnsEnd; ++columnOffset) { auto const pos = CellLocation { lineOffset, columnOffset }; auto const gridPosition = terminal.viewport().translateScreenToGridCoordinate(pos); auto const [fg, bg] = makeColorsForCell(gridPosition, lineBuffer.attributes.styles, lineBuffer.attributes.foregroundColor, lineBuffer.attributes.backgroundColor); output.screen.emplace_back(makeRenderCellExplicit(terminal.colorPalette(), char32_t { 0 }, lineBuffer.attributes.styles, fg, bg, lineBuffer.attributes.underlineColor, lineOffset, columnOffset)); } auto const backIndex = output.screen.size() - 1; output.screen[frontIndex].groupStart = true; output.screen[backIndex].groupEnd = true; } template <typename Cell> void RenderBufferBuilder<Cell>::startLine(LineOffset _line) noexcept { isNewLine = true; lineNr = _line; prevWidth = 0; prevHasCursor = false; } template <typename Cell> void RenderBufferBuilder<Cell>::endLine() noexcept { if (!output.screen.empty()) { output.screen.back().groupEnd = true; } } template <typename Cell> void RenderBufferBuilder<Cell>::renderCell(Cell const& screenCell, LineOffset _line, ColumnOffset _column) { auto const pos = CellLocation { _line, _column }; auto const gridPosition = terminal.viewport().translateScreenToGridCoordinate(pos); auto const [fg, bg] = makeColorsForCell( gridPosition, screenCell.styles(), screenCell.foregroundColor(), screenCell.backgroundColor()); prevWidth = screenCell.width(); prevHasCursor = gridPosition == cursorPosition; auto const cellEmpty = screenCell.empty(); auto const customBackground = bg != terminal.colorPalette().defaultBackground || !!screenCell.styles(); switch (state) { case State::Gap: if (!cellEmpty || customBackground) { state = State::Sequence; output.screen.emplace_back(makeRenderCell(terminal.colorPalette(), terminal.state().hyperlinks, screenCell, fg, bg, _line, _column)); output.screen.back().groupStart = true; } break; case State::Sequence: if (cellEmpty && !customBackground) { output.screen.back().groupEnd = true; state = State::Gap; } else { output.screen.emplace_back(makeRenderCell(terminal.colorPalette(), terminal.state().hyperlinks, screenCell, fg, bg, _line, _column)); if (isNewLine) output.screen.back().groupStart = true; } break; } isNewLine = false; } } // namespace terminal #include <terminal/Cell.h> template class terminal::RenderBufferBuilder<terminal::Cell>;
42.265861
109
0.523159
herrhotzenplotz
9212b19d35ae43515484bada4220f4aad4d45c41
1,654
cpp
C++
examples/uvmsc/simple/registers/models/aliasing/sc_main.cpp
kopinions/uvm-systemc
c8171a98bc75b3ff3ec207d369e1b724ae64632f
[ "ECL-2.0", "Apache-2.0" ]
3
2019-08-16T14:24:43.000Z
2022-03-14T13:02:33.000Z
examples/uvmsc/simple/registers/models/aliasing/sc_main.cpp
ezchi/uvm-systemc
3368d7a1756514d7edd3415282dea812f4a5512a
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
examples/uvmsc/simple/registers/models/aliasing/sc_main.cpp
ezchi/uvm-systemc
3368d7a1756514d7edd3415282dea812f4a5512a
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
//---------------------------------------------------------------------- // Copyright 2004-2011 Synopsys, Inc. // Copyright 2010 Mentor Graphics Corporation // Copyright 2010-2011 Cadence Design Systems, Inc. // Copyright 2013-2014 NXP B.V. // All Rights Reserved Worldwide // // Licensed under the Apache License, Version 2.0 (the // "License"); you may not use this file except in // compliance with the License. You may obtain a copy of // the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in // writing, software distributed under the License is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See // the License for the specific language governing // permissions and limitations under the License. //---------------------------------------------------------------------- #include <systemc> #include <uvm> #include "tb_test.h" //---------------------------------------------------------------------- // This example demonstrates how to model aliased registers // i.e. registers that are present at two physical addresses, // possibily with different access policies. // // In this case, we have a register "R" which is known under two names // "Ra" and "Rb". When accessed as "Ra", field F2 is RO. //---------------------------------------------------------------------- int sc_main(int, char*[]) { uvm::uvm_root::get()->set_report_verbosity_level(uvm::UVM_FULL); uvm::uvm_report_server::get_server()->set_max_quit_count(10); uvm::run_test("tb_test"); return 0; }
35.956522
72
0.585852
kopinions
9214939be76289e7a928231da04d3982c68517ff
3,043
cpp
C++
src/a_datastruct_queue_link.cpp
jinfeng95/algorithms
2a663fe53b494fc6b9dd56cefd368375734de7b0
[ "MIT" ]
null
null
null
src/a_datastruct_queue_link.cpp
jinfeng95/algorithms
2a663fe53b494fc6b9dd56cefd368375734de7b0
[ "MIT" ]
null
null
null
src/a_datastruct_queue_link.cpp
jinfeng95/algorithms
2a663fe53b494fc6b9dd56cefd368375734de7b0
[ "MIT" ]
null
null
null
/* Project: single_linked_queue (链队列) Date: 2018/09/17 Author: Frank Yu InitQueue(LinkQueue &Q) 参数:链队Q 功能:初始化 时间复杂度O(1) EnQueue(LinkQueue &Q,QElemType e) 参数:链队Q,元素e 功能:将e入队 时间复杂度:O(1) DeQueue(LinkQueue &Q,QElemType &e) 参数:链队Q,元素e 功能:队头出队,e接收出队元素值 时间复杂度O(1) GetHead(LinkQueue &Q,QElemType &e) 参数:链队Q,元素e 功能:得到队顶元素 时间复杂度O(1) 注意:有头结点 */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> using namespace std; #define Status int #define QElemType int //链队结点数据结构 typedef struct QNode { QElemType data;//数据域 struct QNode *next;//指针域 }QNode,*QueuePtr; typedef struct { struct QNode *front,*rear;//rear指针指向队尾 用于入队 front指针指向队头 用于出队 }LinkQueue; //**************************基本操作函数***************************// //初始化函数 Status InitQueue(LinkQueue &Q) { Q.front=Q.rear=new QNode;//生成新节点作为头结点,队头队尾指针均指向它 Q.front->next=NULL; return 1; } //入队函数 Status EnQueue(LinkQueue &Q,QElemType e) { QNode *p; p=new QNode;//生成新节点 p->data=e; //赋值 p->next=NULL; Q.rear->next=p;//加入队尾 Q.rear=p; //尾指针后移 return 1; } //出队函数 队头出队用e返回 注意释放空间 bool DeQueue(LinkQueue &Q,QElemType &e) { QueuePtr p; if(Q.front==Q.rear)return false;//队空 e=Q.front->next->data; //e返回值 之前写的Q.front->data 炸了,头结点没数据的,一定要注意头结点 p=Q.front->next; //保留,一会儿释放空间 Q.front->next=p->next; //出队,注意Q.front->next 不是Q.front 还有头结点 if(Q.rear==p)Q.rear=Q.front; //最后一个元素出队,rear指向头结点 free(p); return true; } //取队顶函数 用e返回 bool GetHead(LinkQueue &Q,QElemType &e) { if(Q.front==Q.rear) return false;//队列为空 e=Q.front->next->data; return true; } //**************************功能实现函数***************************// //菜单 void menu() { printf("********1.入队 2.出队*********\n"); printf("********3.取队顶元素 4.退出*********\n"); } //入队功能函数 调用EnQueue函数 void EnterToQueue(LinkQueue &Q) { int n;QElemType e;int flag; printf("请输入入队元素个数(>=1):\n"); scanf("%d",&n); for(int i=0;i<n;i++) { printf("请输入第%d个元素的值:",i+1); scanf("%d",&e); flag=EnQueue(Q,e); if(flag)printf("%d已入队\n",e); } } //出队功能函数 调用DeQueue函数 void DeleteFromQueue(LinkQueue &Q) { int n;QElemType e;int flag; printf("请输入出队元素个数(>=1):\n"); scanf("%d",&n); for(int i=0;i<n;i++) { flag=DeQueue(Q,e); if(flag)printf("%d已出队\n",e); else {printf("队已空!!!\n");break;} } } //取队顶功能函数 调用GetHead函数 void GetHeadOfStack(LinkQueue Q) { QElemType e;bool flag; flag=GetHead(Q,e); if(flag)printf("队头元素为:%d\n",e); else printf("队已空!!!\n"); } //主函数 int main() { LinkQueue Q;int choice; InitQueue(Q); while(1) { menu(); printf("请输入菜单序号:\n"); scanf("%d",&choice); if(4==choice) break; switch(choice) { case 1:EnterToQueue(Q);break; case 2:DeleteFromQueue(Q);break; case 3:GetHeadOfStack(Q);break; default:printf("输入错误!!!\n"); } } return 0; }
23.05303
81
0.564246
jinfeng95
9214a2d9b73606dcd4d3482ce885b05148700b6a
4,480
cpp
C++
WhispEngine/WhispEngine/PanelCreate.cpp
Empty-Whisper/WhispEngine
f1f8412377db24569ea2e2db7118b0339a11e85d
[ "MIT" ]
10
2019-10-09T15:58:03.000Z
2022-01-24T07:09:16.000Z
WhispEngine/WhispEngine/PanelCreate.cpp
Empty-Whisper/WhispEngine
f1f8412377db24569ea2e2db7118b0339a11e85d
[ "MIT" ]
8
2019-10-21T16:48:49.000Z
2019-10-26T14:25:43.000Z
WhispEngine/WhispEngine/PanelCreate.cpp
Empty-Whisper/WhispEngine
f1f8412377db24569ea2e2db7118b0339a11e85d
[ "MIT" ]
5
2019-10-15T09:17:21.000Z
2020-05-17T21:43:03.000Z
#include "PanelCreate.h" #include "Imgui/imgui.h" #include "Imgui/imgui_internal.h" // for ImGui::PushFlag #include "Application.h" #include "Globals.h" #include "mmgr/mmgr.h" PanelCreate::PanelCreate(const bool &start_active, const SDL_Scancode &shortcut1, const SDL_Scancode &shortcut2, const SDL_Scancode &shortcut3) :Panel("Create", start_active, shortcut1, shortcut2, shortcut3) { items.resize((int)Primitives::MAX); for (int i = 0; i < (int)Primitives::MAX; ++i) { switch ((Primitives)i) { case Primitives::CUBE: items[i] = "Cube"; break; case Primitives::TETRAHEDRON: items[i] = "Tetrahedron"; break; case Primitives::OCTAHEDRON: items[i] = "Octahedron"; break; case Primitives::DODECAHEDRON: items[i] = "Dodecahedron"; break; case Primitives::ICOSAHEDRON: items[i] = "Icosahedron"; break; case Primitives::SPHERE: items[i] = "Sphere"; break; case Primitives::HEMISPHERE: items[i] = "Hemisphere"; break; case Primitives::TORUS: items[i] = "Torus"; break; case Primitives::CONE: items[i] = "Cone"; break; case Primitives::CYLINDER: items[i] = "Cylinder"; break; default: LOG("Added more primitives than expected, add the missing primitives to the for"); break; } } iterator = items.begin() + (int)Primitives::CUBE; active = false; } PanelCreate::~PanelCreate() { } void PanelCreate::Update() { if (ImGui::Begin("Create", &active)) { if (ImGui::BeginCombo("Primitive", (*iterator).data())) { for (int n = 0; n < items.size(); n++) { if (ImGui::Selectable(items[n].data(), iterator - items.begin() == n)) iterator = items.begin() + n; } ImGui::EndCombo(); } ImGui::NewLine(); ImGui::PushItemWidth(100); ImGui::PushID("pos"); ImGui::Text("Position"); ImGui::SliderFloat("X", &data.pos.x, -15.f, 15.f); ImGui::SameLine(); ImGui::SliderFloat("Y", &data.pos.y, -15.f, 15.f); ImGui::SameLine(); ImGui::SliderFloat("Z", &data.pos.z, -15.f, 15.f); ImGui::PopID(); ImGui::Separator(); ImGui::PushID("rot"); ImGui::Text("Rotation"); ImGui::SliderFloat("X", &data.rotate.axis[0], 0.f, 1.f); ImGui::SameLine(); ImGui::SliderFloat("Y", &data.rotate.axis[1], 0.f, 1.f); ImGui::SameLine(); ImGui::SliderFloat("Z", &data.rotate.axis[2], 0.f, 1.f); ImGui::SliderFloat("Angle (rad)", &data.rotate.angle, 0.f, 6.28); ImGui::PopID(); ImGui::Separator(); ImGui::PushID("scale"); ImGui::Text("Scale"); ImGui::SliderFloat("X", &data.scale.x, 0.f, 5.f); ImGui::SameLine(); ImGui::SliderFloat("Y", &data.scale.y, 0.f, 5.f); ImGui::SameLine(); ImGui::SliderFloat("Z", &data.scale.z, 0.f, 5.f); ImGui::PopItemWidth(); ImGui::PopID(); ImGui::Separator(); ImGui::NewLine(); switch (Primitives(iterator-items.begin())) { case Primitives::SPHERE: ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); ImGui::SliderFloat("Radius", &data.radius, 0.1f, 5.f); ImGui::SliderInt("Rings", &data.rings, 3, 50); ImGui::SliderInt("Sectors", &data.slices, 3, 50); ImGui::PopStyleVar(); ImGui::PopItemFlag(); ImGui::SameLine(); ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); ImGui::TextUnformatted("That items will replace items below"); ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } break; case Primitives::HEMISPHERE: ImGui::SliderInt("Slices", &data.slices, 3, 20); ImGui::SliderInt("Rings", &data.rings, 3, 20); break; case Primitives::TORUS: ImGui::SliderInt("Slices", &data.slices, 3, 20); ImGui::SliderInt("Rings", &data.rings, 3, 20); ImGui::SliderFloat("Radius", &data.radius, 0.1f, 0.9999f); break; case Primitives::CONE: ImGui::SliderInt("Slices", &data.slices, 3, 20); ImGui::SliderInt("Rings", &data.rings, 3, 20); break; case Primitives::CYLINDER: ImGui::SliderInt("Slices", &data.slices, 3, 20); ImGui::SliderInt("Rings", &data.rings, 3, 20); break; default: break; } ImGui::ColorEdit3("Face color", data.face_color); ImGui::ColorEdit3("Wire color", data.wire_color); ImGui::NewLine(); if (ImGui::Button("Create")) { //App->object_manager->CreatePrimitive((Primitives)(iterator - items.begin()), data); } ImGui::SameLine(); if (ImGui::Button("Demo")) { //App->object_manager->Demo(); } } ImGui::End(); }
27.151515
143
0.642188
Empty-Whisper
9215cd4280a9b341ee18292b18834ad134f3ee16
6,783
cpp
C++
apps/viewer.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
null
null
null
apps/viewer.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
null
null
null
apps/viewer.cpp
jess22664/x3ogre
9de430859d877407ae0308908390c9fa004b0e84
[ "MIT" ]
null
null
null
#include <iostream> #include <OgreApplicationContext.h> #include <core/SceneAccessInterface.h> #include <core/OgreX3DPlugin.h> #include <OgreOverlaySystem.h> #include <OgreTrays.h> #include <OgreAdvancedRenderControls.h> #include <OgreCameraMan.h> #include <OgreSceneLoaderManager.h> #include <World/Viewpoint.h> #if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN #include <emscripten/bind.h> void emloop(void* target) { Ogre::WindowEventUtilities::messagePump(); try { static_cast<Ogre::Root*>(target)->renderOneFrame(); } catch (std::exception& e) { std::cout << e.what() << std::endl; emscripten_cancel_main_loop(); } } #endif namespace { void printSceneGraph(Ogre::SceneNode* node, const std::string& tabs = "") { std::cout << tabs << node->getName() << std::endl; Ogre::SceneNode::ObjectIterator mo = node->getAttachedObjectIterator(); while(mo.hasMoreElements()) { std::cout << tabs+"\t" << mo.getNext()->getName() << std::endl; } Ogre::SceneNode::ChildNodeIterator j = node->getChildIterator(); while(j.hasMoreElements()) { printSceneGraph(static_cast<Ogre::SceneNode*>(j.getNext()), tabs+"\t"); } } struct X3Ogre : public OgreBites::ApplicationContext, OgreBites::InputListener { std::unique_ptr<X3D::SceneAccessInterface> _sai; std::unique_ptr<OgreBites::TrayManager> _trays; std::unique_ptr<OgreBites::AdvancedRenderControls> _controls; std::unique_ptr<OgreBites::CameraMan> _camman; Ogre::SceneManager* _sceneManager = nullptr; X3Ogre() : OgreBites::ApplicationContext("x3ogre") { initApp(); } ~X3Ogre() { closeApp(); } // SAI like API bool nodeExists(const std::string& node) { return _sai->scene()->nodeExists(node); } void setNodeAttribute(const std::string& node, const std::string& field, const std::string& value) { _sai->setNodeAttribute(node, field, value); } std::string getNodeAttribute(const std::string& node, const std::string& field) { return _sai->getNodeAttribute(node, field); } void loadFile(const std::string& file) { // add X3D path to Ogre resources Ogre::String filename, basepath; Ogre::StringUtil::splitFilename(file, filename, basepath); if (!basepath.empty() && !Ogre::ResourceGroupManager::getSingleton().resourceLocationExists(basepath, "X3D")) { // Counts for android, since APK located files (crash if basepath is empty) Ogre::ResourceGroupManager::getSingleton().addResourceLocation(basepath, "FileSystem", "X3D", true); Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("X3D"); } if(_controls) { removeInputListener(_controls.get()); _controls.reset(); } if(_camman) { removeInputListener(_camman.get()); _camman.reset(); } if (_sceneManager) { mShaderGenerator->removeSceneManager(_sceneManager); mRoot->destroySceneManager(_sceneManager); mShaderGenerator->removeAllShaderBasedTechniques(); mShaderGenerator->flushShaderCache(); } // Remove old Viewport if present if (getRenderWindow()->hasViewportWithZOrder(0)) { getRenderWindow()->removeViewport(0); } _sceneManager = mRoot->createSceneManager(); mShaderGenerator->addSceneManager(_sceneManager); _sceneManager->addRenderQueueListener(getOverlaySystem()); Ogre::SceneLoaderManager::getSingleton().load(filename, "X3D", _sceneManager->getRootSceneNode()); // SAI init _sai.reset(new X3D::SceneAccessInterface(_sceneManager->getRootSceneNode())); _sai->addEssentialNodes(); // ensure we have a X3D::Viewpoint auto cam =_sai->scene()->bound<X3D::Viewpoint>()->getCamera(); _sai->scene()->setViewport(getRenderWindow()->addViewport(cam)); _controls.reset(new OgreBites::AdvancedRenderControls(_trays.get(), cam)); addInputListener(_controls.get()); _camman.reset(new OgreBites::CameraMan(cam->getParentSceneNode())); _camman->setStyle(OgreBites::CS_ORBIT); _camman->setYawPitchDist(Ogre::Radian(0), Ogre::Radian(0), _sai->getWorldSize()); addInputListener(_camman.get()); } // internal API void setup() override { // Ogre setup OgreBites::ApplicationContext::setup(); _trays.reset(new OgreBites::TrayManager("Interface", getRenderWindow())); addInputListener(_trays.get()); _trays->showFrameStats(OgreBites::TL_BOTTOMLEFT); _trays->hideCursor(); addInputListener(this); // register x3d file loader getRoot()->installPlugin(new X3D::OgreX3DPlugin); } void loop() { #if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN emscripten_set_main_loop_arg(emloop, getRoot(), 0, 0); #else getRoot()->startRendering(); #endif } void shutdown() override { getRoot()->removeFrameListener(_sai.get()); removeInputListener(this); removeInputListener(_trays.get()); removeInputListener(_controls.get()); _controls.reset(); _sai.reset(); _trays.reset(); } bool keyPressed(const OgreBites::KeyboardEvent& evt) override { using namespace OgreBites; switch(evt.keysym.sym) { case SDLK_ESCAPE: getRoot()->queueEndRendering(); break; case 'b': _sai->switchDebugDrawing(); break; case 'n': loadFile("../examples/flipper.x3d"); break; case 'w': _camman->setYawPitchDist(Ogre::Radian(0), Ogre::Radian(0), _sai->getWorldSize()); break; case 'x': auto comp = getNodeAttribute("vp", "compositors").empty() ? "Night Vision" : ""; setNodeAttribute("vp", "compositors", comp); break; } return true; } }; } #if OGRE_PLATFORM == OGRE_PLATFORM_EMSCRIPTEN EMSCRIPTEN_BINDINGS(my_module) { using namespace emscripten; class_<X3Ogre>("X3Ogre") .constructor() .function("loop", &X3Ogre::loop) .function("setNodeAttribute", &X3Ogre::setNodeAttribute) .function("getNodeAttribute", &X3Ogre::getNodeAttribute) .function("nodeExists", &X3Ogre::nodeExists) .function("loadFile", &X3Ogre::loadFile); } #else int main(int argc, char* argv[]) { if (argc < 2) return 1; // Ogre setup X3Ogre context; context.loadFile(argv[1]); context.loop(); return 0; } #endif
31.696262
117
0.626566
jess22664
921b87e4aff889a0d63cfe0ca6f0ba6c13f72dc7
945
cpp
C++
WTesterClient/widget_setting.cpp
RockRockWhite/WTester
50a9de8ba7c48738eb054680d6eae0a2fc0c06e3
[ "MIT" ]
null
null
null
WTesterClient/widget_setting.cpp
RockRockWhite/WTester
50a9de8ba7c48738eb054680d6eae0a2fc0c06e3
[ "MIT" ]
null
null
null
WTesterClient/widget_setting.cpp
RockRockWhite/WTester
50a9de8ba7c48738eb054680d6eae0a2fc0c06e3
[ "MIT" ]
null
null
null
#include "widget_setting.h" #include "ui_widget_setting.h" #include <QSettings> #include <QMessageBox> #include <QTextCodec> #pragma execution_character_set("utf-8") widget_setting::widget_setting(QWidget *parent) : QWidget(parent), ui(new Ui::widget_setting) { ui->setupUi(this); QSettings setting("\config.ini",QSettings::IniFormat); ui->lineEdit_server_ip->setText(setting.value("setting/IP").toString()); ui->lineEdit_server_port->setText(setting.value("setting/PORT").toString()); } widget_setting::~widget_setting() { delete ui; } void widget_setting::on_pushButton_2_clicked() { this->close(); } void widget_setting::on_pushButton_save_clicked() { QSettings setting("\config.ini",QSettings::IniFormat); setting.setValue("setting/IP",ui->lineEdit_server_ip->text()); setting.setValue("setting/PORT",ui->lineEdit_server_port->text()); QMessageBox::information(this,"提示","您的配置已保存!"); }
25.540541
80
0.725926
RockRockWhite
921cf50c31aca727db5aeb62877e8428ce7318bf
280
hpp
C++
include/RN_Generators.hpp
temken/DaMaSCUS
14be6907230e5ef1b93809a6fb5842330497a7a6
[ "MIT" ]
3
2018-09-13T13:36:50.000Z
2021-10-30T19:35:12.000Z
include/RN_Generators.hpp
temken/DaMaSCUS
14be6907230e5ef1b93809a6fb5842330497a7a6
[ "MIT" ]
2
2017-06-06T14:43:45.000Z
2022-03-16T13:01:56.000Z
include/RN_Generators.hpp
temken/DaMaSCUS
14be6907230e5ef1b93809a6fb5842330497a7a6
[ "MIT" ]
1
2017-06-09T09:48:10.000Z
2017-06-09T09:48:10.000Z
#ifndef __RN_Generators_hpp_ #define __RN_Generators_hpp_ #include <random> extern double ProbabilitySample(std::mt19937& PRNG); extern double MaxwellSample(std::mt19937& PRNG); extern double ThetaSample(std::mt19937& PRNG); extern double PhiSample(std::mt19937& PRNG); #endif
23.333333
52
0.8
temken
921dc15dceff6350cb59a41acd2a84a0fd2a8dc4
1,852
cpp
C++
phoenix/qt/widget/check-button.cpp
vgmtool/vgm2pre
f4f917df35d531512292541234a5c1722b8af96f
[ "MIT" ]
21
2015-04-13T03:07:12.000Z
2021-11-20T00:27:00.000Z
phoenix/qt/widget/check-button.cpp
apollolux/hello-phoenix
71510b5f329804c525a9576fb0367fe8ab2487cd
[ "MIT" ]
2
2015-10-06T14:59:48.000Z
2022-01-27T08:57:57.000Z
phoenix/qt/widget/check-button.cpp
apollolux/hello-phoenix
71510b5f329804c525a9576fb0367fe8ab2487cd
[ "MIT" ]
2
2021-11-19T08:36:57.000Z
2022-03-04T16:03:16.000Z
namespace phoenix { Size pCheckButton::minimumSize() { Size size = pFont::size(qtWidget->font(), checkButton.state.text); if(checkButton.state.orientation == Orientation::Horizontal) { size.width += checkButton.state.image.width; size.height = max(checkButton.state.image.height, size.height); } if(checkButton.state.orientation == Orientation::Vertical) { size.width = max(checkButton.state.image.width, size.width); size.height += checkButton.state.image.height; } return {size.width + 20, size.height + 12}; } void pCheckButton::setChecked(bool checked) { locked = true; qtCheckButton->setChecked(checked); locked = false; } void pCheckButton::setImage(const image& image, Orientation orientation) { qtCheckButton->setIconSize(QSize(image.width, image.height)); qtCheckButton->setIcon(CreateIcon(image)); qtCheckButton->setStyleSheet("text-align: top;"); switch(orientation) { case Orientation::Horizontal: qtCheckButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); break; case Orientation::Vertical: qtCheckButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); break; } } void pCheckButton::setText(string text) { qtCheckButton->setText(QString::fromUtf8(text)); } void pCheckButton::constructor() { qtWidget = qtCheckButton = new QToolButton; qtCheckButton->setCheckable(true); qtCheckButton->setToolButtonStyle(Qt::ToolButtonTextOnly); connect(qtCheckButton, SIGNAL(toggled(bool)), SLOT(onToggle(bool))); pWidget::synchronizeState(); setChecked(checkButton.state.checked); setText(checkButton.state.text); } void pCheckButton::destructor() { } void pCheckButton::orphan() { destructor(); constructor(); } void pCheckButton::onToggle(bool checked) { checkButton.state.checked = checked; if(!locked && checkButton.onToggle) checkButton.onToggle(); } }
28.9375
103
0.74406
vgmtool
922114cbffcf25b5a8c965189d48eab319ed6965
3,275
cpp
C++
src/saiga/vulkan/pipeline/PipelineBase.cpp
SimonMederer/saiga
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
[ "MIT" ]
null
null
null
src/saiga/vulkan/pipeline/PipelineBase.cpp
SimonMederer/saiga
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
[ "MIT" ]
null
null
null
src/saiga/vulkan/pipeline/PipelineBase.cpp
SimonMederer/saiga
ff167e60c50b1cead4d19eb5ab2e93acce8c42a3
[ "MIT" ]
null
null
null
/** * Copyright (c) 2017 Darius Rückert * Licensed under the MIT License. * See LICENSE file for more information. */ #include "PipelineBase.h" #include "saiga/vulkan/Vertex.h" #include "saiga/vulkan/VulkanInitializers.hpp" namespace Saiga { namespace Vulkan { PipelineBase::PipelineBase(vk::PipelineBindPoint type) : type(type) {} void PipelineBase::init(VulkanBase& base, uint32_t numDescriptorSetLayouts) { this->base = &base; device = base.device; descriptorSetLayouts.resize(numDescriptorSetLayouts); } void PipelineBase::destroy() { if (!device) return; VLOG(3) << "Destroying pipeline " << pipeline; vkDestroyPipeline(device, pipeline, nullptr); vkDestroyPipelineLayout(device, pipelineLayout, nullptr); for (auto& l : descriptorSetLayouts) l.destroy(); device = nullptr; } vk::DescriptorSet PipelineBase::createRawDescriptorSet(uint32_t id) { SAIGA_ASSERT(isInitialized()); SAIGA_ASSERT(id >= 0 && id < descriptorSetLayouts.size()); return descriptorSetLayouts[id].createRawDescriptorSet(); } StaticDescriptorSet PipelineBase::createDescriptorSet(uint32_t id) { SAIGA_ASSERT(isInitialized()); SAIGA_ASSERT(id >= 0 && id < descriptorSetLayouts.size()); return descriptorSetLayouts[id].createDescriptorSet(); } DynamicDescriptorSet PipelineBase::createDynamicDescriptorSet(uint32_t id) { SAIGA_ASSERT(isInitialized()); SAIGA_ASSERT(id >= 0 && id < descriptorSetLayouts.size()); return descriptorSetLayouts[id].createDynamicDescriptorSet(); } bool PipelineBase::bind(vk::CommandBuffer cmd) { if (checkShader()) { cmd.bindPipeline(type, pipeline); return true; } else { return false; } } void PipelineBase::pushConstant(vk::CommandBuffer cmd, vk::ShaderStageFlags stage, size_t size, const void* data, size_t offset) { cmd.pushConstants(pipelineLayout, stage, offset, size, data); } void PipelineBase::addDescriptorSetLayout(const DescriptorSetLayout& layout, uint32_t id) { SAIGA_ASSERT(isInitialized()); SAIGA_ASSERT(id >= 0 && id < descriptorSetLayouts.size()); SAIGA_ASSERT(!layout.is_created(), "Creation must not be done beforehand"); descriptorSetLayouts[id] = layout; descriptorSetLayouts[id].create(base); } void PipelineBase::addPushConstantRange(vk::PushConstantRange pcr) { SAIGA_ASSERT(isInitialized()); pushConstantRanges.push_back(pcr); } void PipelineBase::createPipelineLayout() { SAIGA_ASSERT(isInitialized()); std::vector<vk::DescriptorSetLayout> layouts(descriptorSetLayouts.size()); std::transform(descriptorSetLayouts.begin(), descriptorSetLayouts.end(), layouts.begin(), [](auto& entry) { return static_cast<vk::DescriptorSetLayout>(entry); }); vk::PipelineLayoutCreateInfo pPipelineLayoutCreateInfo(vk::PipelineLayoutCreateFlags(), layouts.size(), layouts.data(), pushConstantRanges.size(), pushConstantRanges.data()); pipelineLayout = device.createPipelineLayout(pPipelineLayoutCreateInfo); SAIGA_ASSERT(pipelineLayout); } } // namespace Vulkan } // namespace Saiga
28.478261
113
0.695573
SimonMederer
9221415e18382ac152d76880f3a691de417c4607
817
cpp
C++
competitive_programming/programming_contests/uri/tda_rational_2.cpp
LeandroTk/Algorithms
569ed68eba3eeff902f8078992099c28ce4d7cd6
[ "MIT" ]
205
2018-12-01T17:49:49.000Z
2021-12-22T07:02:27.000Z
competitive_programming/programming_contests/uri/tda_rational_2.cpp
LeandroTk/Algorithms
569ed68eba3eeff902f8078992099c28ce4d7cd6
[ "MIT" ]
2
2020-01-01T16:34:29.000Z
2020-04-26T19:11:13.000Z
competitive_programming/programming_contests/uri/tda_rational_2.cpp
LeandroTk/Algorithms
569ed68eba3eeff902f8078992099c28ce4d7cd6
[ "MIT" ]
50
2018-11-28T20:51:36.000Z
2021-11-29T04:08:25.000Z
// https://www.urionlinejudge.com.br/judge/en/problems/view/1022 #include <iostream> #include <string> using namespace std; int mdc(int num1, int num2) { int remainder; do { remainder = num1 % num2; num1 = num2; num2 = remainder; } while (remainder != 0); return num1; } int main() { string ope, op; int n, num, num1, num2, den, den1, den2, div; cin >> n; while (n--) { cin >> num1 >> op >> den1 >> ope >> num2 >> op >> den2; den = den1 * den2; if (ope == "+") num = num1 * den2 + num2 * den1; else if (ope == "-") num = num1 * den2 - num2 * den1; else if (ope == "*") num = num1 * num2; else { num = num1 * den2; den = num2 * den1; } div = mdc(num, den); if (div < 0) div *= -1; cout << num << "/" << den << " = " << num/div << "/" << den/div << endl; } return 0; }
19.452381
74
0.537332
LeandroTk
9221e6ba8587b0635371a3f355da1beefcba429d
1,405
cpp
C++
carryarm_actionlib/src/carryarm_client.cpp
buzzer/tams_pr2
73eada99f88c300858f05d57b868e6a8109a800c
[ "BSD-2-Clause" ]
null
null
null
carryarm_actionlib/src/carryarm_client.cpp
buzzer/tams_pr2
73eada99f88c300858f05d57b868e6a8109a800c
[ "BSD-2-Clause" ]
null
null
null
carryarm_actionlib/src/carryarm_client.cpp
buzzer/tams_pr2
73eada99f88c300858f05d57b868e6a8109a800c
[ "BSD-2-Clause" ]
null
null
null
#include <ros/ros.h> #include <actionlib/client/simple_action_client.h> #include <actionlib/client/terminal_state.h> #include <carryarm_actionlib/CarryarmAction.h> int main (int argc, char **argv) { ros::init(argc, argv, "test_carryarm"); // create the action client // true causes the client to spin its own thread actionlib::SimpleActionClient<carryarm_actionlib::CarryarmAction> ac("carryarm", true); ROS_INFO("Waiting for action server to start."); // wait for the action server to start ac.waitForServer(); //will wait for infinite time ROS_INFO("Action server started, sending goal."); // send a goal to the action carryarm_actionlib::CarryarmGoal goal; uint8_t pose; uint8_t arm; // parse command line arguments if (argc == 3) { pose = atoi(argv[1]); arm = atoi(argv[2]); } else // default values { pose = 1; arm = 1; // left arm } ROS_INFO("carrypose: %d, carryarm: %s", pose, arm ? "left" : "right"); goal.carrypose = pose; goal.carryarm = arm; ac.sendGoal(goal); //wait for the action to return bool finished_before_timeout = ac.waitForResult(ros::Duration(200.0)); if (finished_before_timeout) { actionlib::SimpleClientGoalState state = ac.getState(); ROS_INFO("Action finished: %s",state.toString().c_str()); } else ROS_INFO("Action did not finish before the time out."); //exit return 0; }
25.089286
89
0.683274
buzzer
92257b0dbddb99cf36172dc9ea3dd8c3f9ea9c33
733
cpp
C++
src/0232.cpp
killf/leetcode_cpp
d1f308a9c3da55ae5416ea28ec2e7a3146533ae9
[ "MIT" ]
null
null
null
src/0232.cpp
killf/leetcode_cpp
d1f308a9c3da55ae5416ea28ec2e7a3146533ae9
[ "MIT" ]
null
null
null
src/0232.cpp
killf/leetcode_cpp
d1f308a9c3da55ae5416ea28ec2e7a3146533ae9
[ "MIT" ]
null
null
null
#include <iostream> #include <string> #include <vector> #include <sstream> #include <algorithm> #include <map> #include <hash_map> #include <hash_set> #include <queue> #include <stack> using namespace std; class MyQueue { public: explicit MyQueue() = default; void push(int x) { while (!p1->empty()) { p2->push(p1->top()); p1->pop(); } p1->push(x); while (!p2->empty()) { p1->push(p2->top()); p2->pop(); } } int pop() { int v = p1->top(); p1->pop(); return v; } int peek() { return p1->top(); } bool empty() { return p1->empty(); } private: stack<int> stack1; stack<int> stack2; stack<int> *p1 = &stack1; stack<int> *p2 = &stack2; };
14.096154
31
0.547067
killf
92258e27bebc9d404a247ecaf7959240b2946ba5
6,829
cxx
C++
Dockerized/rdpstack/cmake-3.17.2/Source/cmLoadCommandCommand.cxx
nsimbi/Proconsul
70cb520463bf9d9e36b37c57db5c7798a8604c03
[ "MIT" ]
3
2021-10-14T07:40:15.000Z
2022-02-27T09:20:33.000Z
Dockerized/rdpstack/cmake-3.17.2/Source/cmLoadCommandCommand.cxx
nsimbi/Proconsul
70cb520463bf9d9e36b37c57db5c7798a8604c03
[ "MIT" ]
null
null
null
Dockerized/rdpstack/cmake-3.17.2/Source/cmLoadCommandCommand.cxx
nsimbi/Proconsul
70cb520463bf9d9e36b37c57db5c7798a8604c03
[ "MIT" ]
2
2021-10-21T06:12:36.000Z
2022-03-07T15:52:28.000Z
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLoadCommandCommand.h" #include <csignal> #include <cstdio> #include <cstdlib> #include <cstring> #include <utility> #include <cm/memory> #include "cmCPluginAPI.h" #include "cmCommand.h" #include "cmDynamicLoader.h" #include "cmExecutionStatus.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmCPluginAPI.cxx" #ifdef __QNX__ # include <malloc.h> /* for malloc/free on QNX */ #endif class cmListFileBacktrace; namespace { const char* LastName = nullptr; extern "C" void TrapsForSignals(int sig) { fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n", LastName, sig); } struct SignalHandlerGuard { explicit SignalHandlerGuard(const char* name) { LastName = name != nullptr ? name : "????"; signal(SIGSEGV, TrapsForSignals); #ifdef SIGBUS signal(SIGBUS, TrapsForSignals); #endif signal(SIGILL, TrapsForSignals); } ~SignalHandlerGuard() { signal(SIGSEGV, nullptr); #ifdef SIGBUS signal(SIGBUS, nullptr); #endif signal(SIGILL, nullptr); } SignalHandlerGuard(SignalHandlerGuard const&) = delete; SignalHandlerGuard& operator=(SignalHandlerGuard const&) = delete; }; struct LoadedCommandImpl : cmLoadedCommandInfo { explicit LoadedCommandImpl(CM_INIT_FUNCTION init) : cmLoadedCommandInfo{ 0, 0, &cmStaticCAPI, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } { init(this); } ~LoadedCommandImpl() { if (this->Destructor) { SignalHandlerGuard guard(this->Name); this->Destructor(this); } if (this->Error != nullptr) { free(this->Error); } } LoadedCommandImpl(LoadedCommandImpl const&) = delete; LoadedCommandImpl& operator=(LoadedCommandImpl const&) = delete; int DoInitialPass(cmMakefile* mf, int argc, char* argv[]) { SignalHandlerGuard guard(this->Name); return this->InitialPass(this, mf, argc, argv); } void DoFinalPass(cmMakefile* mf) { SignalHandlerGuard guard(this->Name); this->FinalPass(this, mf); } }; // a class for loadabple commands class cmLoadedCommand : public cmCommand { public: cmLoadedCommand() = default; explicit cmLoadedCommand(CM_INIT_FUNCTION init) : Impl(std::make_shared<LoadedCommandImpl>(init)) { } /** * This is a virtual constructor for the command. */ std::unique_ptr<cmCommand> Clone() override { auto newC = cm::make_unique<cmLoadedCommand>(); // we must copy when we clone newC->Impl = this->Impl; return std::unique_ptr<cmCommand>(std::move(newC)); } /** * This is called when the command is first encountered in * the CMakeLists.txt file. */ bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) override; private: std::shared_ptr<LoadedCommandImpl> Impl; }; bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { if (!this->Impl->InitialPass) { return true; } // clear the error string if (this->Impl->Error) { free(this->Impl->Error); } // create argc and argv and then invoke the command int argc = static_cast<int>(args.size()); char** argv = nullptr; if (argc) { argv = static_cast<char**>(malloc(argc * sizeof(char*))); } int i; for (i = 0; i < argc; ++i) { argv[i] = strdup(args[i].c_str()); } int result = this->Impl->DoInitialPass(this->Makefile, argc, argv); cmFreeArguments(argc, argv); if (result) { if (this->Impl->FinalPass) { auto impl = this->Impl; this->Makefile->AddGeneratorAction( [impl](cmLocalGenerator& lg, const cmListFileBacktrace&) { impl->DoFinalPass(lg.GetMakefile()); }); } return true; } /* Initial Pass must have failed so set the error string */ if (this->Impl->Error) { this->SetError(this->Impl->Error); } return false; } } // namespace // cmLoadCommandCommand bool cmLoadCommandCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { if (args.empty()) { return true; } // Construct a variable to report what file was loaded, if any. // Start by removing the definition in case of failure. std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]); status.GetMakefile().RemoveDefinition(reportVar); // the file must exist std::string moduleName = cmStrCat( status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"), "cm", args[0], status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX")); // search for the file std::vector<std::string> path; for (unsigned int j = 1; j < args.size(); j++) { // expand variables std::string exp = args[j]; cmSystemTools::ExpandRegistryValues(exp); // Glob the entry in case of wildcards. cmSystemTools::GlobDirs(exp, path); } // Try to find the program. std::string fullPath = cmSystemTools::FindFile(moduleName, path); if (fullPath.empty()) { status.SetError(cmStrCat("Attempt to load command failed from file \"", moduleName, "\"")); return false; } // try loading the shared library / dll cmsys::DynamicLoader::LibraryHandle lib = cmDynamicLoader::OpenLibrary(fullPath.c_str()); if (!lib) { std::string err = cmStrCat("Attempt to load the library ", fullPath, " failed."); const char* error = cmsys::DynamicLoader::LastError(); if (error) { err += " Additional error info is:\n"; err += error; } status.SetError(err); return false; } // Report what file was loaded for this command. status.GetMakefile().AddDefinition(reportVar, fullPath); // find the init function std::string initFuncName = args[0] + "Init"; CM_INIT_FUNCTION initFunction = reinterpret_cast<CM_INIT_FUNCTION>( cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName)); if (!initFunction) { initFuncName = cmStrCat('_', args[0], "Init"); initFunction = reinterpret_cast<CM_INIT_FUNCTION>( cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName)); } // if the symbol is found call it to set the name on the // function blocker if (initFunction) { status.GetMakefile().GetState()->AddScriptedCommand( args[0], cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction))); return true; } status.SetError("Attempt to load command failed. " "No init function found."); return false; }
26.468992
78
0.662176
nsimbi
9227bc3c0f1be4bb041cf3d4a9bb14a12002bf7e
10,204
hpp
C++
src/reconstruction/dataset.hpp
ebarjou/xpulse_recon
5c9eb8e32a2f2b84a9850fabc2103c116a0b9ce6
[ "Apache-2.0" ]
null
null
null
src/reconstruction/dataset.hpp
ebarjou/xpulse_recon
5c9eb8e32a2f2b84a9850fabc2103c116a0b9ce6
[ "Apache-2.0" ]
null
null
null
src/reconstruction/dataset.hpp
ebarjou/xpulse_recon
5c9eb8e32a2f2b84a9850fabc2103c116a0b9ce6
[ "Apache-2.0" ]
null
null
null
/** * ©2020-2022 ALPhANOV (https://www.alphanov.com/) All Rights Reserved * Author: Barjou Emile */ #pragma once namespace dataset { #include "dataset/parameters.hpp" #include "dataset/geometry.hpp" #include "dataset/geometry_chunk.hpp" #include "dataset/data_loader.hpp" /** * @brief Manage the projections data and Input/ouput for the reconstruction. Need to be initialized before use. * */ class Dataset { Parameters *_parameters; int64_t _width, _height; std::vector<std::string> _tiff_files; Geometry _geometry; DataLoader _dataLoader; public: Dataset(Parameters *parameters) : _parameters(parameters), _width(0), _height(0), _tiff_files(collectFromDirectory(prm_r.input)), //Init prm_g.projections, prm_g.dwidth, _dheight _geometry(parameters), //Init all missing fields _dataLoader(parameters, _tiff_files) { std::cout << "Exploring directory..."<< std::flush; collectFromDirectory(prm_r.input); if(_tiff_files.size() == 0 || _width == 0 || _height == 0) { throw std::runtime_error("No valid TIFF file found in the directory."); } std::cout << getElements() << "x(" << getWidth() << "," << getHeight() << ")." << std::endl; } /** * @brief Load all data and create temporary files if needed * */ void initialize(bool chunk) { _dataLoader.initializeTempImages(chunk); } /** * @brief Get the Width of the images * * @return uint64_t */ uint64_t getWidth() { return _width; } /** * @brief Get the Height of the images * * @return uint64_t */ uint64_t getHeight() { return _height; } /** * @brief Get the number of images * * @return uint64_t */ uint64_t getElements() { return _tiff_files.size(); } /** * @brief Get a single layer * * @param layer index of the layer, from 0 (top layer) to volume height - 1 (bottem layer) * @return std::vector<float> */ std::vector<float> getLayer(int64_t layer) { return _dataLoader.getLayer(layer); } /** * @brief Get a single layer * * @param layer index of the layer, from 0 (top layer) to volume height - 1 (bottem layer) * @return std::vector<float> */ std::vector<float> getLayers(int64_t index_start, int64_t index_end, bool MT = false) { std::vector<float> layers((index_end-index_start)*prm_g.vwidth*prm_g.vwidth); #pragma omp parallel for if(MT) for(int64_t i = index_start; i < index_end; ++i) { auto layer = _dataLoader.getLayer(i); std::copy(layer.begin(), layer.end(), layers.begin()+(i-index_start)*prm_g.vwidth*prm_g.vwidth); } return layers; } /** * @brief Save the layer contained in data to a single layer file * * @param data of the layer, should be of size width*width * @param layer index of the layer, from 0 (top layer) to volume height - 1 (bottem layer) */ void saveLayer(std::vector<float> &data, int64_t layer, bool finalize = false) { _dataLoader.saveLayer(data.data(), layer, finalize); } /** * @brief Save multiple continuous layer contained in data * * @param data of the layer, should be of size width*width*(end-start) * @param start first layer index * @param end last layer index, excluded */ void saveLayers(std::vector<float> &data, int64_t index_start, int64_t index_end, bool MT = false) { #pragma omp parallel for if(MT) for(int64_t i = index_start; i < index_end; ++i) { _dataLoader.saveLayer(data.data()+(i-index_start)*prm_g.vwidth*prm_g.vwidth, i, true); } } /** * @brief get all images of a given SIT * * @param sit index of the sub-iteration * @return std::vector<float> */ std::vector<float> getSitImages(int64_t sit, bool MT = false) { std::vector<float> output(((prm_g.projections-sit)/prm_r.sit)*prm_g.dwidth*prm_g.dheight); #pragma omp parallel for if(MT) for(int i = sit; i < prm_g.projections; i += prm_r.sit) { auto image = _dataLoader.getImage(i); std::copy(image.begin(), image.end(), output.begin()+((i-sit)/prm_r.sit)*prm_g.dwidth*prm_g.dheight); } } /** * @brief get a single image * * @param id of the image * @return std::vector<float> */ std::vector<float> getImage(int64_t id) { return _dataLoader.getImage(id); } /** * @brief get a single image from a path * * @param path of the image * @return std::vector<float> */ std::vector<float> getImage(std::string path) { return _dataLoader.getImage(path); } /** * @brief Get all images, cropped to fit a chunk, and separated in sub-iterations * * @param chunk * @return std::vector<std::vector<float>> a vector for each sub-iterations containing the cropped images */ std::vector<std::vector<float>> getImagesCropped(int64_t chunk, bool MT = false) { std::vector<std::vector<float>> output(prm_r.sit); for(int sit = 0; sit < prm_r.sit; ++sit) { output[sit] = std::vector<float>(((prm_g.projections-sit)/prm_r.sit)*prm_g.dwidth*prm_m2.chunks[sit].iSize); #pragma omp parallel for if(MT) for(int i = sit; i < prm_g.projections; i += prm_r.sit) { auto image = _dataLoader.getImage(chunk*prm_g.projections+i); std::copy(image.begin(), image.end(), output[sit].begin()+((i-sit)/prm_r.sit)*prm_g.dwidth*prm_m2.chunks[sit].iSize); } } } /** * @brief Save multiple images * * @param data vector containing all images * @param start offset, in images from the vector * @param end offset, im images from the vector * @param step in image */ void saveSitImages(const std::vector<float> &data, int64_t sit) { /*for(int64_t l = start; l < end; l += step) { _dataLoader.saveProjImage(&data[((l-start)/step)*prm_g.dwidth*prm_g.dheight], l); }*/ //exit(-10); } void saveImage(const std::vector<float> &data, int width, int height, int id) { _dataLoader.saveImage(data.data(), width, height, id); } /** * @brief Get the Geometry object * * @return Geometry* */ Geometry* getGeometry() { return &_geometry; } /** * @brief Etablish the list of images that will be loaded when "initialize()" is called * * @param directory * @return std::vector<std::string> */ std::vector<std::string> collectFromDirectory(std::string directory) { std::vector<std::string> tiff_files; for (const auto & entry : std::filesystem::directory_iterator(directory)) { if(entry.is_regular_file() && (entry.path().extension() == ".tif" || entry.path().extension() == ".tiff")){ if(checkTiffFileInfos(entry.path().string())) { tiff_files.push_back(entry.path().string()); } } } //Fill parameters accordingly prm_g.projections = tiff_files.size(); prm_g.concurrent_projections = int64_t(std::floor( float(prm_g.projections) / float(prm_r.sit) )); prm_g.dwidth = _width; prm_g.dheight = _height; /*for(int64_t i = 0; i < int64_t(prm_md.size()); ++i) { if(!(prm_md[i].start_x.assigned)) prm_md[i].start_x = 0; if(!(prm_md[i].end_x.assigned)) prm_md[i].end_x = prm_g.dwidth; if(!(prm_md[i].start_y.assigned)) prm_md[i].start_y = 0; if(!(prm_md[i].end_y.assigned)) prm_md[i].end_y = prm_g.dheight; }*/ return tiff_files; } private: /** * @brief Check if a tiff file is valid and have the correct size * * @param file */ bool checkTiffFileInfos(std::string file) { TinyTIFFReaderFile* tiffr=NULL; tiffr=TinyTIFFReader_open(file.c_str()); if (tiffr) { const int32_t width = TinyTIFFReader_getWidth(tiffr); const int32_t height = TinyTIFFReader_getHeight(tiffr); const uint16_t bitspersample = TinyTIFFReader_getBitsPerSample(tiffr, 0); const uint16_t format = TinyTIFFReader_getSampleFormat(tiffr); TinyTIFFReader_close(tiffr); if(format != TINYTIFF_SAMPLEFORMAT_FLOAT || bitspersample != 32) { throw std::runtime_error("Trying to load a tiff with an incompatble format (should be floating-point 32bits)"); } if(width == 0 || height == 0) { throw std::runtime_error("Trying to load a tiff with an incorrect size."); } if(_width == 0 && _height == 0) { _width = width; _height = height; } if(_width == width && _height == height) { return true; } return false; } return false; } }; }
37.653137
137
0.53136
ebarjou
92281407fff2a2121ec0282c29bf84649c118096
1,333
cpp
C++
Codeorces/new_colony.cpp
maayami/Data-Structures-Algorithms
f2f7cf808be43b85f35a7b1801460ecc20d75695
[ "CC0-1.0" ]
1
2020-05-14T18:22:10.000Z
2020-05-14T18:22:10.000Z
Codeorces/new_colony.cpp
mayank-genesis/Data-Structures-Algorithms
f2f7cf808be43b85f35a7b1801460ecc20d75695
[ "CC0-1.0" ]
null
null
null
Codeorces/new_colony.cpp
mayank-genesis/Data-Structures-Algorithms
f2f7cf808be43b85f35a7b1801460ecc20d75695
[ "CC0-1.0" ]
null
null
null
#include <bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i, n) for (int i = 0; i < n; i++) #define Fo(i, k, n) for (int i = k; i < n; i++) #define ll long long #define pb(i) push_back(i) #define e "\n" #define traverseVector(i) for (auto i = v.begin(); i != v.end(); ++i) #define rtraverseVector(i) for (auto ir = g1.rbegin(); ir != g1.rend(); ++ir) #define in(n) cin >> n #define out(n) cout << n << e // .fillArray int compare_then_decide_recursive(int *arr, int n, int x) // returns the index of array (latest mountain - 1) { if (x == n - 1) { return x; } else if (arr[x] < arr[x + 1]) { arr[x]++; return x; } else return compare_then_decide_recursive(arr, n, x + 1); } void solve() { int n, k; cin >> n >> k; int arr[n]; for (int j = 0; j < n; j++) cin >> arr[j]; int index; while (k-- > 0) { index = compare_then_decide_recursive(arr, n, 0); if (index == n - 1) break; } if (index == n - 1) cout << -1; else cout << index + 1; cout << endl; } int main(int argc, char const *argv[]) { // ios_base::sync_with_stdio(false); // cin.tie(NULL); int t = 1; cin >> t; while (t--) { solve(); } return 0; }
19.895522
109
0.507877
maayami
922b1feb5079da74b1f3f8f14bc1ccad0ff7d8f6
2,533
hh
C++
track/SenseContainer.hh
celeritas-project/orange-port
9aa2d36984a24a02ed6d14688a889d4266f7b1af
[ "Apache-2.0", "MIT" ]
null
null
null
track/SenseContainer.hh
celeritas-project/orange-port
9aa2d36984a24a02ed6d14688a889d4266f7b1af
[ "Apache-2.0", "MIT" ]
null
null
null
track/SenseContainer.hh
celeritas-project/orange-port
9aa2d36984a24a02ed6d14688a889d4266f7b1af
[ "Apache-2.0", "MIT" ]
null
null
null
//---------------------------------*-C++-*-----------------------------------// /*! * \file track/SenseContainer.hh * \brief SenseContainer class declaration * \note Copyright (c) 2020 Oak Ridge National Laboratory, UT-Battelle, LLC. */ //---------------------------------------------------------------------------// #pragma once #include <iosfwd> #include <vector> namespace celeritas { //---------------------------------------------------------------------------// /*! * Store surface sense state inside a cell. * * This is currently a subset of std::vector functionality. * * \todo Change value_type to Sense */ class SenseContainer { public: //@{ //! Public type aliases using Storage_t = std::vector<bool>; using value_type = bool; using size_type = Storage_t::size_type; using iterator = Storage_t::iterator; using const_iterator = Storage_t::const_iterator; using reference = Storage_t::reference; using const_reference = Storage_t::const_reference; //@} public: //@{ //! Constructors SenseContainer() = default; inline SenseContainer(std::initializer_list<value_type>); //@} //@{ //! Element access inline reference operator[](size_type); inline const_reference operator[](size_type) const; //@} //@{ //! Iterators inline iterator begin(); inline iterator end(); inline const_iterator begin() const; inline const_iterator end() const; inline const_iterator cbegin() const; inline const_iterator cend() const; //@} //@{ //! Capacity inline bool empty() const; inline size_type size() const; //@} //@{ //! Modifiers inline void clear(); inline void resize(size_type); //@} private: //// DATA //// std::vector<bool> storage_; }; //---------------------------------------------------------------------------// // FREE FUNCTIONS //---------------------------------------------------------------------------// std::ostream& operator<<(std::ostream& os, const SenseContainer& senses); //---------------------------------------------------------------------------// } // namespace celeritas //---------------------------------------------------------------------------// // INLINE DEFINITIONS //---------------------------------------------------------------------------// #include "SenseContainer.i.hh" //---------------------------------------------------------------------------//
27.835165
79
0.452033
celeritas-project
923150a8beb661e41363361d78cf8605f67648c1
1,876
cpp
C++
19_RegularExpressionsMatching/RegularExpressions.cpp
tcandzq/coding-interviews
12e29cd59b0773577eddd6868d9381247f3a9fde
[ "MIT" ]
2
2020-07-26T08:57:12.000Z
2020-09-21T01:56:47.000Z
19_RegularExpressionsMatching/RegularExpressions.cpp
tcandzq/coding-interviews
12e29cd59b0773577eddd6868d9381247f3a9fde
[ "MIT" ]
null
null
null
19_RegularExpressionsMatching/RegularExpressions.cpp
tcandzq/coding-interviews
12e29cd59b0773577eddd6868d9381247f3a9fde
[ "MIT" ]
null
null
null
// 面试题19:正则表达式匹配 // 题目:请实现一个函数用来匹配包含'.'和'*'的正则表达式。模式中的字符'.' // 表示任意一个字符,而'*'表示它前面的字符可以出现任意次(含0次)。在本题 // 中,匹配是指字符串的所有字符匹配整个模式。例如,字符串"aaa"与模式"a.a" // 和"ab*ac*a"匹配,但与"aa.a"及"ab*a"均不匹配。 /* 同leetcode https://leetcode-cn.com/problems/regular-expression-matching/ 10. 正则表达式匹配 分情况讨论: //如果模式串当前字符的下一位是 *: 如果当前字符匹配成功: 1. str + 1; pattern + 2; 利用* 可以匹配前面字符出现1次 2. str + 1; pattern; 利用 * 可以匹配前面字符多次(大于1) ,防止当前字符重复出现多次,这样继续留在模式串的当前位置可以匹配重复的那部分,跳过的话就失去了*的这个功能。 比如 str = "aaaaaab" pattern = .*b。 3. str; pattern + 2; 考虑 str = aaab pattern = aaabb*。此时aaab就可以匹配了,那多了的 b* 也无所谓,因为 b* 可以是匹配0次 b,相当于 b * 可以直接去掉了。 如果当前字符没有匹配成功 否则: 如果 字符串和模式串的当前字符偶读匹配成功 字符串和模式串均向后移动一位 str + 1; pattern + 1; 匹配失败 参考:https://leetcode-cn.com/problems/regular-expression-matching/solution/dong-tai-gui-hua-zen-yao-cong-0kai-shi-si-kao-da-b/ */ #include<fstream> bool match(char* str,char* pattern) { if(str == nullptr || pattern == nullptr) return false; return matchCore(str, pattern); } bool matchCore(const char* str,const char* pattern) { if(*str == '\0' && *pattern == '\0') return true; if(*str != '\0' && *pattern == '\0') return false; if (*(pattern+1) == '*') { if(*pattern == *str || (*pattern == '.' && *str != '\0')) // 进入有限状态机的下一个状态 return matchCore(str+1,pattern+2) // 继续留在有限状态机的当前状态 || matchCore(str+1,pattern) // // 略过一个'*' || matchCore(str,pattern+2); else // 略过一个'*' return matchCore(str,pattern+2); } if(*str == *pattern || (*pattern == '.' && *str != '\0')) return matchCore(str + 1, pattern + 1); return false; }
25.69863
124
0.534115
tcandzq
9237ffce68c33af3456a590081ee8855b2d87591
2,520
hpp
C++
examples/interpolate1d/interpolate1d/partition.hpp
McKillroy/hpx
f1bcb93f90a0b3c96e5fb3423028f0347f17f943
[ "BSL-1.0" ]
null
null
null
examples/interpolate1d/interpolate1d/partition.hpp
McKillroy/hpx
f1bcb93f90a0b3c96e5fb3423028f0347f17f943
[ "BSL-1.0" ]
null
null
null
examples/interpolate1d/interpolate1d/partition.hpp
McKillroy/hpx
f1bcb93f90a0b3c96e5fb3423028f0347f17f943
[ "BSL-1.0" ]
null
null
null
// Copyright (c) 2007-2017 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(HPX_PARTITION_AUG_04_2011_0251PM) #define HPX_PARTITION_AUG_04_2011_0251PM #include <hpx/hpx.hpp> #include <hpx/include/client.hpp> #include <cstddef> #include <string> #include "server/partition.hpp" /////////////////////////////////////////////////////////////////////////////// namespace interpolate1d { class partition : public hpx::components::client_base<partition, server::partition> { private: typedef hpx::components::client_base<partition, server::partition> base_type; public: // create a new partition instance and initialize it synchronously partition(std::string const& datafilename, dimension const& dim, std::size_t num_nodes) : base_type(hpx::new_<server::partition>(hpx::find_here())) { init(datafilename, dim, num_nodes); } partition(hpx::id_type id, std::string const& datafilename, dimension const& dim, std::size_t num_nodes) : base_type(hpx::new_<server::partition>(id)) { init(datafilename, dim, num_nodes); } partition(hpx::naming::id_type gid) : base_type(gid) {} // initialize this partition hpx::lcos::future<void> init_async(std::string const& datafilename, dimension const& dim, std::size_t num_nodes) { typedef server::partition::init_action init_action; return hpx::async(init_action(), this->get_id(), datafilename, dim, num_nodes); } void init(std::string const& datafilename, dimension const& dim, std::size_t num_nodes) { init_async(datafilename, dim, num_nodes).get(); } // ask this partition to interpolate, note that value must be in the // range valid for this partition hpx::lcos::future<double> interpolate_async(double value) const { typedef server::partition::interpolate_action interpolate_action; return hpx::async(interpolate_action(), this->get_id(), value); } double interpolate(double value) const { return interpolate_async(value).get(); } }; } #endif
30.731707
80
0.602778
McKillroy
923d20c17f78d19485a495842b2c68e518f25270
174
cpp
C++
src/Engine/Renderer2/D3D11/Renderer_ShaderD3D11.cpp
MasonLeeBack/RSEngine
9ac4a0380898cb59a48d29dc7250dfb70430932f
[ "MIT" ]
1
2019-01-03T13:42:10.000Z
2019-01-03T13:42:10.000Z
src/Engine/Renderer2/D3D11/Renderer_ShaderD3D11.cpp
MasonLeeBack/RSEngine
9ac4a0380898cb59a48d29dc7250dfb70430932f
[ "MIT" ]
2
2019-01-03T19:00:42.000Z
2019-01-03T19:02:16.000Z
src/Engine/Renderer2/D3D11/Renderer_ShaderD3D11.cpp
MasonLeeBack/RSEngine
9ac4a0380898cb59a48d29dc7250dfb70430932f
[ "MIT" ]
null
null
null
/* RSEngine Copyright (c) 2020 Mason Lee Back File name: Renderer_ShaderD3D11.cpp */ #include <Renderer2/D3D11/Renderer_ShaderD3D11.h> namespace rs { } // namespace rs
11.6
49
0.741379
MasonLeeBack
923d3315b54761616f2a1f5afb6f8a22a7b80502
9,453
cpp
C++
src/GUI/ReadWrite.cpp
Olddies710/The-Forgotten-Client
8b7979619ea76bc29581122440d09f241afc175d
[ "Zlib" ]
1
2022-01-15T00:00:27.000Z
2022-01-15T00:00:27.000Z
src/GUI/ReadWrite.cpp
Olddies710/The-Forgotten-Client
8b7979619ea76bc29581122440d09f241afc175d
[ "Zlib" ]
null
null
null
src/GUI/ReadWrite.cpp
Olddies710/The-Forgotten-Client
8b7979619ea76bc29581122440d09f241afc175d
[ "Zlib" ]
3
2021-10-14T02:36:56.000Z
2022-03-22T21:03:31.000Z
/* The Forgotten Client Copyright (C) 2020 Saiyans King This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "GUI_UTIL.h" #include "../engine.h" #include "../GUI_Elements/GUI_Window.h" #include "../GUI_Elements/GUI_Button.h" #include "../GUI_Elements/GUI_Separator.h" #include "../GUI_Elements/GUI_Label.h" #include "../GUI_Elements/GUI_MultiTextBox.h" #include "../GUI_Elements/GUI_StaticImage.h" #include "../game.h" #include "../thingManager.h" #include "ReadWrite.h" #define TEXT_WINDOW_TITLE1 "Show Text" #define TEXT_WINDOW_TITLE2 "Edit Text" #define TEXT_WINDOW_TITLE3 "Edit List" #define TEXT_WINDOW_WIDTH 286 #define TEXT_WINDOW_HEIGHT 284 #define TEXT_WINDOW_CANCEL_EVENTID 1000 #define TEXT_WINDOW_WRITE_EVENTID 1001 #define TEXT_WINDOW_EDIT_EVENTID 1002 #define TEXT_WINDOW_DESCRIPTION_X 62 #define TEXT_WINDOW_DESCRIPTION_Y 32 #define TEXT_WINDOW_ITEM_X 18 #define TEXT_WINDOW_ITEM_Y 32 #define TEXT_WINDOW_ITEM_W GUI_UI_ICON_EDITLIST_W #define TEXT_WINDOW_ITEM_H GUI_UI_ICON_EDITLIST_H #define TEXT_WINDOW_TEXTBOX_X 18 #define TEXT_WINDOW_TEXTBOX_Y 92 #define TEXT_WINDOW_TEXTBOX_W 250 #define TEXT_WINDOW_TEXTBOX_H 132 #define TEXT_WINDOW_TEXTBOX_EVENTID 1003 extern Engine g_engine; extern Game g_game; Uint32 g_windowId = 0; Uint8 g_doorId = 0; void readwrite_Events(Uint32 event, Sint32) { switch(event) { case TEXT_WINDOW_CANCEL_EVENTID: { GUI_Window* pWindow = g_engine.getCurrentWindow(); if(pWindow && pWindow->getInternalID() == GUI_WINDOW_READWRITE) g_engine.removeWindow(pWindow); } break; case TEXT_WINDOW_WRITE_EVENTID: { GUI_Window* pWindow = g_engine.getCurrentWindow(); if(pWindow && pWindow->getInternalID() == GUI_WINDOW_READWRITE) { GUI_MultiTextBox* pTextBox = SDL_static_cast(GUI_MultiTextBox*, pWindow->getChild(TEXT_WINDOW_TEXTBOX_EVENTID)); if(pTextBox) g_game.sendTextWindow(g_windowId, pTextBox->getText()); g_engine.removeWindow(pWindow); } } break; case TEXT_WINDOW_EDIT_EVENTID: { GUI_Window* pWindow = g_engine.getCurrentWindow(); if(pWindow && pWindow->getInternalID() == GUI_WINDOW_READWRITE) { GUI_MultiTextBox* pTextBox = SDL_static_cast(GUI_MultiTextBox*, pWindow->getChild(TEXT_WINDOW_TEXTBOX_EVENTID)); if(pTextBox) g_game.sendHouseWindow(g_windowId, g_doorId, pTextBox->getText()); g_engine.removeWindow(pWindow); } } break; default: break; } } void UTIL_createReadWriteWindow(Uint32 windowId, void* item, Uint16 maxLen, const std::string& text, const std::string& writer, const std::string& date) { GUI_Window* pWindow = g_engine.getWindow(GUI_WINDOW_READWRITE); if(pWindow) g_engine.removeWindow(pWindow); g_windowId = windowId; Uint16 maxLength = maxLen; bool writeAble = false; ItemUI* itemUI = SDL_reinterpret_cast(ItemUI*, item); if(itemUI && itemUI->getThingType()) { ThingType* itemType = itemUI->getThingType(); if(itemType->hasFlag(ThingAttribute_WritableOnce) || itemType->hasFlag(ThingAttribute_Writable)) { //Should we leave maxlen that we got from server? maxLength = itemType->m_writableSize; writeAble = (itemType->hasFlag(ThingAttribute_WritableOnce) ? text.empty() : true); } } if(!text.empty()) { if(!writer.empty()) { if(!date.empty()) SDL_snprintf(g_buffer, sizeof(g_buffer), "You read the following, written by \n%s\non %s.", writer.c_str(), date.c_str()); else SDL_snprintf(g_buffer, sizeof(g_buffer), "\nYou read the following, written by \n%s", writer.c_str()); } else if(!date.empty()) SDL_snprintf(g_buffer, sizeof(g_buffer), "\nYou read the following, written on \n%s.", date.c_str()); else SDL_snprintf(g_buffer, sizeof(g_buffer), "\n\nYou read the following:"); } else { if(writeAble) SDL_snprintf(g_buffer, sizeof(g_buffer), "\n\nIt is currently empty."); else SDL_snprintf(g_buffer, sizeof(g_buffer), "\n\nIt is empty."); } std::string description(g_buffer); if(writeAble) description.append("\nYou can enter new text."); else description.insert(0, "\n"); GUI_Window* newWindow = new GUI_Window(iRect(0, 0, TEXT_WINDOW_WIDTH, TEXT_WINDOW_HEIGHT), (writeAble ? TEXT_WINDOW_TITLE2 : TEXT_WINDOW_TITLE1), GUI_WINDOW_READWRITE); GUI_Label* newLabel = new GUI_Label(iRect(TEXT_WINDOW_DESCRIPTION_X, TEXT_WINDOW_DESCRIPTION_Y, 0, 0), std::move(description)); newWindow->addChild(newLabel); GUI_ReadWriteItem* newImage = new GUI_ReadWriteItem(iRect(TEXT_WINDOW_ITEM_X, TEXT_WINDOW_ITEM_Y, TEXT_WINDOW_ITEM_W, TEXT_WINDOW_ITEM_H), itemUI); newWindow->addChild(newImage); GUI_MultiTextBox* newTextBox = new GUI_MultiTextBox(iRect(TEXT_WINDOW_TEXTBOX_X, TEXT_WINDOW_TEXTBOX_Y, TEXT_WINDOW_TEXTBOX_W, TEXT_WINDOW_TEXTBOX_H), writeAble, text, TEXT_WINDOW_TEXTBOX_EVENTID); newTextBox->setMaxLength(SDL_static_cast(Uint32, maxLength)); newTextBox->startEvents(); newWindow->addChild(newTextBox); if(writeAble) { GUI_Button* newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 56, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Cancel", CLIENT_GUI_ESCAPE_TRIGGER); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_CANCEL_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 109, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Ok"); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_WRITE_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); } else { GUI_Button* newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 56, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Ok", CLIENT_GUI_ESCAPE_TRIGGER); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_CANCEL_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 56, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Ok", CLIENT_GUI_ENTER_TRIGGER); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_CANCEL_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); newTextBox->setColor(175, 175, 175); } GUI_Separator* newSeparator = new GUI_Separator(iRect(13, TEXT_WINDOW_HEIGHT - 40, TEXT_WINDOW_WIDTH - 26, 2)); newWindow->addChild(newSeparator); g_engine.addWindow(newWindow); } void UTIL_createReadWriteWindow(Uint8 doorId, Uint32 windowId, const std::string& text) { GUI_Window* pWindow = g_engine.getWindow(GUI_WINDOW_READWRITE); if(pWindow) g_engine.removeWindow(pWindow); g_windowId = windowId; g_doorId = doorId; GUI_Window* newWindow = new GUI_Window(iRect(0, 0, TEXT_WINDOW_WIDTH, TEXT_WINDOW_HEIGHT), TEXT_WINDOW_TITLE3, GUI_WINDOW_READWRITE); GUI_Label* newLabel = new GUI_Label(iRect(TEXT_WINDOW_DESCRIPTION_X, TEXT_WINDOW_DESCRIPTION_Y, 0, 0), "\n\n\nEnter one name per line."); newWindow->addChild(newLabel); GUI_StaticImage* newImage = new GUI_StaticImage(iRect(TEXT_WINDOW_ITEM_X, TEXT_WINDOW_ITEM_Y, TEXT_WINDOW_ITEM_W, TEXT_WINDOW_ITEM_H), GUI_UI_IMAGE, GUI_UI_ICON_EDITLIST_X, GUI_UI_ICON_EDITLIST_Y); newWindow->addChild(newImage); GUI_MultiTextBox* newTextBox = new GUI_MultiTextBox(iRect(TEXT_WINDOW_TEXTBOX_X, TEXT_WINDOW_TEXTBOX_Y, TEXT_WINDOW_TEXTBOX_W, TEXT_WINDOW_TEXTBOX_H), true, text, TEXT_WINDOW_TEXTBOX_EVENTID); newTextBox->setMaxLength(8192); newTextBox->startEvents(); newWindow->addChild(newTextBox); GUI_Button* newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 56, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Cancel", CLIENT_GUI_ESCAPE_TRIGGER); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_CANCEL_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); newButton = new GUI_Button(iRect(TEXT_WINDOW_WIDTH - 109, TEXT_WINDOW_HEIGHT - 30, GUI_UI_BUTTON_43PX_GRAY_UP_W, GUI_UI_BUTTON_43PX_GRAY_UP_H), "Ok"); newButton->setButtonEventCallback(&readwrite_Events, TEXT_WINDOW_EDIT_EVENTID); newButton->startEvents(); newWindow->addChild(newButton); GUI_Separator* newSeparator = new GUI_Separator(iRect(13, TEXT_WINDOW_HEIGHT - 40, TEXT_WINDOW_WIDTH - 26, 2)); newWindow->addChild(newSeparator); g_engine.addWindow(newWindow); } GUI_ReadWriteItem::GUI_ReadWriteItem(iRect boxRect, ItemUI* item, Uint32 internalID) { setRect(boxRect); m_internalID = internalID; m_item = item; } GUI_ReadWriteItem::~GUI_ReadWriteItem() { if(m_item) delete m_item; } void GUI_ReadWriteItem::render() { if(m_item) m_item->render(m_tRect.x1, m_tRect.y1, m_tRect.y2); }
40.055085
198
0.780281
Olddies710
923f1ca2fb8280e4e0fa9d1260373d30fb265c5b
9,021
cpp
C++
QTermWidget/lib/qtermwidget.cpp
rkoyama1623/Quantum
429d11f0b2c737164005ba70c98611baef69d1c5
[ "Unlicense" ]
35
2015-01-13T00:57:17.000Z
2022-03-16T20:39:56.000Z
QTermWidget/lib/qtermwidget.cpp
KR8T3R/Quantum
429d11f0b2c737164005ba70c98611baef69d1c5
[ "Unlicense" ]
null
null
null
QTermWidget/lib/qtermwidget.cpp
KR8T3R/Quantum
429d11f0b2c737164005ba70c98611baef69d1c5
[ "Unlicense" ]
31
2015-01-29T03:59:52.000Z
2022-03-16T20:40:43.000Z
/* Copyright (C) 2008 e_k (e_k@users.sourceforge.net) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "qtermwidget.h" #include "ColorTables.h" #include "Session.h" #include "TerminalDisplay.h" #include "KeyboardTranslator.h" #include "ColorScheme.h" using namespace Konsole; void *createTermWidget(int startnow, void *parent) { return (void*) new QTermWidget(startnow, (QWidget*)parent); } struct TermWidgetImpl { TermWidgetImpl(QWidget* parent = 0); TerminalDisplay *m_terminalDisplay; Session *m_session; Session* createSession(); TerminalDisplay* createTerminalDisplay(Session *session, QWidget* parent); }; TermWidgetImpl::TermWidgetImpl(QWidget* parent) { this->m_session = createSession(); this->m_terminalDisplay = createTerminalDisplay(this->m_session, parent); } Session *TermWidgetImpl::createSession() { Session *session = new Session(); session->setTitle(Session::NameRole, "QTermWidget"); /* Thats a freaking bad idea!!!! * /bin/bash is not there on every system * better set it to the current $SHELL * Maybe you can also make a list available and then let the widget-owner decide what to use. * By setting it to $SHELL right away we actually make the first filecheck obsolete. * But as iam not sure if you want to do anything else ill just let both checks in and set this to $SHELL anyway. */ //session->setProgram("/bin/bash"); session->setProgram(getenv("SHELL")); QStringList args(""); session->setArguments(args); session->setAutoClose(true); session->setCodec(QTextCodec::codecForName("UTF-8")); session->setFlowControlEnabled(true); session->setHistoryType(HistoryTypeBuffer(1000)); session->setDarkBackground(true); session->setKeyBindings(""); return session; } TerminalDisplay *TermWidgetImpl::createTerminalDisplay(Session *session, QWidget* parent) { // TerminalDisplay* display = new TerminalDisplay(this); TerminalDisplay* display = new TerminalDisplay(parent); display->setBellMode(TerminalDisplay::NotifyBell); display->setTerminalSizeHint(true); display->setTripleClickMode(TerminalDisplay::SelectWholeLine); display->setTerminalSizeStartup(true); display->setRandomSeed(session->sessionId() * 31); return display; } QTermWidget::QTermWidget(int startnow, QWidget *parent) :QWidget(parent) { m_impl = new TermWidgetImpl(this); init(); if (startnow && m_impl->m_session) { m_impl->m_session->run(); } this->setFocus( Qt::OtherFocusReason ); m_impl->m_terminalDisplay->resize(this->size()); this->setFocusProxy(m_impl->m_terminalDisplay); connect(m_impl->m_terminalDisplay, SIGNAL(copyAvailable(bool)), this, SLOT(selectionChanged(bool))); connect(m_impl->m_terminalDisplay, SIGNAL(termGetFocus()), this, SIGNAL(termGetFocus())); connect(m_impl->m_terminalDisplay, SIGNAL(termLostFocus()), this, SIGNAL(termLostFocus())); } void QTermWidget::selectionChanged(bool textSelected) { emit copyAvailable(textSelected); } int QTermWidget::getShellPID() { return m_impl->m_session->processId(); } void QTermWidget::changeDir(const QString & dir) { /* this is a very hackish way of trying to determine if the shell is in the foreground before attempting to change the directory. It may not be portable to anything other than Linux. */ QString strCmd; strCmd.setNum(getShellPID()); strCmd.prepend("ps -j "); strCmd.append(" | tail -1 | awk '{ print $5 }' | grep -q \\+"); int retval = system(strCmd.toStdString().c_str()); if (!retval) { QString cmd = "cd " + dir + "\n"; sendText(cmd); } } QSize QTermWidget::sizeHint() const { QSize size = m_impl->m_terminalDisplay->sizeHint(); size.rheight() = 150; return size; } void QTermWidget::startShellProgram() { if ( m_impl->m_session->isRunning() ) { return; } m_impl->m_session->run(); } void QTermWidget::init() { m_impl->m_terminalDisplay->setSize(80, 40); QFont font = QApplication::font(); font.setFamily("Monospace"); font.setPointSize(10); font.setStyleHint(QFont::TypeWriter); setTerminalFont(font); setScrollBarPosition(NoScrollBar); m_impl->m_session->addView(m_impl->m_terminalDisplay); connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished())); } QTermWidget::~QTermWidget() { emit destroyed(); } void QTermWidget::setTerminalFont(QFont &font) { if (!m_impl->m_terminalDisplay) return; m_impl->m_terminalDisplay->setVTFont(font); } void QTermWidget::setTerminalOpacity(qreal level) { if (!m_impl->m_terminalDisplay) return; m_impl->m_terminalDisplay->setOpacity(level); } void QTermWidget::setShellProgram(const QString &progname) { if (!m_impl->m_session) return; m_impl->m_session->setProgram(progname); } void QTermWidget::setWorkingDirectory(const QString& dir) { if (!m_impl->m_session) return; m_impl->m_session->setInitialWorkingDirectory(dir); } void QTermWidget::setArgs(QStringList &args) { if (!m_impl->m_session) return; m_impl->m_session->setArguments(args); } void QTermWidget::setTextCodec(QTextCodec *codec) { if (!m_impl->m_session) return; m_impl->m_session->setCodec(codec); } void QTermWidget::setColorScheme(const QString & name) { const ColorScheme *cs; // avoid legacy (int) solution if (!availableColorSchemes().contains(name)) cs = ColorSchemeManager::instance()->defaultColorScheme(); else cs = ColorSchemeManager::instance()->findColorScheme(name); if (! cs) { QMessageBox::information(this, tr("Color Scheme Error"), tr("Cannot load color scheme: %1").arg(name)); return; } ColorEntry table[TABLE_COLORS]; cs->getColorTable(table); m_impl->m_terminalDisplay->setColorTable(table); } QStringList QTermWidget::availableColorSchemes() { QStringList ret; foreach (const ColorScheme* cs, ColorSchemeManager::instance()->allColorSchemes()) ret.append(cs->name()); return ret; } void QTermWidget::setSize(int h, int v) { if (!m_impl->m_terminalDisplay) return; m_impl->m_terminalDisplay->setSize(h, v); } void QTermWidget::setHistorySize(int lines) { if (lines < 0) m_impl->m_session->setHistoryType(HistoryTypeFile()); else m_impl->m_session->setHistoryType(HistoryTypeBuffer(lines)); } void QTermWidget::setScrollBarPosition(ScrollBarPosition pos) { if (!m_impl->m_terminalDisplay) return; m_impl->m_terminalDisplay->setScrollBarPosition((TerminalDisplay::ScrollBarPosition)pos); } void QTermWidget::sendText(QString &text) { m_impl->m_session->sendText(text); } void QTermWidget::resizeEvent(QResizeEvent*) { //qDebug("global window resizing...with %d %d", this->size().width(), this->size().height()); m_impl->m_terminalDisplay->resize(this->size()); } void QTermWidget::sessionFinished() { emit finished(); } void QTermWidget::copyClipboard() { m_impl->m_terminalDisplay->copyClipboard(); } void QTermWidget::pasteClipboard() { m_impl->m_terminalDisplay->pasteClipboard(); } void QTermWidget::setKeyBindings(const QString & kb) { m_impl->m_session->setKeyBindings(kb); } void QTermWidget::setFlowControlEnabled(bool enabled) { m_impl->m_session->setFlowControlEnabled(enabled); } QStringList QTermWidget::availableKeyBindings() { return KeyboardTranslatorManager::instance()->allTranslators(); } QString QTermWidget::keyBindings() { return m_impl->m_session->keyBindings(); } bool QTermWidget::flowControlEnabled(void) { return m_impl->m_session->flowControlEnabled(); } void QTermWidget::setFlowControlWarningEnabled(bool enabled) { if (flowControlEnabled()) { // Do not show warning label if flow control is disabled m_impl->m_terminalDisplay->setFlowControlWarningEnabled(enabled); } } void QTermWidget::setEnvironment(const QStringList& environment) { m_impl->m_session->setEnvironment(environment); }
25.627841
117
0.695156
rkoyama1623
9240205fd9fc33462aa38e45572ca65e546edbcf
834
cpp
C++
Data Structures/Prime Numbers/PrimeFactorization.cpp
ravikjha7/Competitive_Programming
86df773c258d6675bb3244030e6d71aa32e01fce
[ "MIT" ]
null
null
null
Data Structures/Prime Numbers/PrimeFactorization.cpp
ravikjha7/Competitive_Programming
86df773c258d6675bb3244030e6d71aa32e01fce
[ "MIT" ]
null
null
null
Data Structures/Prime Numbers/PrimeFactorization.cpp
ravikjha7/Competitive_Programming
86df773c258d6675bb3244030e6d71aa32e01fce
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define mod 1000000007 void file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } // Time Complexity : O(sqrt(N)) void FindPrime(ll n) { for(int i = 2; i <= sqrt(n); i++) { if(n % i == 0) { while(n % i == 0) { cout << i << " "; n /= i; } } } if(n != 1) cout << n; cout << endl; } void solve() { ll n; cin >> n; int i = 2; // Brute Force // Time Complexity : O(N) // while(n > 1) // { // if(n % i == 0) { // cout << i << " "; // n /= i; // } else { // i++; // } // } // cout << endl; FindPrime(n); } int main() { file(); ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while(t--) { solve(); } return 0; }
13.03125
39
0.479616
ravikjha7
924699cf6b0b84cdeeb997b187cde8ae93a8e977
8,356
cpp
C++
HW4_birdeye/src/example_18-01_from_disk.cpp
Citing/CV-Course
f3e062347fa1cea85ca57181c90f23ad577c0e8c
[ "MIT" ]
4
2019-12-14T11:21:54.000Z
2021-01-15T13:55:35.000Z
HW4_birdeye/src/example_18-01_from_disk.cpp
Citing/CV-Course
f3e062347fa1cea85ca57181c90f23ad577c0e8c
[ "MIT" ]
null
null
null
HW4_birdeye/src/example_18-01_from_disk.cpp
Citing/CV-Course
f3e062347fa1cea85ca57181c90f23ad577c0e8c
[ "MIT" ]
2
2020-11-26T13:04:08.000Z
2020-12-02T01:14:53.000Z
#define main e18_2 #define help help2 // Example 18-1. Reading a chessboard’s width and height, reading them from disk and calibrating // the requested number of views, and calibrating the camera // You need these includes for the function // #include <windows.h> // for windows systems #include <dirent.h> // for linux systems #include <sys/stat.h> // for linux systems #include <iostream> // cout #include <algorithm> // std::sort #include <opencv2/opencv.hpp> using std::string; using std::vector; using std::cout; using std::cerr; using std::endl; // Returns a list of files in a directory (except the ones that begin with a dot) int readFilenames(vector<string>& filenames, const string& directory) { DIR *dir; class dirent *ent; class stat st; dir = opendir(directory.c_str()); while ((ent = readdir(dir)) != NULL) { const string file_name = ent->d_name; const string full_file_name = directory + "/" + file_name; if (file_name[0] == '.') continue; if (stat(full_file_name.c_str(), &st) == -1) continue; const bool is_directory = (st.st_mode & S_IFDIR) != 0; if (is_directory) continue; // filenames.push_back(full_file_name); // returns full path filenames.push_back(file_name); // returns just filename } closedir(dir); std::sort(filenames.begin(), filenames.end()); // optional, sort the filenames return(filenames.size()); // return how many we found } // GetFilesInDirectory void help(const char **argv) { cout << "\n\n" << "Example 18-1 (from disk):\Enter a chessboard’s width and height,\n" << " reading in a directory of chessboard images,\n" << " and calibrating the camera\n\n" << "Call:\n" << argv[0] << " <1board_width> <2board_height> <3number_of_boards>" << " <4ms_delay_framee_capture> <5image_scaling_factor> <6path_to_calibration_images>\n\n" << "\nExample:\n" << "./example_18-01_from_disk 9 6 14 100 1.0 ../stereoData/\nor:\n" << "./example_18-01_from_disk 12 12 28 100 0.5 ../calibration/\n\n" << " * First it reads in checker boards and calibrates itself\n" << " * Then it saves and reloads the calibration matricies\n" << " * Then it creates an undistortion map and finaly\n" << " * It displays an undistorted image\n" << endl; } int main(int argc, char *argv[]) { float image_sf = 0.5f; // image scaling factor int delay = 250; // miliseconds int board_w = 0; int board_h = 0; board_w = atoi(argv[1]); board_h = atoi(argv[2]); int n_boards = atoi(argv[3]); // how many boards max to read delay = atof(argv[4]); // milisecond delay image_sf = atof(argv[5]); int board_n = board_w * board_h; // number of corners cv::Size board_sz = cv::Size(board_w, board_h); // width and height of the board string folder = argv[6]; cout << "Reading in directory " << folder << endl; vector<string> filenames; int num_files = readFilenames(filenames, folder); cout << " ... Done. Number of files = " << num_files << "\n" << endl; // PROVIDE PPOINT STORAGE // vector<vector<cv::Point2f> > image_points; vector<vector<cv::Point3f> > object_points; /////////// COLLECT ////////////////////////////////////////////// // Capture corner views: loop through all calibration images // collecting all corners on the boards that are found // cv::Size image_size; int board_count = 0; for (size_t i = 0; (i < filenames.size()) && (board_count < n_boards); ++i) { cv::Mat image, image0 = cv::imread(folder + filenames[i]); board_count += 1; if (!image0.data) { // protect against no file cerr << folder + filenames[i] << ", file #" << i << ", is not an image" << endl; continue; } image_size = image0.size(); cv::resize(image0, image, cv::Size(), image_sf, image_sf, cv::INTER_LINEAR); // Find the board // vector<cv::Point2f> corners; bool found = cv::findChessboardCorners(image, board_sz, corners); // Draw it // drawChessboardCorners(image, board_sz, corners, found); // will draw only if found // If we got a good board, add it to our data // if (found) { image ^= cv::Scalar::all(255); cv::Mat mcorners(corners); // do not copy the data mcorners *= (1.0 / image_sf); // scale the corner coordinates image_points.push_back(corners); object_points.push_back(vector<cv::Point3f>()); vector<cv::Point3f> &opts = object_points.back(); opts.resize(board_n); for (int j = 0; j < board_n; j++) { opts[j] = cv::Point3f(static_cast<float>(j / board_w), static_cast<float>(j % board_w), 0.0f); } cout << "Collected " << static_cast<int>(image_points.size()) << "total boards. This one from chessboard image #" << i << ", " << folder + filenames[i] << endl; } cv::imshow("Calibration", image); // show in color if we did collect the image if ((cv::waitKey(delay) & 255) == 27) { return -1; } } // END COLLECTION WHILE LOOP. cv::destroyWindow("Calibration"); cout << "\n\n*** CALIBRATING THE CAMERA...\n" << endl; /////////// CALIBRATE ////////////////////////////////////////////// // CALIBRATE THE CAMERA! // cv::Mat intrinsic_matrix, distortion_coeffs; double err = cv::calibrateCamera( object_points, image_points, image_size, intrinsic_matrix, distortion_coeffs, cv::noArray(), cv::noArray(), cv::CALIB_ZERO_TANGENT_DIST | cv::CALIB_FIX_PRINCIPAL_POINT); // SAVE THE INTRINSICS AND DISTORTIONS cout << " *** DONE!\n\nReprojection error is " << err << "\nStoring Intrinsics.xml and Distortions.xml files\n\n"; cv::FileStorage fs("intrinsics.xml", cv::FileStorage::WRITE); fs << "image_width" << image_size.width << "image_height" << image_size.height << "camera_matrix" << intrinsic_matrix << "distortion_coefficients" << distortion_coeffs; fs.release(); // EXAMPLE OF LOADING THESE MATRICES BACK IN: fs.open("intrinsics.xml", cv::FileStorage::READ); cout << "\nimage width: " << static_cast<int>(fs["image_width"]); cout << "\nimage height: " << static_cast<int>(fs["image_height"]); cv::Mat intrinsic_matrix_loaded, distortion_coeffs_loaded; fs["camera_matrix"] >> intrinsic_matrix_loaded; fs["distortion_coefficients"] >> distortion_coeffs_loaded; cout << "\nintrinsic matrix:" << intrinsic_matrix_loaded; cout << "\ndistortion coefficients: " << distortion_coeffs_loaded << "\n" << endl; // Build the undistort map which we will use for all // subsequent frames. // cv::Mat map1, map2; cv::initUndistortRectifyMap(intrinsic_matrix_loaded, distortion_coeffs_loaded, cv::Mat(), intrinsic_matrix_loaded, image_size, CV_16SC2, map1, map2); ////////// DISPLAY ////////////////////////////////////////////// cout << "*****************\nPRESS A KEY TO SEE THE NEXT IMAGE, ESQ TO QUIT\n" << "****************\n" << endl; board_count = 0; // resent max boards to read for (size_t i = 0; (i < filenames.size()) && (board_count < n_boards); ++i) { cv::Mat image, image0 = cv::imread(folder + filenames[i]); ++board_count; if (!image0.data) { // protect against no file cerr << folder + filenames[i] << ", file #" << i << ", is not an image" << endl; continue; } // Just run the camera to the screen, now showing the raw and // the undistorted image. // cv::remap(image0, image, map1, map2, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar()); cv::imshow("Original", image0); cv::imshow("Undistorted", image); if ((cv::waitKey(0) & 255) == 27) { break; } } return 0; }
38.865116
99
0.575156
Citing
924e33aff8698577d8e01d40e776b8930c09ca31
920
hpp
C++
SDK/ARKSurvivalEvolved_BoneModifiersContainer_ChibiThylacoleo_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
10
2020-02-17T19:08:46.000Z
2021-07-31T11:07:19.000Z
SDK/ARKSurvivalEvolved_BoneModifiersContainer_ChibiThylacoleo_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
9
2020-02-17T18:15:41.000Z
2021-06-06T19:17:34.000Z
SDK/ARKSurvivalEvolved_BoneModifiersContainer_ChibiThylacoleo_classes.hpp
2bite/ARK-SDK
c38ca9925309516b2093ad8c3a70ed9489e1d573
[ "MIT" ]
3
2020-07-22T17:42:07.000Z
2021-06-19T17:16:13.000Z
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_BoneModifiersContainer_ChibiThylacoleo_structs.hpp" namespace sdk { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BoneModifiersContainer_ChibiThylacoleo.BoneModifiersContainer_ChibiThylacoleo_C // 0x0000 (0x0038 - 0x0038) class UBoneModifiersContainer_ChibiThylacoleo_C : public UBoneModifiersContainer_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BoneModifiersContainer_ChibiThylacoleo.BoneModifiersContainer_ChibiThylacoleo_C"); return ptr; } void ExecuteUbergraph_BoneModifiersContainer_ChibiThylacoleo(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
23.589744
146
0.68587
2bite
9250c4276c9287cf4fabf1563d07006eba3cc982
8,629
cpp
C++
pgadmin/schema/pgTextSearchConfiguration.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
pgadmin/schema/pgTextSearchConfiguration.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
pgadmin/schema/pgTextSearchConfiguration.cpp
jinfroster/pgadmin3
8d573a7f13a8b4161225363f1972d75004589275
[ "PostgreSQL" ]
null
null
null
////////////////////////////////////////////////////////////////////////// // // pgAdmin III - PostgreSQL Tools // // Copyright (C) 2002 - 2014, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // // pgTextSearchConfiguration.cpp - Text Search Configuration class // ////////////////////////////////////////////////////////////////////////// // wxWindows headers #include <wx/wx.h> // App headers #include "pgAdmin3.h" #include "utils/misc.h" #include "schema/pgTextSearchConfiguration.h" pgTextSearchConfiguration::pgTextSearchConfiguration(pgSchema *newSchema, const wxString &newName) : pgSchemaObject(newSchema, textSearchConfigurationFactory, newName) { } pgTextSearchConfiguration::~pgTextSearchConfiguration() { } wxString pgTextSearchConfiguration::GetTranslatedMessage(int kindOfMessage) const { wxString message = wxEmptyString; switch (kindOfMessage) { case RETRIEVINGDETAILS: message = _("Retrieving details on FTS configuration"); message += wxT(" ") + GetName(); break; case REFRESHINGDETAILS: message = _("Refreshing FTS configuration"); message += wxT(" ") + GetName(); break; case DROPINCLUDINGDEPS: message = wxString::Format(_("Are you sure you wish to drop FTS configuration \"%s\" including all objects that depend on it?"), GetFullIdentifier().c_str()); break; case DROPEXCLUDINGDEPS: message = wxString::Format(_("Are you sure you wish to drop FTS configuration \"%s\"?"), GetFullIdentifier().c_str()); break; case DROPCASCADETITLE: message = _("Drop FTS configuration cascaded?"); break; case DROPTITLE: message = _("Drop FTS configuration?"); break; case PROPERTIESREPORT: message = _("FTS configuration properties report"); message += wxT(" - ") + GetName(); break; case PROPERTIES: message = _("FTS configuration properties"); break; case DDLREPORT: message = _("FTS configuration DDL report"); message += wxT(" - ") + GetName(); break; case DDL: message = _("FTS configuration DDL"); break; case DEPENDENCIESREPORT: message = _("FTS configuration dependencies report"); message += wxT(" - ") + GetName(); break; case DEPENDENCIES: message = _("FTS configuration dependencies"); break; case DEPENDENTSREPORT: message = _("FTS configuration dependents report"); message += wxT(" - ") + GetName(); break; case DEPENDENTS: message = _("FTS configuration dependents"); break; } return message; } bool pgTextSearchConfiguration::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded) { wxString sql = wxT("DROP TEXT SEARCH CONFIGURATION ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(this->GetIdentifier()); if (cascaded) sql += wxT(" CASCADE"); return GetDatabase()->ExecuteVoid(sql); } wxString pgTextSearchConfiguration::GetSql(ctlTree *browser) { if (sql.IsNull()) { sql = wxT("-- Text Search Configuration: ") + GetFullIdentifier() + wxT("\n\n") + wxT("-- DROP TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT("\n\n") + wxT("CREATE TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT(" (") + wxT("\n PARSER = ") + qtTypeIdent(GetParser()) + wxT("\n);\n"); for (size_t i = 0 ; i < tokens.GetCount() ; i++) sql += wxT("ALTER TEXT SEARCH CONFIGURATION ") + GetQuotedFullIdentifier() + wxT(" ADD MAPPING FOR ") + tokens.Item(i).BeforeFirst('/') + wxT(" WITH ") + tokens.Item(i).AfterFirst('/') + wxT(";\n"); if (!GetComment().IsNull()) sql += wxT("COMMENT ON TEXT SEARCH CONFIGURATION ") + GetFullIdentifier() + wxT(" IS ") + qtDbString(GetComment()) + wxT(";\n"); } return sql; } void pgTextSearchConfiguration::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane) { if (properties) { CreateListColumns(properties); properties->AppendItem(_("Name"), GetName()); properties->AppendItem(_("OID"), GetOid()); properties->AppendItem(_("Owner"), GetOwner()); properties->AppendItem(_("Parser"), GetParser()); properties->AppendItem(_("Comment"), firstLineOnly(GetComment())); } } pgObject *pgTextSearchConfiguration::Refresh(ctlTree *browser, const wxTreeItemId item) { pgObject *config = 0; pgCollection *coll = browser->GetParentCollection(item); if (coll) config = textSearchConfigurationFactory.CreateObjects(coll, 0, wxT("\n AND cfg.oid=") + GetOidStr()); return config; } /////////////////////////////////////////////////// pgTextSearchConfigurationCollection::pgTextSearchConfigurationCollection(pgaFactory *factory, pgSchema *sch) : pgSchemaObjCollection(factory, sch) { } wxString pgTextSearchConfigurationCollection::GetTranslatedMessage(int kindOfMessage) const { wxString message = wxEmptyString; switch (kindOfMessage) { case RETRIEVINGDETAILS: message = _("Retrieving details on FTS configurations"); break; case REFRESHINGDETAILS: message = _("Refreshing FTS configurations"); break; case OBJECTSLISTREPORT: message = _("FTS configurations list report"); break; } return message; } ////////////////////////////////////////////////////// pgObject *pgTextSearchConfigurationFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &restriction) { pgTextSearchConfiguration *config = 0; pgSet *configurations; configurations = collection->GetDatabase()->ExecuteSet( wxT("SELECT cfg.oid, cfg.cfgname, pg_get_userbyid(cfg.cfgowner) as cfgowner, cfg.cfgparser, parser.prsname as parsername, description\n") wxT(" FROM pg_ts_config cfg\n") wxT(" LEFT OUTER JOIN pg_ts_parser parser ON parser.oid=cfg.cfgparser\n") wxT(" LEFT OUTER JOIN pg_description des ON (des.objoid=cfg.oid AND des.classoid='pg_ts_config'::regclass)\n") wxT(" WHERE cfg.cfgnamespace = ") + collection->GetSchema()->GetOidStr() + restriction + wxT("\n") wxT(" ORDER BY cfg.cfgname")); if (configurations) { while (!configurations->Eof()) { config = new pgTextSearchConfiguration(collection->GetSchema(), configurations->GetVal(wxT("cfgname"))); config->iSetOid(configurations->GetOid(wxT("oid"))); config->iSetOwner(configurations->GetVal(wxT("cfgowner"))); config->iSetComment(configurations->GetVal(wxT("description"))); config->iSetParser(configurations->GetVal(wxT("parsername"))); config->iSetParserOid(configurations->GetOid(wxT("cfgparser"))); pgSet *maps; maps = collection->GetDatabase()->ExecuteSet( wxT("SELECT\n") wxT(" (SELECT t.alias FROM pg_catalog.ts_token_type(cfgparser) AS t") wxT(" WHERE t.tokid = maptokentype) AS tokenalias,\n") wxT(" dictname\n") wxT("FROM pg_ts_config_map\n") wxT(" LEFT OUTER JOIN pg_ts_config ON mapcfg=pg_ts_config.oid\n") wxT(" LEFT OUTER JOIN pg_ts_dict ON mapdict=pg_ts_dict.oid\n") wxT("WHERE mapcfg=") + config->GetOidStr() + wxT("\n") wxT("ORDER BY 1, mapseqno")); if (maps) { wxString tokenToAdd; while (!maps->Eof()) { if (tokenToAdd.Length() > 0 && !tokenToAdd.BeforeFirst('/').IsSameAs(maps->GetVal(wxT("tokenalias")), false)) { config->GetTokens().Add(tokenToAdd); tokenToAdd = wxT(""); } if (tokenToAdd.Length() == 0) tokenToAdd = maps->GetVal(wxT("tokenalias")) + wxT("/") + maps->GetVal(wxT("dictname")); else tokenToAdd += wxT(",") + maps->GetVal(wxT("dictname")); maps->MoveNext(); } delete maps; } if (browser) { browser->AppendObject(collection, config); configurations->MoveNext(); } else break; } delete configurations; } return config; } #include "images/configuration.pngc" #include "images/configurations.pngc" pgTextSearchConfigurationFactory::pgTextSearchConfigurationFactory() : pgSchemaObjFactory(__("FTS Configuration"), __("New FTS Configuration..."), __("Create a new FTS Configuration."), configuration_png_img) { } pgCollection *pgTextSearchConfigurationFactory::CreateCollection(pgObject *obj) { return new pgTextSearchConfigurationCollection(GetCollectionFactory(), (pgSchema *)obj); } pgTextSearchConfigurationFactory textSearchConfigurationFactory; static pgaCollectionFactory cf(&textSearchConfigurationFactory, __("FTS Configurations"), configurations_png_img);
31.039568
159
0.651872
jinfroster
9257cb0b19647e7db2a84ae5a346f6c96efbaaff
12,986
cpp
C++
VGP330/11_HelloPostProcessing/GameState.cpp
TheJimmyGod/JimmyGod_Engine
b9752c6fbd9db17dc23f03330b5e4537bdcadf8e
[ "MIT" ]
null
null
null
VGP330/11_HelloPostProcessing/GameState.cpp
TheJimmyGod/JimmyGod_Engine
b9752c6fbd9db17dc23f03330b5e4537bdcadf8e
[ "MIT" ]
null
null
null
VGP330/11_HelloPostProcessing/GameState.cpp
TheJimmyGod/JimmyGod_Engine
b9752c6fbd9db17dc23f03330b5e4537bdcadf8e
[ "MIT" ]
null
null
null
#include "GameState.h" #include <ImGui/Inc/imgui.h> using namespace JimmyGod::Input; using namespace JimmyGod::Graphics; using namespace JimmyGod::Math; static bool ActiveRadialBlur = false; static bool ActiveGaussianBlur = false; static bool ActiveGreyscale = false; static bool ActiveNegative = false; static bool cloudMap = true; void GameState::Initialize() { GraphicsSystem::Get()->SetClearColor(Colors::Gray); mCamera.SetPosition({ 0.0f,0.0f,-200.0f }); mCamera.SetDirection({ 0.0f,0.0f,1.0f }); mMesh = MeshBuilder::CreateSphere(50.0f,64,64); mMeshBuffer.Initialize(mMesh); mTransformBuffer.Initialize(); mLightBuffer.Initialize(); mMaterialBuffer.Initialize(); mDirectionalLight.direction = Normalize({ 1.0f, -1.0f, 1.0f }); mDirectionalLight.ambient = { 0.2f, 0.2f, 0.2f, 1.0f }; mDirectionalLight.diffuse = { 0.75f,0.75f,0.75f,1.0f }; mDirectionalLight.specular = { 0.5f,0.5f,0.5f,1.0f }; mMaterial.ambient = { 1.0f }; mMaterial.diffuse = { 1.0f }; mMaterial.specular = { 1.0f }; mMaterial.power = { 10.0f }; mSettings.bumpMapWeight = { 0.2f }; mSettingsBuffer.Initialize(); mSampler.Initialize(Sampler::Filter::Anisotropic, Sampler::AddressMode::Clamp); std::filesystem::path assets = "../../Assets/Shaders/Earth.fx"; mBlendState.Initialize(BlendState::Mode::AlphaPremultiplied); mEarth.Initialize("../../Assets/Textures/JimmyEarth.jpg"); mEarthSpecualr.Initialize("../../Assets/Textures/earth_spec.jpg"); mEarthDisplacement.Initialize("../../Assets/Textures/earth_bump.jpg"); mNightMap.Initialize("../../Assets/Textures/earth_lights.jpg"); mEarthCould.Initialize("../../Assets/Textures/earth_clouds.jpg"); mEarthVertexShader.Initialize(assets, "VSEarth",Vertex::Format); mEarthPixelShader.Initialize(assets, "PSEarth"); mCloudVertexShader.Initialize(assets, "VSCloud", Vertex::Format); mCloudPixelShader.Initialize(assets, "PSCloud"); mNormalMap.Initialize("../../Assets/Textures/earth_normal.jpg"); auto graphicsSystem = GraphicsSystem::Get(); mRenderTarget.Initialize(graphicsSystem->GetBackBufferWidth(), graphicsSystem->GetBackBufferHeight(),RenderTarget::Format::RGBA_U8); mNDCMesh = MeshBuilder::CreateNDCQuad(); mScreenQuadBuffer.Initialize(mNDCMesh); mPostProcessingVertexShader.Initialize("../../Assets/Shaders/PostProcess.fx", VertexPX::Format); mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); // Space mSkyDome.Intialize("../../Assets/Textures/Space.jpg", 1000, 12, 360, {0.0f,0.0f,0.0f}); // Moon mMoon.Initialize("../../Assets/Textures/Moon.jpg", Vector3{ 75.5f,0.0f,0.0f }, 15.0f, 12.0f, 36.0f); // Mercury mMercury.Initialize("../../Assets/Textures/Mercury.jpg", Vector3{ 130.0f,0.0f,0.0f }, 24.0f, 12.0f, 36.0f); // Venus mVenus.Initialize("../../Assets/Textures/Venus.jpg", Vector3{ 170.0f,0.0f,0.0f }, 28.0f, 12.0f, 36.0f); // Mars mMars.Initialize("../../Assets/Textures/Mars.jpg", Vector3{ 200.0f,0.0f,0.0f }, 32.0f, 12.0f, 36.0f); // Jupitor mJupiter.Initialize("../../Assets/Textures/Jupiter.jpg", Vector3{ 280.0f,0.0f,0.0f }, 62.0f, 12.0f, 36.0f); // Saturn mSaturn.Initialize("../../Assets/Textures/Saturn.jpg", Vector3{ 360.0f,0.0f,0.0f }, 27.0f, 12.0f, 36.0f); // Uranos mUranos.Initialize("../../Assets/Textures/Uranos.jpg", Vector3{ 420.0f,0.0f,0.0f }, 25.0f, 12.0f, 36.0f); // Neptune mNeptune.Initialize("../../Assets/Textures/Neptune.jpg", Vector3{ 480.0f,0.0f,0.0f }, 23.0f, 12.0f, 36.0f); } void GameState::Terminate() { mRenderTarget.Terminate(); mScreenQuadBuffer.Terminate(); mPostProcessingPixelShader.Terminate(); mPostProcessingVertexShader.Terminate(); mSettingsBuffer.Terminate(); mNormalMap.Terminate(); mEarthVertexShader.Terminate(); mEarthPixelShader.Terminate(); mCloudPixelShader.Terminate(); mCloudVertexShader.Terminate(); mMaterialBuffer.Terminate(); mLightBuffer.Terminate(); mMeshBuffer.Terminate(); mSampler.Terminate(); mEarth.Terminate(); mEarthDisplacement.Terminate(); mEarthSpecualr.Terminate(); mNightMap.Terminate(); mBlendState.Terminate(); mEarthCould.Terminate(); mSkyDome.Terminate(); mMoon.Terminate(); mMercury.Terminate(); mVenus.Terminate(); mMars.Terminate(); mJupiter.Terminate(); mSaturn.Terminate(); mUranos.Terminate(); mNeptune.Terminate(); } void GameState::Update(float deltaTime) { const float kMoveSpeed = 100.5f; const float kTurnSpeed = 0.5f; mAccelation = Vector3::Zero; auto inputSystem = InputSystem::Get(); if (inputSystem->IsKeyDown(KeyCode::W)) { mCamera.Walk(kMoveSpeed*deltaTime); mAccelation += kMoveSpeed; } if (inputSystem->IsKeyDown(KeyCode::S)) { mCamera.Walk(-kMoveSpeed * deltaTime); mAccelation -= kMoveSpeed; } if (inputSystem->IsKeyDown(KeyCode::A)) mCamera.Strafe(-kMoveSpeed * deltaTime); if (inputSystem->IsKeyDown(KeyCode::D)) mCamera.Strafe(kMoveSpeed * deltaTime); mCloudRotation += 0.0001f; //mVelocity += mAccelation * deltaTime; //auto Speed = Magnitude(mVelocity); //if (ActiveRadialBlur) //{ // if (Speed > 30.0f && Speed < 500.0f) // mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSRadialBlur"); // else // mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); //} mSkyDome.Update(mCamera); mMoon.Update(deltaTime); mMercury.Update(deltaTime); mVenus.Update(deltaTime); mMars.Update(deltaTime); mJupiter.Update(deltaTime); mSaturn.Update(deltaTime); mUranos.Update(deltaTime); mNeptune.Update(deltaTime); } void GameState::Render() { mRenderTarget.BeginRender(); DrawScene(); mRenderTarget.EndRender(); mRenderTarget.BindPS(0); PostProcess(); mRenderTarget.UnbindPS(0); std::string str1 = (ActiveRadialBlur) ? "Active Radial Blur" : "Inactive Radial Blur"; SpriteRenderManager::Get()->DrawScreenText(str1.c_str(), 1050.0f, 600.0f, 15.0f, (!ActiveRadialBlur) ? Colors::WhiteSmoke : Colors::Magenta); std::string str2 = (ActiveGaussianBlur) ? "Active Gaussian Blur" : "Inactive Gaussian Blur"; SpriteRenderManager::Get()->DrawScreenText(str2.c_str(), 1050.0f, 620.0f, 15.0f, (!ActiveGaussianBlur) ? Colors::WhiteSmoke : Colors::Magenta); std::string str3 = (ActiveGreyscale) ? "Active Greyscale" : "Inactive Greyscale"; SpriteRenderManager::Get()->DrawScreenText(str3.c_str(), 1050.0f, 640.0f, 15.0f, (!ActiveGreyscale) ? Colors::WhiteSmoke : Colors::Magenta); std::string str4 = (ActiveNegative) ? "Active Negative" : "Inactive Negative"; SpriteRenderManager::Get()->DrawScreenText(str4.c_str(), 1050.0f, 660.0f, 15.0f, (!ActiveNegative) ? Colors::WhiteSmoke : Colors::Magenta); } void GameState::DebugUI() { //ImGui::ShowDemoWindow(); ImGui::Begin("Settings", nullptr, ImGuiWindowFlags_AlwaysAutoResize); if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) { bool directionChanged = false; directionChanged |= ImGui::DragFloat("Direction X##Light", &mDirectionalLight.direction.x, 0.01f); directionChanged |= ImGui::DragFloat("Direction Y##Light", &mDirectionalLight.direction.y, 0.01f); directionChanged |= ImGui::DragFloat("Direction Z##Light", &mDirectionalLight.direction.z, 0.01f); if (directionChanged) { mDirectionalLight.direction = Normalize(mDirectionalLight.direction); } ImGui::ColorEdit4("Ambient##Light", &mDirectionalLight.ambient.x); ImGui::ColorEdit4("Diffuse##Light", &mDirectionalLight.diffuse.x); ImGui::ColorEdit4("Specular##Light", &mDirectionalLight.specular.x); } if (ImGui::CollapsingHeader("Material", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::ColorEdit4("Ambient##Material", &mMaterial.ambient.x); ImGui::ColorEdit4("Diffuse##Material", &mMaterial.diffuse.x); ImGui::ColorEdit4("Specular##Material", &mMaterial.specular.x); ImGui::DragFloat("Power##Material", &mMaterial.power, 1.0f,1.0f,100.0f); } if (ImGui::CollapsingHeader("Settings", ImGuiTreeNodeFlags_DefaultOpen)) { static bool specularMap = true; static bool normalMap = true; ImGui::SliderFloat("Displacement", &mSettings.bumpMapWeight, 0.2f, 100.0f); if(ImGui::Checkbox("Cloud Map", &cloudMap)){} if (ImGui::Checkbox("Normal", &normalMap)) { mSettings.normalMapWeight = normalMap ? 1.0f : 0.0f; } if (ImGui::Checkbox("Specular", &specularMap)) { mSettings.specularWeight = specularMap ? 1.0f : 0.0f; } if (ImGui::Button("Radial Blur")) { if (ActiveGaussianBlur || ActiveGreyscale || ActiveNegative) ActiveRadialBlur = false; else { ActiveRadialBlur = !ActiveRadialBlur; if (!ActiveRadialBlur) mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); else mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSRadialBlur"); } } if (ImGui::Button("Gaussian")) { if (ActiveRadialBlur || ActiveGreyscale || ActiveNegative) ActiveGaussianBlur = false; else { ActiveGaussianBlur = !ActiveGaussianBlur; if (!ActiveGaussianBlur) mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); else mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSGaussian"); } } if (ImGui::Button("GreyScale")) { if (ActiveRadialBlur || ActiveGaussianBlur || ActiveNegative) ActiveGreyscale = false; else { ActiveGreyscale = !ActiveGreyscale; if (!ActiveGreyscale) mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); else mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSGreyScale"); } } if (ImGui::Button("Negative")) { if (ActiveRadialBlur || ActiveGreyscale || ActiveGaussianBlur) ActiveNegative = false; else { ActiveNegative = !ActiveNegative; if (!ActiveNegative) mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNoProcessing"); else mPostProcessingPixelShader.Initialize("../../Assets/Shaders/PostProcess.fx", "PSNegative"); } } } if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::DragFloat3("Rotation##Transform", &mRotation.x, 0.01f); } ImGui::End(); } void GameState::DrawScene() { auto matView = mCamera.GetViewMatrix(); auto matProj = mCamera.GetPerspectiveMatrix(); auto matTrans = Matrix4::Translation({ -1.25f,0.0f,0.0f }); auto matRot = Matrix4::RotationX(mRotation.x) * Matrix4::RotationY(mRotation.y); auto matWorld = matRot * matTrans; mSkyDome.Render(mCamera); TransformData transformData; transformData.world = Transpose(matWorld); transformData.wvp = Transpose(matWorld * matView * matProj); transformData.viewPosition = mCamera.GetPosition(); mTransformBuffer.Update(&transformData); mTransformBuffer.BindVS(0); mTransformBuffer.BindPS(0); mLightBuffer.Update(&mDirectionalLight); mLightBuffer.BindVS(1); mLightBuffer.BindPS(1); mMaterialBuffer.Update(&mMaterial); mMaterialBuffer.BindVS(2); mMaterialBuffer.BindPS(2); mSettingsBuffer.Update(&mSettings); mSettingsBuffer.BindVS(3); mSettingsBuffer.BindPS(3); mEarthPixelShader.Bind(); mEarthVertexShader.Bind(); mEarth.BindPS(0); mEarthSpecualr.BindPS(1); mEarthDisplacement.BindVS(2); mNormalMap.BindPS(3); mNightMap.BindPS(4); mMeshBuffer.Draw(); BlendState::ClearState(); // --- Cloud if (cloudMap) { matRot = Matrix4::RotationX(mRotation.x) * Matrix4::RotationY(mRotation.y + mCloudRotation); matWorld = matRot * matTrans; transformData.world = Transpose(matWorld); transformData.wvp = Transpose(matWorld * matView * matProj); transformData.viewPosition = mCamera.GetPosition(); mTransformBuffer.Update(&transformData); mTransformBuffer.BindVS(0); mTransformBuffer.BindPS(0); mCloudPixelShader.Bind(); mCloudVertexShader.Bind(); mEarthCould.BindPS(5); mEarthCould.BindVS(5); mBlendState.Set(); mMeshBuffer.Draw(); } mMoon.Render(mCamera, 1.5f, 0.15f, matWorld); mMercury.Render(mCamera, 2.1f, 0.2f, matWorld); mVenus.Render(mCamera, 2.6f, 0.25f, matWorld); mMars.Render(mCamera, 3.1f, 0.3f, matWorld); mJupiter.Render(mCamera, 3.6f, 0.5f, matWorld); mSaturn.Render(mCamera, 4.1f, 0.3f, matWorld); mUranos.Render(mCamera, 4.6f, 0.2f, matWorld); mNeptune.Render(mCamera, 5.1f, 0.2f, matWorld); SimpleDraw::Render(mCamera); } void GameState::PostProcess() { mPostProcessingVertexShader.Bind(); mPostProcessingPixelShader.Bind(); mSampler.BindPS(); mScreenQuadBuffer.Draw(); } // Blending : find color = Source color * SourceBlend + destinationColor * destinationBlend // destinationColor = represent the pixel on the backbuffer
34.721925
145
0.705452
TheJimmyGod
925a0eae58dc60ac694c0d0907dc8632d741dbda
26,849
cc
C++
src/net/quic/proto/source_address_token.pb.cc
acmd/GIT-TCC-LIBQUIC-ACMD
f100c1ff7b4c24ed2fbb3ae11d9516f6ce5ccc6d
[ "BSD-3-Clause" ]
1,760
2015-03-16T07:29:25.000Z
2022-03-29T17:04:54.000Z
src/net/quic/core/proto/source_address_token.pb.cc
18901233704/libquic
8954789a056d8e7d5fcb6452fd1572ca57eb5c4e
[ "BSD-3-Clause" ]
41
2015-03-26T02:03:34.000Z
2022-02-09T09:38:47.000Z
src/net/quic/core/proto/source_address_token.pb.cc
18901233704/libquic
8954789a056d8e7d5fcb6452fd1572ca57eb5c4e
[ "BSD-3-Clause" ]
336
2015-03-16T13:52:52.000Z
2022-03-21T10:44:58.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: source_address_token.proto #define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION #include "source_address_token.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/port.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> // @@protoc_insertion_point(includes) namespace net { void protobuf_ShutdownFile_source_5faddress_5ftoken_2eproto() { delete SourceAddressToken::default_instance_; delete SourceAddressTokens::default_instance_; } #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER void protobuf_AddDesc_source_5faddress_5ftoken_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #else void protobuf_AddDesc_source_5faddress_5ftoken_2eproto() { static bool already_here = false; if (already_here) return; already_here = true; GOOGLE_PROTOBUF_VERIFY_VERSION; #endif ::net::protobuf_AddDesc_cached_5fnetwork_5fparameters_2eproto(); SourceAddressToken::default_instance_ = new SourceAddressToken(); SourceAddressTokens::default_instance_ = new SourceAddressTokens(); SourceAddressToken::default_instance_->InitAsDefaultInstance(); SourceAddressTokens::default_instance_->InitAsDefaultInstance(); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_source_5faddress_5ftoken_2eproto); } #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_source_5faddress_5ftoken_2eproto_once_); void protobuf_AddDesc_source_5faddress_5ftoken_2eproto() { ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_source_5faddress_5ftoken_2eproto_once_, &protobuf_AddDesc_source_5faddress_5ftoken_2eproto_impl); } #else // Force AddDescriptors() to be called at static initialization time. struct StaticDescriptorInitializer_source_5faddress_5ftoken_2eproto { StaticDescriptorInitializer_source_5faddress_5ftoken_2eproto() { protobuf_AddDesc_source_5faddress_5ftoken_2eproto(); } } static_descriptor_initializer_source_5faddress_5ftoken_2eproto_; #endif namespace { static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD; GOOGLE_ATTRIBUTE_NOINLINE static void MergeFromFail(int line) { GOOGLE_CHECK(false) << __FILE__ << ":" << line; } } // namespace // =================================================================== static ::std::string* MutableUnknownFieldsForSourceAddressToken( SourceAddressToken* ptr) { return ptr->mutable_unknown_fields(); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceAddressToken::kIpFieldNumber; const int SourceAddressToken::kTimestampFieldNumber; const int SourceAddressToken::kCachedNetworkParametersFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SourceAddressToken::SourceAddressToken() : ::google::protobuf::MessageLite(), _arena_ptr_(NULL) { SharedCtor(); // @@protoc_insertion_point(constructor:net.SourceAddressToken) } void SourceAddressToken::InitAsDefaultInstance() { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER cached_network_parameters_ = const_cast< ::net::CachedNetworkParameters*>( ::net::CachedNetworkParameters::internal_default_instance()); #else cached_network_parameters_ = const_cast< ::net::CachedNetworkParameters*>(&::net::CachedNetworkParameters::default_instance()); #endif } SourceAddressToken::SourceAddressToken(const SourceAddressToken& from) : ::google::protobuf::MessageLite(), _arena_ptr_(NULL) { SharedCtor(); MergeFrom(from); // @@protoc_insertion_point(copy_constructor:net.SourceAddressToken) } void SourceAddressToken::SharedCtor() { ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; _unknown_fields_.UnsafeSetDefault( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); ip_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); timestamp_ = GOOGLE_LONGLONG(0); cached_network_parameters_ = NULL; ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceAddressToken::~SourceAddressToken() { // @@protoc_insertion_point(destructor:net.SourceAddressToken) SharedDtor(); } void SourceAddressToken::SharedDtor() { _unknown_fields_.DestroyNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); ip_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER if (this != &default_instance()) { #else if (this != default_instance_) { #endif delete cached_network_parameters_; } } void SourceAddressToken::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const SourceAddressToken& SourceAddressToken::default_instance() { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER protobuf_AddDesc_source_5faddress_5ftoken_2eproto(); #else if (default_instance_ == NULL) protobuf_AddDesc_source_5faddress_5ftoken_2eproto(); #endif return *default_instance_; } SourceAddressToken* SourceAddressToken::default_instance_ = NULL; SourceAddressToken* SourceAddressToken::New(::google::protobuf::Arena* arena) const { SourceAddressToken* n = new SourceAddressToken; if (arena != NULL) { arena->Own(n); } return n; } void SourceAddressToken::Clear() { // @@protoc_insertion_point(message_clear_start:net.SourceAddressToken) if (_has_bits_[0 / 32] & 7u) { if (has_ip()) { ip_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } timestamp_ = GOOGLE_LONGLONG(0); if (has_cached_network_parameters()) { if (cached_network_parameters_ != NULL) cached_network_parameters_->::net::CachedNetworkParameters::Clear(); } } ::memset(_has_bits_, 0, sizeof(_has_bits_)); _unknown_fields_.ClearToEmptyNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); } bool SourceAddressToken::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; ::google::protobuf::io::LazyStringOutputStream unknown_fields_string( ::google::protobuf::internal::NewPermanentCallback( &MutableUnknownFieldsForSourceAddressToken, this)); ::google::protobuf::io::CodedOutputStream unknown_fields_stream( &unknown_fields_string, false); // @@protoc_insertion_point(parse_start:net.SourceAddressToken) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required bytes ip = 1; case 1: { if (tag == 10) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_ip())); } else { goto handle_unusual; } if (input->ExpectTag(16)) goto parse_timestamp; break; } // required int64 timestamp = 2; case 2: { if (tag == 16) { parse_timestamp: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( input, &timestamp_))); set_has_timestamp(); } else { goto handle_unusual; } if (input->ExpectTag(26)) goto parse_cached_network_parameters; break; } // optional .net.CachedNetworkParameters cached_network_parameters = 3; case 3: { if (tag == 26) { parse_cached_network_parameters: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_cached_network_parameters())); } else { goto handle_unusual; } if (input->ExpectAtEnd()) goto success; break; } default: { handle_unusual: if (tag == 0 || ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { goto success; } DO_(::google::protobuf::internal::WireFormatLite::SkipField( input, tag, &unknown_fields_stream)); break; } } } success: // @@protoc_insertion_point(parse_success:net.SourceAddressToken) return true; failure: // @@protoc_insertion_point(parse_failure:net.SourceAddressToken) return false; #undef DO_ } void SourceAddressToken::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:net.SourceAddressToken) // required bytes ip = 1; if (has_ip()) { ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 1, this->ip(), output); } // required int64 timestamp = 2; if (has_timestamp()) { ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->timestamp(), output); } // optional .net.CachedNetworkParameters cached_network_parameters = 3; if (has_cached_network_parameters()) { ::google::protobuf::internal::WireFormatLite::WriteMessage( 3, *this->cached_network_parameters_, output); } output->WriteRaw(unknown_fields().data(), static_cast<int>(unknown_fields().size())); // @@protoc_insertion_point(serialize_end:net.SourceAddressToken) } int SourceAddressToken::RequiredFieldsByteSizeFallback() const { // @@protoc_insertion_point(required_fields_byte_size_fallback_start:net.SourceAddressToken) int total_size = 0; if (has_ip()) { // required bytes ip = 1; total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( this->ip()); } if (has_timestamp()) { // required int64 timestamp = 2; total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->timestamp()); } return total_size; } int SourceAddressToken::ByteSize() const { // @@protoc_insertion_point(message_byte_size_start:net.SourceAddressToken) int total_size = 0; if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required bytes ip = 1; total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( this->ip()); // required int64 timestamp = 2; total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->timestamp()); } else { total_size += RequiredFieldsByteSizeFallback(); } // optional .net.CachedNetworkParameters cached_network_parameters = 3; if (has_cached_network_parameters()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( *this->cached_network_parameters_); } total_size += unknown_fields().size(); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SourceAddressToken::CheckTypeAndMergeFrom( const ::google::protobuf::MessageLite& from) { MergeFrom(*::google::protobuf::down_cast<const SourceAddressToken*>(&from)); } void SourceAddressToken::MergeFrom(const SourceAddressToken& from) { // @@protoc_insertion_point(class_specific_merge_from_start:net.SourceAddressToken) if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_ip()) { set_has_ip(); ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ip_); } if (from.has_timestamp()) { set_timestamp(from.timestamp()); } if (from.has_cached_network_parameters()) { mutable_cached_network_parameters()->::net::CachedNetworkParameters::MergeFrom(from.cached_network_parameters()); } } if (!from.unknown_fields().empty()) { mutable_unknown_fields()->append(from.unknown_fields()); } } void SourceAddressToken::CopyFrom(const SourceAddressToken& from) { // @@protoc_insertion_point(class_specific_copy_from_start:net.SourceAddressToken) if (&from == this) return; Clear(); MergeFrom(from); } bool SourceAddressToken::IsInitialized() const { if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; return true; } void SourceAddressToken::Swap(SourceAddressToken* other) { if (other == this) return; InternalSwap(other); } void SourceAddressToken::InternalSwap(SourceAddressToken* other) { ip_.Swap(&other->ip_); std::swap(timestamp_, other->timestamp_); std::swap(cached_network_parameters_, other->cached_network_parameters_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } ::std::string SourceAddressToken::GetTypeName() const { return "net.SourceAddressToken"; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceAddressToken // required bytes ip = 1; bool SourceAddressToken::has_ip() const { return (_has_bits_[0] & 0x00000001u) != 0; } void SourceAddressToken::set_has_ip() { _has_bits_[0] |= 0x00000001u; } void SourceAddressToken::clear_has_ip() { _has_bits_[0] &= ~0x00000001u; } void SourceAddressToken::clear_ip() { ip_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); clear_has_ip(); } const ::std::string& SourceAddressToken::ip() const { // @@protoc_insertion_point(field_get:net.SourceAddressToken.ip) return ip_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void SourceAddressToken::set_ip(const ::std::string& value) { set_has_ip(); ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); // @@protoc_insertion_point(field_set:net.SourceAddressToken.ip) } void SourceAddressToken::set_ip(const char* value) { set_has_ip(); ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); // @@protoc_insertion_point(field_set_char:net.SourceAddressToken.ip) } void SourceAddressToken::set_ip(const void* value, size_t size) { set_has_ip(); ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(reinterpret_cast<const char*>(value), size)); // @@protoc_insertion_point(field_set_pointer:net.SourceAddressToken.ip) } ::std::string* SourceAddressToken::mutable_ip() { set_has_ip(); // @@protoc_insertion_point(field_mutable:net.SourceAddressToken.ip) return ip_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } ::std::string* SourceAddressToken::release_ip() { // @@protoc_insertion_point(field_release:net.SourceAddressToken.ip) clear_has_ip(); return ip_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void SourceAddressToken::set_allocated_ip(::std::string* ip) { if (ip != NULL) { set_has_ip(); } else { clear_has_ip(); } ip_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ip); // @@protoc_insertion_point(field_set_allocated:net.SourceAddressToken.ip) } // required int64 timestamp = 2; bool SourceAddressToken::has_timestamp() const { return (_has_bits_[0] & 0x00000002u) != 0; } void SourceAddressToken::set_has_timestamp() { _has_bits_[0] |= 0x00000002u; } void SourceAddressToken::clear_has_timestamp() { _has_bits_[0] &= ~0x00000002u; } void SourceAddressToken::clear_timestamp() { timestamp_ = GOOGLE_LONGLONG(0); clear_has_timestamp(); } ::google::protobuf::int64 SourceAddressToken::timestamp() const { // @@protoc_insertion_point(field_get:net.SourceAddressToken.timestamp) return timestamp_; } void SourceAddressToken::set_timestamp(::google::protobuf::int64 value) { set_has_timestamp(); timestamp_ = value; // @@protoc_insertion_point(field_set:net.SourceAddressToken.timestamp) } // optional .net.CachedNetworkParameters cached_network_parameters = 3; bool SourceAddressToken::has_cached_network_parameters() const { return (_has_bits_[0] & 0x00000004u) != 0; } void SourceAddressToken::set_has_cached_network_parameters() { _has_bits_[0] |= 0x00000004u; } void SourceAddressToken::clear_has_cached_network_parameters() { _has_bits_[0] &= ~0x00000004u; } void SourceAddressToken::clear_cached_network_parameters() { if (cached_network_parameters_ != NULL) cached_network_parameters_->::net::CachedNetworkParameters::Clear(); clear_has_cached_network_parameters(); } const ::net::CachedNetworkParameters& SourceAddressToken::cached_network_parameters() const { // @@protoc_insertion_point(field_get:net.SourceAddressToken.cached_network_parameters) #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER return cached_network_parameters_ != NULL ? *cached_network_parameters_ : *default_instance().cached_network_parameters_; #else return cached_network_parameters_ != NULL ? *cached_network_parameters_ : *default_instance_->cached_network_parameters_; #endif } ::net::CachedNetworkParameters* SourceAddressToken::mutable_cached_network_parameters() { set_has_cached_network_parameters(); if (cached_network_parameters_ == NULL) { cached_network_parameters_ = new ::net::CachedNetworkParameters; } // @@protoc_insertion_point(field_mutable:net.SourceAddressToken.cached_network_parameters) return cached_network_parameters_; } ::net::CachedNetworkParameters* SourceAddressToken::release_cached_network_parameters() { // @@protoc_insertion_point(field_release:net.SourceAddressToken.cached_network_parameters) clear_has_cached_network_parameters(); ::net::CachedNetworkParameters* temp = cached_network_parameters_; cached_network_parameters_ = NULL; return temp; } void SourceAddressToken::set_allocated_cached_network_parameters(::net::CachedNetworkParameters* cached_network_parameters) { delete cached_network_parameters_; cached_network_parameters_ = cached_network_parameters; if (cached_network_parameters) { set_has_cached_network_parameters(); } else { clear_has_cached_network_parameters(); } // @@protoc_insertion_point(field_set_allocated:net.SourceAddressToken.cached_network_parameters) } #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== static ::std::string* MutableUnknownFieldsForSourceAddressTokens( SourceAddressTokens* ptr) { return ptr->mutable_unknown_fields(); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int SourceAddressTokens::kTokensFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 SourceAddressTokens::SourceAddressTokens() : ::google::protobuf::MessageLite(), _arena_ptr_(NULL) { SharedCtor(); // @@protoc_insertion_point(constructor:net.SourceAddressTokens) } void SourceAddressTokens::InitAsDefaultInstance() { } SourceAddressTokens::SourceAddressTokens(const SourceAddressTokens& from) : ::google::protobuf::MessageLite(), _arena_ptr_(NULL) { SharedCtor(); MergeFrom(from); // @@protoc_insertion_point(copy_constructor:net.SourceAddressTokens) } void SourceAddressTokens::SharedCtor() { ::google::protobuf::internal::GetEmptyString(); _cached_size_ = 0; _unknown_fields_.UnsafeSetDefault( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } SourceAddressTokens::~SourceAddressTokens() { // @@protoc_insertion_point(destructor:net.SourceAddressTokens) SharedDtor(); } void SourceAddressTokens::SharedDtor() { _unknown_fields_.DestroyNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER if (this != &default_instance()) { #else if (this != default_instance_) { #endif } } void SourceAddressTokens::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const SourceAddressTokens& SourceAddressTokens::default_instance() { #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER protobuf_AddDesc_source_5faddress_5ftoken_2eproto(); #else if (default_instance_ == NULL) protobuf_AddDesc_source_5faddress_5ftoken_2eproto(); #endif return *default_instance_; } SourceAddressTokens* SourceAddressTokens::default_instance_ = NULL; SourceAddressTokens* SourceAddressTokens::New(::google::protobuf::Arena* arena) const { SourceAddressTokens* n = new SourceAddressTokens; if (arena != NULL) { arena->Own(n); } return n; } void SourceAddressTokens::Clear() { // @@protoc_insertion_point(message_clear_start:net.SourceAddressTokens) tokens_.Clear(); ::memset(_has_bits_, 0, sizeof(_has_bits_)); _unknown_fields_.ClearToEmptyNoArena( &::google::protobuf::internal::GetEmptyStringAlreadyInited()); } bool SourceAddressTokens::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; ::google::protobuf::io::LazyStringOutputStream unknown_fields_string( ::google::protobuf::internal::NewPermanentCallback( &MutableUnknownFieldsForSourceAddressTokens, this)); ::google::protobuf::io::CodedOutputStream unknown_fields_stream( &unknown_fields_string, false); // @@protoc_insertion_point(parse_start:net.SourceAddressTokens) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .net.SourceAddressToken tokens = 4; case 4: { if (tag == 34) { DO_(input->IncrementRecursionDepth()); parse_loop_tokens: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_tokens())); } else { goto handle_unusual; } if (input->ExpectTag(34)) goto parse_loop_tokens; input->UnsafeDecrementRecursionDepth(); if (input->ExpectAtEnd()) goto success; break; } default: { handle_unusual: if (tag == 0 || ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { goto success; } DO_(::google::protobuf::internal::WireFormatLite::SkipField( input, tag, &unknown_fields_stream)); break; } } } success: // @@protoc_insertion_point(parse_success:net.SourceAddressTokens) return true; failure: // @@protoc_insertion_point(parse_failure:net.SourceAddressTokens) return false; #undef DO_ } void SourceAddressTokens::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:net.SourceAddressTokens) // repeated .net.SourceAddressToken tokens = 4; for (unsigned int i = 0, n = this->tokens_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessage( 4, this->tokens(i), output); } output->WriteRaw(unknown_fields().data(), static_cast<int>(unknown_fields().size())); // @@protoc_insertion_point(serialize_end:net.SourceAddressTokens) } int SourceAddressTokens::ByteSize() const { // @@protoc_insertion_point(message_byte_size_start:net.SourceAddressTokens) int total_size = 0; // repeated .net.SourceAddressToken tokens = 4; total_size += 1 * this->tokens_size(); for (int i = 0; i < this->tokens_size(); i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( this->tokens(i)); } total_size += unknown_fields().size(); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = total_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void SourceAddressTokens::CheckTypeAndMergeFrom( const ::google::protobuf::MessageLite& from) { MergeFrom(*::google::protobuf::down_cast<const SourceAddressTokens*>(&from)); } void SourceAddressTokens::MergeFrom(const SourceAddressTokens& from) { // @@protoc_insertion_point(class_specific_merge_from_start:net.SourceAddressTokens) if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); tokens_.MergeFrom(from.tokens_); if (!from.unknown_fields().empty()) { mutable_unknown_fields()->append(from.unknown_fields()); } } void SourceAddressTokens::CopyFrom(const SourceAddressTokens& from) { // @@protoc_insertion_point(class_specific_copy_from_start:net.SourceAddressTokens) if (&from == this) return; Clear(); MergeFrom(from); } bool SourceAddressTokens::IsInitialized() const { if (!::google::protobuf::internal::AllAreInitialized(this->tokens())) return false; return true; } void SourceAddressTokens::Swap(SourceAddressTokens* other) { if (other == this) return; InternalSwap(other); } void SourceAddressTokens::InternalSwap(SourceAddressTokens* other) { tokens_.UnsafeArenaSwap(&other->tokens_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); } ::std::string SourceAddressTokens::GetTypeName() const { return "net.SourceAddressTokens"; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceAddressTokens // repeated .net.SourceAddressToken tokens = 4; int SourceAddressTokens::tokens_size() const { return tokens_.size(); } void SourceAddressTokens::clear_tokens() { tokens_.Clear(); } const ::net::SourceAddressToken& SourceAddressTokens::tokens(int index) const { // @@protoc_insertion_point(field_get:net.SourceAddressTokens.tokens) return tokens_.Get(index); } ::net::SourceAddressToken* SourceAddressTokens::mutable_tokens(int index) { // @@protoc_insertion_point(field_mutable:net.SourceAddressTokens.tokens) return tokens_.Mutable(index); } ::net::SourceAddressToken* SourceAddressTokens::add_tokens() { // @@protoc_insertion_point(field_add:net.SourceAddressTokens.tokens) return tokens_.Add(); } ::google::protobuf::RepeatedPtrField< ::net::SourceAddressToken >* SourceAddressTokens::mutable_tokens() { // @@protoc_insertion_point(field_mutable_list:net.SourceAddressTokens.tokens) return &tokens_; } const ::google::protobuf::RepeatedPtrField< ::net::SourceAddressToken >& SourceAddressTokens::tokens() const { // @@protoc_insertion_point(field_list:net.SourceAddressTokens.tokens) return tokens_; } #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) } // namespace net // @@protoc_insertion_point(global_scope)
34.959635
129
0.73783
acmd
925b5196589388e9a1896e0d317515e5cd754e49
374
cpp
C++
source/GameLogicNew.cpp
gennariarmando/v-hud
788196fb3ce5a983073f0475f06b041c5a4ea949
[ "MIT" ]
69
2021-08-09T21:26:26.000Z
2022-03-25T08:47:42.000Z
source/GameLogicNew.cpp
gennariarmando/v-hud
788196fb3ce5a983073f0475f06b041c5a4ea949
[ "MIT" ]
84
2021-12-01T15:15:27.000Z
2022-03-30T05:12:50.000Z
source/GameLogicNew.cpp
gennariarmando/v-hud
788196fb3ce5a983073f0475f06b041c5a4ea949
[ "MIT" ]
12
2021-12-25T09:27:08.000Z
2022-03-25T08:47:43.000Z
#include "VHud.h" #include "GameLogicNew.h" #include "HudNew.h" #include "MenuNew.h" using namespace plugin; CGameLogicNew GameLogicNew; static LateStaticInit InstallHooks([]() { CdeclEvent<AddressList<0x442128, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> OnResurrection; OnResurrection += [] { CHudNew::ReInit(); MenuNew.Clear(); }; });
19.684211
99
0.684492
gennariarmando
925d1bbdfc9349a924cbaf83942bedb466df6b64
1,084
cpp
C++
11678 Cards Exchange.cpp
zihadboss/UVA-Solutions
020fdcb09da79dc0a0411b04026ce3617c09cd27
[ "Apache-2.0" ]
86
2016-01-20T11:36:50.000Z
2022-03-06T19:43:14.000Z
11678 Cards Exchange.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
null
null
null
11678 Cards Exchange.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
113
2015-12-04T06:40:57.000Z
2022-02-11T02:14:28.000Z
#include <cstdio> #include <map> using namespace std; int main() { map<int, bool> cards; int aCards, bCards, current, aCount, bCount; while (scanf("%d %d", &aCards, &bCards), aCards && bCards) { aCount = bCount = 0; cards.clear(); for (int i = 0; i < aCards; ++i) { scanf("%d", &current); if (cards.find(current) == cards.end()) { ++aCount; cards[current] = true; } } for (int i = 0; i < bCards; ++i) { scanf("%d", &current); map<int, bool>::iterator iter = cards.find(current); if (iter == cards.end()) { cards[current] = false; ++bCount; } else if (iter->second) { iter->second = false; --aCount; } } printf("%d\n", aCount < bCount ? aCount : bCount); } }
21.68
64
0.373616
zihadboss
177df375e0ba93a76b8d74c51ee777016f3e5064
1,726
cpp
C++
codeforces/A - Acacius and String/Wrong answer on pretest 2.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
1
2022-02-11T16:55:36.000Z
2022-02-11T16:55:36.000Z
codeforces/A - Acacius and String/Wrong answer on pretest 2.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
codeforces/A - Acacius and String/Wrong answer on pretest 2.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
/**************************************************************************************** * @author: * kzvd4729 created: Jul/19/2020 15:20 * solution_verdict: Wrong answer on pretest 2 language: GNU C++17 * run_time: 15 ms memory_used: 3600 KB * problem: https://codeforces.com/contest/1379/problem/A ****************************************************************************************/ #include<iostream> #include<vector> #include<cstring> #include<map> #include<bitset> #include<assert.h> #include<algorithm> #include<iomanip> #include<cmath> #include<set> #include<queue> #include<unordered_map> #include<random> #include<chrono> #include<stack> #include<deque> #define endl '\n' #define long long long using namespace std; const int N=1e6; string p="abacaba",s; bool solve() { int n;cin>>n;cin>>s; int cnt=0; for(int i=0;i<n;i++) { int f=1; for(int j=0;j<p.size();j++) { if(i+j==n){f=0;break;} if(s[i+j]!=p[j])f=0; } cnt+=f; } if(cnt==1) { for(int i=0;i<n;i++)if(s[i]=='?')s[i]='d'; return true; } if(cnt>1)return false; for(int i=0;i<n;i++) { int f=1; for(int j=0;j<p.size();j++) { if(i+j==n){f=0;break;} if(s[i+j]==p[j]||s[i+j]=='?'); else f=0; } if(f) { for(int j=0;j<p.size();j++) s[i+j]=p[j]; return true; } } return false; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int t;cin>>t; while(t--) { if(solve())cout<<"Yes\n"<<s<<"\n"; else cout<<"No\n"; } return 0; }
22.710526
111
0.445539
kzvd4729
178144aa9475178f061047f39de48fe5181a1534
10,949
hpp
C++
libraries/chain/include/graphene/chain/contract_object.hpp
BlockLink/HX-core
646bdb19d7be7b4fd1ee94c777ef8e42d9aea783
[ "MIT" ]
1
2018-12-12T08:38:09.000Z
2018-12-12T08:38:09.000Z
libraries/chain/include/graphene/chain/contract_object.hpp
BlockLink/HX-core
646bdb19d7be7b4fd1ee94c777ef8e42d9aea783
[ "MIT" ]
null
null
null
libraries/chain/include/graphene/chain/contract_object.hpp
BlockLink/HX-core
646bdb19d7be7b4fd1ee94c777ef8e42d9aea783
[ "MIT" ]
null
null
null
#pragma once #include <graphene/chain/protocol/operations.hpp> #include <graphene/db/generic_index.hpp> #include <boost/multi_index/composite_key.hpp> #include <graphene/chain/contract_entry.hpp> #include <graphene/chain/vesting_balance_object.hpp> #include <vector> namespace graphene { namespace chain { struct by_contract_id; struct by_contract_name {}; class contract_object : public abstract_object<contract_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_object_type; uint32_t registered_block; uvm::blockchain::Code code; address owner_address; time_point_sec create_time; string name; contract_address_type contract_address; string contract_name; string contract_desc; contract_type type_of_contract = normal_contract; string native_contract_key; // key to find native contract code vector<contract_address_type> derived; contract_address_type inherit_from; }; struct by_owner{}; struct by_contract_obj_id {}; struct by_registered_block {}; typedef multi_index_container< contract_object, indexed_by< ordered_unique<tag<by_id>, member<object, object_id_type, &object::id>>, ordered_unique<tag<by_contract_id>, member<contract_object, contract_address_type, &contract_object::contract_address>>, ordered_non_unique<tag<by_contract_name>, member<contract_object, string, &contract_object::contract_name>>, ordered_non_unique<tag<by_owner>, member<contract_object, address, &contract_object::owner_address>>, ordered_non_unique<tag<by_registered_block>, member<contract_object, uint32_t, &contract_object::registered_block>> >> contract_object_multi_index_type; typedef generic_index<contract_object, contract_object_multi_index_type> contract_object_index; class contract_storage_change_object : public abstract_object<contract_storage_change_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_storage_change_object_type; contract_address_type contract_address; uint32_t block_num; }; struct by_block_num {}; typedef multi_index_container< contract_storage_change_object, indexed_by< ordered_unique<tag<by_id>, member<object, object_id_type, &object::id>>, ordered_unique<tag<by_contract_id>, member<contract_storage_change_object, contract_address_type, &contract_storage_change_object::contract_address>>, ordered_non_unique<tag<by_block_num>, member<contract_storage_change_object, uint32_t, &contract_storage_change_object::block_num>> >> contract_storage_change_object_multi_index_type; typedef generic_index<contract_storage_change_object, contract_storage_change_object_multi_index_type> contract_storage_change_index; class contract_storage_object : public abstract_object<contract_storage_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_storage_object_type; contract_address_type contract_address; string storage_name; std::vector<char> storage_value; }; struct by_contract_id_storage_name {}; typedef multi_index_container< contract_storage_object, indexed_by< ordered_unique<tag<by_id>, member<object, object_id_type, &object::id>>, ordered_unique< tag<by_contract_id_storage_name>, composite_key< contract_storage_object, member<contract_storage_object, contract_address_type, &contract_storage_object::contract_address>, member<contract_storage_object, string, &contract_storage_object::storage_name> > > >> contract_storage_object_multi_index_type; typedef generic_index<contract_storage_object, contract_storage_object_multi_index_type> contract_storage_object_index; class contract_balance_object : public abstract_object<contract_balance_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_balance_object_type; bool is_vesting_balance()const { return vesting_policy.valid(); } asset available(fc::time_point_sec now)const { return is_vesting_balance() ? vesting_policy->get_allowed_withdraw({ balance, now,{} }) : balance; } void adjust_balance(asset delta, fc::time_point_sec now) { balance += delta; last_claim_date = now; } contract_address_type owner; asset balance; optional<linear_vesting_policy> vesting_policy; time_point_sec last_claim_date; asset_id_type asset_type()const { return balance.asset_id; } }; struct by_owner; /** * @ingroup object_index */ using contract_balance_multi_index_type = multi_index_container< contract_balance_object, indexed_by< ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >, ordered_non_unique< tag<by_contract_id>, member< contract_balance_object, contract_address_type, &contract_balance_object::owner > >, ordered_non_unique< tag<by_owner>, composite_key< contract_balance_object, member<contract_balance_object, contract_address_type, &contract_balance_object::owner>, const_mem_fun<contract_balance_object, asset_id_type, &contract_balance_object::asset_type> > > > >; /** * @ingroup object_index */ using contract_balance_index = generic_index<contract_balance_object, contract_balance_multi_index_type>; class contract_event_notify_object : public abstract_object<contract_event_notify_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_event_notify_object_type; contract_address_type contract_address; string event_name; string event_arg; transaction_id_type trx_id; uint64_t block_num; uint64_t op_num; }; using contract_event_notify_multi_index_type = multi_index_container< contract_event_notify_object, indexed_by< ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >, ordered_non_unique<tag<by_contract_id>, member<contract_event_notify_object, contract_address_type, &contract_event_notify_object::contract_address>> > >; using contract_event_notify_index = generic_index<contract_event_notify_object, contract_event_notify_multi_index_type>; class contract_invoke_result_object : public abstract_object<contract_invoke_result_object> { public: static const uint8_t space_id = protocol_ids; static const uint8_t type_id = contract_invoke_result_object_type; transaction_id_type trx_id; uint32_t block_num; int op_num; std::string api_result; std::vector<contract_event_notify_info> events; bool exec_succeed = true; share_type acctual_fee; address invoker; std::map<std::string, contract_storage_changes_type, comparator_for_string> storage_changes; std::map<std::pair<contract_address_type, asset_id_type>, share_type> contract_withdraw; std::map<std::pair<contract_address_type, asset_id_type>, share_type> contract_balances; std::map<std::pair<address, asset_id_type>, share_type> deposit_to_address; std::map<std::pair<contract_address_type, asset_id_type>, share_type> deposit_contract; inline bool operator<(const contract_invoke_result_object& obj) const { if (block_num < obj.block_num) return true; if(block_num == obj.block_num) return op_num < obj.op_num; return false; } }; struct by_trxid_and_opnum {}; struct by_trxid {}; using contract_invoke_result_multi_index_type = multi_index_container < contract_invoke_result_object, indexed_by < ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >, ordered_non_unique<tag<by_trxid>, member<contract_invoke_result_object, transaction_id_type, &contract_invoke_result_object::trx_id>>, ordered_unique<tag<by_trxid_and_opnum>, composite_key<contract_invoke_result_object, member<contract_invoke_result_object, transaction_id_type, &contract_invoke_result_object::trx_id>, member<contract_invoke_result_object, int, &contract_invoke_result_object::op_num>>> > >; using contract_invoke_result_index = generic_index<contract_invoke_result_object, contract_invoke_result_multi_index_type>; class contract_hash_entry { public: std::string contract_address; std::string hash; public: contract_hash_entry() {} inline contract_hash_entry(const chain::contract_object& cont) { contract_address = cont.contract_address.operator fc::string(); hash = cont.code.GetHash(); } }; } } FC_REFLECT_DERIVED(graphene::chain::contract_object, (graphene::db::object), (registered_block)(code)(owner_address)(create_time)(name)(contract_address)(type_of_contract)(native_contract_key)(contract_name)(contract_desc)(derived)(inherit_from)) FC_REFLECT_DERIVED(graphene::chain::contract_storage_object, (graphene::db::object), (contract_address)(storage_name)(storage_value)) FC_REFLECT_DERIVED(graphene::chain::contract_balance_object, (graphene::db::object), (owner)(balance)(vesting_policy)(last_claim_date)) FC_REFLECT_DERIVED(graphene::chain::contract_event_notify_object, (graphene::db::object), (contract_address)(event_name)(event_arg)(trx_id)(block_num)(op_num)) FC_REFLECT_DERIVED(graphene::chain::contract_invoke_result_object, (graphene::db::object), (trx_id)(block_num)(op_num)(api_result)(events)(exec_succeed)(acctual_fee)(invoker)(contract_withdraw)(contract_balances)(deposit_to_address)(deposit_contract)) //(contract_withdraw)(contract_balances)(deposit_to_address)(deposit_contract) FC_REFLECT(graphene::chain::contract_hash_entry,(contract_address)(hash)) FC_REFLECT_DERIVED(graphene::chain::contract_storage_change_object, (graphene::db::object),(contract_address)(block_num))
47.193966
173
0.704539
BlockLink
178214975f3950a6298c123328751d524acfcf13
7,538
cpp
C++
lib/cml/utils/Command_line.cpp
JayKickliter/CML
d21061a3abc013a8386798280b9595e9d4a2978c
[ "MIT" ]
null
null
null
lib/cml/utils/Command_line.cpp
JayKickliter/CML
d21061a3abc013a8386798280b9595e9d4a2978c
[ "MIT" ]
null
null
null
lib/cml/utils/Command_line.cpp
JayKickliter/CML
d21061a3abc013a8386798280b9595e9d4a2978c
[ "MIT" ]
null
null
null
/* Name: Command_line.cpp Copyright(c) 2019 Mateusz Semegen This code is licensed under MIT license (see LICENSE file for details) */ //this #include <cml/utils/Command_line.hpp> //cml #include <cml/common/memory.hpp> #include <cml/debug/assert.hpp> #include <cml/hal/peripherals/USART.hpp> namespace cml { namespace utils { using namespace cml::collection; using namespace cml::common; using namespace cml::hal; void Command_line::update() { char c[] = { 0, 0, 0 }; uint32_t length = this->read_character.function(c, sizeof(c), this->read_character.p_user_data); if (1 == length) { switch (c[0]) { case '\n': { if (this->line_length > 0) { this->line_buffer[this->line_length] = 0; this->commands_carousel.push(this->line_buffer, this->line_length); this->callback_parameters_buffer_view = this->get_callback_parameters(this->line_buffer, this->line_length, " -", 2); bool command_executed = this->execute_command(this->callback_parameters_buffer_view); if (false == command_executed) { this->write_new_line(); this->write_string.function(this->p_command_not_found_message, this->command_not_found_message_length, this->write_string.p_user_data); } this->line_length = 0; } this->write_new_line(); this->write_prompt(); } break; case '\b': { if (this->line_length > 0) { this->line_buffer[this->line_length--] = 0; this->write_string.function("\b \b", 3, this->write_string.p_user_data); } } break; default: { if (this->line_length + 1 < config::command_line::line_buffer_capacity) { this->line_buffer[this->line_length++] = c[0]; this->write_character.function(c[0], this->write_character.p_user_data); } } } } else if (3 == length && '\033' == c[0]) { this->execute_escape_sequence(c[1], c[2]); } } Vector<Command_line::Callback::Parameter> Command_line::get_callback_parameters(char* a_p_line, uint32_t a_length, const char* a_p_separators, uint32_t a_separators_count) { Vector<Callback::Parameter> ret(this->callback_parameters_buffer, config::command_line::callback_parameters_buffer_capacity); auto contains = [](char a_character, const char* a_p_separators, uint32_t a_separators_count) { bool ret = false; for (decltype(a_separators_count) i = 0; i < a_separators_count && false == ret; i++) { ret = a_p_separators[i] == a_character; } return ret; }; const char* p_begin = &(a_p_line[0]); for (decltype(a_length) i = 0; i < a_length && false == ret.is_full(); i++) { if (nullptr != p_begin && true == contains(a_p_line[i], a_p_separators, a_separators_count)) { assert(&(a_p_line[i]) > p_begin); ret.push_back({ p_begin, static_cast<uint32_t>(&(a_p_line[i]) - p_begin) }); a_p_line[i] = 0; p_begin = nullptr; } else if (nullptr == p_begin && false == contains(a_p_line[i], a_p_separators, a_separators_count)) { p_begin = &(a_p_line[i]); } } if (nullptr != p_begin && false == ret.is_full()) { assert(&(a_p_line[a_length]) > p_begin); ret.push_back({ p_begin, static_cast<uint32_t>(&(a_p_line[a_length]) - p_begin) }); } return ret; } bool Command_line::execute_command(const Vector<Callback::Parameter>& a_parameters) { uint32_t index = this->callbacks_buffer_view.get_capacity(); for (uint32_t i = 0; i < this->callbacks_buffer_view.get_length() && this->callbacks_buffer_view.get_capacity() == index; i++) { if (true == cstring::equals(a_parameters[0].a_p_value, this->callbacks_buffer_view[i].p_name, a_parameters[0].length)) { index = i; } } bool ret = index != this->callbacks_buffer_view.get_capacity(); if (true == ret) { this->callbacks_buffer_view[index].function(a_parameters, this->callbacks_buffer_view[index].p_user_data); } return ret; } void Command_line::execute_escape_sequence(char a_first, char a_second) { if ('[' == a_first && this->commands_carousel.get_length() > 0) { this->write_string.function("\033[2K\r", 5, this->write_string.p_user_data); this->write_prompt(); switch (a_second) { case 'A': { const Commands_carousel::Command& command = this->commands_carousel.read_next(); memory::copy(this->line_buffer, sizeof(this->line_buffer), command.buffer, command.length); this->line_length = command.length; this->write_string.function(command.buffer, command.length, this->write_string.p_user_data); } break; case 'B': { const Commands_carousel::Command& command = this->commands_carousel.read_prev(); memory::copy(this->line_buffer, sizeof(this->line_buffer), command.buffer, command.length); this->line_length = command.length; this->write_string.function(command.buffer, command.length, this->write_string.p_user_data); } break; } } } void Command_line::Commands_carousel::push(const char* a_p_line, uint32_t a_length) { if (this->write_index == config::command_line::commands_carousel_capacity) { this->write_index = 0; } this->commands[this->write_index].length = a_length; memory::copy(this->commands[this->write_index].buffer, sizeof(this->commands[this->write_index].buffer), a_p_line, a_length); this->write_index++; if (this->length < config::command_line::commands_carousel_capacity) { this->length++; } } const Command_line::Commands_carousel::Command& Command_line::Commands_carousel::read_next() const { assert(this->length > 0); return this->commands[this->read_index++ % this->length]; } const Command_line::Commands_carousel::Command& Command_line::Commands_carousel::read_prev() const { assert(this->length > 0); return this->commands[this->read_index-- % this->length]; } } // namespace utils } // namespace cml
32.491379
114
0.529849
JayKickliter
1783119049e7e8958e5190c6a21a7eafa84b09dd
5,349
cpp
C++
experiment/synth.cpp
keryell/muSYCL
130e4b29c3a4daf4c908b08263b53910acb13787
[ "Apache-2.0" ]
16
2021-05-07T11:33:59.000Z
2022-03-05T02:36:06.000Z
experiment/synth.cpp
keryell/muSYCL
130e4b29c3a4daf4c908b08263b53910acb13787
[ "Apache-2.0" ]
null
null
null
experiment/synth.cpp
keryell/muSYCL
130e4b29c3a4daf4c908b08263b53910acb13787
[ "Apache-2.0" ]
null
null
null
#include "rtaudio/RtAudio.h" #include "rtmidi/RtMidi.h" #include <atomic> #include <chrono> #include <cmath> #include <cstdint> #include <cstdlib> #include <iostream> #include <thread> #include <vector> /// The configuration part to adapt to the context // Jack auto constexpr midi_api = RtMidi::UNIX_JACK; auto constexpr midi_in_port = 0; // ALSA //auto constexpr midi_api = RtMidi::LINUX_ALSA; //auto constexpr midi_in_port = 1; /// The configuration part to adapt to the context // Jack auto constexpr audio_api = RtAudio::UNIX_JACK; // ALSA //auto constexpr audio_api = RtAudio::LINUX_ALSA; // To use time unit literals directly using namespace std::chrono_literals; std::atomic saw_level = 0.; std::atomic dt = 0.; /// Check for errors auto check_error = [] (auto&& function) { try { return function(); } catch (const RtAudioError &error) { error.printMessage(); std::exit(EXIT_FAILURE); } catch (const RtMidiError &error) { error.printMessage(); std::exit(EXIT_FAILURE); } }; /// Process the incomming MIDI messages void midi_in_callback(double time_stamp, std::vector<std::uint8_t>* p_midi_message, void* user_data ) { auto &midi_message = *p_midi_message; auto n_bytes = midi_message.size(); for (int i = 0; i < n_bytes; ++i) std::cout << "Byte " << i << " = " << static_cast<int>(midi_message[i]) << ", "; std::cout << "time stamp = " << time_stamp << std::endl; if (midi_message[0] == 176 && midi_message[1] == 27) // Use the left pedal value of an FCB1010 to change the sound saw_level = (midi_message[2] - 64)/70.; else if (midi_message[0] == 144 && midi_message[2] != 0) { // Start the note auto frequency = 440*std::pow(2., (midi_message[1] - 69)/12.); dt = 2*frequency/48000; } else if (midi_message[0] == 128 || (midi_message[0] == 144 && midi_message[2] == 0)) // Stop the note dt = 0; } // 1 channel sawtooth wave generator. int audio_callback(void *output_buffer, void *input_buffer, unsigned int frame_size, double time_stamp, RtAudioStreamStatus status, void *user_data) { auto buffer = static_cast<double*>(output_buffer); auto& last_value = *static_cast<double *>(user_data); if (status) std::cerr << "Stream underflow detected!" << std::endl; for (auto i = 0; i < frame_size; ++i) { // Add some clamping to the saw signal to change the sound buffer[i] = last_value > saw_level ? 1. : last_value; // Advance the phase last_value += dt; // The value is cyclic, between -1 and 1 if (last_value >= 1.0) last_value -= 2.0; } return 0; } int main() { std::cout << "RtMidi version " << RtMidi::getVersion() << std::endl; /* Only from RtMidi 4.0.0... std::cout << "RtMidi version " << RtMidi::getVersion() << "\nAPI availables:" << std::endl; std::vector<RtMidi::Api> apis; RtMidi::getCompiledApi(apis); for (auto a : apis) std::cout << '\t' << RtMidi::getApiName(a) << std::endl; */ // Create a MIDI input using Jack and a fancy client name auto midi_in = check_error([] { return RtMidiIn { midi_api, "muSYCLtest" }; }); auto n_ports = midi_in.getPortCount(); std::cout << "There are " << n_ports << " MIDI input sources available." << std::endl; for (int i = 0; i < n_ports; ++i) { auto port_name = midi_in.getPortName(i); std::cout << " Input Port #" << i << ": " << port_name << '\n'; } // Open the first port and give it a fancy name check_error([&] { midi_in.openPort(midi_in_port, "testMIDIinput"); }); // Don't ignore sysex, timing, or active sensing messages midi_in.ignoreTypes(false, false, false); // Drain the message queue to avoid leftover MIDI messages std::vector<std::uint8_t> message; do { // There is some race condition in RtMidi where the messages are // not seen if there is not some sleep here std::this_thread::sleep_for(1ms); midi_in.getMessage(&message); } while (!message.empty()); // Handle MIDI messages with this callback function midi_in.setCallback(midi_in_callback, nullptr); auto audio = check_error([] { return RtAudio { audio_api }; }); auto device = audio.getDefaultOutputDevice(); RtAudio::StreamParameters parameters; parameters.deviceId = device; parameters.nChannels = 1; parameters.firstChannel = 0; RtAudio::StreamOptions options; options.streamName = "muSYCLtest"; auto sample_rate = audio.getDeviceInfo(device).preferredSampleRate; auto frame_size = 256U; // 256 sample frames double data {}; check_error([&] { audio.openStream(&parameters, nullptr, RTAUDIO_FLOAT64, sample_rate, &frame_size, audio_callback, &data, &options, [] (RtAudioError::Type type, const std::string &error_text) { std::cerr << error_text << std::endl; }); }); std::cout << "Sample rate: " << sample_rate << "\nSamples per frame: " << frame_size << std::endl; // Start the sound generation check_error([&] { audio.startStream(); }); std::cout << "\nReading MIDI input ... press <enter> to quit.\n"; char input; std::cin.get(input); return 0; }
31.650888
79
0.627594
keryell
1783b817ce7ce681ea631e49cbfc4192b904d265
12,406
hpp
C++
include/System/Net/Http/Headers/HttpHeaders.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/System/Net/Http/Headers/HttpHeaders.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/System/Net/Http/Headers/HttpHeaders.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" // Including type: System.Collections.Generic.IEnumerable`1 #include "System/Collections/Generic/IEnumerable_1.hpp" // Including type: System.Collections.Generic.KeyValuePair`2 #include "System/Collections/Generic/KeyValuePair_2.hpp" // Including type: System.Net.Http.Headers.HttpHeaderKind #include "System/Net/Http/Headers/HttpHeaderKind.hpp" // Including type: System.Nullable`1 #include "System/Nullable_1.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "extern/beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: System::Net::Http::Headers namespace System::Net::Http::Headers { // Forward declaring type: HeaderInfo class HeaderInfo; // Forward declaring type: HttpHeaderValueCollection`1<T> template<typename T> class HttpHeaderValueCollection_1; } // Forward declaring namespace: System::Collections::Generic namespace System::Collections::Generic { // Forward declaring type: Dictionary`2<TKey, TValue> template<typename TKey, typename TValue> class Dictionary_2; // Forward declaring type: IEnumerator`1<T> template<typename T> class IEnumerator_1; // Forward declaring type: List`1<T> template<typename T> class List_1; } // Forward declaring namespace: System::Collections namespace System::Collections { // Forward declaring type: IEnumerator class IEnumerator; } // Forward declaring namespace: System namespace System { // Forward declaring type: Func`2<T, TResult> template<typename T, typename TResult> class Func_2; } // Completed forward declares // Type namespace: System.Net.Http.Headers namespace System::Net::Http::Headers { // WARNING Size may be invalid! // Autogenerated type: System.Net.Http.Headers.HttpHeaders class HttpHeaders : public ::Il2CppObject/*, public System::Collections::Generic::IEnumerable_1<System::Collections::Generic::KeyValuePair_2<::Il2CppString*, System::Collections::Generic::IEnumerable_1<::Il2CppString*>*>>*/ { public: // Nested type: System::Net::Http::Headers::HttpHeaders::HeaderBucket class HeaderBucket; // Nested type: System::Net::Http::Headers::HttpHeaders::$GetEnumerator$d__19 class $GetEnumerator$d__19; // private readonly System.Collections.Generic.Dictionary`2<System.String,System.Net.Http.Headers.HttpHeaders/HeaderBucket> headers // Size: 0x8 // Offset: 0x10 System::Collections::Generic::Dictionary_2<::Il2CppString*, System::Net::Http::Headers::HttpHeaders::HeaderBucket*>* headers; // Field size check static_assert(sizeof(System::Collections::Generic::Dictionary_2<::Il2CppString*, System::Net::Http::Headers::HttpHeaders::HeaderBucket*>*) == 0x8); // private readonly System.Net.Http.Headers.HttpHeaderKind HeaderKind // Size: 0x4 // Offset: 0x18 System::Net::Http::Headers::HttpHeaderKind HeaderKind; // Field size check static_assert(sizeof(System::Net::Http::Headers::HttpHeaderKind) == 0x4); // System.Nullable`1<System.Boolean> connectionclose // Size: 0xFFFFFFFF // Offset: 0x1C System::Nullable_1<bool> connectionclose; // System.Nullable`1<System.Boolean> transferEncodingChunked // Size: 0xFFFFFFFF // Offset: 0x1E System::Nullable_1<bool> transferEncodingChunked; // Creating value type constructor for type: HttpHeaders HttpHeaders(System::Collections::Generic::Dictionary_2<::Il2CppString*, System::Net::Http::Headers::HttpHeaders::HeaderBucket*>* headers_ = {}, System::Net::Http::Headers::HttpHeaderKind HeaderKind_ = {}, System::Nullable_1<bool> connectionclose_ = {}, System::Nullable_1<bool> transferEncodingChunked_ = {}) noexcept : headers{headers_}, HeaderKind{HeaderKind_}, connectionclose{connectionclose_}, transferEncodingChunked{transferEncodingChunked_} {} // Creating interface conversion operator: operator System::Collections::Generic::IEnumerable_1<System::Collections::Generic::KeyValuePair_2<::Il2CppString*, System::Collections::Generic::IEnumerable_1<::Il2CppString*>*>> operator System::Collections::Generic::IEnumerable_1<System::Collections::Generic::KeyValuePair_2<::Il2CppString*, System::Collections::Generic::IEnumerable_1<::Il2CppString*>*>>() noexcept { return *reinterpret_cast<System::Collections::Generic::IEnumerable_1<System::Collections::Generic::KeyValuePair_2<::Il2CppString*, System::Collections::Generic::IEnumerable_1<::Il2CppString*>*>>*>(this); } // Get static field: static private readonly System.Collections.Generic.Dictionary`2<System.String,System.Net.Http.Headers.HeaderInfo> known_headers static System::Collections::Generic::Dictionary_2<::Il2CppString*, System::Net::Http::Headers::HeaderInfo*>* _get_known_headers(); // Set static field: static private readonly System.Collections.Generic.Dictionary`2<System.String,System.Net.Http.Headers.HeaderInfo> known_headers static void _set_known_headers(System::Collections::Generic::Dictionary_2<::Il2CppString*, System::Net::Http::Headers::HeaderInfo*>* value); // static private System.Void .cctor() // Offset: 0x1578514 static void _cctor(); // System.Void .ctor(System.Net.Http.Headers.HttpHeaderKind headerKind) // Offset: 0x1578314 template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static HttpHeaders* New_ctor(System::Net::Http::Headers::HttpHeaderKind headerKind) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::Http::Headers::HttpHeaders::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<HttpHeaders*, creationType>(headerKind))); } // private System.Boolean AddInternal(System.String name, System.Collections.Generic.IEnumerable`1<System.String> values, System.Net.Http.Headers.HeaderInfo headerInfo, System.Boolean ignoreInvalid) // Offset: 0x157A068 bool AddInternal(::Il2CppString* name, System::Collections::Generic::IEnumerable_1<::Il2CppString*>* values, System::Net::Http::Headers::HeaderInfo* headerInfo, bool ignoreInvalid); // public System.Boolean TryAddWithoutValidation(System.String name, System.Collections.Generic.IEnumerable`1<System.String> values) // Offset: 0x157A60C bool TryAddWithoutValidation(::Il2CppString* name, System::Collections::Generic::IEnumerable_1<::Il2CppString*>* values); // private System.Boolean TryCheckName(System.String name, out System.Net.Http.Headers.HeaderInfo headerInfo) // Offset: 0x157A6E4 bool TryCheckName(::Il2CppString* name, System::Net::Http::Headers::HeaderInfo*& headerInfo); // public System.Collections.Generic.IEnumerator`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Collections.Generic.IEnumerable`1<System.String>>> GetEnumerator() // Offset: 0x157A844 System::Collections::Generic::IEnumerator_1<System::Collections::Generic::KeyValuePair_2<::Il2CppString*, System::Collections::Generic::IEnumerable_1<::Il2CppString*>*>>* GetEnumerator(); // private System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() // Offset: 0x157A8E0 System::Collections::IEnumerator* System_Collections_IEnumerable_GetEnumerator(); // static System.String GetSingleHeaderString(System.String key, System.Collections.Generic.IEnumerable`1<System.String> values) // Offset: 0x157A8E4 static ::Il2CppString* GetSingleHeaderString(::Il2CppString* key, System::Collections::Generic::IEnumerable_1<::Il2CppString*>* values); // private System.Collections.Generic.List`1<System.String> GetAllHeaderValues(System.Net.Http.Headers.HttpHeaders/HeaderBucket bucket, System.Net.Http.Headers.HeaderInfo headerInfo) // Offset: 0x157AF58 System::Collections::Generic::List_1<::Il2CppString*>* GetAllHeaderValues(System::Net::Http::Headers::HttpHeaders::HeaderBucket* bucket, System::Net::Http::Headers::HeaderInfo* headerInfo); // static System.Net.Http.Headers.HttpHeaderKind GetKnownHeaderKind(System.String name) // Offset: 0x157B1B8 static System::Net::Http::Headers::HttpHeaderKind GetKnownHeaderKind(::Il2CppString* name); // T GetValue(System.String name) // Offset: 0xFFFFFFFF template<class T> T GetValue(::Il2CppString* name) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::Http::Headers::HttpHeaders::GetValue"); static auto* ___internal__method = THROW_UNLESS((::il2cpp_utils::FindMethod(this, "GetValue", std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()}, ::std::vector<const Il2CppType*>{::il2cpp_utils::ExtractType(name)}))); static auto* ___generic__method = THROW_UNLESS(::il2cpp_utils::MakeGenericMethod(___internal__method, std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()})); return ::il2cpp_utils::RunMethodThrow<T, false>(this, ___generic__method, name); } // System.Net.Http.Headers.HttpHeaderValueCollection`1<T> GetValues(System.String name) // Offset: 0xFFFFFFFF template<class T> System::Net::Http::Headers::HttpHeaderValueCollection_1<T>* GetValues(::Il2CppString* name) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::Http::Headers::HttpHeaders::GetValues"); static auto* ___internal__method = THROW_UNLESS((::il2cpp_utils::FindMethod(this, "GetValues", std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()}, ::std::vector<const Il2CppType*>{::il2cpp_utils::ExtractType(name)}))); static auto* ___generic__method = THROW_UNLESS(::il2cpp_utils::MakeGenericMethod(___internal__method, std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()})); return ::il2cpp_utils::RunMethodThrow<System::Net::Http::Headers::HttpHeaderValueCollection_1<T>*, false>(this, ___generic__method, name); } // System.Void SetValue(System.String name, T value, System.Func`2<System.Object,System.String> toStringConverter) // Offset: 0xFFFFFFFF template<class T> void SetValue(::Il2CppString* name, T value, System::Func_2<::Il2CppObject*, ::Il2CppString*>* toStringConverter) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::Http::Headers::HttpHeaders::SetValue"); static auto* ___internal__method = THROW_UNLESS((::il2cpp_utils::FindMethod(this, "SetValue", std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()}, ::std::vector<const Il2CppType*>{::il2cpp_utils::ExtractType(name), ::il2cpp_utils::ExtractType(value), ::il2cpp_utils::ExtractType(toStringConverter)}))); static auto* ___generic__method = THROW_UNLESS(::il2cpp_utils::MakeGenericMethod(___internal__method, std::vector<Il2CppClass*>{::il2cpp_utils::il2cpp_type_check::il2cpp_no_arg_class<T>::get()})); ::il2cpp_utils::RunMethodThrow<void, false>(this, ___generic__method, name, value, toStringConverter); } // protected System.Void .ctor() // Offset: 0x1579F80 // Implemented from: System.Object // Base method: System.Void Object::.ctor() template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static HttpHeaders* New_ctor() { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::Http::Headers::HttpHeaders::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<HttpHeaders*, creationType>())); } // public override System.String ToString() // Offset: 0x157AC90 // Implemented from: System.Object // Base method: System.String Object::ToString() ::Il2CppString* ToString(); }; // System.Net.Http.Headers.HttpHeaders // WARNING Not writing size check since size may be invalid! } DEFINE_IL2CPP_ARG_TYPE(System::Net::Http::Headers::HttpHeaders*, "System.Net.Http.Headers", "HttpHeaders");
72.127907
456
0.740206
darknight1050
17879160c66cdaeb1fc0900083b9355dfd6d580c
1,862
hpp
C++
src/ndnph/core/operators.hpp
Pesa/NDNph
70b0b4ef90649cc923ab4bbbfbdb31efe027d4a8
[ "0BSD" ]
2
2020-03-06T02:07:21.000Z
2021-12-29T04:53:58.000Z
src/ndnph/core/operators.hpp
Pesa/NDNph
70b0b4ef90649cc923ab4bbbfbdb31efe027d4a8
[ "0BSD" ]
null
null
null
src/ndnph/core/operators.hpp
Pesa/NDNph
70b0b4ef90649cc923ab4bbbfbdb31efe027d4a8
[ "0BSD" ]
2
2020-02-26T20:31:07.000Z
2021-04-22T18:27:19.000Z
#ifndef NDNPH_CORE_OPERATORS_HPP #define NDNPH_CORE_OPERATORS_HPP /** @brief Declare operator!= in terms of operator== */ #define NDNPH_DECLARE_NE(T, specifier) \ specifier bool operator!=(const T& lhs, const T& rhs) \ { \ return !(lhs == rhs); \ } /** @brief Declare operator>, operator<=, operator>= in terms of operator< */ #define NDNPH_DECLARE_GT_LE_GE(T, specifier) \ specifier bool operator>(const T& lhs, const T& rhs) \ { \ return rhs < lhs; \ } \ specifier bool operator<=(const T& lhs, const T& rhs) \ { \ return !(lhs > rhs); \ } \ specifier bool operator>=(const T& lhs, const T& rhs) \ { \ return !(lhs < rhs); \ } #endif // NDNPH_CORE_OPERATORS_HPP
68.962963
100
0.243287
Pesa
178c507178cd02e8052698a69397b7aedd4e417b
18,805
cpp
C++
olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp
fermeise/here-data-sdk-cpp
e0ebd7bd74463fa3958eb0447b90227a4f322643
[ "Apache-2.0" ]
null
null
null
olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp
fermeise/here-data-sdk-cpp
e0ebd7bd74463fa3958eb0447b90227a4f322643
[ "Apache-2.0" ]
null
null
null
olp-cpp-sdk-dataservice-write/src/StreamLayerClientImpl.cpp
fermeise/here-data-sdk-cpp
e0ebd7bd74463fa3958eb0447b90227a4f322643
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2019-2021 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 * License-Filename: LICENSE */ #include "StreamLayerClientImpl.h" #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_io.hpp> #include <olp/core/cache/KeyValueCache.h> #include <olp/core/client/CancellationContext.h> #include <olp/core/client/OlpClient.h> #include <olp/core/client/PendingRequests.h> #include <olp/core/client/TaskContext.h> #include <olp/core/logging/Log.h> #include <olp/core/thread/TaskScheduler.h> #include <olp/dataservice/write/model/PublishDataRequest.h> #include <olp/dataservice/write/model/PublishSdiiRequest.h> #include "ApiClientLookup.h" #include "generated/BlobApi.h" #include "generated/ConfigApi.h" #include "generated/IngestApi.h" #include "generated/PublishApi.h" // clang-format off #include <generated/serializer/CatalogSerializer.h> #include <generated/serializer/PublishDataRequestSerializer.h> #include <generated/serializer/JsonSerializer.h> // clang-format on // clang-format off #include <generated/parser/CatalogParser.h> #include <generated/parser/PublishDataRequestParser.h> #include "JsonResultParser.h" // clang-format on namespace olp { namespace dataservice { namespace write { namespace { constexpr auto kLogTag = "StreamLayerClientImpl"; constexpr int64_t kTwentyMib = 20971520; // 20 MiB } // namespace StreamLayerClientImpl::StreamLayerClientImpl( client::HRN catalog, StreamLayerClientSettings client_settings, client::OlpClientSettings settings) : catalog_(catalog), settings_(settings), catalog_settings_(catalog, settings), cache_(settings_.cache), cache_mutex_(), stream_client_settings_(std::move(client_settings)), pending_requests_(std::make_shared<client::PendingRequests>()), task_scheduler_(std::move(settings_.task_scheduler)) {} StreamLayerClientImpl::~StreamLayerClientImpl() { pending_requests_->CancelAllAndWait(); } bool StreamLayerClientImpl::CancelPendingRequests() { OLP_SDK_LOG_TRACE(kLogTag, "CancelPendingRequests"); return pending_requests_->CancelAll(); } std::string StreamLayerClientImpl::GetUuidListKey() const { static const std::string kStreamCachePostfix = "-stream-queue-cache"; const std::string uuid_list_key = catalog_.ToCatalogHRNString() + kStreamCachePostfix; return uuid_list_key; } size_t StreamLayerClientImpl::QueueSize() const { std::lock_guard<std::mutex> lock(cache_mutex_); const auto uuid_list_any = cache_->Get(GetUuidListKey(), [](const std::string& s) { return s; }); std::string uuid_list = ""; if (!uuid_list_any.empty()) { uuid_list = boost::any_cast<std::string>(uuid_list_any); return std::count(uuid_list.cbegin(), uuid_list.cend(), ','); } return 0; } boost::optional<std::string> StreamLayerClientImpl::Queue( const model::PublishDataRequest& request) { if (!cache_) { return boost::make_optional<std::string>( "No cache provided to StreamLayerClient"); } if (!request.GetData()) { return boost::make_optional<std::string>( "PublishDataRequest does not contain any Data"); } if (request.GetLayerId().empty()) { return boost::make_optional<std::string>( "PublishDataRequest does not contain a Layer ID"); } if (!(StreamLayerClientImpl::QueueSize() < stream_client_settings_.maximum_requests)) { return boost::make_optional<std::string>( "Maximum number of requests has reached"); } { std::lock_guard<std::mutex> lock(cache_mutex_); const auto publish_data_key = GenerateUuid(); cache_->Put(publish_data_key, request, [=]() { return olp::serializer::serialize<model::PublishDataRequest>(request); }); const auto uuid_list_any = cache_->Get(GetUuidListKey(), [](const std::string& s) { return s; }); std::string uuid_list = ""; if (!uuid_list_any.empty()) { uuid_list = boost::any_cast<std::string>(uuid_list_any); } uuid_list += publish_data_key + ","; cache_->Put(GetUuidListKey(), uuid_list, [&uuid_list]() { return uuid_list; }); } return boost::none; } boost::optional<model::PublishDataRequest> StreamLayerClientImpl::PopFromQueue() { std::lock_guard<std::mutex> lock(cache_mutex_); const auto uuid_list_any = cache_->Get(GetUuidListKey(), [](const std::string& s) { return s; }); if (uuid_list_any.empty()) { OLP_SDK_LOG_ERROR(kLogTag, "Unable to Restore UUID list from Cache"); return boost::none; } auto uuid_list = boost::any_cast<std::string>(uuid_list_any); auto pos = uuid_list.find(","); if (pos == std::string::npos) { return boost::none; } const auto publish_data_key = uuid_list.substr(0, pos); auto publish_data_any = cache_->Get(publish_data_key, [](const std::string& s) { return olp::parser::parse<model::PublishDataRequest>(s); }); cache_->Remove(publish_data_key); uuid_list.erase(0, pos + 1); cache_->Put(GetUuidListKey(), uuid_list, [&uuid_list]() { return uuid_list; }); if (publish_data_any.empty()) { OLP_SDK_LOG_ERROR(kLogTag, "Unable to Restore PublishData Request from Cache"); return boost::none; } return boost::any_cast<model::PublishDataRequest>(publish_data_any); } olp::client::CancellableFuture<StreamLayerClient::FlushResponse> StreamLayerClientImpl::Flush(model::FlushRequest request) { auto promise = std::make_shared<std::promise<StreamLayerClient::FlushResponse>>(); auto cancel_token = Flush( std::move(request), [promise](StreamLayerClient::FlushResponse response) { promise->set_value(std::move(response)); }); return client::CancellableFuture<StreamLayerClient::FlushResponse>( cancel_token, promise); } olp::client::CancellationToken StreamLayerClientImpl::Flush( model::FlushRequest request, StreamLayerClient::FlushCallback callback) { // Because TaskContext accepts the execution callbacks which return only // ApiResponse object, we need to simulate the 'empty' response in order to // be able to use Flush execution lambda in TaskContext. struct EmptyFlushResponse {}; using EmptyFlushApiResponse = client::ApiResponse<EmptyFlushResponse, client::ApiError>; // this flag is required in order to protect the user from 2 `callback` // invocation: one during execution phase and other when `Flush` is cancelled. auto exec_started = std::make_shared<std::atomic_bool>(false); auto task_context = client::TaskContext::Create( [=](client::CancellationContext context) -> EmptyFlushApiResponse { exec_started->exchange(true); StreamLayerClient::FlushResponse responses; const auto maximum_events_number = request.GetNumberOfRequestsToFlush(); if (maximum_events_number < 0) { callback(std::move(responses)); return EmptyFlushApiResponse{}; } int counter = 0; while ((!maximum_events_number || counter < maximum_events_number) && (this->QueueSize() > 0) && !context.IsCancelled()) { auto publish_request = this->PopFromQueue(); if (publish_request == boost::none) { continue; } auto publish_response = PublishDataTask(*publish_request, context); responses.emplace_back(std::move(publish_response)); // If cancelled queue back task if (context.IsCancelled()) { this->Queue(*publish_request); break; } counter++; } OLP_SDK_LOG_INFO_F(kLogTag, "Flushed %d publish requests", counter); callback(responses); return EmptyFlushApiResponse{}; }, [=](EmptyFlushApiResponse /*response*/) { // we don't need to notify user 2 times, cause we already invoke a // callback in the execution function: if (!exec_started->load()) { callback(StreamLayerClient::FlushResponse{}); } }); auto pending_requests = pending_requests_; pending_requests->Insert(task_context); thread::ExecuteOrSchedule(task_scheduler_, [=]() { task_context.Execute(); pending_requests->Remove(task_context); }); return task_context.CancelToken(); } olp::client::CancellableFuture<PublishDataResponse> StreamLayerClientImpl::PublishData(model::PublishDataRequest request) { auto promise = std::make_shared<std::promise<PublishDataResponse>>(); auto cancel_token = PublishData(std::move(request), [promise](PublishDataResponse response) { promise->set_value(std::move(response)); }); return client::CancellableFuture<PublishDataResponse>(cancel_token, promise); } client::CancellationToken StreamLayerClientImpl::PublishData( model::PublishDataRequest request, PublishDataCallback callback) { if (!request.GetData()) { callback(PublishDataResponse(client::ApiError( client::ErrorCode::InvalidArgument, "Request's data is null."))); return client::CancellationToken(); } using std::placeholders::_1; client::TaskContext task_context = olp::client::TaskContext::Create( std::bind(&StreamLayerClientImpl::PublishDataTask, this, request, _1), callback); auto pending_requests = pending_requests_; pending_requests->Insert(task_context); thread::ExecuteOrSchedule(task_scheduler_, [=]() { task_context.Execute(); pending_requests->Remove(task_context); }); return task_context.CancelToken(); } PublishDataResponse StreamLayerClientImpl::PublishDataTask( model::PublishDataRequest request, client::CancellationContext context) { const int64_t data_size = request.GetData()->size() * sizeof(unsigned char); if (data_size <= kTwentyMib) { return PublishDataLessThanTwentyMib(std::move(request), std::move(context)); } else { return PublishDataGreaterThanTwentyMib(std::move(request), std::move(context)); } } PublishDataResponse StreamLayerClientImpl::PublishDataLessThanTwentyMib( model::PublishDataRequest request, client::CancellationContext context) { OLP_SDK_LOG_TRACE_F(kLogTag, "Started publishing data less than 20 MB, size=%zu B", request.GetData()->size()); auto layer_settings_result = catalog_settings_.GetLayerSettings( context, request.GetBillingTag(), request.GetLayerId()); if (!layer_settings_result.IsSuccessful()) { return layer_settings_result.GetError(); } const auto& layer_settings = layer_settings_result.GetResult(); if (layer_settings.content_type.empty()) { return PublishDataResponse(client::ApiError( client::ErrorCode::InvalidArgument, "Unable to find the Layer ID=`" + request.GetLayerId() + "` provided in the PublishDataRequest in the Catalog=" + catalog_.ToString())); } auto ingest_api = ApiClientLookup::LookupApiClient(catalog_, context, "ingest", "v1", settings_); if (!ingest_api.IsSuccessful()) { return PublishDataResponse(ingest_api.GetError()); } auto ingest_api_client = ingest_api.GetResult(); auto ingest_data_response = IngestApi::IngestData( ingest_api_client, request.GetLayerId(), layer_settings.content_type, layer_settings.content_encoding, request.GetData(), request.GetTraceId(), request.GetBillingTag(), request.GetChecksum(), context); if (!ingest_data_response.IsSuccessful()) { return ingest_data_response; } OLP_SDK_LOG_TRACE_F( kLogTag, "Successfully published data less than 20 MB, size=%zu B, trace_id=%s", request.GetData()->size(), ingest_data_response.GetResult().GetTraceID().c_str()); return ingest_data_response; } PublishDataResponse StreamLayerClientImpl::PublishDataGreaterThanTwentyMib( model::PublishDataRequest request, client::CancellationContext context) { OLP_SDK_LOG_TRACE_F(kLogTag, "Started publishing data greater than 20MB, size=%zu B", request.GetData()->size()); auto layer_settings_result = catalog_settings_.GetLayerSettings( context, request.GetBillingTag(), request.GetLayerId()); if (!layer_settings_result.IsSuccessful()) { return layer_settings_result.GetError(); } const auto& layer_settings = layer_settings_result.GetResult(); if (layer_settings.content_type.empty()) { return PublishDataResponse(client::ApiError( client::ErrorCode::InvalidArgument, "Unable to find the Layer ID=`" + request.GetLayerId() + "` provided in the PublishDataRequest in the Catalog=" + catalog_.ToString())); } // Init api clients for publications: auto publish_client_response = ApiClientLookup::LookupApiClient( catalog_, context, "publish", "v2", settings_); if (!publish_client_response.IsSuccessful()) { return PublishDataResponse(publish_client_response.GetError()); } client::OlpClient publish_client = publish_client_response.MoveResult(); auto blob_client_response = ApiClientLookup::LookupApiClient( catalog_, context, "blob", "v1", settings_); if (!blob_client_response.IsSuccessful()) { return PublishDataResponse(blob_client_response.GetError()); } client::OlpClient blob_client = blob_client_response.MoveResult(); // 1. init publication: model::Publication publication; publication.SetLayerIds({request.GetLayerId()}); auto init_publicaion_response = PublishApi::InitPublication( publish_client, publication, request.GetBillingTag(), context); if (!init_publicaion_response.IsSuccessful()) { return PublishDataResponse(init_publicaion_response.GetError()); } if (!init_publicaion_response.GetResult().GetId()) { return PublishDataResponse( client::ApiError(client::ErrorCode::InvalidArgument, "Response from server on InitPublication request " "doesn't contain any publication")); } const std::string publication_id = init_publicaion_response.GetResult().GetId().get(); // 2. Put blob API: const auto data_handle = GenerateUuid(); auto put_blob_response = BlobApi::PutBlob( blob_client, request.GetLayerId(), layer_settings.content_type, layer_settings.content_encoding, data_handle, request.GetData(), request.GetBillingTag(), context); if (!put_blob_response.IsSuccessful()) { return PublishDataResponse(put_blob_response.GetError()); } // 3. Upload partition: const auto partition_id = request.GetTraceId() ? request.GetTraceId().value() : GenerateUuid(); model::PublishPartition publish_partition; publish_partition.SetPartition(partition_id); publish_partition.SetDataHandle(data_handle); model::PublishPartitions partitions; partitions.SetPartitions({publish_partition}); auto upload_partitions_response = PublishApi::UploadPartitions( publish_client, partitions, publication_id, request.GetLayerId(), request.GetBillingTag(), context); if (!upload_partitions_response.IsSuccessful()) { return PublishDataResponse(upload_partitions_response.GetError()); } // 4. Sumbit publication: auto submit_publication_response = PublishApi::SubmitPublication( publish_client, publication_id, request.GetBillingTag(), context); if (!submit_publication_response.IsSuccessful()) { return PublishDataResponse(submit_publication_response.GetError()); } // 5. final result on successful submit of publication: model::ResponseOkSingle response_ok_single; response_ok_single.SetTraceID(partition_id); OLP_SDK_LOG_TRACE_F( kLogTag, "Successfully published data greater than 20 MB, size=%zu B, trace_id=%s", request.GetData()->size(), partition_id.c_str()); return PublishDataResponse(response_ok_single); } client::CancellableFuture<PublishSdiiResponse> StreamLayerClientImpl::PublishSdii(model::PublishSdiiRequest request) { auto promise = std::make_shared<std::promise<PublishSdiiResponse>>(); auto cancel_token = PublishSdii(std::move(request), [promise](PublishSdiiResponse response) { promise->set_value(std::move(response)); }); return client::CancellableFuture<PublishSdiiResponse>(cancel_token, promise); } client::CancellationToken StreamLayerClientImpl::PublishSdii( model::PublishSdiiRequest request, PublishSdiiCallback callback) { using std::placeholders::_1; auto context = olp::client::TaskContext::Create( std::bind(&StreamLayerClientImpl::PublishSdiiTask, this, std::move(request), _1), callback); auto pending_requests = pending_requests_; pending_requests->Insert(context); thread::ExecuteOrSchedule(task_scheduler_, [=]() { context.Execute(); pending_requests->Remove(context); }); return context.CancelToken(); } PublishSdiiResponse StreamLayerClientImpl::PublishSdiiTask( model::PublishSdiiRequest request, olp::client::CancellationContext context) { if (!request.GetSdiiMessageList()) { return {{client::ErrorCode::InvalidArgument, "Request sdii message list null."}}; } if (request.GetLayerId().empty()) { return {{client::ErrorCode::InvalidArgument, "Request layer id empty."}}; } return IngestSdii(std::move(request), context); } PublishSdiiResponse StreamLayerClientImpl::IngestSdii( model::PublishSdiiRequest request, client::CancellationContext context) { auto api_response = ApiClientLookup::LookupApiClient( catalog_, context, "ingest", "v1", settings_); if (!api_response.IsSuccessful()) { return api_response.GetError(); } auto client = api_response.MoveResult(); return IngestApi::IngestSdii(client, request.GetLayerId(), request.GetSdiiMessageList(), request.GetTraceId(), request.GetBillingTag(), request.GetChecksum(), context); } std::string StreamLayerClientImpl::GenerateUuid() const { static boost::uuids::random_generator gen; return boost::uuids::to_string(gen()); } } // namespace write } // namespace dataservice } // namespace olp
35.548204
80
0.709279
fermeise
178d11f99a5ef3336e03d2f45e092b0edb54c4aa
430
hxx
C++
inc/html5xx.d/Code.hxx
astrorigin/html5xx
cbaaeb232597a713630df7425752051036cf0cb2
[ "MIT" ]
null
null
null
inc/html5xx.d/Code.hxx
astrorigin/html5xx
cbaaeb232597a713630df7425752051036cf0cb2
[ "MIT" ]
null
null
null
inc/html5xx.d/Code.hxx
astrorigin/html5xx
cbaaeb232597a713630df7425752051036cf0cb2
[ "MIT" ]
null
null
null
/* * */ #ifndef _HTML5XX_CODE_HXX_ #define _HTML5XX_CODE_HXX_ #include "Element.hxx" #include "TextElement.hxx" using namespace std; namespace html { class Code: public Element { public: Code(): Element(Block, "code") {} Code( const string& text ): Element(Block, "code") { put(new TextElement(text)); } }; } // end namespace html #endif // _HTML5XX_CODE_HXX_ // vi: set ai et sw=2 sts=2 ts=2 :
11.621622
34
0.646512
astrorigin
179024b13e96f04345bd225f8fbc24dc36f936e5
4,513
cpp
C++
pose_refinement/SA-LMPE/ba/openMVG/graph/triplet_finder_test.cpp
Aurelio93/satellite-pose-estimation
46957a9bc9f204d468f8fe3150593b3db0f0726a
[ "MIT" ]
90
2019-05-19T03:48:23.000Z
2022-02-02T15:20:49.000Z
pose_refinement/SA-LMPE/ba/openMVG/graph/triplet_finder_test.cpp
Aurelio93/satellite-pose-estimation
46957a9bc9f204d468f8fe3150593b3db0f0726a
[ "MIT" ]
11
2019-05-22T07:45:46.000Z
2021-05-20T01:48:26.000Z
pose_refinement/SA-LMPE/ba/openMVG/graph/triplet_finder_test.cpp
Aurelio93/satellite-pose-estimation
46957a9bc9f204d468f8fe3150593b3db0f0726a
[ "MIT" ]
18
2019-05-19T03:48:32.000Z
2021-05-29T18:19:16.000Z
// This file is part of OpenMVG, an Open Multiple View Geometry C++ library. // Copyright (c) 2012, 2013 Pierre MOULON. // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "openMVG/graph/triplet_finder.hpp" #include "CppUnitLite/TestHarness.h" #include "testing/testing.h" #include <iostream> #include <vector> using namespace openMVG::graph; using Pairs = std::vector<std::pair<int,int>>; TEST(TripletFinder, test_no_triplet) { // a - b - c const int a = 0, b = 1, c = 2; const Pairs pairs = {{a, b}, {b, c}}; std::vector<Triplet> vec_triplets; EXPECT_FALSE(ListTriplets(pairs, vec_triplets)); EXPECT_TRUE(vec_triplets.empty()); } TEST(TripletFinder, test_one_triplet) { { // // a_b // |/ // c const int a = 0, b = 1, c = 2; const Pairs pairs = {{a, b}, {a, c}, {b, c}}; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(1, vec_triplets.size()); //Check the cycle values EXPECT_EQ(0, vec_triplets[0].i); EXPECT_EQ(1, vec_triplets[0].j); EXPECT_EQ(2, vec_triplets[0].k); } { // // a_b__c // |/ // d const int a = 0, b = 1, c = 2, d = 3; const Pairs pairs = {{a, b}, {b, c}, {b, d}, {c, d}}; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(1, vec_triplets.size()); //Check the cycle values EXPECT_EQ(1,vec_triplets[0].i); EXPECT_EQ(2,vec_triplets[0].j); EXPECT_EQ(3,vec_triplets[0].k); } } TEST(TripletFinder, test_two_triplet) { { // // a__b // |\ | // | \| // c--d const int a = 0, b = 1, c = 2, d = 3; const Pairs pairs = {{a, b}, {a, c}, {a, d}, {c, d}, {b,d}}; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(2, vec_triplets.size()); } { // // a c // |\ /| // | b | // |/ \| // d e const int a = 0, b = 1, c = 2, d = 3, e = 4; const Pairs pairs = {{a, b}, {b,c}, {c,e}, {e,b}, {b,d}, {d,a}}; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(2, vec_triplets.size()); } { // // a c // |\ /| // | b--f | // |/ \| // d e const int a = 0, b = 1, c = 2, d = 3, e = 4, f = 5; const Pairs pairs = {{a,b}, {b,f}, {f,c}, {c,e}, {e,f}, {f,b}, {b,d}, {d,a}}; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(2, vec_triplets.size()); } } TEST(TripletFinder, test_three_triplet) { { // // a b // |\ /| // c-d-e // |/ // f const int a = 0, b = 1, c = 2, d = 3, e = 4, f = 5; const Pairs pairs = { {a,c}, {a,d}, {c,d}, {c,f}, {f,d}, {d,b}, {b,e}, {e,d} }; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(3, vec_triplets.size()); } { // // a b--g--h // | \ / | \/ // | d--e | i // | / \ | // c f const int a = 0, b = 1, c = 2, d = 3, e = 4, f = 5, g = 6, h = 7, i = 8; const Pairs pairs = { {a,c}, {a,d}, {d,c}, {d,e}, {e,b}, {e,f}, {b,f}, {b,g}, {g,h}, {h,i}, {i,g} }; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(3, vec_triplets.size()); } { // // a---b // |\ |\ // | \ | \ // | \| \ // c---d---e // const int a = 0, b = 1, c = 2, d = 3, e = 4; const Pairs pairs = { {a,b}, {b,d}, {d,c}, {c,a}, {a,d}, {b,e}, {d,e} }; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(3, vec_triplets.size()); } } TEST(TripletFinder, test_for_triplet) { { // // a__b // |\/| // |/\| // c--d const int a = 0, b = 1, c = 2, d = 3; const Pairs pairs = { {a,b}, {a,c}, {a,d}, {c,d}, {b,d}, {c,b} }; std::vector<Triplet> vec_triplets; EXPECT_TRUE(ListTriplets(pairs, vec_triplets)); EXPECT_EQ(4, vec_triplets.size()); } } /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr);} /* ************************************************************************* */
23.38342
83
0.499003
Aurelio93
17956c8d436b4db062a273254cb1a979205712e1
2,564
hxx
C++
vtkm/filter/ZFPDecompressor1D.hxx
yisyuanliou/VTK-m
cc483c8c2319a78b58b3ab849da8ca448e896220
[ "BSD-3-Clause" ]
1
2021-07-21T07:15:44.000Z
2021-07-21T07:15:44.000Z
vtkm/filter/ZFPDecompressor1D.hxx
yisyuanliou/VTK-m
cc483c8c2319a78b58b3ab849da8ca448e896220
[ "BSD-3-Clause" ]
null
null
null
vtkm/filter/ZFPDecompressor1D.hxx
yisyuanliou/VTK-m
cc483c8c2319a78b58b3ab849da8ca448e896220
[ "BSD-3-Clause" ]
null
null
null
//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ #ifndef vtk_m_filter_ZFPDecompressor1D_hxx #define vtk_m_filter_ZFPDecompressor1D_hxx #include <vtkm/cont/CellSetStructured.h> #include <vtkm/cont/DynamicCellSet.h> #include <vtkm/cont/ErrorFilterExecution.h> namespace vtkm { namespace filter { //----------------------------------------------------------------------------- inline VTKM_CONT ZFPDecompressor1D::ZFPDecompressor1D() : vtkm::filter::FilterField<ZFPDecompressor1D>() { } //----------------------------------------------------------------------------- template <typename T, typename StorageType, typename DerivedPolicy> inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor1D::DoExecute( const vtkm::cont::DataSet&, const vtkm::cont::ArrayHandle<T, StorageType>&, const vtkm::filter::FieldMetadata&, const vtkm::filter::PolicyBase<DerivedPolicy>&) { VTKM_ASSERT(true); vtkm::cont::DataSet ds; return ds; } //----------------------------------------------------------------------------- template <typename StorageType, typename DerivedPolicy> inline VTKM_CONT vtkm::cont::DataSet ZFPDecompressor1D::DoExecute( const vtkm::cont::DataSet&, const vtkm::cont::ArrayHandle<vtkm::Int64, StorageType>& field, const vtkm::filter::FieldMetadata&, const vtkm::filter::PolicyBase<DerivedPolicy>&) { vtkm::cont::ArrayHandle<vtkm::Float64> decompress; decompressor.Decompress(field, decompress, rate, field.GetNumberOfValues()); vtkm::cont::DataSet dataset; dataset.AddField(vtkm::cont::make_FieldPoint("decompressed", decompress)); return dataset; } //----------------------------------------------------------------------------- template <typename T, typename StorageType, typename DerivedPolicy> inline VTKM_CONT bool ZFPDecompressor1D::DoMapField(vtkm::cont::DataSet&, const vtkm::cont::ArrayHandle<T, StorageType>&, const vtkm::filter::FieldMetadata&, const vtkm::filter::PolicyBase<DerivedPolicy>&) { return false; } } } // namespace vtkm::filter #endif
37.15942
99
0.578783
yisyuanliou
1798defc82f233f79277bcdaabc40110541b0899
6,245
cpp
C++
GenericCardReaderFriend/GenericCardReaderFriend.cpp
0xFireWolf/GenericCardReaderFriend
c835c62c81ff06c8c788096a24eb19bc4ff5e05d
[ "BSD-3-Clause" ]
8
2021-07-26T04:20:50.000Z
2022-01-14T11:11:47.000Z
GenericCardReaderFriend/GenericCardReaderFriend.cpp
0xFireWolf/GenericCardReaderFriend
c835c62c81ff06c8c788096a24eb19bc4ff5e05d
[ "BSD-3-Clause" ]
3
2021-07-30T00:44:49.000Z
2021-12-03T13:40:34.000Z
GenericCardReaderFriend/GenericCardReaderFriend.cpp
0xFireWolf/GenericCardReaderFriend
c835c62c81ff06c8c788096a24eb19bc4ff5e05d
[ "BSD-3-Clause" ]
1
2022-01-18T13:26:35.000Z
2022-01-18T13:26:35.000Z
// // GenericCardReaderFriend.cpp // GenericCardReaderFriend // // Created by FireWolf on 7/24/21. // #include <Headers/plugin_start.hpp> #include <Headers/kern_api.hpp> #include <Headers/kern_user.hpp> // // MARK: - Constants & Patches // static const char* kCardReaderReporterPath = "/System/Library/SystemProfiler/SPCardReaderReporter.spreporter"; static const size_t kCardReaderReporterPathLength = strlen(kCardReaderReporterPath); // MARK: USB-based Card Reader // Function: SPCardReaderReporter::updateDictionary() // Find: IOServiceMatching("com_apple_driver_AppleUSBCardReaderSBC") // Repl: IOServiceMatching("GenericUSBCardReaderController") // Note: Patch the name of the controller class static const uint8_t kAppleUSBCardReaderSBC[] = { 0x63, 0x6F, 0x6D, // "com" 0x5F, // "_" 0x61, 0x70, 0x70, 0x6C, 0x65, // "apple" 0x5F, // "_" 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, // "driver" 0x5F, // "_" 0x41, 0x70, 0x70, 0x6C, 0x65, // "Apple" 0x55, 0x53, 0x42, // "USB" 0x43, 0x61, 0x72, 0x64, // "Card" 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, // "Reader" 0x53, 0x42, 0x43, // "SBC" 0x00 // "\0" }; static const uint8_t kGenericUSBCardReaderController[] = { 0x47, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x55, 0x53, 0x42, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Function: SPCardReaderReporter::updateDictionary() // Find: IORegistryEntrySearchCFProperty(entry, "IOService", kCFBundleIdentifierKey, kCFAllocatorDefault, kIORegistryIterateRecursively) // NSString isEqualToString("com.apple.driver.AppleUSBCardReader") // Repl: NSString isEqualToString("science.firewolf.gcrf") // Note: Patch the bundle identifier static const uint8_t kAppleUCRBundleIdentifier[] = { 0x63, 0x6F, 0x6D, // "com" 0x2E, // "." 0x61, 0x70, 0x70, 0x6C, 0x65, // "apple" 0x2E, // "." 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, // "driver" 0x2E, // "." 0x41, 0x70, 0x70, 0x6C, 0x65, // "Apple" 0x55, 0x53, 0x42, // "USB" 0x43, 0x61, 0x72, 0x64, // "Card" 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, // "Reader" 0x00 // "\0" }; static const uint8_t kDummyUCRBundleIdentifier[] = { 0x73, 0x63, 0x69, 0x65, 0x6E, 0x63, 0x65, 0x2E, 0x66, 0x69, 0x72, 0x65, 0x77, 0x6F, 0x6C, 0x66, 0x2E, 0x67, 0x63, 0x72, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; // // MARK: - Helper Functions // static inline bool matchReporterPath(const char* path) { return strncmp(path, kCardReaderReporterPath, kCardReaderReporterPathLength) == 0; } static void patchReporter(const void* data, vm_size_t size) { void* memory = const_cast<void*>(data); SYSLOG_COND(UNLIKELY(KernelPatcher::findAndReplace(memory, size, kAppleUSBCardReaderSBC, kGenericUSBCardReaderController)), "GCRF", "Patched the USB controller name."); SYSLOG_COND(UNLIKELY(KernelPatcher::findAndReplace(memory, size, kAppleUCRBundleIdentifier, kDummyUCRBundleIdentifier)), "GCRF", "Patched the USB bundle identifier."); } // // MARK: - Routed Functions // // macOS Catalina and earlier static boolean_t (*orgCSValidateRange)(vnode_t, memory_object_t, memory_object_offset_t, const void*, vm_size_t, unsigned int*) = nullptr; static boolean_t wrapCSValidateRange(vnode_t vp, memory_object_t pager, memory_object_offset_t offset, const void* data, vm_size_t size, unsigned int* result) { char path[PATH_MAX]; int pathlen = PATH_MAX; boolean_t retVal = (*orgCSValidateRange)(vp, pager, offset, data, size, result); if (retVal && vn_getpath(vp, path, &pathlen) == 0 && matchReporterPath(path)) { patchReporter(data, size); } return retVal; } // macOS Big Sur and later static void (*orgCSValidatePage)(vnode_t, memory_object_t, memory_object_offset_t, const void*, int*, int*, int*) = nullptr; static void wrapCSValidatePage(vnode_t vp, memory_object_t pager, memory_object_offset_t page_offset, const void* data, int* validated_p, int* tainted_p, int* nx_p) { char path[PATH_MAX]; int pathlen = PATH_MAX; (*orgCSValidatePage)(vp, pager, page_offset, data, validated_p, tainted_p, nx_p); if (vn_getpath(vp, path, &pathlen) == 0 && matchReporterPath(path)) { patchReporter(data, PAGE_SIZE); } } // // MARK: - Boot Args // static const char *bootargOff[] = { "-gcrfoff" }; static const char *bootargDebug[] = { "-gcrfdbg" }; static const char *bootargBeta[] = { "-gcrfbeta" }; // // MARK: - Plugin Start Routine // static KernelPatcher::RouteRequest gRequestLegacy = { "_cs_validate_range", wrapCSValidateRange, orgCSValidateRange }; static KernelPatcher::RouteRequest gRequestCurrent = { "_cs_validate_page", wrapCSValidatePage, orgCSValidatePage }; static void start() { DBGLOG("GCRF", "Realtek card reader friend started."); auto action = [](void*, KernelPatcher& patcher) -> void { KernelPatcher::RouteRequest* request = getKernelVersion() >= KernelVersion::BigSur ? &gRequestCurrent : &gRequestLegacy; if (!patcher.routeMultipleLong(KernelPatcher::KernelID, request, 1)) { SYSLOG("GCRF", "Failed to route the function."); } }; lilu.onPatcherLoadForce(action); } // // MARK: - Plugin Configuration // PluginConfiguration ADDPR(config) = { xStringify(PRODUCT_NAME), parseModuleVersion(xStringify(MODULE_VERSION)), LiluAPI::AllowNormal, bootargOff, arrsize(bootargOff), bootargDebug, arrsize(bootargDebug), bootargBeta, arrsize(bootargBeta), KernelVersion::ElCapitan, KernelVersion::Monterey, start };
29.046512
172
0.63779
0xFireWolf
17a2a53a5a1d802aa6a3cdaf70d9d47bd9b0b224
1,725
hpp
C++
src/integrator/host/util.hpp
ValeevGroup/GauXC
cbc377c191e1159540d8ed923338cb849ae090ee
[ "BSD-3-Clause-LBNL" ]
null
null
null
src/integrator/host/util.hpp
ValeevGroup/GauXC
cbc377c191e1159540d8ed923338cb849ae090ee
[ "BSD-3-Clause-LBNL" ]
null
null
null
src/integrator/host/util.hpp
ValeevGroup/GauXC
cbc377c191e1159540d8ed923338cb849ae090ee
[ "BSD-3-Clause-LBNL" ]
null
null
null
#pragma once #include "blas.hpp" #include <vector> #include <tuple> #include <cstdint> namespace GauXC { namespace detail { template <typename _F1, typename _F2> void submat_set(int32_t M, int32_t N, int32_t MSub, int32_t NSub, _F1 *ABig, int32_t LDAB, _F2 *ASmall, int32_t LDAS, std::vector<std::pair<int32_t,int32_t>> &submat_map) { (void)(M); (void)(N); (void)(MSub); (void)(NSub); int32_t i(0); for( auto& iCut : submat_map ) { int32_t deltaI = iCut.second - iCut.first; int32_t j(0); for( auto& jCut : submat_map ) { int32_t deltaJ = jCut.second - jCut.first; auto* ABig_use = ABig + iCut.first + jCut.first * LDAB; auto* ASmall_use = ASmall + i + j * LDAS; GauXC::blas::lacpy( 'A', deltaI, deltaJ, ABig_use, LDAB, ASmall_use, LDAS ); j += deltaJ; } i += deltaI; } } template <typename _F1, typename _F2> void inc_by_submat(int32_t M, int32_t N, int32_t MSub, int32_t NSub, _F1 *ABig, int32_t LDAB, _F2 *ASmall, int32_t LDAS, std::vector<std::pair<int32_t,int32_t>> &submat_map) { (void)(M); (void)(N); (void)(MSub); (void)(NSub); int32_t i(0); for( auto& iCut : submat_map ) { int32_t deltaI = iCut.second - iCut.first; int32_t j(0); for( auto& jCut : submat_map ) { int32_t deltaJ = jCut.second - jCut.first; auto* ABig_use = ABig + iCut.first + jCut.first * LDAB; auto* ASmall_use = ASmall + i + j * LDAS; for( int32_t jj = 0; jj < deltaJ; ++jj ) for( int32_t ii = 0; ii < deltaI; ++ii ) ABig_use[ ii + jj * LDAB ] += ASmall_use[ ii + jj * LDAS ]; j += deltaJ; } i += deltaI; } } } }
21.296296
65
0.582029
ValeevGroup
17b0ab779c9cba1d89aedb70329996f16cd5dd58
1,972
cc
C++
game-server/test/unit/tictactwo/test_place_piece_action.cc
Towerism/morphling
cdfcb5949ca23417b5c6df9046f3a1924ba74771
[ "MIT" ]
4
2017-05-04T01:53:14.000Z
2017-05-09T05:55:57.000Z
game-server/test/unit/tictactwo/test_place_piece_action.cc
Towerism/morphling
cdfcb5949ca23417b5c6df9046f3a1924ba74771
[ "MIT" ]
null
null
null
game-server/test/unit/tictactwo/test_place_piece_action.cc
Towerism/morphling
cdfcb5949ca23417b5c6df9046f3a1924ba74771
[ "MIT" ]
null
null
null
#include <gtest/gtest.h> #include <games/tictactwo/tictactwo_model.h> #include <games/tictactwo/action_place_piece.h> #include <games/tictactwo/tictactwo_player.h> using namespace Morphling::Gamelogic::Tictactwo; using Morphling::Gamelogic::Game_object; class PlacePieceActionTests : public ::testing::Test { public: PlacePieceActionTests() : piece_x(new Game_object('X')), player("playerone", piece_x), model({ 2, 2 }) { model.set_player_one(&player); } Game_object* piece_x; Tictactwo_player player; Tictactwo_model model; }; TEST_F(PlacePieceActionTests, LegalToPlaceInsideGrid) { Action_place_piece action({ 2, 3 }); EXPECT_TRUE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlacePastOriginOfGrid) { Action_place_piece action({ 1, 1 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlacePastEndOfGrid) { Action_place_piece action({ 5, 5 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlacePastRightOfGrid) { Action_place_piece action({ 5, 2 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlacePastLeftOfGrid) { Action_place_piece action({ 2, 5 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlaceAboveGrid) { Action_place_piece action({ 2, 1 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, IllegalToPlaceBelowGrid) { Action_place_piece action({ 2, 5 }); EXPECT_FALSE(action.is_legal(&model)); } TEST_F(PlacePieceActionTests, PlacingPieceOccupiesTheSpace) { Action_place_piece action({ 2, 3 }); action.execute(&model); ASSERT_NE(nullptr, model.get_element({2, 3})); EXPECT_TRUE(model.get_element({2, 3})->equals(piece_x)); } TEST_F(PlacePieceActionTests, IllegalToPlaceOnOccupiedSpace) { Action_place_piece action({ 2, 3 }); action.execute(&model); EXPECT_FALSE(action.is_legal(&model)); }
24.345679
84
0.755071
Towerism
17b254b6d8b216b9f478aaa5e8f230e8b1c1d2b1
10,190
cpp
C++
Source/FlightSimulator/Private/System/FlightAutoPilotSystem.cpp
Lynnvon/FlightSimulator
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
[ "MIT" ]
1
2022-02-03T08:29:35.000Z
2022-02-03T08:29:35.000Z
Source/FlightSimulator/Private/System/FlightAutoPilotSystem.cpp
Lynnvon/FlightSimulator
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
[ "MIT" ]
null
null
null
Source/FlightSimulator/Private/System/FlightAutoPilotSystem.cpp
Lynnvon/FlightSimulator
2dca6f8364b7f4972a248de3dbc3a711740f5ed4
[ "MIT" ]
null
null
null
//MIT License // //Copyright(c) 2021 HaiLiang Feng // //QQ : 632865163 //Blog : https ://www.cnblogs.com/LynnVon/ // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this softwareand associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and /or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions : // //The above copyright noticeand this permission notice shall be included in all //copies or substantial portions of the Software. // //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE. #include "FlightAutoPilotSystem.h" #include "GameFramework/Actor.h" #include "Components/InputComponent.h" UFlightAutoPilotSystem::UFlightAutoPilotSystem(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) { // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features SetSystemName(FName("FlightAutoPilotSystem")); SetTickSystemEnable(true); Reset(); AttributeHold(); } void UFlightAutoPilotSystem::BeginPlay() { Super::BeginPlay(); } void UFlightAutoPilotSystem::BindKey() { if (GetOwner() && GetOwner()->InputComponent) { GetOwner()->InputComponent->BindAction(FName("SwitchAPOn"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::SwitchSubsystemOn); GetOwner()->InputComponent->BindAction(FName("SwitchAPOff"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::SwitchSubsystemOff); GetOwner()->InputComponent->BindAction(FName("ToggleAPOnoff"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::ToggleSubsystemOnOff); GetOwner()->InputComponent->BindAction(FName("Disengage"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::Disengage); GetOwner()->InputComponent->BindAction(FName("ToggleAPMode"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::ToggleAPMode); GetOwner()->InputComponent->BindAction(FName("WaypointFollowHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::WaypointFollowHold); GetOwner()->InputComponent->BindAction(FName("AttributeHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::AttributeHold); GetOwner()->InputComponent->BindAction(FName("BarometricAltitudeHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::BarometricAltitudeHold); GetOwner()->InputComponent->BindAction(FName("BarometricAltitude_HHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::BarometricAltitude_HHold); GetOwner()->InputComponent->BindAction(FName("RodioAltitudeHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::RodioAltitudeHold); GetOwner()->InputComponent->BindAction(FName("AltitudeAndSlopeHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::AltitudeAndSlopeHold); GetOwner()->InputComponent->BindAction(FName("LevelFlightHold"), EInputEvent::IE_Pressed, this, &UFlightAutoPilotSystem::LevelFlightHold); } } void UFlightAutoPilotSystem::StartUp() { Super::StartUp(); GetFlightControlSystem()->set_autopilot_engage(1, true); Hold(); } void UFlightAutoPilotSystem::ShutDown() { Super::ShutDown(); GetFlightControlSystem()->set_autopilot_engage(1, false); Reset(); } void UFlightAutoPilotSystem::TickSystem() { Super::TickSystem(); //如果自动驾驶期间摇杆有输入 就退出自动驾驶 if (GetFlightControlSystem()->HasControlInput()) { //Disengage(); ShutDown(); } } void UFlightAutoPilotSystem::Disengage() { Reset(); } void UFlightAutoPilotSystem::WaypointFollowHold() { SetAPMode(EAutoPoilotMode::EAPM_WAYPOINTFOLLOW); } void UFlightAutoPilotSystem::AttributeHold() { SetAPMode(EAutoPoilotMode::EAPM_ATTRIBUTE); } void UFlightAutoPilotSystem::BarometricAltitudeHold() { SetAPMode(EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE); bNeedInput = true; ConfirmInput = ConfirmInput.IsEmpty() ? FString("0500") : ConfirmInput; } void UFlightAutoPilotSystem::BarometricAltitude_HHold() { SetAPMode(EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE_H); bNeedInput = true; ConfirmInput = ConfirmInput.IsEmpty() ? FString("0500") : ConfirmInput; } void UFlightAutoPilotSystem::RodioAltitudeHold() { SetAPMode(EAutoPoilotMode::EAPM_RADIO_ALTITUDE); bNeedInput = true; ConfirmInput = ConfirmInput.IsEmpty() ? FString("0500") : ConfirmInput; } void UFlightAutoPilotSystem::AltitudeAndSlopeHold() { SetAPMode(EAutoPoilotMode::EAPM_ALTITUDE_AND_SLOPE); } void UFlightAutoPilotSystem::LevelFlightHold() { SetAPMode(EAutoPoilotMode::EAPM_LEVEL); } void UFlightAutoPilotSystem::ToggleAPMode() { CHECK_FALSE_RETURN(GetIsSystemRunning()); switch (CurrentAPMode) { case EAutoPoilotMode::EAPM_ATTRIBUTE: BarometricAltitudeHold(); break; case EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE: AttributeHold(); break; default: AttributeHold(); break; } } void UFlightAutoPilotSystem::Confirm() { CHECK_FALSE_RETURN(GetIsSystemRunning()); //有的模式需要输入 有的不需要 CHECK_FALSE_RETURN(bNeedInput); bCanInput = !bCanInput; if (bCanInput) { //开始输入 CurrentUFCPInput.Empty(); } else { //结束输入 if (!CurrentUFCPInput.IsEmpty() && CurrentUFCPInput.Len() == 4) { ConfirmInput = CurrentUFCPInput; switch (GetCurrentAPMode()) { case EAutoPoilotMode::EAPM_ATTRIBUTE: break; case EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE: AltitudeNeedHold = FCString::Atod(*ConfirmInput); break; case EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE_H: AltitudeNeedHold = FCString::Atod(*ConfirmInput); break; case EAutoPoilotMode::EAPM_RADIO_ALTITUDE: AltitudeNeedHold = FCString::Atod(*ConfirmInput); break; case EAutoPoilotMode::EAPM_ALTITUDE_AND_SLOPE: break; case EAutoPoilotMode::EAPM_LEVEL: break; case EAutoPoilotMode::EAPM_WAYPOINTFOLLOW: break; case EAutoPoilotMode::NONE: break; default: checkNoEntry(); break; } Hold(); } else { PRINTWARNING(TEXT("Current UFCP Input Occurs Error,Check Your Input")); CurrentUFCPInput.Empty(); } } } void UFlightAutoPilotSystem::UFCPInput(FString val) { CHECK_FALSE_RETURN(bCanInput); //有的模式需要输入 有的不需要 CHECK_FALSE_RETURN(bNeedInput); if (CurrentUFCPInput.Len() < 4) { CurrentUFCPInput.Append(val); } } void UFlightAutoPilotSystem::HoldHeading(bool bHold) { if (bHold) { //保持 GetFlightControlSystem()->set_heading_select(HeadingNeedHold); } else { //不保持 } } void UFlightAutoPilotSystem::HoldSpeed(bool bHold) { if (bHold) { //保持 GetFlightControlSystem()->set_heading_select(SpeedNeedHold); } else { //不保持 } } void UFlightAutoPilotSystem::HoldAltitude(bool bHold) { if (bHold) { //保持 GetFlightControlSystem()->set_heading_select(AltitudeNeedHold); } else { //不保持 } } void UFlightAutoPilotSystem::HoldRadioAltitude(bool bHold) { if (bHold) { //保持 GetFlightControlSystem()->set_heading_select(AltitudeNeedHold); } } void UFlightAutoPilotSystem::NavigateToNextWaypoint(bool bHold) { } void UFlightAutoPilotSystem::Hold() { //具体自动驾驶实现 switch (GetCurrentAPMode()) { case EAutoPoilotMode::EAPM_ATTRIBUTE: HoldHeading(true); HoldSpeed(true); HoldAltitude(true); HoldRadioAltitude(false); NavigateToNextWaypoint(false); break; case EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE: HoldHeading(false); HoldAltitude(true); HoldRadioAltitude(false); HoldSpeed(false); NavigateToNextWaypoint(false); break; case EAutoPoilotMode::EAPM_BAROMETRIC_ALTITUDE_H: break; case EAutoPoilotMode::EAPM_RADIO_ALTITUDE: HoldHeading(false); HoldAltitude(false); HoldSpeed(false); NavigateToNextWaypoint(false); HoldRadioAltitude(true); break; case EAutoPoilotMode::EAPM_ALTITUDE_AND_SLOPE: break; case EAutoPoilotMode::EAPM_LEVEL: break; case EAutoPoilotMode::EAPM_WAYPOINTFOLLOW: HoldHeading(false); HoldAltitude(false); HoldRadioAltitude(false); HoldSpeed(false); NavigateToNextWaypoint(true); break; case EAutoPoilotMode::NONE: break; default: checkNoEntry(); break; } } void UFlightAutoPilotSystem::SetAPMode(EAutoPoilotMode mode) { CHECK_FALSE_RETURN(GetIsSystemRunning()); CHECK_TRUE_RETURN(CurrentAPMode == mode); Reset(); InitHoldProperty(); CurrentAPMode = mode; if (OnAutopoilotModeChange.IsBound()) { OnAutopoilotModeChange.Broadcast(CurrentAPMode); } } void UFlightAutoPilotSystem::Reset() { CurrentAPMode = EAutoPoilotMode::NONE; bCanInput = false; CurrentUFCPInput.Empty(); bNeedInput = false; SpeedNeedHold = 0; HeadingNeedHold = 0; AltitudeNeedHold = 0; HoldHeading(false); HoldSpeed(false); HoldAltitude(false); HoldRadioAltitude(false); NavigateToNextWaypoint(false); } void UFlightAutoPilotSystem::InitHoldProperty() { if (GetFlightPropertySystem()) { SpeedNeedHold = GetFlightPropertySystem()->mach_number; HeadingNeedHold = GetFlightPropertySystem()->euler_angles_v.Y; AltitudeNeedHold = GetFlightPropertySystem()->altitude_agl; } }
26.957672
162
0.708047
Lynnvon
17b320ad26d6479e3150f76f73e193dda73b24aa
9,660
cpp
C++
src/chatwindow/qmlchatwidget.cpp
nameisalreadytakenexception/PairStormIDE
7c41dc91611f9a9db62c8c9ac0373e0fe33fec59
[ "MIT" ]
4
2019-07-23T13:00:58.000Z
2021-09-24T19:03:01.000Z
src/chatwindow/qmlchatwidget.cpp
nameisalreadytakenexception/PairStormIDE
7c41dc91611f9a9db62c8c9ac0373e0fe33fec59
[ "MIT" ]
4
2019-07-23T12:33:11.000Z
2019-08-20T11:39:16.000Z
src/chatwindow/qmlchatwidget.cpp
nameisalreadytakenexception/PairStormIDE
7c41dc91611f9a9db62c8c9ac0373e0fe33fec59
[ "MIT" ]
1
2019-11-02T15:07:13.000Z
2019-11-02T15:07:13.000Z
#include "qmlchatwidget.h" // ========================================================================================== // ========================================================================================== // CONSTRUCTOR QmlChatWidget::QmlChatWidget() { // Set default user name mUserName = QString(); QQuickView *tmpView = new QQuickView(); mpCurrentChatContext = tmpView->engine()->rootContext(); mpCurrentChatContext->setContextProperty("globalTheme", "white"); tmpView->setResizeMode(QQuickView::SizeRootObjectToView); tmpView->setSource(QUrl("qrc:/chatdisabled.qml")); mpCurrentQmlChatWidget = QWidget::createWindowContainer(tmpView, this); mpCurrentQmlChatWidget->setContentsMargins(0, 0, 0, 0); mpCurrentQmlChatWidget->setFocusPolicy(Qt::StrongFocus); mpCurrentQmlChatWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mpCurrentChatLayout = new QBoxLayout(QBoxLayout::BottomToTop, this); mpCurrentChatLayout->addWidget(mpCurrentQmlChatWidget); mpCurrentChatLayout->setSpacing(0); mpCurrentChatLayout->setMargin(0); setLayout(mpCurrentChatLayout); setMinimumSize(210, 400); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // DOCKER KEY PRESS EVENTS PROCESSOR void QmlChatWidget::keyPressEvent(QKeyEvent *event) { // idle by now event->key(); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // CHAT CONFIGURATOR void QmlChatWidget::configureOnLogin(const QString &userName) { if (mUserName != QString()) { // Hold the damage & inform user that he/she can't log in second time mpMessagesController->sendSystemMessage(SystemMessage::CanNotLogInTwiceMessage); return; } mUserName = userName; // Create & connect chat users controller mpUsersController = new ChatUsersController(mUserName); connect(mpUsersController, &ChatUsersController::userStateChangedConnected, this, &QmlChatWidget::connectUserOnSwitchOn, Qt::UniqueConnection); connect(mpUsersController, &ChatUsersController::userStateChangedDisconnected, this, &QmlChatWidget::disconnectUserOnSwitchOff, Qt::UniqueConnection); // Register chat users model & users controller in the QML qmlRegisterType<ChatUsersModel>("PairStormChat", 1, 0, "UsersModel"); qmlRegisterUncreatableType<ChatUsersController>("PairStormChat", 1, 0, "UsersList", "Users list can be created only in backend"); // Create & connect chat messages controller mpMessagesController = new ChatMessagesController(userName); mpMessagesController->sendSystemMessage(SystemMessage::GreetingsMessage); connect(mpMessagesController, &ChatMessagesController::sendingMessage, this, &QmlChatWidget::shareMessageOnSendingMessage, Qt::UniqueConnection); // Register chat messages model & messages controller in the QML qmlRegisterType<ChatMessagesModel>("PairStormChat", 1, 0, "MessagesModel"); qmlRegisterUncreatableType<ChatMessagesController>("PairStormChat", 1, 0, "MessagesList", "Messages list can be created only in backend"); QQuickView *tmpView = new QQuickView(); mpCurrentChatContext = tmpView->engine()->rootContext(); mpCurrentChatContext->setContextProperty("globalTheme", "white"); mpCurrentChatContext->setContextProperty("globalUserName", mUserName); mpCurrentChatContext->setContextProperty("messagesList", mpMessagesController); mpCurrentChatContext->setContextProperty("usersList", mpUsersController); tmpView->setResizeMode(QQuickView::SizeRootObjectToView); tmpView->setSource(QUrl("qrc:/chat.qml")); mpCurrentChatLayout->removeWidget(mpCurrentQmlChatWidget); mpCurrentQmlChatWidget->hide(); delete mpCurrentQmlChatWidget; mpCurrentQmlChatWidget = QWidget::createWindowContainer(tmpView, this); mpCurrentQmlChatWidget->setContentsMargins(0, 0, 0, 0); mpCurrentQmlChatWidget->setFocusPolicy(Qt::StrongFocus); mpCurrentQmlChatWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mpCurrentChatLayout->addWidget(mpCurrentQmlChatWidget); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // UPDATE ONLINE USERS IN CONTROLLER void QmlChatWidget::updateOnlineUsers(const QStringList &onlineUsers) { if (mpMessagesController) { mpUsersController->updateOnlineUsers(onlineUsers); } } // ========================================================================================== // ========================================================================================== // ========================================================================================== // UPDATE CONNECTED USERS IN CONTROLLER void QmlChatWidget::updateConnectedUsers(const QStringList &connectedUsers) { if (mpMessagesController) { mpUsersController->updateConnectedUsers(connectedUsers); } } // ========================================================================================== // ========================================================================================== // ========================================================================================== // APPEND NEW MESSAGE TO THE CHAT void QmlChatWidget::appendMessage(const QString &messageAuthor, const QString &messageBody) { // Here we IGNORE messageAuthor because it is solely NEEDED FOR BACK COMPATIBILITY if (!mpMessagesController) { // Hold the damage if it is called before user has logged in return; } ChatMessage newMessage; newMessage.fromJsonQString(messageBody); if (newMessage.empty()) { // Hold the damage if json bearer string is broken return; } mpMessagesController->appendMessage(newMessage); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // UPDATE CHAT THEME void QmlChatWidget::updateTheme(const QString &themeName) { Theme newTheme = mThemes[themeName]; switch(newTheme) { case Theme::DefaultTheme: mpCurrentChatContext->setContextProperty("globalTheme", "white"); break; case Theme::WhiteTheme: mpCurrentChatContext->setContextProperty("globalTheme", "white"); break; case Theme::BlueTheme: mpCurrentChatContext->setContextProperty("globalTheme", "blue"); break; case Theme::DarkTheme: mpCurrentChatContext->setContextProperty("globalTheme", "dark"); break; } } // ========================================================================================== // ========================================================================================== // ========================================================================================== // SHARE MESSAGE WHEN USER INVOKES SEND MESSAGE ACTION void QmlChatWidget::shareMessageOnSendingMessage(const ChatMessage &message) { const QString messageString = message.toJsonQString(); emit messageSent(messageString); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // SEND CONNECT REQUEST WHEN USER TRUNS ON THE SWITCH void QmlChatWidget::connectUserOnSwitchOn(const QString &userName) { emit startSharingRequested(userName); } // ========================================================================================== // ========================================================================================== // ========================================================================================== // SEND DISCONNECT REQUEST WHEN USER TRUNS OFF THE SWITCH void QmlChatWidget::disconnectUserOnSwitchOff(const QString &userName) { emit stopSharingRequested(userName); }
48.542714
103
0.467391
nameisalreadytakenexception
17b9a6eb0767bb5d5cdccf0a0919975bae4686bf
1,925
cpp
C++
Editor/DecalWindow.cpp
sadernalwis/WickedEngine
a1924cc97d36d0dac5e405f4197a9b1e982b2740
[ "WTFPL", "MIT" ]
3,589
2015-06-20T23:08:26.000Z
2022-03-31T13:45:07.000Z
Editor/DecalWindow.cpp
sadernalwis/WickedEngine
a1924cc97d36d0dac5e405f4197a9b1e982b2740
[ "WTFPL", "MIT" ]
303
2015-11-23T18:23:59.000Z
2022-03-31T09:31:03.000Z
Editor/DecalWindow.cpp
sadernalwis/WickedEngine
a1924cc97d36d0dac5e405f4197a9b1e982b2740
[ "WTFPL", "MIT" ]
496
2015-06-22T18:14:06.000Z
2022-03-30T21:53:21.000Z
#include "stdafx.h" #include "DecalWindow.h" #include "Editor.h" using namespace wiECS; using namespace wiScene; void DecalWindow::Create(EditorComponent* editor) { wiWindow::Create("Decal Window"); SetSize(XMFLOAT2(400, 200)); float x = 200; float y = 5; float hei = 18; float step = hei + 2; placementCheckBox.Create("Decal Placement Enabled: "); placementCheckBox.SetPos(XMFLOAT2(x, y += step)); placementCheckBox.SetSize(XMFLOAT2(hei, hei)); placementCheckBox.SetCheck(false); placementCheckBox.SetTooltip("Enable decal placement. Use the left mouse button to place decals to the scene."); AddWidget(&placementCheckBox); y += step; infoLabel.Create(""); infoLabel.SetText("Selecting decals will select the according material. Set decal properties (texture, color, etc.) in the Material window."); infoLabel.SetSize(XMFLOAT2(400 - 20, 100)); infoLabel.SetPos(XMFLOAT2(10, y)); infoLabel.SetColor(wiColor::Transparent()); AddWidget(&infoLabel); y += infoLabel.GetScale().y - step + 5; decalNameField.Create("Decal Name"); decalNameField.SetPos(XMFLOAT2(10, y+=step)); decalNameField.SetSize(XMFLOAT2(300, hei)); decalNameField.OnInputAccepted([=](wiEventArgs args) { NameComponent* name = wiScene::GetScene().names.GetComponent(entity); if (name != nullptr) { *name = args.sValue; editor->RefreshSceneGraphView(); } }); AddWidget(&decalNameField); Translate(XMFLOAT3(30, 30, 0)); SetVisible(false); SetEntity(INVALID_ENTITY); } void DecalWindow::SetEntity(Entity entity) { this->entity = entity; Scene& scene = wiScene::GetScene(); const DecalComponent* decal = scene.decals.GetComponent(entity); if (decal != nullptr) { const NameComponent& name = *scene.names.GetComponent(entity); decalNameField.SetValue(name.name); decalNameField.SetEnabled(true); } else { decalNameField.SetValue("No decal selected"); decalNameField.SetEnabled(false); } }
25.328947
143
0.72987
sadernalwis
17c67fb22995dad75c1e23509bf318b079adfcb0
16,235
cpp
C++
export/windows/cpp/obj/src/flixel/input/FlxPointer.cpp
TinyPlanetStudios/Project-Crash-Land
365f196be4212602d32251566f26b53fb70693f6
[ "MIT" ]
null
null
null
export/windows/cpp/obj/src/flixel/input/FlxPointer.cpp
TinyPlanetStudios/Project-Crash-Land
365f196be4212602d32251566f26b53fb70693f6
[ "MIT" ]
null
null
null
export/windows/cpp/obj/src/flixel/input/FlxPointer.cpp
TinyPlanetStudios/Project-Crash-Land
365f196be4212602d32251566f26b53fb70693f6
[ "MIT" ]
null
null
null
// Generated by Haxe 3.3.0 #include <hxcpp.h> #ifndef INCLUDED_Std #include <Std.h> #endif #ifndef INCLUDED_flixel_FlxBasic #include <flixel/FlxBasic.h> #endif #ifndef INCLUDED_flixel_FlxCamera #include <flixel/FlxCamera.h> #endif #ifndef INCLUDED_flixel_FlxG #include <flixel/FlxG.h> #endif #ifndef INCLUDED_flixel_FlxObject #include <flixel/FlxObject.h> #endif #ifndef INCLUDED_flixel_group_FlxTypedGroup #include <flixel/group/FlxTypedGroup.h> #endif #ifndef INCLUDED_flixel_input_FlxPointer #include <flixel/input/FlxPointer.h> #endif #ifndef INCLUDED_flixel_math_FlxPoint #include <flixel/math/FlxPoint.h> #endif #ifndef INCLUDED_flixel_system_scaleModes_BaseScaleMode #include <flixel/system/scaleModes/BaseScaleMode.h> #endif #ifndef INCLUDED_flixel_util_FlxPool_flixel_math_FlxPoint #include <flixel/util/FlxPool_flixel_math_FlxPoint.h> #endif #ifndef INCLUDED_flixel_util_FlxPool_flixel_util_LabelValuePair #include <flixel/util/FlxPool_flixel_util_LabelValuePair.h> #endif #ifndef INCLUDED_flixel_util_FlxStringUtil #include <flixel/util/FlxStringUtil.h> #endif #ifndef INCLUDED_flixel_util_IFlxDestroyable #include <flixel/util/IFlxDestroyable.h> #endif #ifndef INCLUDED_flixel_util_IFlxPool #include <flixel/util/IFlxPool.h> #endif #ifndef INCLUDED_flixel_util_IFlxPooled #include <flixel/util/IFlxPooled.h> #endif #ifndef INCLUDED_flixel_util_LabelValuePair #include <flixel/util/LabelValuePair.h> #endif static const Bool _hx_array_data_0[] = { 0, }; namespace flixel{ namespace input{ void FlxPointer_obj::__construct(){ HX_STACK_FRAME("flixel.input.FlxPointer","new",0x20c36c33,"flixel.input.FlxPointer.new","flixel/input/FlxPointer.hx",8,0xe6a2529b) HX_STACK_THIS(this) HXLINE( 17) this->_globalScreenY = (int)0; HXLINE( 16) this->_globalScreenX = (int)0; HXLINE( 14) this->screenY = (int)0; HXLINE( 13) this->screenX = (int)0; HXLINE( 11) this->y = (int)0; HXLINE( 10) this->x = (int)0; } Dynamic FlxPointer_obj::__CreateEmpty() { return new FlxPointer_obj; } hx::ObjectPtr< FlxPointer_obj > FlxPointer_obj::__new() { hx::ObjectPtr< FlxPointer_obj > _hx_result = new FlxPointer_obj(); _hx_result->__construct(); return _hx_result; } Dynamic FlxPointer_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< FlxPointer_obj > _hx_result = new FlxPointer_obj(); _hx_result->__construct(); return _hx_result; } ::flixel::math::FlxPoint FlxPointer_obj::getWorldPosition( ::flixel::FlxCamera Camera, ::flixel::math::FlxPoint point){ HX_STACK_FRAME("flixel.input.FlxPointer","getWorldPosition",0x52927af2,"flixel.input.FlxPointer.getWorldPosition","flixel/input/FlxPointer.hx",30,0xe6a2529b) HX_STACK_THIS(this) HX_STACK_ARG(Camera,"Camera") HX_STACK_ARG(point,"point") HXLINE( 31) Bool _hx_tmp = hx::IsNull( Camera ); HXDLIN( 31) if (_hx_tmp) { HXLINE( 33) Camera = ::flixel::FlxG_obj::camera; } HXLINE( 35) Bool _hx_tmp1 = hx::IsNull( point ); HXDLIN( 35) if (_hx_tmp1) { HXLINE( 37) HX_VARI_NAME( ::flixel::math::FlxPoint,point1,"point") = ::flixel::math::FlxPoint_obj::_pool->get()->set((int)0,(int)0); HXDLIN( 37) point1->_inPool = false; HXDLIN( 37) point = point1; } HXLINE( 39) HX_VARI( ::flixel::math::FlxPoint,screenPosition) = this->getScreenPosition(Camera,null()); HXLINE( 40) Float _hx_tmp2 = (screenPosition->x + Camera->scroll->x); HXDLIN( 40) point->set_x(_hx_tmp2); HXLINE( 41) Float _hx_tmp3 = (screenPosition->y + Camera->scroll->y); HXDLIN( 41) point->set_y(_hx_tmp3); HXLINE( 42) screenPosition->put(); HXLINE( 43) return point; } HX_DEFINE_DYNAMIC_FUNC2(FlxPointer_obj,getWorldPosition,return ) ::flixel::math::FlxPoint FlxPointer_obj::getScreenPosition( ::flixel::FlxCamera Camera, ::flixel::math::FlxPoint point){ HX_STACK_FRAME("flixel.input.FlxPointer","getScreenPosition",0xae561a7e,"flixel.input.FlxPointer.getScreenPosition","flixel/input/FlxPointer.hx",55,0xe6a2529b) HX_STACK_THIS(this) HX_STACK_ARG(Camera,"Camera") HX_STACK_ARG(point,"point") HXLINE( 56) Bool _hx_tmp = hx::IsNull( Camera ); HXDLIN( 56) if (_hx_tmp) { HXLINE( 58) Camera = ::flixel::FlxG_obj::camera; } HXLINE( 60) Bool _hx_tmp1 = hx::IsNull( point ); HXDLIN( 60) if (_hx_tmp1) { HXLINE( 62) HX_VARI_NAME( ::flixel::math::FlxPoint,point1,"point") = ::flixel::math::FlxPoint_obj::_pool->get()->set((int)0,(int)0); HXDLIN( 62) point1->_inPool = false; HXDLIN( 62) point = point1; } HXLINE( 65) Float _hx_tmp2 = ((Float)((this->_globalScreenX - Camera->x) + ((((Float)0.5) * Camera->width) * (Camera->zoom - Camera->initialZoom))) / (Float)Camera->zoom); HXDLIN( 65) point->set_x(_hx_tmp2); HXLINE( 66) Float _hx_tmp3 = ((Float)((this->_globalScreenY - Camera->y) + ((((Float)0.5) * Camera->height) * (Camera->zoom - Camera->initialZoom))) / (Float)Camera->zoom); HXDLIN( 66) point->set_y(_hx_tmp3); HXLINE( 68) return point; } HX_DEFINE_DYNAMIC_FUNC2(FlxPointer_obj,getScreenPosition,return ) ::flixel::math::FlxPoint FlxPointer_obj::getPosition( ::flixel::math::FlxPoint point){ HX_STACK_FRAME("flixel.input.FlxPointer","getPosition",0x9fea8a32,"flixel.input.FlxPointer.getPosition","flixel/input/FlxPointer.hx",75,0xe6a2529b) HX_STACK_THIS(this) HX_STACK_ARG(point,"point") HXLINE( 76) Bool _hx_tmp = hx::IsNull( point ); HXDLIN( 76) if (_hx_tmp) { HXLINE( 77) HX_VARI_NAME( ::flixel::math::FlxPoint,point1,"point") = ::flixel::math::FlxPoint_obj::_pool->get()->set((int)0,(int)0); HXDLIN( 77) point1->_inPool = false; HXDLIN( 77) point = point1; } HXLINE( 78) return point->set(this->x,this->y); } HX_DEFINE_DYNAMIC_FUNC1(FlxPointer_obj,getPosition,return ) Bool FlxPointer_obj::overlaps( ::flixel::FlxBasic ObjectOrGroup, ::flixel::FlxCamera Camera){ HX_STACK_FRAME("flixel.input.FlxPointer","overlaps",0xe0967a59,"flixel.input.FlxPointer.overlaps","flixel/input/FlxPointer.hx",92,0xe6a2529b) HX_STACK_THIS(this) HX_STACK_ARG(ObjectOrGroup,"ObjectOrGroup") HX_STACK_ARG(Camera,"Camera") HXLINE( 91) HX_VARI( ::flixel::input::FlxPointer,_gthis) = hx::ObjectPtr<OBJ_>(this); HXLINE( 93) HX_VARI( ::Array< Bool >,result) = ::Array_obj< Bool >::fromData( _hx_array_data_0,1); HXLINE( 95) HX_VARI( ::flixel::group::FlxTypedGroup,group) = ::flixel::group::FlxTypedGroup_obj::resolveGroup(ObjectOrGroup); HXLINE( 96) Bool _hx_tmp = hx::IsNotNull( group ); HXDLIN( 96) if (_hx_tmp) { HX_BEGIN_LOCAL_FUNC_S3(hx::LocalFunc,_hx_Closure_0, ::flixel::input::FlxPointer,_gthis, ::flixel::FlxCamera,Camera,::Array< Bool >,result) HXARGC(1) void _hx_run( ::flixel::FlxBasic basic){ HX_STACK_FRAME("flixel.input.FlxPointer","overlaps",0xe0967a59,"flixel.input.FlxPointer.overlaps","flixel/input/FlxPointer.hx",100,0xe6a2529b) HX_STACK_ARG(basic,"basic") HXLINE( 100) Bool _hx_tmp1 = _gthis->overlaps(basic,Camera); HXDLIN( 100) if (_hx_tmp1) { HXLINE( 102) result[(int)0] = true; HXLINE( 103) return; } } HX_END_LOCAL_FUNC1((void)) HXLINE( 98) group->forEachExists( ::Dynamic(new _hx_Closure_0(_gthis,Camera,result)),null()); } else { HXLINE( 109) HX_VARI( ::flixel::math::FlxPoint,point) = this->getPosition(null()); HXLINE( 111) Bool _hx_tmp2 = ( ( ::flixel::FlxObject)(ObjectOrGroup) )->overlapsPoint(point,true,Camera); HXDLIN( 111) result[(int)0] = _hx_tmp2; HXLINE( 112) point->put(); } HXLINE( 115) return result->__get((int)0); } HX_DEFINE_DYNAMIC_FUNC2(FlxPointer_obj,overlaps,return ) void FlxPointer_obj::setGlobalScreenPositionUnsafe(Float newX,Float newY){ HX_STACK_FRAME("flixel.input.FlxPointer","setGlobalScreenPositionUnsafe",0x8f7aed13,"flixel.input.FlxPointer.setGlobalScreenPositionUnsafe","flixel/input/FlxPointer.hx",123,0xe6a2529b) HX_STACK_THIS(this) HX_STACK_ARG(newX,"newX") HX_STACK_ARG(newY,"newY") HXLINE( 124) Float _hx_tmp = ((Float)newX / (Float)::flixel::FlxG_obj::scaleMode->scale->x); HXDLIN( 124) this->_globalScreenX = ::Std_obj::_hx_int(_hx_tmp); HXLINE( 125) Float _hx_tmp1 = ((Float)newY / (Float)::flixel::FlxG_obj::scaleMode->scale->y); HXDLIN( 125) this->_globalScreenY = ::Std_obj::_hx_int(_hx_tmp1); HXLINE( 127) this->updatePositions(); } HX_DEFINE_DYNAMIC_FUNC2(FlxPointer_obj,setGlobalScreenPositionUnsafe,(void)) ::String FlxPointer_obj::toString(){ HX_STACK_FRAME("flixel.input.FlxPointer","toString",0xd3da77f9,"flixel.input.FlxPointer.toString","flixel/input/FlxPointer.hx",132,0xe6a2529b) HX_STACK_THIS(this) HXLINE( 133) ::Dynamic value = this->x; HXDLIN( 133) HX_VARI( ::flixel::util::LabelValuePair,_this) = ::flixel::util::LabelValuePair_obj::_pool->get(); HXDLIN( 133) _this->label = HX_("x",78,00,00,00); HXDLIN( 133) _this->value = value; HXLINE( 134) ::Dynamic value1 = this->y; HXDLIN( 134) HX_VARI_NAME( ::flixel::util::LabelValuePair,_this1,"_this") = ::flixel::util::LabelValuePair_obj::_pool->get(); HXDLIN( 134) _this1->label = HX_("y",79,00,00,00); HXDLIN( 134) _this1->value = value1; HXLINE( 132) return ::flixel::util::FlxStringUtil_obj::getDebugString(::Array_obj< ::Dynamic>::__new(2)->init(0,_this)->init(1,_this1)); } HX_DEFINE_DYNAMIC_FUNC0(FlxPointer_obj,toString,return ) void FlxPointer_obj::updatePositions(){ HX_STACK_FRAME("flixel.input.FlxPointer","updatePositions",0xb47050b4,"flixel.input.FlxPointer.updatePositions","flixel/input/FlxPointer.hx",142,0xe6a2529b) HX_STACK_THIS(this) HXLINE( 143) HX_VARI( ::flixel::math::FlxPoint,screenPosition) = this->getScreenPosition(null(),null()); HXLINE( 144) this->screenX = ::Std_obj::_hx_int(screenPosition->x); HXLINE( 145) this->screenY = ::Std_obj::_hx_int(screenPosition->y); HXLINE( 146) screenPosition->put(); HXLINE( 148) HX_VARI( ::flixel::math::FlxPoint,worldPosition) = this->getWorldPosition(null(),null()); HXLINE( 149) this->x = ::Std_obj::_hx_int(worldPosition->x); HXLINE( 150) this->y = ::Std_obj::_hx_int(worldPosition->y); HXLINE( 151) worldPosition->put(); } HX_DEFINE_DYNAMIC_FUNC0(FlxPointer_obj,updatePositions,(void)) FlxPointer_obj::FlxPointer_obj() { } hx::Val FlxPointer_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp) { switch(inName.length) { case 1: if (HX_FIELD_EQ(inName,"x") ) { return hx::Val( x); } if (HX_FIELD_EQ(inName,"y") ) { return hx::Val( y); } break; case 7: if (HX_FIELD_EQ(inName,"screenX") ) { return hx::Val( screenX); } if (HX_FIELD_EQ(inName,"screenY") ) { return hx::Val( screenY); } break; case 8: if (HX_FIELD_EQ(inName,"overlaps") ) { return hx::Val( overlaps_dyn()); } if (HX_FIELD_EQ(inName,"toString") ) { return hx::Val( toString_dyn()); } break; case 11: if (HX_FIELD_EQ(inName,"getPosition") ) { return hx::Val( getPosition_dyn()); } break; case 14: if (HX_FIELD_EQ(inName,"_globalScreenX") ) { return hx::Val( _globalScreenX); } if (HX_FIELD_EQ(inName,"_globalScreenY") ) { return hx::Val( _globalScreenY); } break; case 15: if (HX_FIELD_EQ(inName,"updatePositions") ) { return hx::Val( updatePositions_dyn()); } break; case 16: if (HX_FIELD_EQ(inName,"getWorldPosition") ) { return hx::Val( getWorldPosition_dyn()); } break; case 17: if (HX_FIELD_EQ(inName,"getScreenPosition") ) { return hx::Val( getScreenPosition_dyn()); } break; case 29: if (HX_FIELD_EQ(inName,"setGlobalScreenPositionUnsafe") ) { return hx::Val( setGlobalScreenPositionUnsafe_dyn()); } } return super::__Field(inName,inCallProp); } hx::Val FlxPointer_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 1: if (HX_FIELD_EQ(inName,"x") ) { x=inValue.Cast< Int >(); return inValue; } if (HX_FIELD_EQ(inName,"y") ) { y=inValue.Cast< Int >(); return inValue; } break; case 7: if (HX_FIELD_EQ(inName,"screenX") ) { screenX=inValue.Cast< Int >(); return inValue; } if (HX_FIELD_EQ(inName,"screenY") ) { screenY=inValue.Cast< Int >(); return inValue; } break; case 14: if (HX_FIELD_EQ(inName,"_globalScreenX") ) { _globalScreenX=inValue.Cast< Int >(); return inValue; } if (HX_FIELD_EQ(inName,"_globalScreenY") ) { _globalScreenY=inValue.Cast< Int >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } void FlxPointer_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_HCSTRING("x","\x78","\x00","\x00","\x00")); outFields->push(HX_HCSTRING("y","\x79","\x00","\x00","\x00")); outFields->push(HX_HCSTRING("screenX","\x6c","\xc3","\x36","\x2a")); outFields->push(HX_HCSTRING("screenY","\x6d","\xc3","\x36","\x2a")); outFields->push(HX_HCSTRING("_globalScreenX","\x8a","\xec","\xc1","\x8e")); outFields->push(HX_HCSTRING("_globalScreenY","\x8b","\xec","\xc1","\x8e")); super::__GetFields(outFields); }; #if HXCPP_SCRIPTABLE static hx::StorageInfo FlxPointer_obj_sMemberStorageInfo[] = { {hx::fsInt,(int)offsetof(FlxPointer_obj,x),HX_HCSTRING("x","\x78","\x00","\x00","\x00")}, {hx::fsInt,(int)offsetof(FlxPointer_obj,y),HX_HCSTRING("y","\x79","\x00","\x00","\x00")}, {hx::fsInt,(int)offsetof(FlxPointer_obj,screenX),HX_HCSTRING("screenX","\x6c","\xc3","\x36","\x2a")}, {hx::fsInt,(int)offsetof(FlxPointer_obj,screenY),HX_HCSTRING("screenY","\x6d","\xc3","\x36","\x2a")}, {hx::fsInt,(int)offsetof(FlxPointer_obj,_globalScreenX),HX_HCSTRING("_globalScreenX","\x8a","\xec","\xc1","\x8e")}, {hx::fsInt,(int)offsetof(FlxPointer_obj,_globalScreenY),HX_HCSTRING("_globalScreenY","\x8b","\xec","\xc1","\x8e")}, { hx::fsUnknown, 0, null()} }; static hx::StaticInfo *FlxPointer_obj_sStaticStorageInfo = 0; #endif static ::String FlxPointer_obj_sMemberFields[] = { HX_HCSTRING("x","\x78","\x00","\x00","\x00"), HX_HCSTRING("y","\x79","\x00","\x00","\x00"), HX_HCSTRING("screenX","\x6c","\xc3","\x36","\x2a"), HX_HCSTRING("screenY","\x6d","\xc3","\x36","\x2a"), HX_HCSTRING("_globalScreenX","\x8a","\xec","\xc1","\x8e"), HX_HCSTRING("_globalScreenY","\x8b","\xec","\xc1","\x8e"), HX_HCSTRING("getWorldPosition","\xa5","\x3e","\x0b","\xe6"), HX_HCSTRING("getScreenPosition","\x6b","\x93","\x88","\x24"), HX_HCSTRING("getPosition","\x5f","\x63","\xee","\xf0"), HX_HCSTRING("overlaps","\x0c","\xd3","\x2a","\x45"), HX_HCSTRING("setGlobalScreenPositionUnsafe","\x80","\x95","\xb5","\x56"), HX_HCSTRING("toString","\xac","\xd0","\x6e","\x38"), HX_HCSTRING("updatePositions","\x61","\xc4","\xdc","\x1f"), ::String(null()) }; static void FlxPointer_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(FlxPointer_obj::__mClass,"__mClass"); }; #ifdef HXCPP_VISIT_ALLOCS static void FlxPointer_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(FlxPointer_obj::__mClass,"__mClass"); }; #endif hx::Class FlxPointer_obj::__mClass; void FlxPointer_obj::__register() { hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("flixel.input.FlxPointer","\xc1","\xd6","\x8e","\xc2"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField; __mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField; __mClass->mMarkFunc = FlxPointer_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */); __mClass->mMembers = hx::Class_obj::dupFunctions(FlxPointer_obj_sMemberFields); __mClass->mCanCast = hx::TCanCast< FlxPointer_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = FlxPointer_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = FlxPointer_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = FlxPointer_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } } // end namespace flixel } // end namespace input
42.949735
197
0.698429
TinyPlanetStudios
17c6fa1fccbb51a85c36ec50a1cfaed05e5b9793
4,975
cxx
C++
src/Command.cxx
vlad-korneev/virgil-cli
3077f9f8d0c474265a1888cac8dd65a89becff5a
[ "BSD-3-Clause" ]
1
2019-03-28T16:47:29.000Z
2019-03-28T16:47:29.000Z
src/Command.cxx
vlad-korneev/virgil-cli
3077f9f8d0c474265a1888cac8dd65a89becff5a
[ "BSD-3-Clause" ]
null
null
null
src/Command.cxx
vlad-korneev/virgil-cli
3077f9f8d0c474265a1888cac8dd65a89becff5a
[ "BSD-3-Clause" ]
null
null
null
/** * Copyright (C) 2015-2017 Virgil Security Inc. * * Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * (1) Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * (2) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * (3) Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include <cli/command/Command.h> #include <cli/error/ArgumentError.h> #include <cli/error/ExitError.h> #include <cli/api/Version.h> #include <cli/io/Logger.h> #include <cli/argument/ArgumentParseOptions.h> #include <virgil/crypto/VirgilCryptoException.h> #include <virgil/crypto/VirgilCryptoError.h> #include <virgil/sdk/VirgilSdkException.h> #include <iostream> using cli::argument::ArgumentIO; using cli::argument::ArgumentSource; using cli::command::Command; using cli::argument::ArgumentParseOptions; using virgil::crypto::VirgilCryptoException; using virgil::crypto::VirgilCryptoError; using virgil::sdk::VirgilSdkException; static std::string buildErrorMessage(const VirgilCryptoException& exception) { if (exception.condition().category() == virgil::crypto::crypto_category()) { switch(static_cast<VirgilCryptoError>(exception.condition().value())) { case VirgilCryptoError::NotFoundPasswordRecipient: return "Recipient password mismatch."; case VirgilCryptoError::NotFoundKeyRecipient: return "Recipient private key mismatch or alias mismatch."; default: break; } } if (VLOG_IS_ON(1)) { return exception.what(); } else { return exception.condition().message(); } } static std::string buildErrorMessage(const VirgilSdkException& exception) { std::string message(exception.what()); if (message.find("HTTP Code: 404") != std::string::npos) { //TODO: Change this hot-fix when service will support informative message for this case. return exception.condition().message() + " Requested entity is not found."; } else { return exception.what(); } } Command::Command(std::shared_ptr<argument::ArgumentIO> argumentIO) : argumentIO_(argumentIO) { DCHECK(argumentIO_); } const char* Command::getName() const { return doGetName(); } const char* Command::getUsage() const { return doGetUsage(); } std::shared_ptr<ArgumentIO> Command::getArgumentIO() const { return argumentIO_; } ArgumentParseOptions Command::getArgumentParseOptions() const { return doGetArgumentParseOptions(); } void Command::process() { LOG(INFO) << "Start process command:" << getName(); try { getArgumentIO()->configureUsage(getUsage(), getArgumentParseOptions()); doProcess(); } catch (const error::ArgumentShowUsageError&) { showUsage(); } catch (const error::ArgumentShowVersionError&) { showVersion(); } catch (const error::ArgumentRuntimeError& error) { showUsage(error.what()); } catch (const VirgilCryptoException& exception) { LOG(FATAL) << exception.what(); showUsage(buildErrorMessage(exception).c_str()); } catch (const VirgilSdkException& exception) { LOG(FATAL) << exception.what(); showUsage(buildErrorMessage(exception).c_str()); } } void Command::showUsage(const char* errorMessage) const { if (errorMessage != nullptr && strlen(errorMessage) != 0) { ULOG(FATAL) << errorMessage; if (VLOG_IS_ON(1)) { std::cout << getUsage(); } throw error::ExitFailure(); } std::cout << getUsage(); } void Command::showVersion() const { std::cout << api::Version::cliVersion(); }
35.035211
96
0.697085
vlad-korneev
17cc76921f2b7b92731d820df3de35b410b1154f
469
cpp
C++
LazyEngine/LazyEngine/src/LazyEngine/Renderer/RendererAPI.cpp
PhiliGuertler/ManifoldDMC
d9740e17ebadce0320f7cfb7dbb1cd728119a8ab
[ "MIT" ]
null
null
null
LazyEngine/LazyEngine/src/LazyEngine/Renderer/RendererAPI.cpp
PhiliGuertler/ManifoldDMC
d9740e17ebadce0320f7cfb7dbb1cd728119a8ab
[ "MIT" ]
null
null
null
LazyEngine/LazyEngine/src/LazyEngine/Renderer/RendererAPI.cpp
PhiliGuertler/ManifoldDMC
d9740e17ebadce0320f7cfb7dbb1cd728119a8ab
[ "MIT" ]
null
null
null
// ######################################################################### // // ### RendererAPI.cpp ##################################################### // // ### initializes static members of the class RendererAPI. ### // // ######################################################################### // #include "LazyEngine/gepch.h" #include "RendererAPI.h" namespace LazyEngine { RendererAPI::API RendererAPI::s_API = RendererAPI::API::OpenGL; }
33.5
79
0.362473
PhiliGuertler
17d0c2b0d93c008e0fddc20dc66a8b8026c1ac93
288
cpp
C++
ftpserver/src/Request.cpp
aminst/ftp-server
ca019e21b14cdf41346be3328640064b865b136f
[ "MIT" ]
1
2021-04-09T14:32:51.000Z
2021-04-09T14:32:51.000Z
ftpserver/src/Request.cpp
aminst/ftp-server
ca019e21b14cdf41346be3328640064b865b136f
[ "MIT" ]
null
null
null
ftpserver/src/Request.cpp
aminst/ftp-server
ca019e21b14cdf41346be3328640064b865b136f
[ "MIT" ]
1
2021-04-09T14:32:53.000Z
2021-04-09T14:32:53.000Z
#include "Request.hpp" using namespace std; Request::Request(const string& command, const vector<string>& arguments) : command(command), arguments(arguments) { } string Request::get_command() { return command; } vector<string> Request::get_arguments() { return arguments; }
16.941176
72
0.722222
aminst
17d3005c6c0d2bcb7425b889152603d21149318d
3,339
cpp
C++
tests/validate_email_test.cpp
beached/validate_email
2b08876ede9ad01ac43f1d0a7110d2150a9b5a72
[ "MIT" ]
null
null
null
tests/validate_email_test.cpp
beached/validate_email
2b08876ede9ad01ac43f1d0a7110d2150a9b5a72
[ "MIT" ]
null
null
null
tests/validate_email_test.cpp
beached/validate_email
2b08876ede9ad01ac43f1d0a7110d2150a9b5a72
[ "MIT" ]
null
null
null
// The MIT License (MIT) // // Copyright (c) 2016-2018 Darrell Wright // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files( the "Software" ), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #define BOOST_TEST_MODULE validate_email #include <iostream> #include <daw/boost_test.h> #include <daw/daw_string_view.h> #include <daw/json/daw_json_link.h> #include <daw/json/daw_json_link_file.h> #include <daw/puny_coder/puny_coder.h> #include "validate_email.h" struct address_tests_t : public daw::json::daw_json_link<address_tests_t> { struct address_test_t : public daw::json::daw_json_link<address_test_t> { std::string email_address; std::string comment; static void json_link_map( ) { link_json_string( "email_address", email_address ); link_json_string( "comment", comment ); } }; // address_test_t std::vector<address_test_t> tests; static void json_link_map( ) { link_json_object_array( "tests", tests ); } }; // address_tests_t struct puny_tests_t : public daw::json::daw_json_link<puny_tests_t> { struct puny_test_t : public daw::json::daw_json_link<puny_test_t> { std::string in; std::string out; static void json_link_map( ) { link_json_string( "in", in ); link_json_string( "out", out ); } }; // puny_test_t std::vector<puny_test_t> tests; static void json_link_map( ) { link_json_object_array( "tests", tests ); } }; // puny_tests_t bool test_address( daw::string_view address ) { std::cout << "Testing: " << address.data( ); std::cout << " Puny: " << daw::get_local_part( address ) << "@" << daw::to_puny_code( daw::get_domain_part( address ) ) << std::endl; auto result = daw::is_email_address( address ); return result; } BOOST_AUTO_TEST_CASE( good_email_test ) { std::cout << "\n\nGood email addresses\n"; auto config_data = daw::json::from_file<address_tests_t>( "../good_addresses.json" ); for( auto const &address : config_data.tests ) { BOOST_REQUIRE_MESSAGE( test_address( address.email_address ), address.comment ); } std::cout << std::endl; } BOOST_AUTO_TEST_CASE( bad_email_test ) { std::cout << "\nBad email addresses\n"; auto config_data = daw::json::from_file<address_tests_t>( "../bad_addresses.json" ); for( auto const &address : config_data.tests ) { BOOST_REQUIRE_MESSAGE( !test_address( address.email_address ), address.comment ); } std::cout << "\n" << std::endl; }
34.78125
86
0.727463
beached
17d4c1a25d08835961e57aacbabf18d04baf20ad
9,972
cpp
C++
src/syllo/catkin_ws/src/syllo_blueview/src/syllo_blueview/Sonar.cpp
toremobjo/VideoRayROS
aa13a6d4f924fbcd7c2b0b2016a7b409b9272d63
[ "MIT" ]
6
2015-06-17T18:23:27.000Z
2018-05-14T05:33:24.000Z
src/syllo/catkin_ws/src/syllo_blueview/src/syllo_blueview/Sonar.cpp
toremobjo/VideoRayROS
aa13a6d4f924fbcd7c2b0b2016a7b409b9272d63
[ "MIT" ]
1
2016-07-01T09:01:17.000Z
2016-07-02T15:24:15.000Z
src/syllo/catkin_ws/src/syllo_blueview/src/syllo_blueview/Sonar.cpp
toremobjo/VideoRayROS
aa13a6d4f924fbcd7c2b0b2016a7b409b9272d63
[ "MIT" ]
10
2015-02-20T11:57:42.000Z
2020-12-20T12:42:54.000Z
#include <iostream> #include <stdio.h> #include <unistd.h> #include <fstream> #include <syllo_blueview/Sonar.h> #include <syllo_common/Utils.h> #if ENABLE_SONAR == 1 #include <bvt_sdk.h> #endif using std::cout; using std::endl; Sonar::Sonar() : initialized_(false), fn_(""), ip_addr_(""), logging_(false), mode_(Sonar::net), data_mode_(Sonar::image), min_range_(0), max_range_(40), color_map_(""), save_directory_("./") { } Sonar::~Sonar() { #if ENABLE_SONAR == 1 if (cimg_) { BVTColorImage_Destroy(cimg_); } if (img_) { BVTMagImage_Destroy(img_); } if (mapper_) { BVTColorMapper_Destroy(mapper_); } if (son_) { BVTSonar_Destroy(son_); } // Close logging file this->SonarLogEnable(false); #endif } Sonar::Status_t Sonar::init() { #if ENABLE_SONAR == 1 logging_ = false; cur_ping_ = 0; son_ = BVTSonar_Create(); if (son_ == NULL ) { printf("BVTSonar_Create: failed\n"); return Sonar::Failure; } int ret; if (mode_ == Sonar::net) { ///////////////////////////////////////// // Reading from physical sonar ///////////////////////////////////////// // If the ip address string is set, try to manually connect // to sonar first. bool manual_sonar_found = false; if (ip_addr_ != "" && ip_addr_ != "0.0.0.0") { ret = BVTSonar_Open(son_, "NET", ip_addr_.c_str()); if( ret != 0 ) { printf("Couldn't find sonar at defined IP address: %s", ip_addr_.c_str()); } else { manual_sonar_found = true; } } if (!manual_sonar_found) { //Create the discovery agent BVTSonarDiscoveryAgent agent = BVTSonarDiscoveryAgent_Create(); if( agent == NULL ) { printf("BVTSonarDiscoverAgent_Create: failed\n"); return Sonar::Failure; } // Kick off the discovery process ret = BVTSonarDiscoveryAgent_Start(agent); //Let the discovery process run for a short while (5 secs) cout << "Searching for available sonars..." << endl; sleep(5); // See what we found int numSonars = 0; numSonars = BVTSonarDiscoveryAgent_GetSonarCount(agent); char SonarIPAddress[20]; for(int i = 0; i < numSonars; i++) { ret = BVTSonarDiscoveryAgent_GetSonarInfo(agent, i, &SonarIPAddress[0], 20); printf("Found Sonar: %d, IP address: %s\n", i, SonarIPAddress); } if(numSonars == 0) { printf("No Sonars Found\n"); return Sonar::Failure; } // Open the sonar //ret = BVTSonar_Open(son_, "NET", "192.168.1.45"); ret = BVTSonar_Open(son_, "NET", SonarIPAddress); if( ret != 0 ) { printf("BVTSonar_Open: ret=%d\n", ret); return Sonar::Failure; } } } else { ///////////////////////////////////////// // Reading from sonar file ///////////////////////////////////////// // Open the sonar ret = BVTSonar_Open(son_, "FILE", fn_.c_str()); if (ret != 0 ) { printf("BVTSonar_Open: ret=%d\n", ret); return Sonar::Failure; } } // Make sure we have the right number of heads_ heads_ = -1; heads_ = BVTSonar_GetHeadCount(son_); printf("BVTSonar_GetHeadCount: %d\n", heads_); // Get the first head head_ = NULL; ret = BVTSonar_GetHead(son_, 0, &head_); if (ret != 0 ) { // Some sonar heads start at 1 ret = BVTSonar_GetHead(son_, 1, &head_); if (ret != 0) { printf( "BVTSonar_GetHead: ret=%d\n", ret) ; return Sonar::Failure; } } // Check the ping count pings_ = -1; pings_ = BVTHead_GetPingCount(head_); printf("BVTHead_GetPingCount: %d\n", pings_); // Set the range window this->set_range(min_range_, max_range_); // Build a color mapper mapper_ = BVTColorMapper_Create(); if (mapper_ == NULL) { printf("BVTColorMapper_Create: failed\n"); return Sonar::Failure; } // Load the bone colormap ret = BVTColorMapper_Load(mapper_, color_map_.c_str()); if(ret != 0) { if (color_map_ == "") { printf("Color map not set.\n"); } printf("BVTColorMapper_Load: ret=%d\n", ret); return Sonar::Failure; } initialized_ = true; return Sonar::Success; #else return Sonar::Failure; #endif } int Sonar::getNumPings() { return pings_; } int Sonar::getCurrentPingNum() { return cur_ping_; } void Sonar::setFrameNum(int num) { cur_ping_ = num; } int Sonar::reset() { cur_ping_ = 0; return 0; } Sonar::Status_t Sonar::SonarLogEnable(bool enable) { // Whether enable is true or false, if we enter the function here, // we should properly close the current file if currently logging if (logging_ && son_logger_) { BVTSonar_Destroy(son_logger_); } if (!enable) { // If logging is disabled, exit. logging_ = false; return Sonar::Success; } son_logger_ = BVTSonar_Create(); if (son_logger_ == NULL) { printf("BVTSonar_Create: failed\n"); return Sonar::Failure; } // Create the sonar file cur_log_file_ = save_directory_ + "/" + syllo::get_time_string() + ".son"; int ret = BVTSonar_CreateFile(son_logger_, cur_log_file_.c_str(), son_, ""); if (ret != 0) { printf("BVTSonar_CreateFile: ret=%d\n", ret); return Sonar::Failure; } // Get the first head of the file output out_head_ = NULL ; ret = BVTSonar_GetHead(son_logger_, 0, &out_head_); if (ret != 0) { printf("BVTSonar_GetHead: ret=%d\n" ,ret); return Sonar::Failure; } logging_ = true; return Sonar::Success; } Sonar::Status_t Sonar::getNextSonarImage(cv::Mat &image) { Status_t status = Sonar::Failure; if (mode_ == Sonar::net) { status = getSonarImage(image, -1); } else if (cur_ping_ < pings_) { status = getSonarImage(image, cur_ping_++); } else { status = Sonar::Failure; } return status; } Sonar::Status_t Sonar::getSonarImage(cv::Mat &image, int index) { #if ENABLE_SONAR == 1 if (!initialized_) { cout << "Sonar wasn't initialized." << endl; return Sonar::Failure; } BVTPing ping = NULL; int ret = BVTHead_GetPing(head_, index, &ping); if(ret != 0) { printf("BVTHead_GetPing: ret=%d\n", ret); return Sonar::Failure; } // Logging is enabled, write to file if (logging_) { ret = BVTHead_PutPing(out_head_, ping); if (ret != 0) { printf("BVTHead_PutPing: ret=%d\n", ret); return Sonar::Failure; } } ret = BVTPing_GetImage(ping, &img_); //ret = BVTPing_GetImageXY(ping, &img_); //ret = BVTPing_GetImageRTheta(ping, &img_); if (ret != 0) { printf("BVTPing_GetImage: ret=%d\n", ret); return Sonar::Failure; } // Perform the colormapping ret = BVTColorMapper_MapImage(mapper_, img_, &cimg_); if (ret != 0) { printf("BVTColorMapper_MapImage: ret=%d\n", ret); return Sonar::Failure; } height_ = BVTColorImage_GetHeight(cimg_); width_ = BVTColorImage_GetWidth(cimg_); IplImage* sonarImg; sonarImg = cvCreateImageHeader(cvSize(width_,height_), IPL_DEPTH_8U, 4); // And set it's data cvSetImageData(sonarImg, BVTColorImage_GetBits(cimg_), width_*4); //cv::Mat tempImg(sonarImg); //cv::Mat tempImg = sonarImg); //image = sonarImg; image = cv::cvarrToMat(sonarImg); // opencv3? cvReleaseImageHeader(&sonarImg); BVTPing_Destroy(ping); return Sonar::Success; #else return Sonar::Failure; #endif } int Sonar::width() { return width_; } int Sonar::height() { return height_; } void Sonar::set_mode(SonarMode_t mode) { mode_ = mode; } void Sonar::set_data_mode(DataMode_t data_mode) { data_mode_ = data_mode; } void Sonar::set_ip_addr(const std::string &ip_addr) { ip_addr_ = ip_addr; } void Sonar::set_input_son_filename(const std::string &fn) { fn_ = fn; } void Sonar::set_range(double min_range, double max_range) { min_range_ = min_range; max_range_ = max_range; if (min_range_ < 0 || min_range_ > max_range_ ) { min_range = 0; } if (max_range_ < 0 || max_range_ <= min_range_+1) { max_range_ = min_range_ + 2; } BVTHead_SetRange(head_, min_range_, max_range_); } void Sonar::set_min_range(double min_range) { this->set_range(min_range, max_range_); } void Sonar::set_max_range(double max_range) { this->set_range(min_range_, max_range); } void Sonar::set_color_map(const std::string &color_map) { color_map_ = color_map; } void Sonar::set_save_directory(const std::string &save_directory) { save_directory_ = save_directory; } const std::string& Sonar::current_sonar_file() { return cur_log_file_; }
25.309645
96
0.5356
toremobjo
17d54356096393f228721efe594100ff244ad159
2,260
cpp
C++
Sources/Core/Components/Renderer.cpp
alelievr/LWGEngine
655ed35350206401e20bc2fe6063574e1ede603f
[ "MIT" ]
3
2019-09-05T12:49:14.000Z
2020-06-08T00:13:49.000Z
Sources/Core/Components/Renderer.cpp
alelievr/LWGEngine
655ed35350206401e20bc2fe6063574e1ede603f
[ "MIT" ]
4
2018-12-16T15:39:19.000Z
2019-03-23T20:29:26.000Z
Sources/Core/Components/Renderer.cpp
alelievr/LWGEngine
655ed35350206401e20bc2fe6063574e1ede603f
[ "MIT" ]
2
2020-06-08T00:13:55.000Z
2021-12-12T10:10:20.000Z
#include "Renderer.hpp" #include "Core/PrimitiveMeshFactory.hpp" #include "Core/Hierarchy.hpp" #include "Core/Rendering/RenderPipeline.hpp" #include "Core/Vulkan/VulkanInstance.hpp" #include "Utils/Vector.hpp" #include "Core/Application.hpp" #include "IncludeDeps.hpp" #include GLM_INCLUDE using namespace LWGC; Renderer::Renderer(void) { _material = Material::Create(); } Renderer::Renderer(Material * material) { _material = material; } Renderer::~Renderer(void) { vkDestroyBuffer(device, _uniformModelBuffer.buffer, nullptr); vkFreeMemory(device, _uniformModelBuffer.memory, nullptr); } void Renderer::Initialize(void) noexcept { Component::Initialize(); _material->MarkAsReady(); Vk::CreateBuffer( sizeof(LWGC_PerObject), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, _uniformModelBuffer.buffer, _uniformModelBuffer.memory ); _perRendererSet.AddBinding(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, _uniformModelBuffer.buffer, sizeof(LWGC_PerObject)); } void Renderer::Update(void) noexcept { // TODO: check for transform changes before to reupload the uniform datas UpdateUniformData(); } void Renderer::UpdateUniformData(void) { _perObject.model = transform->GetLocalToWorldMatrix(); // Transpose for HLSL _perObject.model = glm::transpose(_perObject.model); Vk::UploadToMemory(_uniformModelBuffer.memory, &_perObject, sizeof(_perObject)); } Bounds Renderer::GetBounds(void) noexcept { return Bounds(); } void Renderer::OnEnable() noexcept { Component::OnEnable(); _renderContextIndex = hierarchy->RegisterComponentInRenderContext(GetType(), this); } void Renderer::OnDisable() noexcept { Component::OnDisable(); hierarchy->UnregisterComponentInRenderContext(GetType(), _renderContextIndex); } void Renderer::RecordCommands(VkCommandBuffer cmd) { RecordDrawCommand(cmd); } Material * Renderer::GetMaterial(void) { return (this->_material); } void Renderer::SetMaterial(Material * tmp) { this->_material = tmp; } VkDescriptorSet Renderer::GetDescriptorSet(void) { return _perRendererSet.GetDescriptorSet(); } std::ostream & operator<<(std::ostream & o, Renderer const & r) { o << "Renderer" << std::endl; (void)r; return (o); }
23.541667
118
0.766814
alelievr
17d83130a9b4941b3ce231c2f58eb493f815ce45
2,600
hh
C++
KalmanTrack/KalPairConduit.hh
brownd1978/FastSim
05f590d72d8e7f71856fd833114a38b84fc7fd48
[ "Apache-2.0" ]
null
null
null
KalmanTrack/KalPairConduit.hh
brownd1978/FastSim
05f590d72d8e7f71856fd833114a38b84fc7fd48
[ "Apache-2.0" ]
null
null
null
KalmanTrack/KalPairConduit.hh
brownd1978/FastSim
05f590d72d8e7f71856fd833114a38b84fc7fd48
[ "Apache-2.0" ]
null
null
null
//-------------------------------------------------------------------------- // File and Version Information: // $Id: KalPairConduit.hh,v 1.5 2001/10/17 14:55:17 steinke Exp $ // // Description: // // // Environment: // Software developed for the BaBar Detector at the SLAC B-Factory. // // Author(s): Doug Roberts // //------------------------------------------------------------------------ #ifndef KALPAIRCONDUIT_HH #define KALPAIRCONDUIT_HH #include "BbrGeom/BbrDoubleErr.hh" #include "BbrGeom/BbrVectorErr.hh" #include "KalmanTrack/KalPairRep.hh" #include "KalmanTrack/KalPairSite.hh" #include "KalmanTrack/KalParams.hh" // Class interface // class KalPairConduit { friend class KalPairRep; friend class KalPairSite; public: enum repId {plusRep=0, minusRep}; KalPairConduit(const TrkDifPieceTraj& plusTraj , const TrkDifPieceTraj& minusTraj, const BbrVectorErr& beamMom); ~KalPairConduit(); // bool updateConstraints(); bool converged() const {return _converged;} int iterations() const {return _niter;} BbrPointErr prodPoint() const {return _prodPoint;} double prodPointChi2() const {return _prodPointChi2;} protected: private: // Keep links to KalPairReps and KalPairSites KalPairRep* _reps[2]; KalPairSite* _sites[2]; int _nreps; int _nsites; int _niter; KalPairRep* otherPairRep(KalPairRep* rep); BbrDoubleErr _plusFltLen; BbrDoubleErr _minusFltLen; BbrPointErr _prodPoint; double _prodPointChi2; bool _converged; bool _needsUpdate; // Beam momentum used in the constraint BbrVectorErr _beamMom; // Actual constraints to be used by KalPairSites KalParams* _constraintPar[2]; KalParams* _inwardPar[2]; double _fltlens[2]; bool _siteLAM[2]; // Functions void calcProdPoint(); bool updateConstraints(); TrkErrCode coordinateFit(); void killedBy(KalPairRep* thisRep); int thisRepIndex(KalPairRep* thisRep); int otherRepIndex(KalPairRep* thisRep); int thisSiteIndex(KalPairSite* site); void addRep(KalPairRep* newRep); void addSite(KalPairSite* newSite, KalPairRep* rep); double getFltLen(KalPairRep* thisRep); double getFltLen(KalPairSite* thisSite); double getFltChi2(KalPairRep* thisRep); double getFltChi2(KalPairSite* thisSite); KalParams getConstraint(KalPairRep* thisRep); KalParams getConstraint(KalPairSite* thisSite); bool checkLAM(KalPairSite* site); void uploadParams(const KalParams& params, KalPairSite* site); // Preempt KalPairConduit& operator= (const KalPairConduit&); KalPairConduit(const KalPairConduit &); }; #endif
23.214286
76
0.696923
brownd1978
17d8c6d7baf6ce70c546f7ea9ab809a75b0a8d74
128
cpp
C++
DaVinskky Engine/Source/R_Material.cpp
Vinskky/DaVinskky_Engine
a9d46847d72ad20287e415cc8fd63b6f875bba4e
[ "MIT" ]
null
null
null
DaVinskky Engine/Source/R_Material.cpp
Vinskky/DaVinskky_Engine
a9d46847d72ad20287e415cc8fd63b6f875bba4e
[ "MIT" ]
null
null
null
DaVinskky Engine/Source/R_Material.cpp
Vinskky/DaVinskky_Engine
a9d46847d72ad20287e415cc8fd63b6f875bba4e
[ "MIT" ]
null
null
null
#include "R_Material.h" R_Material::R_Material() { diffuseColor = { 1.0f,1.0f, 1.0f, 1.0f }; } R_Material::~R_Material() { }
11.636364
42
0.640625
Vinskky
17dd6e476c2cbe0d6c47ae2173d658ae96817eb1
17,036
cpp
C++
src/frameworks/native/services/surfaceflinger/Scheduler/EventThread.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
null
null
null
src/frameworks/native/services/surfaceflinger/Scheduler/EventThread.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
null
null
null
src/frameworks/native/services/surfaceflinger/Scheduler/EventThread.cpp
dAck2cC2/m3e
475b89b59d5022a94e00b636438b25e27e4eaab2
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <pthread.h> #include <sched.h> #include <sys/types.h> #include <chrono> #include <cstdint> #include <optional> #include <type_traits> #include <android-base/stringprintf.h> #include <cutils/compiler.h> #include <cutils/sched_policy.h> #include <gui/DisplayEventReceiver.h> #include <utils/Errors.h> #include <utils/Trace.h> #include "EventThread.h" using namespace std::chrono_literals; namespace android { using base::StringAppendF; using base::StringPrintf; namespace { auto vsyncPeriod(VSyncRequest request) { return static_cast<std::underlying_type_t<VSyncRequest>>(request); } std::string toString(VSyncRequest request) { switch (request) { case VSyncRequest::None: return "VSyncRequest::None"; case VSyncRequest::Single: return "VSyncRequest::Single"; default: return StringPrintf("VSyncRequest::Periodic{period=%d}", vsyncPeriod(request)); } } std::string toString(const EventThreadConnection& connection) { return StringPrintf("Connection{%p, %s}", &connection, toString(connection.vsyncRequest).c_str()); } std::string toString(const DisplayEventReceiver::Event& event) { switch (event.header.type) { case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: return StringPrintf("Hotplug{displayId=%" ANDROID_PHYSICAL_DISPLAY_ID_FORMAT ", %s}", event.header.displayId, event.hotplug.connected ? "connected" : "disconnected"); case DisplayEventReceiver::DISPLAY_EVENT_VSYNC: return StringPrintf("VSync{displayId=%" ANDROID_PHYSICAL_DISPLAY_ID_FORMAT ", count=%u}", event.header.displayId, event.vsync.count); case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: return StringPrintf("ConfigChanged{displayId=%" ANDROID_PHYSICAL_DISPLAY_ID_FORMAT ", configId=%u}", event.header.displayId, event.config.configId); default: return "Event{}"; } } DisplayEventReceiver::Event makeHotplug(PhysicalDisplayId displayId, nsecs_t timestamp, bool connected) { DisplayEventReceiver::Event event; event.header = {DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG, displayId, timestamp}; event.hotplug.connected = connected; return event; } DisplayEventReceiver::Event makeVSync(PhysicalDisplayId displayId, nsecs_t timestamp, uint32_t count) { DisplayEventReceiver::Event event; event.header = {DisplayEventReceiver::DISPLAY_EVENT_VSYNC, displayId, timestamp}; event.vsync.count = count; return event; } DisplayEventReceiver::Event makeConfigChanged(PhysicalDisplayId displayId, int32_t configId) { DisplayEventReceiver::Event event; event.header = {DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, displayId, systemTime()}; event.config.configId = configId; return event; } } // namespace EventThreadConnection::EventThreadConnection(EventThread* eventThread, ResyncCallback resyncCallback, ISurfaceComposer::ConfigChanged configChanged) : resyncCallback(std::move(resyncCallback)), configChanged(configChanged), mEventThread(eventThread), mChannel(gui::BitTube::DefaultSize) {} EventThreadConnection::~EventThreadConnection() { // do nothing here -- clean-up will happen automatically // when the main thread wakes up } void EventThreadConnection::onFirstRef() { // NOTE: mEventThread doesn't hold a strong reference on us mEventThread->registerDisplayEventConnection(this); } status_t EventThreadConnection::stealReceiveChannel(gui::BitTube* outChannel) { outChannel->setReceiveFd(mChannel.moveReceiveFd()); return NO_ERROR; } status_t EventThreadConnection::setVsyncRate(uint32_t rate) { mEventThread->setVsyncRate(rate, this); return NO_ERROR; } void EventThreadConnection::requestNextVsync() { ATRACE_NAME("requestNextVsync"); mEventThread->requestNextVsync(this); } status_t EventThreadConnection::postEvent(const DisplayEventReceiver::Event& event) { ssize_t size = DisplayEventReceiver::sendEvents(&mChannel, &event, 1); return size < 0 ? status_t(size) : status_t(NO_ERROR); } // --------------------------------------------------------------------------- EventThread::~EventThread() = default; namespace impl { EventThread::EventThread(std::unique_ptr<VSyncSource> src, InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName) : EventThread(nullptr, std::move(src), std::move(interceptVSyncsCallback), threadName) {} EventThread::EventThread(VSyncSource* src, InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName) : EventThread(src, nullptr, std::move(interceptVSyncsCallback), threadName) {} EventThread::EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSrc, InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName) : mVSyncSource(src), mVSyncSourceUnique(std::move(uniqueSrc)), mInterceptVSyncsCallback(std::move(interceptVSyncsCallback)), mThreadName(threadName) { if (src == nullptr) { mVSyncSource = mVSyncSourceUnique.get(); } mVSyncSource->setCallback(this); mThread = std::thread([this]() NO_THREAD_SAFETY_ANALYSIS { std::unique_lock<std::mutex> lock(mMutex); threadMain(lock); }); #if 0 // M3E: no pthread_setname_np pthread_setname_np(mThread.native_handle(), threadName); pid_t tid = pthread_gettid_np(mThread.native_handle()); // Use SCHED_FIFO to minimize jitter constexpr int EVENT_THREAD_PRIORITY = 2; struct sched_param param = {0}; param.sched_priority = EVENT_THREAD_PRIORITY; if (pthread_setschedparam(mThread.native_handle(), SCHED_FIFO, &param) != 0) { ALOGE("Couldn't set SCHED_FIFO for EventThread"); } set_sched_policy(tid, SP_FOREGROUND); #endif // M3E } EventThread::~EventThread() { mVSyncSource->setCallback(nullptr); { std::lock_guard<std::mutex> lock(mMutex); mState = State::Quit; mCondition.notify_all(); } mThread.join(); } void EventThread::setPhaseOffset(nsecs_t phaseOffset) { std::lock_guard<std::mutex> lock(mMutex); mVSyncSource->setPhaseOffset(phaseOffset); } sp<EventThreadConnection> EventThread::createEventConnection( ResyncCallback resyncCallback, ISurfaceComposer::ConfigChanged configChanged) const { return new EventThreadConnection(const_cast<EventThread*>(this), std::move(resyncCallback), configChanged); } status_t EventThread::registerDisplayEventConnection(const sp<EventThreadConnection>& connection) { std::lock_guard<std::mutex> lock(mMutex); // this should never happen auto it = std::find(mDisplayEventConnections.cbegin(), mDisplayEventConnections.cend(), connection); if (it != mDisplayEventConnections.cend()) { ALOGW("DisplayEventConnection %p already exists", connection.get()); mCondition.notify_all(); return ALREADY_EXISTS; } mDisplayEventConnections.push_back(connection); mCondition.notify_all(); return NO_ERROR; } void EventThread::removeDisplayEventConnectionLocked(const wp<EventThreadConnection>& connection) { auto it = std::find(mDisplayEventConnections.cbegin(), mDisplayEventConnections.cend(), connection); if (it != mDisplayEventConnections.cend()) { mDisplayEventConnections.erase(it); } } void EventThread::setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) { if (static_cast<std::underlying_type_t<VSyncRequest>>(rate) < 0) { return; } std::lock_guard<std::mutex> lock(mMutex); const auto request = rate == 0 ? VSyncRequest::None : static_cast<VSyncRequest>(rate); if (connection->vsyncRequest != request) { connection->vsyncRequest = request; mCondition.notify_all(); } } void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection) { if (connection->resyncCallback) { connection->resyncCallback(); } std::lock_guard<std::mutex> lock(mMutex); if (connection->vsyncRequest == VSyncRequest::None) { connection->vsyncRequest = VSyncRequest::Single; mCondition.notify_all(); } } void EventThread::onScreenReleased() { std::lock_guard<std::mutex> lock(mMutex); if (!mVSyncState || mVSyncState->synthetic) { return; } mVSyncState->synthetic = true; mCondition.notify_all(); } void EventThread::onScreenAcquired() { std::lock_guard<std::mutex> lock(mMutex); if (!mVSyncState || !mVSyncState->synthetic) { return; } mVSyncState->synthetic = false; mCondition.notify_all(); } void EventThread::onVSyncEvent(nsecs_t timestamp) { std::lock_guard<std::mutex> lock(mMutex); LOG_FATAL_IF(!mVSyncState, "M3E"); mPendingEvents.push_back(makeVSync(mVSyncState->displayId, timestamp, ++mVSyncState->count)); mCondition.notify_all(); } void EventThread::onHotplugReceived(PhysicalDisplayId displayId, bool connected) { std::lock_guard<std::mutex> lock(mMutex); mPendingEvents.push_back(makeHotplug(displayId, systemTime(), connected)); mCondition.notify_all(); } void EventThread::onConfigChanged(PhysicalDisplayId displayId, int32_t configId) { std::lock_guard<std::mutex> lock(mMutex); mPendingEvents.push_back(makeConfigChanged(displayId, configId)); mCondition.notify_all(); } void EventThread::threadMain(std::unique_lock<std::mutex>& lock) { DisplayEventConsumers consumers; while (mState != State::Quit) { std::optional<DisplayEventReceiver::Event> event; // Determine next event to dispatch. if (!mPendingEvents.empty()) { event = mPendingEvents.front(); mPendingEvents.pop_front(); switch (event->header.type) { case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: if (event->hotplug.connected && !mVSyncState) { mVSyncState.emplace(event->header.displayId); } else if (!event->hotplug.connected && mVSyncState && mVSyncState->displayId == event->header.displayId) { mVSyncState.reset(); } break; case DisplayEventReceiver::DISPLAY_EVENT_VSYNC: if (mInterceptVSyncsCallback) { mInterceptVSyncsCallback(event->header.timestamp); } break; } } bool vsyncRequested = false; // Find connections that should consume this event. auto it = mDisplayEventConnections.begin(); while (it != mDisplayEventConnections.end()) { if (const auto connection = it->promote()) { vsyncRequested |= connection->vsyncRequest != VSyncRequest::None; if (event && shouldConsumeEvent(*event, connection)) { consumers.push_back(connection); } ++it; } else { it = mDisplayEventConnections.erase(it); } } if (!consumers.empty()) { dispatchEvent(*event, consumers); consumers.clear(); } State nextState; if (mVSyncState && vsyncRequested) { nextState = mVSyncState->synthetic ? State::SyntheticVSync : State::VSync; } else { ALOGW_IF(!mVSyncState, "Ignoring VSYNC request while display is disconnected"); nextState = State::Idle; } if (mState != nextState) { if (mState == State::VSync) { mVSyncSource->setVSyncEnabled(false); } else if (nextState == State::VSync) { mVSyncSource->setVSyncEnabled(true); } mState = nextState; } if (event) { continue; } // Wait for event or client registration/request. if (mState == State::Idle) { mCondition.wait(lock); } else { // Generate a fake VSYNC after a long timeout in case the driver stalls. When the // display is off, keep feeding clients at 60 Hz. const auto timeout = mState == State::SyntheticVSync ? 16ms : 1000ms; if (mCondition.wait_for(lock, timeout) == std::cv_status::timeout) { ALOGW_IF(mState == State::VSync, "Faking VSYNC due to driver stall"); LOG_FATAL_IF(!mVSyncState, "M3E: MSVC"); mPendingEvents.push_back(makeVSync(mVSyncState->displayId, systemTime(SYSTEM_TIME_MONOTONIC), ++mVSyncState->count)); } } } } bool EventThread::shouldConsumeEvent(const DisplayEventReceiver::Event& event, const sp<EventThreadConnection>& connection) const { switch (event.header.type) { case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: return true; case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: return connection->configChanged == ISurfaceComposer::eConfigChangedDispatch; case DisplayEventReceiver::DISPLAY_EVENT_VSYNC: switch (connection->vsyncRequest) { case VSyncRequest::None: return false; case VSyncRequest::Single: connection->vsyncRequest = VSyncRequest::None; return true; case VSyncRequest::Periodic: return true; default: return event.vsync.count % vsyncPeriod(connection->vsyncRequest) == 0; } default: return false; } } void EventThread::dispatchEvent(const DisplayEventReceiver::Event& event, const DisplayEventConsumers& consumers) { for (const auto& consumer : consumers) { switch (consumer->postEvent(event)) { case NO_ERROR: break; case -EAGAIN: // TODO: Try again if pipe is full. ALOGW("Failed dispatching %s for %s", toString(event).c_str(), toString(*consumer).c_str()); break; default: // Treat EPIPE and other errors as fatal. removeDisplayEventConnectionLocked(consumer); } } } void EventThread::dump(std::string& result) const { std::lock_guard<std::mutex> lock(mMutex); StringAppendF(&result, "%s: state=%s VSyncState=", mThreadName, toCString(mState)); if (mVSyncState) { StringAppendF(&result, "{displayId=%" ANDROID_PHYSICAL_DISPLAY_ID_FORMAT ", count=%u%s}\n", mVSyncState->displayId, mVSyncState->count, mVSyncState->synthetic ? ", synthetic" : ""); } else { StringAppendF(&result, "none\n"); } StringAppendF(&result, " pending events (count=%zu):\n", mPendingEvents.size()); for (const auto& event : mPendingEvents) { StringAppendF(&result, " %s\n", toString(event).c_str()); } StringAppendF(&result, " connections (count=%zu):\n", mDisplayEventConnections.size()); for (const auto& ptr : mDisplayEventConnections) { if (const auto connection = ptr.promote()) { StringAppendF(&result, " %s\n", toString(*connection).c_str()); } } } const char* EventThread::toCString(State state) { switch (state) { case State::Idle: return "Idle"; case State::Quit: return "Quit"; case State::SyntheticVSync: return "SyntheticVSync"; case State::VSync: return "VSync"; } } } // namespace impl } // namespace android
34.48583
99
0.632954
dAck2cC2
17e6ceb112afc10d0d21a4724e4bd76d351e87aa
9,988
cpp
C++
qbf_solve/main.cpp
appu226/FactorGraph
26e4de8518874abf2696a167eaf3dbaede5930f8
[ "MIT" ]
null
null
null
qbf_solve/main.cpp
appu226/FactorGraph
26e4de8518874abf2696a167eaf3dbaede5930f8
[ "MIT" ]
null
null
null
qbf_solve/main.cpp
appu226/FactorGraph
26e4de8518874abf2696a167eaf3dbaede5930f8
[ "MIT" ]
null
null
null
/* Copyright 2019 Parakram Majumdar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <cstdio> #include <cstdlib> #include <cassert> #include <iostream> #include <memory> #include <time.h> #include <string> #include <factor_graph/srt.h> using namespace std; #ifdef DEBUG #define DBG(stmt) stmt #else #define DBG(stmt) (void)0 #endif #ifdef DEBUGMAIN #define DBGMAIN(stmt) stmt #else #define DBGMAIN(stmt) (void)0 #endif bool contains(DdManager *d, bdd_ptr varDep, bdd_ptr block) { bdd_ptr temp = bdd_cube_intersection(d, varDep, block); if(bdd_is_one(d, temp)) { bdd_free(d, temp); return false; } bdd_free(d, temp); return true; } bool QBF_Solve(char* filename) { const int threshold = 1; int start, end; std::shared_ptr<SRT> t; Quant* q; CNF_vector* c; bdd_ptr varDep,supp; QBlock* qb; SRTNode_Queue leaves; SRTNode* curr; CNF_vector* cv; bool does_contain; SRTNode* Lnew; Vector_Int* ss; DdManager* d; SRTNode* root; bdd_ptr cv_bdd; bdd_ptr res,compand; bdd_ptr block; BDD_List* cv_bdd_list; t = std::make_shared<SRT>(); DBG(cout<<"parsing..."<<endl); t->parse_qdimacs_srt(filename); d = t->SRT_getddm(); varDep = bdd_one(d); q = t->SRT_vars(); c = t->SRT_clauses(); // clock_t big_init, big_final; // clock_t init, final; // double time_merge = 0, time_fg = 0, time_convert = 0, time_forall = 0; // t->SRT_getroot()->split(197); // t->SRT_getroot()->SRT_Then()->split(84); // t->SRT_getroot()->SRT_Else()->split(84); // big_init = clock(); DBGMAIN(cout<<"entering loop"<<endl); while(!q->empty()) { DBGMAIN(cout<<"new iteration"<<endl); DBGMAIN(t->SRT_print()); qb = q->innermost(); start = qb->start; end = qb->end; DBGMAIN(cout<<"start = "<<start<<" end = "<<end<<endl); // MERGING // init=clock(); for(int v=start; v<end; v++) t->SRT_merge(v,threshold); // final=clock(); // time_merge += (double)(final-init) / ((double)CLOCKS_PER_SEC); DBGMAIN(cout<<"computing varcube..."<<endl); block = bdd_one(d); for(int i=start;i<end; i++) { bdd_ptr temp_var = bdd_new_var_with_index(d,i); bdd_and_accumulate(d,&block,temp_var); bdd_free(d,temp_var); } does_contain = contains(d, varDep,block); if(qb->is_universal) { DBGMAIN(cout<<"Universal Quantification"<<endl); c->drop_vars(start,end); if(does_contain) { // FOR EACH LEAF, OPTIMIZE LATER BY TRAVERSING AND MAINTAINING A LIST OF LEAVES leaves.push(t->SRT_getroot()); while(!leaves.empty()) { curr = leaves.front(); leaves.pop(); assert(curr != NULL); if(curr->is_leaf()) { // init = clock(); curr->for_all_innermost(d,q); curr->deduce(); // final=clock(); // time_forall += (double)(final-init) / ((double)CLOCKS_PER_SEC); } else { leaves.push(curr->SRT_Then()); leaves.push(curr->SRT_Else()); } } } // ELSE NOTHING TO DO, VARIABLES FROM GLOBAL CNF_VECTOR ALREADY DROPPED } else { // EXISTENTIAL QUANTIFICATION DBGMAIN(cout<<"Existential Quantification"<<endl); cv = c->filter_innermost(q); /* for(int cvs = 0; cvs < cv->clauses.size(); cvs ++) { DBG(cout<<"filtered clause "); for(int cvscs = 0; cvscs < cv->clauses[cvs]->vars.size(); cvscs++) DBG(cout<<cv->clauses[cvs]->vars[cvscs]<<" "); DBG(cout<<endl); } */ //cv_bdd = CNF_to_BDD(cv, d); cv_bdd_list = CNF_to_BDD_List(cv, d); DBGMAIN(cout<<"cv has "<<cv->clauses.size()<<" out of "<<c->clauses.size()<<" clauses"<<endl); if (does_contain) { DBGMAIN(cout<<"some leaf contains the vars..."<<endl); // FOR EACH LEAF, OPTIMIZE LATER BY TRAVERSING AND MAINTAINING A LIST OF LEAVES leaves.push(t->SRT_getroot()); while(!leaves.empty()) { curr = leaves.front(); leaves.pop(); if(curr->is_leaf()) { // FOR EACH LEAF curr->append(cv_bdd_list); //FACTOR GRAPH // init = clock(); //apply the split history of L to CV, add these clauses to L factor_graph *fg = make_factor_graph(d, curr); factor_graph_eliminate(fg, start, end, curr); factor_graph_delete(fg); curr->deduce(); // final=clock(); // time_fg += (double)(final-init) / ((double)CLOCKS_PER_SEC); /*curr->join_bdds(d); res = bdd_forsome(d,(*(curr->get_func()))[0],block); bdd_free(d, (*(curr->get_func()))[0]); (*(curr->get_func()))[0] = res; */ } else { leaves.push(curr->SRT_Then()); leaves.push(curr->SRT_Else()); } } } else { // no leaves depend on V DBGMAIN(cout<<"no leaf contains the vars..."<<endl); Lnew = make_leaf(t->SRT_getddm(), cv); // no leaf depends on V, form a global leaf from CV //FACTOR GRAPH // init = clock(); factor_graph *fg = make_factor_graph(d, Lnew); factor_graph_eliminate(fg, start, end, Lnew); factor_graph_delete(fg); // final=clock(); // time_fg += (double)(final-init) / ((double)CLOCKS_PER_SEC); // FOR EACH LEAF, OPTIMIZE LATER BY TRAVERSING AND MAINTAINING A LIST OF LEAVES leaves.push(t->SRT_getroot()); while(!leaves.empty()) { curr = leaves.front(); leaves.pop(); if(curr->is_leaf()) { // FOR EACH LEAF curr->append(Lnew); curr->deduce(); } else { leaves.push(curr->SRT_Then()); leaves.push(curr->SRT_Else()); } } } ss = cv->support_set(); // CV.support_set for(Vector_Int::iterator i = ss->begin(); i!=ss->end();) { if((*i) >= start && (*i) < end) i = ss->erase(i); else i++; } // CV.support_set - V // Now construct the bdd having these variables if(!ss->empty()) { supp = bdd_one(d); for(int i=0;i<ss->size(); i++) { bdd_ptr temp = bdd_new_var_with_index(d,(*ss)[i]); bdd_and_accumulate(d,&supp,temp); bdd_free(d, temp); } bdd_and_accumulate(d,&varDep,supp); bdd_free(d, supp); // mark variables coming from CV into T*/ } } DBGMAIN(printf("post removal : \n")); DBGMAIN(t->SRT_print()); // MERGING // init = clock(); for(int v=end-1; v>=start; v--) { t->SRT_merge(v,threshold); } // final=clock(); // time_merge += (double)(final-init) / ((double)CLOCKS_PER_SEC); // assert(t->SRT_getroot()->is_leaf()); // printf("SIZE OF FUNC ON ROOT: %d\n",t->SRT_getroot()->type.leaf.func->size()); // t->SRT_getroot()->type.leaf.print(d); // assert(t->SRT_getroot()->type.leaf.check_func(d,bdd_or(d,bdd_new_var_with_index(d,1),bdd_new_var_with_index(d,2)))); q->remove_innermost(); DBGMAIN(printf("post merge : \n")); DBGMAIN(t->SRT_print()); } assert(t->SRT_getroot()); assert(t->SRT_getroot()->is_leaf()); // big_final = clock(); // cout<<"Time for Merging: "<<time_merge<<endl; // cout<<"Time for Factor Graph: "<<time_fg<<endl; // cout<<"Time for Forall: "<<time_forall<<endl; // cout<<"Time for BDD-CNF Conversion: "<<time_convert<<endl; // profile(); // cout<<"Total Time: "<<(double)(big_final-big_init)/((double)CLOCKS_PER_SEC)<<endl; //assert(t->SRT_getroot()->get_func()->size()==1); for(int g = 0; g < t->global_clauses->clauses.size(); g++) { assert(t->global_clauses->clauses[g]->vars.size() == 0); return false; } for(int g = 0; g < t->SRT_getroot()->get_func()->size(); g++) // size == 1?? if( !bdd_is_one(t->SRT_getddm(), (*(t->SRT_getroot()->get_func())) [g] ) ) return false; return true; } int main(int argc, char **argv) { /* int n; printf("Enter number of variables: "); scanf("%d",&n); SRT* t = new SRT(n); int option; int mergevar; int threshold; while(true) { printf("Select Option:\n"); printf("1. Print Tree\n"); printf("2. Split a node\n"); printf("3. Merge a node\n"); printf("4. Exit\n"); scanf("%d",&option); std::string splitnode; int var; switch(option) { case 1: t->SRT_print(); break; case 2: printf("Enter the string for the node: "); std::cin>>splitnode; printf("Enter the variable: "); scanf("%d",&var); t->split(splitnode,var); t->SRT_print(); break; case 3: printf("Enter the variable to merge on: "); scanf("%d",&mergevar); printf("Enter the threshold for merging: "); scanf("%d",&threshold); t->SRT_merge(mergevar,threshold); t->SRT_print(); break; case 4: exit(0); break; default: printf("Sorry, option unavailable\n"); } } return 0;*/ if(argc != 2) { cout<<"Usage : "<<endl<<"\t"<<argv[0]<<" <filename>"<<endl; return 0; } bool res = QBF_Solve(argv[1]); if(res) cout<<"\t\t\t====================================\n" <<"\t\t\t======== Result is TRUE ==========\n" <<"\t\t\t====================================" <<endl; else cout<<"\t\t\t====================================\n" <<"\t\t\t======== Result is FALSE =========\n" <<"\t\t\t====================================" <<endl; }
26.493369
124
0.604626
appu226
17e73146a4c193de9587418a56a96588ee72f5ed
17,823
hpp
C++
sparta/sparta/app/MultiDetailOptions.hpp
debjyoti0891/map
abdae67964420d7d36255dcbf83e4240a1ef4295
[ "MIT" ]
44
2019-12-13T06:39:13.000Z
2022-03-29T23:09:28.000Z
sparta/sparta/app/MultiDetailOptions.hpp
debjyoti0891/map
abdae67964420d7d36255dcbf83e4240a1ef4295
[ "MIT" ]
222
2020-01-14T21:58:56.000Z
2022-03-31T20:05:12.000Z
sparta/sparta/app/MultiDetailOptions.hpp
debjyoti0891/map
abdae67964420d7d36255dcbf83e4240a1ef4295
[ "MIT" ]
19
2020-01-03T19:03:22.000Z
2022-01-09T08:36:20.000Z
// <MultiDetailOptions.hpp> -*- C++ -*- /*! * \file MultiDetailOptions.hpp * \brief Wrapper for boost program_options option_description that allows * multiple levels of detail */ #pragma once #include <boost/program_options.hpp> #include "sparta/sparta.hpp" namespace po = boost::program_options; namespace sparta { namespace app { /*! * \brief Helper class for populating boost program options */ template <typename ArgT> class named_value_type : public po::typed_value<ArgT> { unsigned min_; unsigned max_; std::string my_name_; public: /*! * \brief Type of base class */ typedef po::typed_value<ArgT> base_t; /*! * \brief Constructor */ named_value_type(std::string const& name, ArgT* val) : po::typed_value<ArgT>(val), min_(0), max_(1), my_name_(name) { } /*! * \brief Constructor with min and max extents */ named_value_type(std::string const& name, ArgT* val, unsigned min, unsigned max) : po::typed_value<ArgT>(val), min_(min), max_(max), my_name_(name) { } virtual ~named_value_type() {} /*! * \brief boost semantic for getting name of this option */ virtual std::string name() const override { return my_name_; } named_value_type* min(unsigned min) { min_ = min; return this; } named_value_type* max(unsigned max) { max_ = max; return this; } named_value_type* multitoken() { base_t::multitoken(); return this; } /*! * \brief boost semantic for specifying min tokens */ virtual unsigned min_tokens() const override { return min_; } /*! * \brief boost semantic for specifying max tokens */ virtual unsigned max_tokens() const override { return max_; } /*! * \brief Override parser * \note Defined inline later because of dependency on named_value_parser */ virtual void xparse(boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) const override; /*! * \brief Call xparse on base class. This is available to named_value_parser * for invoking the default parser when needed */ void xparse_base_(boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) const { po::typed_value<ArgT>::xparse(value_store, new_tokens); } }; /*! * \brief Parser helper for named_value_type */ template <typename ArgT> class named_value_parser { public: /*! * \brief Default implementation of parse_ - overridden in class template * specializations * * Invokes the corresponding named_value_type's base_class' parser */ static void parse_(const named_value_type<ArgT>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { nvt.xparse_base_(value_store, new_tokens); } }; template <class ArgT> void named_value_type<ArgT>::xparse(boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) const { // Invoked the appropriately typed named_value_parser //std::cout << "parsing " << my_name_ << " : " << new_tokens << std::endl; named_value_parser<ArgT>::parse_(*this, value_store, new_tokens); } /*! * \brief named_value_parser specialization for uint64_t */ template <> class named_value_parser<uint64_t> { public: static void parse_(const named_value_type<uint64_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; uint64_t val = utils::smartLexicalCast<uint64_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for int64_t */ template <> class named_value_parser<int64_t> { public: static void parse_(const named_value_type<int64_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; int64_t val = utils::smartLexicalCast<int64_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for uint32_t */ template <> class named_value_parser<uint32_t> { public: static void parse_(const named_value_type<uint32_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; uint32_t val = utils::smartLexicalCast<uint32_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for int32_t */ template <> class named_value_parser<int32_t> { public: static void parse_(const named_value_type<int32_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; int32_t val = utils::smartLexicalCast<int32_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for uint16_t */ template <> class named_value_parser<uint16_t> { public: static void parse_(const named_value_type<uint16_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; uint16_t val = utils::smartLexicalCast<uint16_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for int16_t */ template <> class named_value_parser<int16_t> { public: static void parse_(const named_value_type<int16_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; int16_t val = utils::smartLexicalCast<int16_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for uint8_t */ template <> class named_value_parser<uint8_t> { public: static void parse_(const named_value_type<uint8_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; uint8_t val = utils::smartLexicalCast<uint8_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief named_value_parser specialization for int8_t */ template <> class named_value_parser<int8_t> { public: static void parse_(const named_value_type<int8_t>& nvt, boost::any& value_store, const std::vector<std::basic_string<char>>& new_tokens) { (void) nvt; size_t end_pos; int8_t val = utils::smartLexicalCast<int8_t>(new_tokens.at(0), end_pos); //std::cout << " got: " << val << std::endl; value_store = val; } }; /*! * \brief Helper function for generating new named_value_type structs in the * boost style */ template <typename ArgT> inline named_value_type<ArgT>* named_value(std::string const& name, ArgT* val=nullptr) { return new named_value_type<ArgT>(name, val); } template <typename ArgT> inline named_value_type<ArgT>* named_value(std::string const& name, unsigned min, unsigned max, ArgT* val=nullptr) { return new named_value_type<ArgT>(name, val, min, max); } /*! * \brief Class for containing multiple levels of boost program options */ class MultiDetailOptions final { public: typedef uint32_t level_t; static const level_t VERBOSE = 0; static const level_t BRIEF = 1; /*! * \brief Helper class for chained calls to add_options */ class OptAdder { MultiDetailOptions& opts_; public: OptAdder(MultiDetailOptions& opts) : opts_(opts) {;} /*! * \brief Acts like calling MultiDetailOptions::add_options on the * object that created this OptAdder. */ template <typename ...Args> OptAdder& operator()(const char* name, const char* verbose_desc, const Args& ...args) { opts_.add_option_with_desc_level_(0, name, verbose_desc, args...); return *this; } /*! * \brief Acts like calling MultiDetailOptions::add_options on the * object that created this OptAdder. */ template <typename ...Args> OptAdder operator()(const char* name, const boost::program_options::value_semantic* s, const char* verbose_desc, const Args& ...args) { opts_.add_option_with_desc_level_(0, name, s, verbose_desc, args...); return *this; } }; /*! * \brief Allow access to private adding methods */ friend class OptAdded; /*! * \brief Not copy-constructable */ MultiDetailOptions(const MultiDetailOptions&) = delete; /*! * \brief Not assignable */ MultiDetailOptions& operator=(const MultiDetailOptions&) = delete; /*! * \brief Not default-constructable */ MultiDetailOptions() = delete; /*! * \brief Construction with group nam * \post Ensures that the VERBOSE options entry and BRIEF entries exist */ MultiDetailOptions(const std::string& name, uint32_t w=80, uint32_t hw=40) : opt_adder_(*this), name_(name) { descs_.emplace_back(new po::options_description(name_, w, hw)); descs_.emplace_back(new po::options_description(name_, w, hw)); sparta_assert(descs_.size() > VERBOSE); sparta_assert(descs_.size() > BRIEF); } /*! * \brief Gets the description object for a particular level if that level * exists. If that level does not exist, returns the highest level less than * \a level where options exist. Will never throw because VERBOSE is * guaranteed to exist. * Only VERBOSE and BRIEF levels are guaranteed to exist * \note When actually parsing using these options, use the VERBOSE level */ const po::options_description& getOptionsLevelUpTo(level_t level) const { if(level < descs_.size()){ return *descs_.at(level); }else{ sparta_assert(descs_.size() > 0); return *descs_.at(descs_.size() - 1); } } /*! * \brief Gets the description object for a particular level. * Only VERBOSE and BRIEF levels are guaranteed to exist * \note When actually parsing using these options, use the VERBOSE level * \throws Exception if there is no options set at \a level */ const po::options_description& getOptionsLevel(level_t level) const { return *descs_.at(level); } /*! * \brief Gets the description object for the VERBOSE level */ const po::options_description& getVerboseOptions() const noexcept { return *descs_.at(VERBOSE); } /*! * \brief Returns the number of levels that have an options description * which can be retrieved through getLevel */ size_t getNumLevels() const { return descs_.size(); } /*! * \brief Add an option with NO value semantic and any number of * descriptions. See the other add_options signature for details */ template <typename ...Args> OptAdder& add_options(const char* name, const char* verbose_desc, const Args& ...args) { add_option_with_desc_level_(0, name, verbose_desc, args...); return opt_adder_; } /*! * \brief Add an option with a value semantic and any number of descriptions * \tparam ...Args variadic argument container type. Automatically deduced * by call signature * \param name Name of the option to be interpreted by * boost::program_options::options_description (e.g. "help,h"). * \param s Value semantic. Typically something generated by the helper * sparta::app::named_value or boost::program_options::value<T>(). * \param verbose_desc Verbose description. All options have a required * verbose description so they show up in verbose help (which is practically * a man page) and can be appropriately parsed by boost * \param ...args Additional const char* description arguments (like * verbose_desc). Each additional argument is assigned to the next higher * options level for this option (\a name). If no additional descriptions * are given, this option will not have an entry when the options are * printed for that level. Generally, each additional level becomes more * brief. * Example: * \code * // MultiDetailOptions opts("foo"); * opts.add_option("bar", * "verbose description of bar", * "brief bar desc") * \endcode */ template <typename ...Args> OptAdder& add_options(const char* name, const boost::program_options::value_semantic* s, const char* verbose_desc, const Args& ...args) { add_option_with_desc_level_(0, name, s, verbose_desc, args...); return opt_adder_; } /*! * \brief Empty add_options shell allowing the start of chained calls * (exists solely to mimic boost's syntax) * * Example: * \code * // MultiDetailOptions opts("foo"); * opts.add_option()("bar", * "verbose description of bar", * "brief bar desc") * \endcode */ OptAdder& add_options() { return opt_adder_; } private: /*! * \brief Terminator for calls to add_option_with_desc_level_. Invoked when * ...args is empty */ void add_option_with_desc_level_(size_t level, const char* name) { (void) level; (void) name; } /*! * \brief Private recursive helper for handling variable argument calls to * add_options. See the other signature for more details */ template <typename ...Args> void add_option_with_desc_level_(size_t level, const char* name, const char* desc, const Args& ...args) { while(descs_.size() <= level){ descs_.emplace_back(new po::options_description(name_)); } descs_.at(level)->add_options() (name, desc); // Recursively invoke until terminator overload of this func is reached add_option_with_desc_level_(level+1, name, args...); } //// Terminator //void add_option_with_desc_level_(size_t level, // const char* name, // const boost::program_options::value_semantic* s) //{ // (void) level; // (void) name; // delete s; // Delete unused copy of value_semantic //} /*! * \brief Private recursive helper for handling variable argument calls to * add_options. Each description is added to the specified \a level and the * rest are passed recursively to be added at the next level. Once * \a ...args is empty, the non-templated terminator signature of this * function is called */ template <typename ...Args> void add_option_with_desc_level_(size_t level, const char* name, const boost::program_options::value_semantic* s, const char* desc, const Args& ...args) { while(descs_.size() <= level){ descs_.emplace_back(new po::options_description(name_)); } descs_.at(level)->add_options() (name, s, desc); // Recursively invoke until terminator overload of this func is reached // Note that this invoked the OTHER signature with NO VALUE SEMANTIC. // Boost frees these on destruction, so assigning the same pointer to // multiple options will create a double-free segfault. // The implication is that parsing must be done at the verbose level and // higher levels will have no semantic information (e.g. arguments) add_option_with_desc_level_(level+1, name, args...); } /*! * \brief Option adder which is returned by add_options() to allow chained * calls */ OptAdder opt_adder_; /*! * \brief Name of this set of options */ const std::string name_; /*! * \brief Vector of levels of boost program options option_description sets */ std::vector<std::unique_ptr<po::options_description>> descs_; }; // class MultiDetailOptions } // namespace app } // namespace sparta
30.67642
116
0.601246
debjyoti0891
17e7af81d392d433bb24ade2234e33c988c1466f
328,494
cc
C++
schemas/cpp/openconfig/openconfig_wavelength_router/openconfig_wavelength_router.pb.cc
seilis/serialization-perf
447cab4bfee66c8a86062b1b6169bddf81036a79
[ "Apache-2.0" ]
null
null
null
schemas/cpp/openconfig/openconfig_wavelength_router/openconfig_wavelength_router.pb.cc
seilis/serialization-perf
447cab4bfee66c8a86062b1b6169bddf81036a79
[ "Apache-2.0" ]
2
2018-05-10T22:57:40.000Z
2018-05-16T10:14:23.000Z
schemas/cpp/openconfig/openconfig_wavelength_router/openconfig_wavelength_router.pb.cc
seilis/serialization-perf
447cab4bfee66c8a86062b1b6169bddf81036a79
[ "Apache-2.0" ]
1
2018-05-09T03:03:01.000Z
2018-05-09T03:03:01.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: openconfig/openconfig_wavelength_router/openconfig_wavelength_router.proto #include "openconfig/openconfig_wavelength_router/openconfig_wavelength_router.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/port.h> #include <google/protobuf/stubs/once.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // This is a temporary google only hack #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS #include "third_party/protobuf/version.h" #endif // @@protoc_insertion_point(includes) namespace openconfig { namespace openconfig_wavelength_router { class WavelengthRouter_MediaChannels_Channel_ConfigDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Config> _instance; } _WavelengthRouter_MediaChannels_Channel_Config_default_instance_; class WavelengthRouter_MediaChannels_Channel_Dest_ConfigDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Dest_Config> _instance; } _WavelengthRouter_MediaChannels_Channel_Dest_Config_default_instance_; class WavelengthRouter_MediaChannels_Channel_Dest_StateDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Dest_State> _instance; } _WavelengthRouter_MediaChannels_Channel_Dest_State_default_instance_; class WavelengthRouter_MediaChannels_Channel_DestDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Dest> _instance; } _WavelengthRouter_MediaChannels_Channel_Dest_default_instance_; class WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_ConfigDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config> _instance; } _WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_; class WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_StateDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State> _instance; } _WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_; class WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue> _instance; } _WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_default_instance_; class WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKeyDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey> _instance; } _WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey_default_instance_; class WavelengthRouter_MediaChannels_Channel_PsdDistributionDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_PsdDistribution> _instance; } _WavelengthRouter_MediaChannels_Channel_PsdDistribution_default_instance_; class WavelengthRouter_MediaChannels_Channel_Source_ConfigDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Source_Config> _instance; } _WavelengthRouter_MediaChannels_Channel_Source_Config_default_instance_; class WavelengthRouter_MediaChannels_Channel_Source_StateDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Source_State> _instance; } _WavelengthRouter_MediaChannels_Channel_Source_State_default_instance_; class WavelengthRouter_MediaChannels_Channel_SourceDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_Source> _instance; } _WavelengthRouter_MediaChannels_Channel_Source_default_instance_; class WavelengthRouter_MediaChannels_Channel_StateDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel_State> _instance; } _WavelengthRouter_MediaChannels_Channel_State_default_instance_; class WavelengthRouter_MediaChannels_ChannelDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_Channel> _instance; } _WavelengthRouter_MediaChannels_Channel_default_instance_; class WavelengthRouter_MediaChannels_ChannelKeyDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels_ChannelKey> _instance; } _WavelengthRouter_MediaChannels_ChannelKey_default_instance_; class WavelengthRouter_MediaChannelsDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter_MediaChannels> _instance; } _WavelengthRouter_MediaChannels_default_instance_; class WavelengthRouterDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<WavelengthRouter> _instance; } _WavelengthRouter_default_instance_; } // namespace openconfig_wavelength_router } // namespace openconfig namespace protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto { void InitDefaultsWavelengthRouter_MediaChannels_Channel_ConfigImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsUintValue(); protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Config() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_ConfigImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_ConfigImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_Config_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_Config() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_ConfigImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_StateImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_State_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_State() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_StateImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_DestImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_Config(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_State(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_DestImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_ConfigImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsUintValue(); protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsBytesValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_ConfigImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_StateImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsUintValue(); protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsBytesValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_StateImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKeyImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKeyImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistributionImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistributionImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_ConfigImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_Config_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_Config() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_ConfigImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_StateImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_State_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_State() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_StateImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_SourceImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_Config(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_State(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_Source() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_SourceImpl); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_StateImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsUintValue(); protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::InitDefaultsStringValue(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel_State() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_Channel_StateImpl); } void InitDefaultsWavelengthRouter_MediaChannels_ChannelImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Config(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source(); protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_State(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_Channel() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_ChannelImpl); } void InitDefaultsWavelengthRouter_MediaChannels_ChannelKeyImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_ChannelKey_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels_ChannelKey() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannels_ChannelKeyImpl); } void InitDefaultsWavelengthRouter_MediaChannelsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_ChannelKey(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter_MediaChannels() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouter_MediaChannelsImpl); } void InitDefaultsWavelengthRouterImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS ::google::protobuf::internal::InitProtobufDefaultsForceUnique(); #else ::google::protobuf::internal::InitProtobufDefaults(); #endif // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels(); { void* ptr = &::openconfig::openconfig_wavelength_router::_WavelengthRouter_default_instance_; new (ptr) ::openconfig::openconfig_wavelength_router::WavelengthRouter(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::openconfig::openconfig_wavelength_router::WavelengthRouter::InitAsDefaultInstance(); } void InitDefaultsWavelengthRouter() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWavelengthRouterImpl); } ::google::protobuf::Metadata file_level_metadata[17]; const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, admin_status_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, lower_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config, upper_frequency_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config, port_name_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State, port_name_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest, config_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest, state_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config, lower_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config, psd_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config, upper_frequency_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State, lower_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State, psd_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State, upper_frequency_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue, config_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue, state_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey, lower_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey, upper_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey, psd_value_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution, psd_value_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config, port_name_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State, port_name_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source, config_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source, state_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, admin_status_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, lower_frequency_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, oper_status_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State, upper_frequency_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, config_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, dest_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, psd_distribution_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, source_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel, state_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey, index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey, channel_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels, channel_), ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::openconfig::openconfig_wavelength_router::WavelengthRouter, media_channels_), }; static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config)}, { 10, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config)}, { 16, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State)}, { 22, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest)}, { 29, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config)}, { 37, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State)}, { 45, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue)}, { 52, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey)}, { 60, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution)}, { 66, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config)}, { 72, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State)}, { 78, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source)}, { 85, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State)}, { 96, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel)}, { 106, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_ChannelKey)}, { 113, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels)}, { 119, -1, sizeof(::openconfig::openconfig_wavelength_router::WavelengthRouter)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_Config_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_State_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_Config_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_State_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_ChannelKey_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_default_instance_), reinterpret_cast<const ::google::protobuf::Message*>(&::openconfig::openconfig_wavelength_router::_WavelengthRouter_default_instance_), }; void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; AssignDescriptors( "openconfig/openconfig_wavelength_router/openconfig_wavelength_router.proto", schemas, file_default_instances, TableStruct::offsets, factory, file_level_metadata, file_level_enum_descriptors, NULL); } void protobuf_AssignDescriptorsOnce() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 17); } void AddDescriptorsImpl() { InitDefaults(); static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\nJopenconfig/openconfig_wavelength_route" "r/openconfig_wavelength_router.proto\022\'op" "enconfig.openconfig_wavelength_router\0328g" "ithub.com/openconfig/ygot/proto/ywrapper" "/ywrapper.proto\0320github.com/openconfig/y" "got/proto/yext/yext.proto\032\034openconfig/en" "ums/enums.proto\"\213.\n\020WavelengthRouter\022\210\001\n" "\016media_channels\030\306\265\346< \001(\0132G.openconfig.op" "enconfig_wavelength_router.WavelengthRou" "ter.MediaChannelsB$\202A!/wavelength-router" "/media-channels\032\353,\n\rMediaChannels\022\225\001\n\007ch" "annel\030\322\217\376\377\001 \003(\0132R.openconfig.openconfig_" "wavelength_router.WavelengthRouter.Media" "Channels.ChannelKeyB,\202A)/wavelength-rout" "er/media-channels/channel\032\215*\n\007Channel\022\237\001" "\n\006config\030\223\233\271\303\001 \001(\0132V.openconfig.openconf" "ig_wavelength_router.WavelengthRouter.Me" "diaChannels.Channel.ConfigB3\202A0/waveleng" "th-router/media-channels/channel/config\022" "\230\001\n\004dest\030\345\324\264E \001(\0132T.openconfig.openconfi" "g_wavelength_router.WavelengthRouter.Med" "iaChannels.Channel.DestB1\202A./wavelength-" "router/media-channels/channel/dest\022\273\001\n\020p" "sd_distribution\030\335\367\215\027 \001(\0132_.openconfig.op" "enconfig_wavelength_router.WavelengthRou" "ter.MediaChannels.Channel.PsdDistributio" "nB=\202A:/wavelength-router/media-channels/" "channel/psd-distribution\022\236\001\n\006source\030\312\245\310u" " \001(\0132V.openconfig.openconfig_wavelength_" "router.WavelengthRouter.MediaChannels.Ch" "annel.SourceB3\202A0/wavelength-router/medi" "a-channels/channel/source\022\234\001\n\005state\030\364\330\354\313" "\001 \001(\0132U.openconfig.openconfig_wavelength" "_router.WavelengthRouter.MediaChannels.C" "hannel.StateB2\202A//wavelength-router/medi" "a-channels/channel/state\032\324\004\n\006Config\022\225\001\n\014" "admin_status\030\212\320\321F \001(\0162:.openconfig.enums" ".OpenconfigWavelengthRouterAdminStateTyp" "eB@\202A=/wavelength-router/media-channels/" "channel/config/admin-status\022a\n\005index\030\342\362\337" "\217\001 \001(\0132\023.ywrapper.UintValueB9\202A6/wavelen" "gth-router/media-channels/channel/config" "/index\022u\n\017lower_frequency\030\210\262\333\376\001 \001(\0132\023.yw" "rapper.UintValueBC\202A@/wavelength-router/" "media-channels/channel/config/lower-freq" "uency\022a\n\004name\030\303\321\264\247\001 \001(\0132\025.ywrapper.Strin" "gValueB8\202A5/wavelength-router/media-chan" "nels/channel/config/name\022u\n\017upper_freque" "ncy\030\207\340\374\315\001 \001(\0132\023.ywrapper.UintValueBC\202A@/" "wavelength-router/media-channels/channel" "/config/upper-frequency\032\317\004\n\004Dest\022\251\001\n\006con" "fig\030\252\236\260\212\001 \001(\0132[.openconfig.openconfig_wa" "velength_router.WavelengthRouter.MediaCh" "annels.Channel.Dest.ConfigB8\202A5/waveleng" "th-router/media-channels/channel/dest/co" "nfig\022\245\001\n\005state\030\307\212\220\005 \001(\0132Z.openconfig.ope" "nconfig_wavelength_router.WavelengthRout" "er.MediaChannels.Channel.Dest.StateB7\202A4" "/wavelength-router/media-channels/channe" "l/dest/state\032y\n\006Config\022o\n\tport_name\030\270\205\360\013" " \001(\0132\025.ywrapper.StringValueBB\202A\?/wavelen" "gth-router/media-channels/channel/dest/c" "onfig/port-name\032x\n\005State\022o\n\tport_name\030\255\244" "\321\250\001 \001(\0132\025.ywrapper.StringValueBA\202A>/wave" "length-router/media-channels/channel/des" "t/state/port-name\032\325\016\n\017PsdDistribution\022\313\001" "\n\tpsd_value\030\275\325\245\247\001 \003(\0132k.openconfig.openc" "onfig_wavelength_router.WavelengthRouter" ".MediaChannels.Channel.PsdDistribution.P" "sdValueKeyBG\202AD/wavelength-router/media-" "channels/channel/psd-distribution/psd-va" "lue\032\202\n\n\010PsdValue\022\322\001\n\006config\030\362\373\330C \001(\0132o.o" "penconfig.openconfig_wavelength_router.W" "avelengthRouter.MediaChannels.Channel.Ps" "dDistribution.PsdValue.ConfigBN\202AK/wavel" "ength-router/media-channels/channel/psd-" "distribution/psd-value/config\022\317\001\n\005state\030" "\357\325\223\t \001(\0132n.openconfig.openconfig_wavelen" "gth_router.WavelengthRouter.MediaChannel" "s.Channel.PsdDistribution.PsdValue.State" "BM\202AJ/wavelength-router/media-channels/c" "hannel/psd-distribution/psd-value/state\032" "\247\003\n\006Config\022\217\001\n\017lower_frequency\030\255\216\2052 \001(\0132" "\023.ywrapper.UintValueB^\202A[/wavelength-rou" "ter/media-channels/channel/psd-distribut" "ion/psd-value/config/lower-frequency\022x\n\003" "psd\030\302\333\317\002 \001(\0132\024.ywrapper.BytesValueBR\202AO/" "wavelength-router/media-channels/channel" "/psd-distribution/psd-value/config/psd\022\220" "\001\n\017upper_frequency\030\352\271\201\354\001 \001(\0132\023.ywrapper." "UintValueB^\202A[/wavelength-router/media-c" "hannels/channel/psd-distribution/psd-val" "ue/config/upper-frequency\032\244\003\n\005State\022\216\001\n\017" "lower_frequency\030\374\346\272J \001(\0132\023.ywrapper.Uint" "ValueB]\202AZ/wavelength-router/media-chann" "els/channel/psd-distribution/psd-value/s" "tate/lower-frequency\022x\n\003psd\030\227\230\204\301\001 \001(\0132\024." "ywrapper.BytesValueBQ\202AN/wavelength-rout" "er/media-channels/channel/psd-distributi" "on/psd-value/state/psd\022\217\001\n\017upper_frequen" "cy\030\253\271\362\234\001 \001(\0132\023.ywrapper.UintValueB]\202AZ/w" "avelength-router/media-channels/channel/" "psd-distribution/psd-value/state/upper-f" "requency\032\356\002\n\013PsdValueKey\022p\n\017lower_freque" "ncy\030\001 \001(\004BW\202AT/wavelength-router/media-c" "hannels/channel/psd-distribution/psd-val" "ue/lower-frequency\022p\n\017upper_frequency\030\002 " "\001(\004BW\202AT/wavelength-router/media-channel" "s/channel/psd-distribution/psd-value/upp" "er-frequency\022{\n\tpsd_value\030\003 \001(\0132h.openco" "nfig.openconfig_wavelength_router.Wavele" "ngthRouter.MediaChannels.Channel.PsdDist" "ribution.PsdValue\032\335\004\n\006Source\022\255\001\n\006config\030" "\233\251\342\350\001 \001(\0132].openconfig.openconfig_wavele" "ngth_router.WavelengthRouter.MediaChanne" "ls.Channel.Source.ConfigB:\202A7/wavelength" "-router/media-channels/channel/source/co" "nfig\022\251\001\n\005state\030\234\345\205T \001(\0132\\.openconfig.ope" "nconfig_wavelength_router.WavelengthRout" "er.MediaChannels.Channel.Source.StateB9\202" "A6/wavelength-router/media-channels/chan" "nel/source/state\032|\n\006Config\022r\n\tport_name\030" "\331\346\202\255\001 \001(\0132\025.ywrapper.StringValueBD\202AA/wa" "velength-router/media-channels/channel/s" "ource/config/port-name\032y\n\005State\022p\n\tport_" "name\030\212\370\331\004 \001(\0132\025.ywrapper.StringValueBC\202A" "@/wavelength-router/media-channels/chann" "el/source/state/port-name\032\345\006\n\005State\022\225\001\n\014" "admin_status\030\263\326\341\230\001 \001(\0162:.openconfig.enum" "s.OpenconfigWavelengthRouterAdminStateTy" "peB\?\202A</wavelength-router/media-channels" "/channel/state/admin-status\022_\n\005index\030\245\275\350" "i \001(\0132\023.ywrapper.UintValueB8\202A5/waveleng" "th-router/media-channels/channel/state/i" "ndex\022s\n\017lower_frequency\030\277\273\331\035 \001(\0132\023.ywrap" "per.UintValueBB\202A\?/wavelength-router/med" "ia-channels/channel/state/lower-frequenc" "y\022`\n\004name\030\226\372\340\211\001 \001(\0132\025.ywrapper.StringVal" "ueB7\202A4/wavelength-router/media-channels" "/channel/state/name\022\271\001\n\013oper_status\030\212\321\231\373" "\001 \001(\0162`.openconfig.openconfig_wavelength" "_router.WavelengthRouter.MediaChannels.C" "hannel.State.OperStatusB>\202A;/wavelength-" "router/media-channels/channel/state/oper" "-status\022t\n\017upper_frequency\030\244\321\310\311\001 \001(\0132\023.y" "wrapper.UintValueBB\202A\?/wavelength-router" "/media-channels/channel/state/upper-freq" "uency\"Z\n\nOperStatus\022\024\n\020OPERSTATUS_UNSET\020" "\000\022\030\n\rOPERSTATUS_UP\020\001\032\005\202A\002UP\022\034\n\017OPERSTATU" "S_DOWN\020\002\032\007\202A\004DOWN\032\261\001\n\nChannelKey\022A\n\005inde" "x\030\001 \001(\004B2\202A//wavelength-router/media-cha" "nnels/channel/index\022`\n\007channel\030\002 \001(\0132O.o" "penconfig.openconfig_wavelength_router.W" "avelengthRouter.MediaChannels.Channelb\006p" "roto3" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( descriptor, 6165); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "openconfig/openconfig_wavelength_router/openconfig_wavelength_router.proto", &protobuf_RegisterTypes); ::protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fywrapper_2fywrapper_2eproto::AddDescriptors(); ::protobuf_github_2ecom_2fopenconfig_2fygot_2fproto_2fyext_2fyext_2eproto::AddDescriptors(); ::protobuf_openconfig_2fenums_2fenums_2eproto::AddDescriptors(); } void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; } // namespace protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto namespace openconfig { namespace openconfig_wavelength_router { const ::google::protobuf::EnumDescriptor* WavelengthRouter_MediaChannels_Channel_State_OperStatus_descriptor() { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_enum_descriptors[0]; } bool WavelengthRouter_MediaChannels_Channel_State_OperStatus_IsValid(int value) { switch (value) { case 0: case 1: case 2: return true; default: return false; } } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const WavelengthRouter_MediaChannels_Channel_State_OperStatus WavelengthRouter_MediaChannels_Channel_State::OPERSTATUS_UNSET; const WavelengthRouter_MediaChannels_Channel_State_OperStatus WavelengthRouter_MediaChannels_Channel_State::OPERSTATUS_UP; const WavelengthRouter_MediaChannels_Channel_State_OperStatus WavelengthRouter_MediaChannels_Channel_State::OPERSTATUS_DOWN; const WavelengthRouter_MediaChannels_Channel_State_OperStatus WavelengthRouter_MediaChannels_Channel_State::OperStatus_MIN; const WavelengthRouter_MediaChannels_Channel_State_OperStatus WavelengthRouter_MediaChannels_Channel_State::OperStatus_MAX; const int WavelengthRouter_MediaChannels_Channel_State::OperStatus_ARRAYSIZE; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 // =================================================================== void WavelengthRouter_MediaChannels_Channel_Config::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_._instance.get_mutable()->index_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_._instance.get_mutable()->lower_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_._instance.get_mutable()->name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Config_default_instance_._instance.get_mutable()->upper_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_Config::clear_index() { if (GetArenaNoVirtual() == NULL && index_ != NULL) { delete index_; } index_ = NULL; } void WavelengthRouter_MediaChannels_Channel_Config::clear_lower_frequency() { if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; } void WavelengthRouter_MediaChannels_Channel_Config::clear_name() { if (GetArenaNoVirtual() == NULL && name_ != NULL) { delete name_; } name_ = NULL; } void WavelengthRouter_MediaChannels_Channel_Config::clear_upper_frequency() { if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Config::kAdminStatusFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Config::kIndexFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Config::kLowerFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Config::kNameFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Config::kUpperFrequencyFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Config::WavelengthRouter_MediaChannels_Channel_Config() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Config(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) } WavelengthRouter_MediaChannels_Channel_Config::WavelengthRouter_MediaChannels_Channel_Config(const WavelengthRouter_MediaChannels_Channel_Config& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_index()) { index_ = new ::ywrapper::UintValue(*from.index_); } else { index_ = NULL; } if (from.has_name()) { name_ = new ::ywrapper::StringValue(*from.name_); } else { name_ = NULL; } if (from.has_upper_frequency()) { upper_frequency_ = new ::ywrapper::UintValue(*from.upper_frequency_); } else { upper_frequency_ = NULL; } if (from.has_lower_frequency()) { lower_frequency_ = new ::ywrapper::UintValue(*from.lower_frequency_); } else { lower_frequency_ = NULL; } admin_status_ = from.admin_status_; // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) } void WavelengthRouter_MediaChannels_Channel_Config::SharedCtor() { ::memset(&index_, 0, static_cast<size_t>( reinterpret_cast<char*>(&admin_status_) - reinterpret_cast<char*>(&index_)) + sizeof(admin_status_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Config::~WavelengthRouter_MediaChannels_Channel_Config() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Config::SharedDtor() { if (this != internal_default_instance()) delete index_; if (this != internal_default_instance()) delete name_; if (this != internal_default_instance()) delete upper_frequency_; if (this != internal_default_instance()) delete lower_frequency_; } void WavelengthRouter_MediaChannels_Channel_Config::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Config::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Config& WavelengthRouter_MediaChannels_Channel_Config::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Config(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Config* WavelengthRouter_MediaChannels_Channel_Config::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Config* n = new WavelengthRouter_MediaChannels_Channel_Config; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Config::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && index_ != NULL) { delete index_; } index_ = NULL; if (GetArenaNoVirtual() == NULL && name_ != NULL) { delete name_; } name_ = NULL; if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; admin_status_ = 0; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Config::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(4273391682u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 148137994 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/admin-status"]; case 148137994: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(80u /* 1185103952 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( input, &value))); set_admin_status(static_cast< ::openconfig::enums::OpenconfigWavelengthRouterAdminStateType >(value)); } else { goto handle_unusual; } break; } // .ywrapper.UintValue index = 301463906 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/index"]; case 301463906: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(18u /* 2411711250 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_index())); } else { goto handle_unusual; } break; } // .ywrapper.StringValue name = 351086787 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/name"]; case 351086787: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(26u /* 2808694298 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_name())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue upper_frequency = 431960071 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/upper-frequency"]; case 431960071: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(58u /* 3455680570 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_upper_frequency())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue lower_frequency = 534173960 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/lower-frequency"]; case 534173960: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(66u /* 4273391682 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_lower_frequency())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Config::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 148137994 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/admin-status"]; if (this->admin_status() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 148137994, this->admin_status(), output); } // .ywrapper.UintValue index = 301463906 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/index"]; if (this->has_index()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 301463906, *this->index_, output); } // .ywrapper.StringValue name = 351086787 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/name"]; if (this->has_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 351086787, *this->name_, output); } // .ywrapper.UintValue upper_frequency = 431960071 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/upper-frequency"]; if (this->has_upper_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 431960071, *this->upper_frequency_, output); } // .ywrapper.UintValue lower_frequency = 534173960 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/lower-frequency"]; if (this->has_lower_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 534173960, *this->lower_frequency_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Config::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 148137994 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/admin-status"]; if (this->admin_status() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 148137994, this->admin_status(), target); } // .ywrapper.UintValue index = 301463906 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/index"]; if (this->has_index()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 301463906, *this->index_, deterministic, target); } // .ywrapper.StringValue name = 351086787 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/name"]; if (this->has_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 351086787, *this->name_, deterministic, target); } // .ywrapper.UintValue upper_frequency = 431960071 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/upper-frequency"]; if (this->has_upper_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 431960071, *this->upper_frequency_, deterministic, target); } // .ywrapper.UintValue lower_frequency = 534173960 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/lower-frequency"]; if (this->has_lower_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 534173960, *this->lower_frequency_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) return target; } size_t WavelengthRouter_MediaChannels_Channel_Config::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.UintValue index = 301463906 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/index"]; if (this->has_index()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->index_); } // .ywrapper.StringValue name = 351086787 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/name"]; if (this->has_name()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->name_); } // .ywrapper.UintValue upper_frequency = 431960071 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/upper-frequency"]; if (this->has_upper_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->upper_frequency_); } // .ywrapper.UintValue lower_frequency = 534173960 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/lower-frequency"]; if (this->has_lower_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->lower_frequency_); } // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 148137994 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config/admin-status"]; if (this->admin_status() != 0) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->admin_status()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Config::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Config* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Config>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Config::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Config& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_index()) { mutable_index()->::ywrapper::UintValue::MergeFrom(from.index()); } if (from.has_name()) { mutable_name()->::ywrapper::StringValue::MergeFrom(from.name()); } if (from.has_upper_frequency()) { mutable_upper_frequency()->::ywrapper::UintValue::MergeFrom(from.upper_frequency()); } if (from.has_lower_frequency()) { mutable_lower_frequency()->::ywrapper::UintValue::MergeFrom(from.lower_frequency()); } if (from.admin_status() != 0) { set_admin_status(from.admin_status()); } } void WavelengthRouter_MediaChannels_Channel_Config::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Config::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Config& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Config::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Config::Swap(WavelengthRouter_MediaChannels_Channel_Config* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Config::InternalSwap(WavelengthRouter_MediaChannels_Channel_Config* other) { using std::swap; swap(index_, other->index_); swap(name_, other->name_); swap(upper_frequency_, other->upper_frequency_); swap(lower_frequency_, other->lower_frequency_); swap(admin_status_, other->admin_status_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Config::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Dest_Config::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_Config_default_instance_._instance.get_mutable()->port_name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_Dest_Config::clear_port_name() { if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Dest_Config::kPortNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Dest_Config::WavelengthRouter_MediaChannels_Channel_Dest_Config() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_Config(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) } WavelengthRouter_MediaChannels_Channel_Dest_Config::WavelengthRouter_MediaChannels_Channel_Dest_Config(const WavelengthRouter_MediaChannels_Channel_Dest_Config& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_port_name()) { port_name_ = new ::ywrapper::StringValue(*from.port_name_); } else { port_name_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) } void WavelengthRouter_MediaChannels_Channel_Dest_Config::SharedCtor() { port_name_ = NULL; _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Dest_Config::~WavelengthRouter_MediaChannels_Channel_Dest_Config() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Dest_Config::SharedDtor() { if (this != internal_default_instance()) delete port_name_; } void WavelengthRouter_MediaChannels_Channel_Dest_Config::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Dest_Config::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Dest_Config& WavelengthRouter_MediaChannels_Channel_Dest_Config::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_Config(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Dest_Config* WavelengthRouter_MediaChannels_Channel_Dest_Config::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Dest_Config* n = new WavelengthRouter_MediaChannels_Channel_Dest_Config; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Dest_Config::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Dest_Config::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(199235010u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.StringValue port_name = 24904376 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config/port-name"]; case 24904376: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(194u /* 199235010 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_port_name())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Dest_Config::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 24904376 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config/port-name"]; if (this->has_port_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 24904376, *this->port_name_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Dest_Config::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 24904376 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config/port-name"]; if (this->has_port_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 24904376, *this->port_name_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) return target; } size_t WavelengthRouter_MediaChannels_Channel_Dest_Config::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.StringValue port_name = 24904376 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config/port-name"]; if (this->has_port_name()) { total_size += 4 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->port_name_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Dest_Config::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Dest_Config* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Dest_Config>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Dest_Config::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Dest_Config& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_port_name()) { mutable_port_name()->::ywrapper::StringValue::MergeFrom(from.port_name()); } } void WavelengthRouter_MediaChannels_Channel_Dest_Config::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Dest_Config::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Dest_Config& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Dest_Config::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Dest_Config::Swap(WavelengthRouter_MediaChannels_Channel_Dest_Config* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Dest_Config::InternalSwap(WavelengthRouter_MediaChannels_Channel_Dest_Config* other) { using std::swap; swap(port_name_, other->port_name_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Dest_Config::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Dest_State::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_State_default_instance_._instance.get_mutable()->port_name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_Dest_State::clear_port_name() { if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Dest_State::kPortNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Dest_State::WavelengthRouter_MediaChannels_Channel_Dest_State() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_State(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) } WavelengthRouter_MediaChannels_Channel_Dest_State::WavelengthRouter_MediaChannels_Channel_Dest_State(const WavelengthRouter_MediaChannels_Channel_Dest_State& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_port_name()) { port_name_ = new ::ywrapper::StringValue(*from.port_name_); } else { port_name_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) } void WavelengthRouter_MediaChannels_Channel_Dest_State::SharedCtor() { port_name_ = NULL; _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Dest_State::~WavelengthRouter_MediaChannels_Channel_Dest_State() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Dest_State::SharedDtor() { if (this != internal_default_instance()) delete port_name_; } void WavelengthRouter_MediaChannels_Channel_Dest_State::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Dest_State::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Dest_State& WavelengthRouter_MediaChannels_Channel_Dest_State::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest_State(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Dest_State* WavelengthRouter_MediaChannels_Channel_Dest_State::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Dest_State* n = new WavelengthRouter_MediaChannels_Channel_Dest_State; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Dest_State::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Dest_State::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(2829226346u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.StringValue port_name = 353653293 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state/port-name"]; case 353653293: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(106u /* 2829226346 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_port_name())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Dest_State::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 353653293 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state/port-name"]; if (this->has_port_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 353653293, *this->port_name_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Dest_State::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 353653293 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state/port-name"]; if (this->has_port_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 353653293, *this->port_name_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) return target; } size_t WavelengthRouter_MediaChannels_Channel_Dest_State::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.StringValue port_name = 353653293 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state/port-name"]; if (this->has_port_name()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->port_name_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Dest_State::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Dest_State* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Dest_State>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Dest_State::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Dest_State& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_port_name()) { mutable_port_name()->::ywrapper::StringValue::MergeFrom(from.port_name()); } } void WavelengthRouter_MediaChannels_Channel_Dest_State::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Dest_State::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Dest_State& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Dest_State::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Dest_State::Swap(WavelengthRouter_MediaChannels_Channel_Dest_State* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Dest_State::InternalSwap(WavelengthRouter_MediaChannels_Channel_Dest_State* other) { using std::swap; swap(port_name_, other->port_name_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Dest_State::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Dest::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_default_instance_._instance.get_mutable()->config_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Dest_default_instance_._instance.get_mutable()->state_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Dest::kConfigFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Dest::kStateFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Dest::WavelengthRouter_MediaChannels_Channel_Dest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) } WavelengthRouter_MediaChannels_Channel_Dest::WavelengthRouter_MediaChannels_Channel_Dest(const WavelengthRouter_MediaChannels_Channel_Dest& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_state()) { state_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State(*from.state_); } else { state_ = NULL; } if (from.has_config()) { config_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config(*from.config_); } else { config_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) } void WavelengthRouter_MediaChannels_Channel_Dest::SharedCtor() { ::memset(&state_, 0, static_cast<size_t>( reinterpret_cast<char*>(&config_) - reinterpret_cast<char*>(&state_)) + sizeof(config_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Dest::~WavelengthRouter_MediaChannels_Channel_Dest() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Dest::SharedDtor() { if (this != internal_default_instance()) delete state_; if (this != internal_default_instance()) delete config_; } void WavelengthRouter_MediaChannels_Channel_Dest::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Dest::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Dest& WavelengthRouter_MediaChannels_Channel_Dest::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Dest(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Dest* WavelengthRouter_MediaChannels_Channel_Dest::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Dest* n = new WavelengthRouter_MediaChannels_Channel_Dest; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Dest::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && state_ != NULL) { delete state_; } state_ = NULL; if (GetArenaNoVirtual() == NULL && config_ != NULL) { delete config_; } config_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Dest::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(2321578322u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State state = 10749255 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state"]; case 10749255: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(58u /* 85994042 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_state())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config config = 290197290 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config"]; case 290197290: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(82u /* 2321578322 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_config())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Dest::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State state = 10749255 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state"]; if (this->has_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 10749255, *this->state_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config config = 290197290 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config"]; if (this->has_config()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 290197290, *this->config_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Dest::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State state = 10749255 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state"]; if (this->has_state()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 10749255, *this->state_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config config = 290197290 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config"]; if (this->has_config()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 290197290, *this->config_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) return target; } size_t WavelengthRouter_MediaChannels_Channel_Dest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.State state = 10749255 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/state"]; if (this->has_state()) { total_size += 4 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->state_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest.Config config = 290197290 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest/config"]; if (this->has_config()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->config_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Dest::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Dest* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Dest>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Dest::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Dest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_state()) { mutable_state()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_State::MergeFrom(from.state()); } if (from.has_config()) { mutable_config()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest_Config::MergeFrom(from.config()); } } void WavelengthRouter_MediaChannels_Channel_Dest::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Dest::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Dest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Dest::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Dest::Swap(WavelengthRouter_MediaChannels_Channel_Dest* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Dest::InternalSwap(WavelengthRouter_MediaChannels_Channel_Dest* other) { using std::swap; swap(state_, other->state_); swap(config_, other->config_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Dest::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_._instance.get_mutable()->lower_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_._instance.get_mutable()->psd_ = const_cast< ::ywrapper::BytesValue*>( ::ywrapper::BytesValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config_default_instance_._instance.get_mutable()->upper_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::clear_lower_frequency() { if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::clear_psd() { if (GetArenaNoVirtual() == NULL && psd_ != NULL) { delete psd_; } psd_ = NULL; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::clear_upper_frequency() { if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::kLowerFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::kPsdFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::kUpperFrequencyFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_psd()) { psd_ = new ::ywrapper::BytesValue(*from.psd_); } else { psd_ = NULL; } if (from.has_lower_frequency()) { lower_frequency_ = new ::ywrapper::UintValue(*from.lower_frequency_); } else { lower_frequency_ = NULL; } if (from.has_upper_frequency()) { upper_frequency_ = new ::ywrapper::UintValue(*from.upper_frequency_); } else { upper_frequency_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::SharedCtor() { ::memset(&psd_, 0, static_cast<size_t>( reinterpret_cast<char*>(&upper_frequency_) - reinterpret_cast<char*>(&psd_)) + sizeof(upper_frequency_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::~WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::SharedDtor() { if (this != internal_default_instance()) delete psd_; if (this != internal_default_instance()) delete lower_frequency_; if (this != internal_default_instance()) delete upper_frequency_; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config& WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config* n = new WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && psd_ != NULL) { delete psd_; } psd_ = NULL; if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(3959613266u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.BytesValue psd = 5500354 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/psd"]; case 5500354: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(18u /* 44002834 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_psd())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue lower_frequency = 104941357 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/lower-frequency"]; case 104941357: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(106u /* 839530858 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_lower_frequency())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue upper_frequency = 494951658 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/upper-frequency"]; case 494951658: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(82u /* 3959613266 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_upper_frequency())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.BytesValue psd = 5500354 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/psd"]; if (this->has_psd()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5500354, *this->psd_, output); } // .ywrapper.UintValue lower_frequency = 104941357 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/lower-frequency"]; if (this->has_lower_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 104941357, *this->lower_frequency_, output); } // .ywrapper.UintValue upper_frequency = 494951658 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/upper-frequency"]; if (this->has_upper_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 494951658, *this->upper_frequency_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.BytesValue psd = 5500354 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/psd"]; if (this->has_psd()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 5500354, *this->psd_, deterministic, target); } // .ywrapper.UintValue lower_frequency = 104941357 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/lower-frequency"]; if (this->has_lower_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 104941357, *this->lower_frequency_, deterministic, target); } // .ywrapper.UintValue upper_frequency = 494951658 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/upper-frequency"]; if (this->has_upper_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 494951658, *this->upper_frequency_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) return target; } size_t WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.BytesValue psd = 5500354 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/psd"]; if (this->has_psd()) { total_size += 4 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->psd_); } // .ywrapper.UintValue lower_frequency = 104941357 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/lower-frequency"]; if (this->has_lower_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->lower_frequency_); } // .ywrapper.UintValue upper_frequency = 494951658 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config/upper-frequency"]; if (this->has_upper_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->upper_frequency_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::MergeFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_psd()) { mutable_psd()->::ywrapper::BytesValue::MergeFrom(from.psd()); } if (from.has_lower_frequency()) { mutable_lower_frequency()->::ywrapper::UintValue::MergeFrom(from.lower_frequency()); } if (from.has_upper_frequency()) { mutable_upper_frequency()->::ywrapper::UintValue::MergeFrom(from.upper_frequency()); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::CopyFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::Swap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::InternalSwap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config* other) { using std::swap; swap(psd_, other->psd_); swap(lower_frequency_, other->lower_frequency_); swap(upper_frequency_, other->upper_frequency_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_._instance.get_mutable()->lower_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_._instance.get_mutable()->psd_ = const_cast< ::ywrapper::BytesValue*>( ::ywrapper::BytesValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State_default_instance_._instance.get_mutable()->upper_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::clear_lower_frequency() { if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::clear_psd() { if (GetArenaNoVirtual() == NULL && psd_ != NULL) { delete psd_; } psd_ = NULL; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::clear_upper_frequency() { if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::kLowerFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::kPsdFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::kUpperFrequencyFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_lower_frequency()) { lower_frequency_ = new ::ywrapper::UintValue(*from.lower_frequency_); } else { lower_frequency_ = NULL; } if (from.has_upper_frequency()) { upper_frequency_ = new ::ywrapper::UintValue(*from.upper_frequency_); } else { upper_frequency_ = NULL; } if (from.has_psd()) { psd_ = new ::ywrapper::BytesValue(*from.psd_); } else { psd_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::SharedCtor() { ::memset(&lower_frequency_, 0, static_cast<size_t>( reinterpret_cast<char*>(&psd_) - reinterpret_cast<char*>(&lower_frequency_)) + sizeof(psd_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::~WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::SharedDtor() { if (this != internal_default_instance()) delete lower_frequency_; if (this != internal_default_instance()) delete upper_frequency_; if (this != internal_default_instance()) delete psd_; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State& WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State* n = new WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; if (GetArenaNoVirtual() == NULL && psd_ != NULL) { delete psd_; } psd_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(3238551738u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.UintValue lower_frequency = 156152700 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/lower-frequency"]; case 156152700: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(226u /* 1249221602 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_lower_frequency())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue upper_frequency = 329030827 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/upper-frequency"]; case 329030827: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(90u /* 2632246618 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_upper_frequency())); } else { goto handle_unusual; } break; } // .ywrapper.BytesValue psd = 404818967 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/psd"]; case 404818967: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(186u /* 3238551738 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_psd())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.UintValue lower_frequency = 156152700 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/lower-frequency"]; if (this->has_lower_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 156152700, *this->lower_frequency_, output); } // .ywrapper.UintValue upper_frequency = 329030827 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/upper-frequency"]; if (this->has_upper_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 329030827, *this->upper_frequency_, output); } // .ywrapper.BytesValue psd = 404818967 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/psd"]; if (this->has_psd()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 404818967, *this->psd_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.UintValue lower_frequency = 156152700 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/lower-frequency"]; if (this->has_lower_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 156152700, *this->lower_frequency_, deterministic, target); } // .ywrapper.UintValue upper_frequency = 329030827 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/upper-frequency"]; if (this->has_upper_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 329030827, *this->upper_frequency_, deterministic, target); } // .ywrapper.BytesValue psd = 404818967 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/psd"]; if (this->has_psd()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 404818967, *this->psd_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) return target; } size_t WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.UintValue lower_frequency = 156152700 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/lower-frequency"]; if (this->has_lower_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->lower_frequency_); } // .ywrapper.UintValue upper_frequency = 329030827 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/upper-frequency"]; if (this->has_upper_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->upper_frequency_); } // .ywrapper.BytesValue psd = 404818967 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state/psd"]; if (this->has_psd()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->psd_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::MergeFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_lower_frequency()) { mutable_lower_frequency()->::ywrapper::UintValue::MergeFrom(from.lower_frequency()); } if (from.has_upper_frequency()) { mutable_upper_frequency()->::ywrapper::UintValue::MergeFrom(from.upper_frequency()); } if (from.has_psd()) { mutable_psd()->::ywrapper::BytesValue::MergeFrom(from.psd()); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::CopyFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::Swap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::InternalSwap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State* other) { using std::swap; swap(lower_frequency_, other->lower_frequency_); swap(upper_frequency_, other->upper_frequency_); swap(psd_, other->psd_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_default_instance_._instance.get_mutable()->config_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_default_instance_._instance.get_mutable()->state_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::kConfigFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::kStateFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_state()) { state_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State(*from.state_); } else { state_ = NULL; } if (from.has_config()) { config_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config(*from.config_); } else { config_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::SharedCtor() { ::memset(&state_, 0, static_cast<size_t>( reinterpret_cast<char*>(&config_) - reinterpret_cast<char*>(&state_)) + sizeof(config_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::~WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::SharedDtor() { if (this != internal_default_instance()) delete state_; if (this != internal_default_instance()) delete config_; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue& WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue* n = new WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && state_ != NULL) { delete state_; } state_ = NULL; if (GetArenaNoVirtual() == NULL && config_ != NULL) { delete config_; } config_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(1135734674u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State state = 19196655 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state"]; case 19196655: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(122u /* 153573242 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_state())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config config = 141966834 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config"]; case 141966834: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(146u /* 1135734674 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_config())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State state = 19196655 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state"]; if (this->has_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 19196655, *this->state_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config config = 141966834 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config"]; if (this->has_config()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 141966834, *this->config_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State state = 19196655 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state"]; if (this->has_state()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 19196655, *this->state_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config config = 141966834 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config"]; if (this->has_config()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 141966834, *this->config_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) return target; } size_t WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.State state = 19196655 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/state"]; if (this->has_state()) { total_size += 4 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->state_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue.Config config = 141966834 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/config"]; if (this->has_config()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->config_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::MergeFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_state()) { mutable_state()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_State::MergeFrom(from.state()); } if (from.has_config()) { mutable_config()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue_Config::MergeFrom(from.config()); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::CopyFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::Swap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::InternalSwap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue* other) { using std::swap; swap(state_, other->state_); swap(config_, other->config_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey_default_instance_._instance.get_mutable()->psd_value_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::kLowerFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::kUpperFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::kPsdValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_psd_value()) { psd_value_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue(*from.psd_value_); } else { psd_value_ = NULL; } ::memcpy(&lower_frequency_, &from.lower_frequency_, static_cast<size_t>(reinterpret_cast<char*>(&upper_frequency_) - reinterpret_cast<char*>(&lower_frequency_)) + sizeof(upper_frequency_)); // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::SharedCtor() { ::memset(&psd_value_, 0, static_cast<size_t>( reinterpret_cast<char*>(&upper_frequency_) - reinterpret_cast<char*>(&psd_value_)) + sizeof(upper_frequency_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::~WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::SharedDtor() { if (this != internal_default_instance()) delete psd_value_; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey& WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey* n = new WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && psd_value_ != NULL) { delete psd_value_; } psd_value_ = NULL; ::memset(&lower_frequency_, 0, static_cast<size_t>( reinterpret_cast<char*>(&upper_frequency_) - reinterpret_cast<char*>(&lower_frequency_)) + sizeof(upper_frequency_)); _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint64 lower_frequency = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/lower-frequency"]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &lower_frequency_))); } else { goto handle_unusual; } break; } // uint64 upper_frequency = 2 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/upper-frequency"]; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &upper_frequency_))); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue psd_value = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_psd_value())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // uint64 lower_frequency = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/lower-frequency"]; if (this->lower_frequency() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->lower_frequency(), output); } // uint64 upper_frequency = 2 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/upper-frequency"]; if (this->upper_frequency() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->upper_frequency(), output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue psd_value = 3; if (this->has_psd_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 3, *this->psd_value_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // uint64 lower_frequency = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/lower-frequency"]; if (this->lower_frequency() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->lower_frequency(), target); } // uint64 upper_frequency = 2 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/upper-frequency"]; if (this->upper_frequency() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->upper_frequency(), target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue psd_value = 3; if (this->has_psd_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 3, *this->psd_value_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) return target; } size_t WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValue psd_value = 3; if (this->has_psd_value()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->psd_value_); } // uint64 lower_frequency = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/lower-frequency"]; if (this->lower_frequency() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( this->lower_frequency()); } // uint64 upper_frequency = 2 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value/upper-frequency"]; if (this->upper_frequency() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( this->upper_frequency()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::MergeFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_psd_value()) { mutable_psd_value()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValue::MergeFrom(from.psd_value()); } if (from.lower_frequency() != 0) { set_lower_frequency(from.lower_frequency()); } if (from.upper_frequency() != 0) { set_upper_frequency(from.upper_frequency()); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::CopyFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::Swap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::InternalSwap(WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey* other) { using std::swap; swap(psd_value_, other->psd_value_); swap(lower_frequency_, other->lower_frequency_); swap(upper_frequency_, other->upper_frequency_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_PsdDistribution_PsdValueKey::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_PsdDistribution::InitAsDefaultInstance() { } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_PsdDistribution::kPsdValueFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_PsdDistribution::WavelengthRouter_MediaChannels_Channel_PsdDistribution() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) } WavelengthRouter_MediaChannels_Channel_PsdDistribution::WavelengthRouter_MediaChannels_Channel_PsdDistribution(const WavelengthRouter_MediaChannels_Channel_PsdDistribution& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), psd_value_(from.psd_value_), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::SharedCtor() { _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_PsdDistribution::~WavelengthRouter_MediaChannels_Channel_PsdDistribution() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::SharedDtor() { } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_PsdDistribution::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_PsdDistribution& WavelengthRouter_MediaChannels_Channel_PsdDistribution::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_PsdDistribution(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_PsdDistribution* WavelengthRouter_MediaChannels_Channel_PsdDistribution::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_PsdDistribution* n = new WavelengthRouter_MediaChannels_Channel_PsdDistribution; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; psd_value_.Clear(); _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(2806732266u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey psd_value = 350841533 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value"]; case 350841533: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(234u /* 2806732266 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_psd_value())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey psd_value = 350841533 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value"]; for (unsigned int i = 0, n = static_cast<unsigned int>(this->psd_value_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 350841533, this->psd_value(static_cast<int>(i)), output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_PsdDistribution::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey psd_value = 350841533 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value"]; for (unsigned int i = 0, n = static_cast<unsigned int>(this->psd_value_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 350841533, this->psd_value(static_cast<int>(i)), deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) return target; } size_t WavelengthRouter_MediaChannels_Channel_PsdDistribution::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution.PsdValueKey psd_value = 350841533 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution/psd-value"]; { unsigned int count = static_cast<unsigned int>(this->psd_value_size()); total_size += 5UL * count; for (unsigned int i = 0; i < count; i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSize( this->psd_value(static_cast<int>(i))); } } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_PsdDistribution* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_PsdDistribution>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::MergeFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; psd_value_.MergeFrom(from.psd_value_); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::CopyFrom(const WavelengthRouter_MediaChannels_Channel_PsdDistribution& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_PsdDistribution::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::Swap(WavelengthRouter_MediaChannels_Channel_PsdDistribution* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_PsdDistribution::InternalSwap(WavelengthRouter_MediaChannels_Channel_PsdDistribution* other) { using std::swap; psd_value_.InternalSwap(&other->psd_value_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_PsdDistribution::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Source_Config::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_Config_default_instance_._instance.get_mutable()->port_name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_Source_Config::clear_port_name() { if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Source_Config::kPortNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Source_Config::WavelengthRouter_MediaChannels_Channel_Source_Config() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_Config(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) } WavelengthRouter_MediaChannels_Channel_Source_Config::WavelengthRouter_MediaChannels_Channel_Source_Config(const WavelengthRouter_MediaChannels_Channel_Source_Config& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_port_name()) { port_name_ = new ::ywrapper::StringValue(*from.port_name_); } else { port_name_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) } void WavelengthRouter_MediaChannels_Channel_Source_Config::SharedCtor() { port_name_ = NULL; _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Source_Config::~WavelengthRouter_MediaChannels_Channel_Source_Config() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Source_Config::SharedDtor() { if (this != internal_default_instance()) delete port_name_; } void WavelengthRouter_MediaChannels_Channel_Source_Config::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Source_Config::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Source_Config& WavelengthRouter_MediaChannels_Channel_Source_Config::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_Config(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Source_Config* WavelengthRouter_MediaChannels_Channel_Source_Config::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Source_Config* n = new WavelengthRouter_MediaChannels_Channel_Source_Config; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Source_Config::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Source_Config::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(2902825674u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.StringValue port_name = 362853209 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config/port-name"]; case 362853209: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(202u /* 2902825674 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_port_name())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Source_Config::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 362853209 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config/port-name"]; if (this->has_port_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 362853209, *this->port_name_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Source_Config::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 362853209 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config/port-name"]; if (this->has_port_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 362853209, *this->port_name_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) return target; } size_t WavelengthRouter_MediaChannels_Channel_Source_Config::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.StringValue port_name = 362853209 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config/port-name"]; if (this->has_port_name()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->port_name_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Source_Config::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Source_Config* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Source_Config>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Source_Config::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Source_Config& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_port_name()) { mutable_port_name()->::ywrapper::StringValue::MergeFrom(from.port_name()); } } void WavelengthRouter_MediaChannels_Channel_Source_Config::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Source_Config::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Source_Config& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Source_Config::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Source_Config::Swap(WavelengthRouter_MediaChannels_Channel_Source_Config* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Source_Config::InternalSwap(WavelengthRouter_MediaChannels_Channel_Source_Config* other) { using std::swap; swap(port_name_, other->port_name_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Source_Config::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Source_State::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_State_default_instance_._instance.get_mutable()->port_name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_Source_State::clear_port_name() { if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Source_State::kPortNameFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Source_State::WavelengthRouter_MediaChannels_Channel_Source_State() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_State(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) } WavelengthRouter_MediaChannels_Channel_Source_State::WavelengthRouter_MediaChannels_Channel_Source_State(const WavelengthRouter_MediaChannels_Channel_Source_State& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_port_name()) { port_name_ = new ::ywrapper::StringValue(*from.port_name_); } else { port_name_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) } void WavelengthRouter_MediaChannels_Channel_Source_State::SharedCtor() { port_name_ = NULL; _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Source_State::~WavelengthRouter_MediaChannels_Channel_Source_State() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Source_State::SharedDtor() { if (this != internal_default_instance()) delete port_name_; } void WavelengthRouter_MediaChannels_Channel_Source_State::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Source_State::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Source_State& WavelengthRouter_MediaChannels_Channel_Source_State::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source_State(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Source_State* WavelengthRouter_MediaChannels_Channel_Source_State::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Source_State* n = new WavelengthRouter_MediaChannels_Channel_Source_State; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Source_State::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && port_name_ != NULL) { delete port_name_; } port_name_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Source_State::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(78897234u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.StringValue port_name = 9862154 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state/port-name"]; case 9862154: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(82u /* 78897234 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_port_name())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Source_State::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 9862154 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state/port-name"]; if (this->has_port_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 9862154, *this->port_name_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Source_State::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.StringValue port_name = 9862154 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state/port-name"]; if (this->has_port_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 9862154, *this->port_name_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) return target; } size_t WavelengthRouter_MediaChannels_Channel_Source_State::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.StringValue port_name = 9862154 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state/port-name"]; if (this->has_port_name()) { total_size += 4 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->port_name_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Source_State::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Source_State* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Source_State>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Source_State::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Source_State& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_port_name()) { mutable_port_name()->::ywrapper::StringValue::MergeFrom(from.port_name()); } } void WavelengthRouter_MediaChannels_Channel_Source_State::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Source_State::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Source_State& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Source_State::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Source_State::Swap(WavelengthRouter_MediaChannels_Channel_Source_State* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Source_State::InternalSwap(WavelengthRouter_MediaChannels_Channel_Source_State* other) { using std::swap; swap(port_name_, other->port_name_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Source_State::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_Source::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_default_instance_._instance.get_mutable()->config_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_Source_default_instance_._instance.get_mutable()->state_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_Source::kConfigFieldNumber; const int WavelengthRouter_MediaChannels_Channel_Source::kStateFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_Source::WavelengthRouter_MediaChannels_Channel_Source() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) } WavelengthRouter_MediaChannels_Channel_Source::WavelengthRouter_MediaChannels_Channel_Source(const WavelengthRouter_MediaChannels_Channel_Source& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_state()) { state_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State(*from.state_); } else { state_ = NULL; } if (from.has_config()) { config_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config(*from.config_); } else { config_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) } void WavelengthRouter_MediaChannels_Channel_Source::SharedCtor() { ::memset(&state_, 0, static_cast<size_t>( reinterpret_cast<char*>(&config_) - reinterpret_cast<char*>(&state_)) + sizeof(config_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_Source::~WavelengthRouter_MediaChannels_Channel_Source() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_Source::SharedDtor() { if (this != internal_default_instance()) delete state_; if (this != internal_default_instance()) delete config_; } void WavelengthRouter_MediaChannels_Channel_Source::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_Source::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_Source& WavelengthRouter_MediaChannels_Channel_Source::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_Source(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_Source* WavelengthRouter_MediaChannels_Channel_Source::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_Source* n = new WavelengthRouter_MediaChannels_Channel_Source; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_Source::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && state_ != NULL) { delete state_; } state_ = NULL; if (GetArenaNoVirtual() == NULL && config_ != NULL) { delete config_; } config_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_Source::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(3905201370u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State state = 176255644 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state"]; case 176255644: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(226u /* 1410045154 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_state())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config config = 488150171 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config"]; case 488150171: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(218u /* 3905201370 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_config())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_Source::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State state = 176255644 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state"]; if (this->has_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 176255644, *this->state_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config config = 488150171 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config"]; if (this->has_config()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 488150171, *this->config_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_Source::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State state = 176255644 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state"]; if (this->has_state()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 176255644, *this->state_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config config = 488150171 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config"]; if (this->has_config()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 488150171, *this->config_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) return target; } size_t WavelengthRouter_MediaChannels_Channel_Source::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.State state = 176255644 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/state"]; if (this->has_state()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->state_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source.Config config = 488150171 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source/config"]; if (this->has_config()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->config_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_Source::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_Source* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_Source>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_Source::MergeFrom(const WavelengthRouter_MediaChannels_Channel_Source& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_state()) { mutable_state()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_State::MergeFrom(from.state()); } if (from.has_config()) { mutable_config()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source_Config::MergeFrom(from.config()); } } void WavelengthRouter_MediaChannels_Channel_Source::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_Source::CopyFrom(const WavelengthRouter_MediaChannels_Channel_Source& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_Source::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_Source::Swap(WavelengthRouter_MediaChannels_Channel_Source* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_Source::InternalSwap(WavelengthRouter_MediaChannels_Channel_Source* other) { using std::swap; swap(state_, other->state_); swap(config_, other->config_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_Source::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel_State::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_._instance.get_mutable()->index_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_._instance.get_mutable()->lower_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_._instance.get_mutable()->name_ = const_cast< ::ywrapper::StringValue*>( ::ywrapper::StringValue::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_State_default_instance_._instance.get_mutable()->upper_frequency_ = const_cast< ::ywrapper::UintValue*>( ::ywrapper::UintValue::internal_default_instance()); } void WavelengthRouter_MediaChannels_Channel_State::clear_index() { if (GetArenaNoVirtual() == NULL && index_ != NULL) { delete index_; } index_ = NULL; } void WavelengthRouter_MediaChannels_Channel_State::clear_lower_frequency() { if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; } void WavelengthRouter_MediaChannels_Channel_State::clear_name() { if (GetArenaNoVirtual() == NULL && name_ != NULL) { delete name_; } name_ = NULL; } void WavelengthRouter_MediaChannels_Channel_State::clear_upper_frequency() { if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel_State::kAdminStatusFieldNumber; const int WavelengthRouter_MediaChannels_Channel_State::kIndexFieldNumber; const int WavelengthRouter_MediaChannels_Channel_State::kLowerFrequencyFieldNumber; const int WavelengthRouter_MediaChannels_Channel_State::kNameFieldNumber; const int WavelengthRouter_MediaChannels_Channel_State::kOperStatusFieldNumber; const int WavelengthRouter_MediaChannels_Channel_State::kUpperFrequencyFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel_State::WavelengthRouter_MediaChannels_Channel_State() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_State(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) } WavelengthRouter_MediaChannels_Channel_State::WavelengthRouter_MediaChannels_Channel_State(const WavelengthRouter_MediaChannels_Channel_State& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_lower_frequency()) { lower_frequency_ = new ::ywrapper::UintValue(*from.lower_frequency_); } else { lower_frequency_ = NULL; } if (from.has_index()) { index_ = new ::ywrapper::UintValue(*from.index_); } else { index_ = NULL; } if (from.has_name()) { name_ = new ::ywrapper::StringValue(*from.name_); } else { name_ = NULL; } if (from.has_upper_frequency()) { upper_frequency_ = new ::ywrapper::UintValue(*from.upper_frequency_); } else { upper_frequency_ = NULL; } ::memcpy(&admin_status_, &from.admin_status_, static_cast<size_t>(reinterpret_cast<char*>(&oper_status_) - reinterpret_cast<char*>(&admin_status_)) + sizeof(oper_status_)); // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) } void WavelengthRouter_MediaChannels_Channel_State::SharedCtor() { ::memset(&lower_frequency_, 0, static_cast<size_t>( reinterpret_cast<char*>(&oper_status_) - reinterpret_cast<char*>(&lower_frequency_)) + sizeof(oper_status_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel_State::~WavelengthRouter_MediaChannels_Channel_State() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel_State::SharedDtor() { if (this != internal_default_instance()) delete lower_frequency_; if (this != internal_default_instance()) delete index_; if (this != internal_default_instance()) delete name_; if (this != internal_default_instance()) delete upper_frequency_; } void WavelengthRouter_MediaChannels_Channel_State::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel_State::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel_State& WavelengthRouter_MediaChannels_Channel_State::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel_State(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel_State* WavelengthRouter_MediaChannels_Channel_State::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel_State* n = new WavelengthRouter_MediaChannels_Channel_State; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel_State::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && lower_frequency_ != NULL) { delete lower_frequency_; } lower_frequency_ = NULL; if (GetArenaNoVirtual() == NULL && index_ != NULL) { delete index_; } index_ = NULL; if (GetArenaNoVirtual() == NULL && name_ != NULL) { delete name_; } name_ = NULL; if (GetArenaNoVirtual() == NULL && upper_frequency_ != NULL) { delete upper_frequency_; } upper_frequency_ = NULL; ::memset(&admin_status_, 0, static_cast<size_t>( reinterpret_cast<char*>(&oper_status_) - reinterpret_cast<char*>(&admin_status_)) + sizeof(oper_status_)); _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel_State::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(4214441040u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .ywrapper.UintValue lower_frequency = 62283199 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/lower-frequency"]; case 62283199: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(250u /* 498265594 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_lower_frequency())); } else { goto handle_unusual; } break; } // .ywrapper.UintValue index = 221912741 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/index"]; case 221912741: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(42u /* 1775301930 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_index())); } else { goto handle_unusual; } break; } // .ywrapper.StringValue name = 288898326 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/name"]; case 288898326: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(178u /* 2311186610 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_name())); } else { goto handle_unusual; } break; } // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 320367411 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/admin-status"]; case 320367411: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(152u /* 2562939288 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( input, &value))); set_admin_status(static_cast< ::openconfig::enums::OpenconfigWavelengthRouterAdminStateType >(value)); } else { goto handle_unusual; } break; } // .ywrapper.UintValue upper_frequency = 422717604 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/upper-frequency"]; case 422717604: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(34u /* 3381740834 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_upper_frequency())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State.OperStatus oper_status = 526805130 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/oper-status"]; case 526805130: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(80u /* 4214441040 & 0xFF */)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( input, &value))); set_oper_status(static_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State_OperStatus >(value)); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel_State::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.UintValue lower_frequency = 62283199 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/lower-frequency"]; if (this->has_lower_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 62283199, *this->lower_frequency_, output); } // .ywrapper.UintValue index = 221912741 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/index"]; if (this->has_index()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 221912741, *this->index_, output); } // .ywrapper.StringValue name = 288898326 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/name"]; if (this->has_name()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 288898326, *this->name_, output); } // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 320367411 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/admin-status"]; if (this->admin_status() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 320367411, this->admin_status(), output); } // .ywrapper.UintValue upper_frequency = 422717604 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/upper-frequency"]; if (this->has_upper_frequency()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 422717604, *this->upper_frequency_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State.OperStatus oper_status = 526805130 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/oper-status"]; if (this->oper_status() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 526805130, this->oper_status(), output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel_State::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .ywrapper.UintValue lower_frequency = 62283199 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/lower-frequency"]; if (this->has_lower_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 62283199, *this->lower_frequency_, deterministic, target); } // .ywrapper.UintValue index = 221912741 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/index"]; if (this->has_index()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 221912741, *this->index_, deterministic, target); } // .ywrapper.StringValue name = 288898326 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/name"]; if (this->has_name()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 288898326, *this->name_, deterministic, target); } // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 320367411 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/admin-status"]; if (this->admin_status() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 320367411, this->admin_status(), target); } // .ywrapper.UintValue upper_frequency = 422717604 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/upper-frequency"]; if (this->has_upper_frequency()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 422717604, *this->upper_frequency_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State.OperStatus oper_status = 526805130 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/oper-status"]; if (this->oper_status() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 526805130, this->oper_status(), target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) return target; } size_t WavelengthRouter_MediaChannels_Channel_State::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .ywrapper.UintValue lower_frequency = 62283199 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/lower-frequency"]; if (this->has_lower_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->lower_frequency_); } // .ywrapper.UintValue index = 221912741 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/index"]; if (this->has_index()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->index_); } // .ywrapper.StringValue name = 288898326 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/name"]; if (this->has_name()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->name_); } // .ywrapper.UintValue upper_frequency = 422717604 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/upper-frequency"]; if (this->has_upper_frequency()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->upper_frequency_); } // .openconfig.enums.OpenconfigWavelengthRouterAdminStateType admin_status = 320367411 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/admin-status"]; if (this->admin_status() != 0) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->admin_status()); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State.OperStatus oper_status = 526805130 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state/oper-status"]; if (this->oper_status() != 0) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->oper_status()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel_State::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel_State* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel_State>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel_State::MergeFrom(const WavelengthRouter_MediaChannels_Channel_State& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_lower_frequency()) { mutable_lower_frequency()->::ywrapper::UintValue::MergeFrom(from.lower_frequency()); } if (from.has_index()) { mutable_index()->::ywrapper::UintValue::MergeFrom(from.index()); } if (from.has_name()) { mutable_name()->::ywrapper::StringValue::MergeFrom(from.name()); } if (from.has_upper_frequency()) { mutable_upper_frequency()->::ywrapper::UintValue::MergeFrom(from.upper_frequency()); } if (from.admin_status() != 0) { set_admin_status(from.admin_status()); } if (from.oper_status() != 0) { set_oper_status(from.oper_status()); } } void WavelengthRouter_MediaChannels_Channel_State::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel_State::CopyFrom(const WavelengthRouter_MediaChannels_Channel_State& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel_State::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel_State::Swap(WavelengthRouter_MediaChannels_Channel_State* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel_State::InternalSwap(WavelengthRouter_MediaChannels_Channel_State* other) { using std::swap; swap(lower_frequency_, other->lower_frequency_); swap(index_, other->index_); swap(name_, other->name_); swap(upper_frequency_, other->upper_frequency_); swap(admin_status_, other->admin_status_); swap(oper_status_, other->oper_status_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel_State::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_Channel::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_._instance.get_mutable()->config_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_._instance.get_mutable()->dest_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_._instance.get_mutable()->psd_distribution_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_._instance.get_mutable()->source_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source::internal_default_instance()); ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_Channel_default_instance_._instance.get_mutable()->state_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_Channel::kConfigFieldNumber; const int WavelengthRouter_MediaChannels_Channel::kDestFieldNumber; const int WavelengthRouter_MediaChannels_Channel::kPsdDistributionFieldNumber; const int WavelengthRouter_MediaChannels_Channel::kSourceFieldNumber; const int WavelengthRouter_MediaChannels_Channel::kStateFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_Channel::WavelengthRouter_MediaChannels_Channel() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) } WavelengthRouter_MediaChannels_Channel::WavelengthRouter_MediaChannels_Channel(const WavelengthRouter_MediaChannels_Channel& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_psd_distribution()) { psd_distribution_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution(*from.psd_distribution_); } else { psd_distribution_ = NULL; } if (from.has_dest()) { dest_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest(*from.dest_); } else { dest_ = NULL; } if (from.has_source()) { source_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source(*from.source_); } else { source_ = NULL; } if (from.has_config()) { config_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config(*from.config_); } else { config_ = NULL; } if (from.has_state()) { state_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State(*from.state_); } else { state_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) } void WavelengthRouter_MediaChannels_Channel::SharedCtor() { ::memset(&psd_distribution_, 0, static_cast<size_t>( reinterpret_cast<char*>(&state_) - reinterpret_cast<char*>(&psd_distribution_)) + sizeof(state_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_Channel::~WavelengthRouter_MediaChannels_Channel() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) SharedDtor(); } void WavelengthRouter_MediaChannels_Channel::SharedDtor() { if (this != internal_default_instance()) delete psd_distribution_; if (this != internal_default_instance()) delete dest_; if (this != internal_default_instance()) delete source_; if (this != internal_default_instance()) delete config_; if (this != internal_default_instance()) delete state_; } void WavelengthRouter_MediaChannels_Channel::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_Channel::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_Channel& WavelengthRouter_MediaChannels_Channel::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_Channel(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_Channel* WavelengthRouter_MediaChannels_Channel::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_Channel* n = new WavelengthRouter_MediaChannels_Channel; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_Channel::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && psd_distribution_ != NULL) { delete psd_distribution_; } psd_distribution_ = NULL; if (GetArenaNoVirtual() == NULL && dest_ != NULL) { delete dest_; } dest_ = NULL; if (GetArenaNoVirtual() == NULL && source_ != NULL) { delete source_; } source_ = NULL; if (GetArenaNoVirtual() == NULL && config_ != NULL) { delete config_; } config_ = NULL; if (GetArenaNoVirtual() == NULL && state_ != NULL) { delete state_; } state_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_Channel::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(3420021666u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution psd_distribution = 48462813 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution"]; case 48462813: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(234u /* 387702506 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_psd_distribution())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest dest = 145566309 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest"]; case 145566309: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(42u /* 1164530474 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_dest())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source source = 246551242 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source"]; case 246551242: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(82u /* 1972409938 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_source())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config config = 409882003 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config"]; case 409882003: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(154u /* 3279056026 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_config())); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State state = 427502708 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state"]; case 427502708: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(162u /* 3420021666 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_state())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) return false; #undef DO_ } void WavelengthRouter_MediaChannels_Channel::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution psd_distribution = 48462813 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution"]; if (this->has_psd_distribution()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 48462813, *this->psd_distribution_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest dest = 145566309 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest"]; if (this->has_dest()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 145566309, *this->dest_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source source = 246551242 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source"]; if (this->has_source()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 246551242, *this->source_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config config = 409882003 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config"]; if (this->has_config()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 409882003, *this->config_, output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State state = 427502708 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state"]; if (this->has_state()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 427502708, *this->state_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_Channel::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution psd_distribution = 48462813 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution"]; if (this->has_psd_distribution()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 48462813, *this->psd_distribution_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest dest = 145566309 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest"]; if (this->has_dest()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 145566309, *this->dest_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source source = 246551242 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source"]; if (this->has_source()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 246551242, *this->source_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config config = 409882003 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config"]; if (this->has_config()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 409882003, *this->config_, deterministic, target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State state = 427502708 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state"]; if (this->has_state()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 427502708, *this->state_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) return target; } size_t WavelengthRouter_MediaChannels_Channel::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.PsdDistribution psd_distribution = 48462813 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/psd-distribution"]; if (this->has_psd_distribution()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->psd_distribution_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Dest dest = 145566309 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/dest"]; if (this->has_dest()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->dest_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Source source = 246551242 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/source"]; if (this->has_source()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->source_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.Config config = 409882003 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/config"]; if (this->has_config()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->config_); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel.State state = 427502708 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/state"]; if (this->has_state()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->state_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_Channel::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_Channel* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_Channel>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_Channel::MergeFrom(const WavelengthRouter_MediaChannels_Channel& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_psd_distribution()) { mutable_psd_distribution()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_PsdDistribution::MergeFrom(from.psd_distribution()); } if (from.has_dest()) { mutable_dest()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Dest::MergeFrom(from.dest()); } if (from.has_source()) { mutable_source()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Source::MergeFrom(from.source()); } if (from.has_config()) { mutable_config()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_Config::MergeFrom(from.config()); } if (from.has_state()) { mutable_state()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel_State::MergeFrom(from.state()); } } void WavelengthRouter_MediaChannels_Channel::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_Channel::CopyFrom(const WavelengthRouter_MediaChannels_Channel& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_Channel::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_Channel::Swap(WavelengthRouter_MediaChannels_Channel* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_Channel::InternalSwap(WavelengthRouter_MediaChannels_Channel* other) { using std::swap; swap(psd_distribution_, other->psd_distribution_); swap(dest_, other->dest_); swap(source_, other->source_); swap(config_, other->config_); swap(state_, other->state_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_Channel::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels_ChannelKey::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_MediaChannels_ChannelKey_default_instance_._instance.get_mutable()->channel_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels_ChannelKey::kIndexFieldNumber; const int WavelengthRouter_MediaChannels_ChannelKey::kChannelFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels_ChannelKey::WavelengthRouter_MediaChannels_ChannelKey() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_ChannelKey(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) } WavelengthRouter_MediaChannels_ChannelKey::WavelengthRouter_MediaChannels_ChannelKey(const WavelengthRouter_MediaChannels_ChannelKey& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_channel()) { channel_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel(*from.channel_); } else { channel_ = NULL; } index_ = from.index_; // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) } void WavelengthRouter_MediaChannels_ChannelKey::SharedCtor() { ::memset(&channel_, 0, static_cast<size_t>( reinterpret_cast<char*>(&index_) - reinterpret_cast<char*>(&channel_)) + sizeof(index_)); _cached_size_ = 0; } WavelengthRouter_MediaChannels_ChannelKey::~WavelengthRouter_MediaChannels_ChannelKey() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) SharedDtor(); } void WavelengthRouter_MediaChannels_ChannelKey::SharedDtor() { if (this != internal_default_instance()) delete channel_; } void WavelengthRouter_MediaChannels_ChannelKey::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels_ChannelKey::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels_ChannelKey& WavelengthRouter_MediaChannels_ChannelKey::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels_ChannelKey(); return *internal_default_instance(); } WavelengthRouter_MediaChannels_ChannelKey* WavelengthRouter_MediaChannels_ChannelKey::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels_ChannelKey* n = new WavelengthRouter_MediaChannels_ChannelKey; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels_ChannelKey::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && channel_ != NULL) { delete channel_; } channel_ = NULL; index_ = GOOGLE_ULONGLONG(0); _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels_ChannelKey::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // uint64 index = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/index"]; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( input, &index_))); } else { goto handle_unusual; } break; } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel channel = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_channel())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) return false; #undef DO_ } void WavelengthRouter_MediaChannels_ChannelKey::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // uint64 index = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/index"]; if (this->index() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->index(), output); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel channel = 2; if (this->has_channel()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 2, *this->channel_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels_ChannelKey::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // uint64 index = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/index"]; if (this->index() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->index(), target); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel channel = 2; if (this->has_channel()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 2, *this->channel_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) return target; } size_t WavelengthRouter_MediaChannels_ChannelKey::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.Channel channel = 2; if (this->has_channel()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->channel_); } // uint64 index = 1 [(.yext.schemapath) = "/wavelength-router/media-channels/channel/index"]; if (this->index() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( this->index()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels_ChannelKey::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels_ChannelKey* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels_ChannelKey>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) MergeFrom(*source); } } void WavelengthRouter_MediaChannels_ChannelKey::MergeFrom(const WavelengthRouter_MediaChannels_ChannelKey& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_channel()) { mutable_channel()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels_Channel::MergeFrom(from.channel()); } if (from.index() != 0) { set_index(from.index()); } } void WavelengthRouter_MediaChannels_ChannelKey::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels_ChannelKey::CopyFrom(const WavelengthRouter_MediaChannels_ChannelKey& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels_ChannelKey::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels_ChannelKey::Swap(WavelengthRouter_MediaChannels_ChannelKey* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels_ChannelKey::InternalSwap(WavelengthRouter_MediaChannels_ChannelKey* other) { using std::swap; swap(channel_, other->channel_); swap(index_, other->index_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels_ChannelKey::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter_MediaChannels::InitAsDefaultInstance() { } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter_MediaChannels::kChannelFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter_MediaChannels::WavelengthRouter_MediaChannels() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) } WavelengthRouter_MediaChannels::WavelengthRouter_MediaChannels(const WavelengthRouter_MediaChannels& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), channel_(from.channel_), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) } void WavelengthRouter_MediaChannels::SharedCtor() { _cached_size_ = 0; } WavelengthRouter_MediaChannels::~WavelengthRouter_MediaChannels() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) SharedDtor(); } void WavelengthRouter_MediaChannels::SharedDtor() { } void WavelengthRouter_MediaChannels::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter_MediaChannels::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter_MediaChannels& WavelengthRouter_MediaChannels::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter_MediaChannels(); return *internal_default_instance(); } WavelengthRouter_MediaChannels* WavelengthRouter_MediaChannels::New(::google::protobuf::Arena* arena) const { WavelengthRouter_MediaChannels* n = new WavelengthRouter_MediaChannels; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter_MediaChannels::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; channel_.Clear(); _internal_metadata_.Clear(); } bool WavelengthRouter_MediaChannels::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(4294721170u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey channel = 536840146 [(.yext.schemapath) = "/wavelength-router/media-channels/channel"]; case 536840146: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(146u /* 4294721170 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_channel())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) return false; #undef DO_ } void WavelengthRouter_MediaChannels::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey channel = 536840146 [(.yext.schemapath) = "/wavelength-router/media-channels/channel"]; for (unsigned int i = 0, n = static_cast<unsigned int>(this->channel_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 536840146, this->channel(static_cast<int>(i)), output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) } ::google::protobuf::uint8* WavelengthRouter_MediaChannels::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey channel = 536840146 [(.yext.schemapath) = "/wavelength-router/media-channels/channel"]; for (unsigned int i = 0, n = static_cast<unsigned int>(this->channel_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 536840146, this->channel(static_cast<int>(i)), deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) return target; } size_t WavelengthRouter_MediaChannels::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // repeated .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels.ChannelKey channel = 536840146 [(.yext.schemapath) = "/wavelength-router/media-channels/channel"]; { unsigned int count = static_cast<unsigned int>(this->channel_size()); total_size += 5UL * count; for (unsigned int i = 0; i < count; i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSize( this->channel(static_cast<int>(i))); } } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter_MediaChannels::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter_MediaChannels* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter_MediaChannels>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) MergeFrom(*source); } } void WavelengthRouter_MediaChannels::MergeFrom(const WavelengthRouter_MediaChannels& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; channel_.MergeFrom(from.channel_); } void WavelengthRouter_MediaChannels::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter_MediaChannels::CopyFrom(const WavelengthRouter_MediaChannels& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter_MediaChannels::IsInitialized() const { return true; } void WavelengthRouter_MediaChannels::Swap(WavelengthRouter_MediaChannels* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter_MediaChannels::InternalSwap(WavelengthRouter_MediaChannels* other) { using std::swap; channel_.InternalSwap(&other->channel_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter_MediaChannels::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // =================================================================== void WavelengthRouter::InitAsDefaultInstance() { ::openconfig::openconfig_wavelength_router::_WavelengthRouter_default_instance_._instance.get_mutable()->media_channels_ = const_cast< ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels*>( ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels::internal_default_instance()); } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int WavelengthRouter::kMediaChannelsFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 WavelengthRouter::WavelengthRouter() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter(); } SharedCtor(); // @@protoc_insertion_point(constructor:openconfig.openconfig_wavelength_router.WavelengthRouter) } WavelengthRouter::WavelengthRouter(const WavelengthRouter& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.has_media_channels()) { media_channels_ = new ::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels(*from.media_channels_); } else { media_channels_ = NULL; } // @@protoc_insertion_point(copy_constructor:openconfig.openconfig_wavelength_router.WavelengthRouter) } void WavelengthRouter::SharedCtor() { media_channels_ = NULL; _cached_size_ = 0; } WavelengthRouter::~WavelengthRouter() { // @@protoc_insertion_point(destructor:openconfig.openconfig_wavelength_router.WavelengthRouter) SharedDtor(); } void WavelengthRouter::SharedDtor() { if (this != internal_default_instance()) delete media_channels_; } void WavelengthRouter::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* WavelengthRouter::descriptor() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const WavelengthRouter& WavelengthRouter::default_instance() { ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::InitDefaultsWavelengthRouter(); return *internal_default_instance(); } WavelengthRouter* WavelengthRouter::New(::google::protobuf::Arena* arena) const { WavelengthRouter* n = new WavelengthRouter; if (arena != NULL) { arena->Own(n); } return n; } void WavelengthRouter::Clear() { // @@protoc_insertion_point(message_clear_start:openconfig.openconfig_wavelength_router.WavelengthRouter) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; if (GetArenaNoVirtual() == NULL && media_channels_ != NULL) { delete media_channels_; } media_channels_ = NULL; _internal_metadata_.Clear(); } bool WavelengthRouter::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:openconfig.openconfig_wavelength_router.WavelengthRouter) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(1020057138u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels media_channels = 127507142 [(.yext.schemapath) = "/wavelength-router/media-channels"]; case 127507142: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(50u /* 1020057138 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessage( input, mutable_media_channels())); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:openconfig.openconfig_wavelength_router.WavelengthRouter) return true; failure: // @@protoc_insertion_point(parse_failure:openconfig.openconfig_wavelength_router.WavelengthRouter) return false; #undef DO_ } void WavelengthRouter::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:openconfig.openconfig_wavelength_router.WavelengthRouter) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels media_channels = 127507142 [(.yext.schemapath) = "/wavelength-router/media-channels"]; if (this->has_media_channels()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 127507142, *this->media_channels_, output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:openconfig.openconfig_wavelength_router.WavelengthRouter) } ::google::protobuf::uint8* WavelengthRouter::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:openconfig.openconfig_wavelength_router.WavelengthRouter) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels media_channels = 127507142 [(.yext.schemapath) = "/wavelength-router/media-channels"]; if (this->has_media_channels()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageToArray( 127507142, *this->media_channels_, deterministic, target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:openconfig.openconfig_wavelength_router.WavelengthRouter) return target; } size_t WavelengthRouter::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:openconfig.openconfig_wavelength_router.WavelengthRouter) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // .openconfig.openconfig_wavelength_router.WavelengthRouter.MediaChannels media_channels = 127507142 [(.yext.schemapath) = "/wavelength-router/media-channels"]; if (this->has_media_channels()) { total_size += 5 + ::google::protobuf::internal::WireFormatLite::MessageSize( *this->media_channels_); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void WavelengthRouter::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter) GOOGLE_DCHECK_NE(&from, this); const WavelengthRouter* source = ::google::protobuf::internal::DynamicCastToGenerated<const WavelengthRouter>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:openconfig.openconfig_wavelength_router.WavelengthRouter) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:openconfig.openconfig_wavelength_router.WavelengthRouter) MergeFrom(*source); } } void WavelengthRouter::MergeFrom(const WavelengthRouter& from) { // @@protoc_insertion_point(class_specific_merge_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.has_media_channels()) { mutable_media_channels()->::openconfig::openconfig_wavelength_router::WavelengthRouter_MediaChannels::MergeFrom(from.media_channels()); } } void WavelengthRouter::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter) if (&from == this) return; Clear(); MergeFrom(from); } void WavelengthRouter::CopyFrom(const WavelengthRouter& from) { // @@protoc_insertion_point(class_specific_copy_from_start:openconfig.openconfig_wavelength_router.WavelengthRouter) if (&from == this) return; Clear(); MergeFrom(from); } bool WavelengthRouter::IsInitialized() const { return true; } void WavelengthRouter::Swap(WavelengthRouter* other) { if (other == this) return; InternalSwap(other); } void WavelengthRouter::InternalSwap(WavelengthRouter* other) { using std::swap; swap(media_channels_, other->media_channels_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata WavelengthRouter::GetMetadata() const { protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_openconfig_2fopenconfig_5fwavelength_5frouter_2fopenconfig_5fwavelength_5frouter_2eproto::file_level_metadata[kIndexInFileMessages]; } // @@protoc_insertion_point(namespace_scope) } // namespace openconfig_wavelength_router } // namespace openconfig // @@protoc_insertion_point(global_scope)
52.042776
293
0.786437
seilis
17ee409ea0e51f14852a538d89cfe59cc9a194b1
348
hpp
C++
include/oxu/framework/threading/pipeline.hpp
oda404/oxu
5df4755f796be976bed767cd889a2e71ed867f9b
[ "MIT" ]
null
null
null
include/oxu/framework/threading/pipeline.hpp
oda404/oxu
5df4755f796be976bed767cd889a2e71ed867f9b
[ "MIT" ]
null
null
null
include/oxu/framework/threading/pipeline.hpp
oda404/oxu
5df4755f796be976bed767cd889a2e71ed867f9b
[ "MIT" ]
null
null
null
#pragma once #include<mutex> #include<vector> #include<oxu/framework/threading/request.hpp> namespace oxu::framework::threading { class Pipeline { private: std::vector<Request> pipeline; std::mutex mtx; public: void makeRequest(Request request); bool pollRequest(Request &targetRequest); }; }
17.4
49
0.655172
oda404
17ef4969f04e393baccff657a51faa1eb4fe1ff4
1,646
cc
C++
src/mutex.cc
cjhoward92/lokker
220977718fe6da4b19b86ae4e27c5547bdf586c8
[ "MIT" ]
null
null
null
src/mutex.cc
cjhoward92/lokker
220977718fe6da4b19b86ae4e27c5547bdf586c8
[ "MIT" ]
null
null
null
src/mutex.cc
cjhoward92/lokker
220977718fe6da4b19b86ae4e27c5547bdf586c8
[ "MIT" ]
null
null
null
#include "mutex.h" namespace Lokker { LockWorker::LockWorker(Nan::Callback *callback, uv_mutex_t *mutex) : AsyncWorker(callback) { _mutex = mutex; } LockWorker::~LockWorker() {} void LockWorker::Execute() { uv_mutex_lock(_mutex); } void LockWorker::HandleOkCallback() { Nan::HandleScope scope; v8::Local<v8::Value> argv[2] = { Nan::Null(), Nan::Null() }; callback->Call(2, argv, async_resource); } Mutex::Mutex() { uv_mutex_init(&_mutex); } Mutex::~Mutex() { uv_mutex_destroy(&_mutex); } NAN_METHOD(Mutex::New) { if (!info.IsConstructCall()) { return Nan::ThrowError("non-constructor invocation not supported"); } Mutex *mut = new Mutex(); mut->Wrap(info.This()); info.GetReturnValue().Set(info.This()); } NAN_METHOD(Mutex::Lock) { Nan::Callback *callback = new Nan::Callback(info[0].As<v8::Function>()); Mutex *mut = ObjectWrap::Unwrap<Mutex>(info.Holder()); Nan::AsyncQueueWorker(new LockWorker(callback, &mut->_mutex)); } NAN_METHOD(Mutex::Unlock) { Mutex *mut = ObjectWrap::Unwrap<Mutex>(info.Holder()); uv_mutex_unlock(&mut->_mutex); } Nan::Persistent<v8::Function> Mutex::constructor; void Mutex::Init(v8::Local<v8::Object> exports) { v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New); tpl->SetClassName(Nan::New("Mutex").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); SetPrototypeMethod(tpl, "lock", Lock); SetPrototypeMethod(tpl, "unlock", Unlock); constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); exports->Set(Nan::New("Mutex").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } }
23.855072
76
0.684083
cjhoward92
17f3a670537114c1e27c87fe7885a03faf04a9ed
1,420
cpp
C++
2667.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
2667.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
2667.cpp
jaemin2682/BAEKJOON_ONLINE_JUDGE
0d5c6907baee61e1fabdbcd96ea473079a9475ed
[ "MIT" ]
null
null
null
#include <vector> #include <iostream> #include <queue> #include <algorithm> #include <string> using namespace std; int map[26][26]; bool visit[26][26]; int main() { int n; vector<pair<int, int>> dxy = { {1,0}, {-1,0}, {0,-1}, {0,1} }; string temp; vector<string> store; vector<int> answer; cin >> n; for (int i = 0; i < n; i++) { cin >> temp; store.push_back(temp); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { map[i][j] = store[i-1][j-1] - '0'; } } int cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (map[i][j] && !visit[i][j]) { int num = 1; cnt++; map[i][j] = cnt; queue<pair<int, int>> q; q.push({ i,j }); visit[i][j] = true; while (!q.empty()) { int dx = q.front().first; int dy = q.front().second; q.pop(); for (int k = 0; k < 4; k++) { int nx = dx + dxy[k].first; int ny = dy + dxy[k].second; if (map[nx][ny] && !visit[nx][ny] && nx > 0 && nx <= n && ny > 0 && ny <= n) { visit[nx][ny] = true; num++; map[nx][ny] = cnt; q.push({ nx, ny }); } } } answer.push_back(num); } else visit[i][j] = true; } } sort(answer.begin(), answer.end()); cout << cnt << endl; for (int i = 0; i < answer.size(); i++) { cout << answer[i] << endl; } return 0; }
21.515152
85
0.442254
jaemin2682