hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
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
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
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
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
b46cd4505721586d9f5050dd12a97724c9a39757
4,715
h
C
Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.h
zhaomengxiao/MITK
a09fd849a4328276806008bfa92487f83a9e2437
[ "BSD-3-Clause" ]
1
2022-03-03T12:03:32.000Z
2022-03-03T12:03:32.000Z
Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.h
zhaomengxiao/MITK
a09fd849a4328276806008bfa92487f83a9e2437
[ "BSD-3-Clause" ]
1
2021-12-22T10:19:02.000Z
2021-12-22T10:19:02.000Z
Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/NavigationStepWidgets/QmitkUSNavigationStepPlacementPlanning.h
zhaomengxiao/MITK_lancet
a09fd849a4328276806008bfa92487f83a9e2437
[ "BSD-3-Clause" ]
1
2020-11-27T09:41:18.000Z
2020-11-27T09:41:18.000Z
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITKUSNAVIGATIONSTEPPLACEMENTPLANNING_H #define QMITKUSNAVIGATIONSTEPPLACEMENTPLANNING_H #include "QmitkUSAbstractNavigationStep.h" namespace Ui { class QmitkUSNavigationStepPlacementPlanning; } namespace mitk { class USNavigationTargetUpdateFilter; class USNavigationTargetIntersectionFilter; class USPointMarkInteractor; class NodeDisplacementFilter; class NeedleProjectionFilter; class LookupTableProperty; class TextAnnotation3D; class Surface; class PointSet; class USTargetPlacementQualityCalculator; } /** * \brief Navigation step for planning the positions for implanting markers. * * The planned targets are stored in the data storage under DATANAME_BASENODE -> * DATANAME_TARGETS and the needle path to the planned targets are stored under * DATANAME_BASENODE -> DATANAME_TARGETS_PATHS. The target structure is expected * to be stored under DATANAME_BASENODE -> DATANAME_TUMOR -> * DATANAME_TARGETSURFACE. * */ class QmitkUSNavigationStepPlacementPlanning : public QmitkUSAbstractNavigationStep { Q_OBJECT protected slots: /** * \brief Freezes or unfreezes the combined modality. * In freeze state an interactor is activated in the render window, so the * position of the currently active target can be planned by clicking into the * render window. */ void OnFreeze(bool freezed); /** * \brief Plan target position at the intersection between needle path and target surface. */ void OnPlaceTargetButtonClicked(); /** * \brief Selects the previous target as active target. */ void OnGoToPreviousTarget(); /** * \brief Selects the next target as active target. */ void OnGoToNextTarget(); /** * \brief The currently active target is removed from the data storage. */ void OnRemoveCurrentTargetClicked(); public: explicit QmitkUSNavigationStepPlacementPlanning(QWidget *parent = nullptr); ~QmitkUSNavigationStepPlacementPlanning() override; QString GetTitle() override; FilterVector GetFilter() override; protected: bool OnStartStep() override; bool OnStopStep() override; bool OnRestartStep() override; bool OnFinishStep() override; bool OnActivateStep() override; bool OnDeactivateStep() override; void OnUpdate() override; void OnSettingsChanged(const itk::SmartPointer<mitk::DataNode> settingsNode) override; void OnSetCombinedModality() override; void CreateTargetNodesIfNecessary(); void UpdateTargetCoordinates(mitk::DataNode *); void UpdateTargetColors(); void UpdateTargetDescriptions(); void GenerateTargetColorLookupTable(); void ReinitNodeDisplacementFilter(); void CalculatePlanningQuality(); itk::SmartPointer<mitk::DataNode> CalculatePlanningQuality(itk::SmartPointer<mitk::Surface> targetSurface, itk::SmartPointer<mitk::PointSet>); itk::SmartPointer<mitk::Surface> CreateSphere(float radius); void UpdateBodyMarkerStatus(mitk::NavigationData::Pointer bodyMarker); void UpdateSensorsNames(); int m_NumberOfTargets; int m_CurrentTargetIndex; bool m_BodyMarkerValid; itk::SmartPointer<mitk::USPointMarkInteractor> m_PointMarkInteractor; itk::SmartPointer<mitk::USNavigationTargetUpdateFilter> m_TargetUpdateFilter; itk::SmartPointer<mitk::NodeDisplacementFilter> m_NodeDisplacementFilter; itk::SmartPointer<mitk::NeedleProjectionFilter> m_NeedleProjectionFilter; itk::SmartPointer<mitk::USNavigationTargetIntersectionFilter> m_TargetIntersectionFilter; itk::SmartPointer<mitk::USTargetPlacementQualityCalculator> m_PlacementQualityCalculator; itk::SmartPointer<mitk::LookupTableProperty> m_TargetColorLookupTableProperty; itk::SmartPointer<mitk::DataNode> m_TargetNode; QVector<itk::SmartPointer<mitk::DataNode>> m_PlannedTargetNodes; QVector<itk::SmartPointer<mitk::DataNode>> m_PlannedNeedlePaths; itk::SmartPointer<mitk::TextAnnotation3D> m_CurrentTargetNodeOverlay; std::string m_ReferenceSensorName; std::string m_NeedleSensorName; unsigned int m_ReferenceSensorIndex; unsigned int m_NeedleSensorIndex; private: mitk::MessageDelegate1<QmitkUSNavigationStepPlacementPlanning, mitk::DataNode *> m_ListenerTargetCoordinatesChanged; Ui::QmitkUSNavigationStepPlacementPlanning *ui; }; #endif // QMITKUSNAVIGATIONSTEPPLACEMENTPLANNING_H
32.517241
118
0.758431
[ "render" ]
b46e51a2a66977319e6dfc96a6a655bde9846031
1,214
h
C
PrivateFrameworks/HomeKitBackingStore/HMBMirrorOutputTuple.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/HomeKitBackingStore/HMBMirrorOutputTuple.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/HomeKitBackingStore/HMBMirrorOutputTuple.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "HMFObject.h" @class HMBLocalSQLQueryTable, HMBModel, NSData; @interface HMBMirrorOutputTuple : HMFObject { HMBModel *_model; NSData *_externalID; NSData *_externalData; HMBLocalSQLQueryTable *_queryTable; unsigned long long _recordRow; unsigned long long _outputBlockRow; } @property(readonly) unsigned long long outputBlockRow; // @synthesize outputBlockRow=_outputBlockRow; @property(readonly) unsigned long long recordRow; // @synthesize recordRow=_recordRow; @property(readonly, nonatomic) HMBLocalSQLQueryTable *queryTable; // @synthesize queryTable=_queryTable; @property(copy, nonatomic) NSData *externalData; // @synthesize externalData=_externalData; @property(copy, nonatomic) NSData *externalID; // @synthesize externalID=_externalID; @property(readonly, nonatomic) HMBModel *model; // @synthesize model=_model; - (void).cxx_destruct; - (id)description; - (id)initWithOutputBlockRow:(unsigned long long)arg1 recordRow:(unsigned long long)arg2 model:(id)arg3 queryTable:(id)arg4 externalID:(id)arg5 externalData:(id)arg6; @end
36.787879
166
0.763591
[ "model" ]
b47c823b49fb10133b8eba989707da0350ba7caa
770
h
C
Project/src/Generator/Random/UniformRandom.h
olegat/uea-dissertation
3768908aa172715278dc9307b99361746fb38f2e
[ "MIT" ]
null
null
null
Project/src/Generator/Random/UniformRandom.h
olegat/uea-dissertation
3768908aa172715278dc9307b99361746fb38f2e
[ "MIT" ]
null
null
null
Project/src/Generator/Random/UniformRandom.h
olegat/uea-dissertation
3768908aa172715278dc9307b99361746fb38f2e
[ "MIT" ]
null
null
null
// // UniformSeeder.h // Dissert // // Created by Olivier Legat on 12/05/12. // Copyright (c) 2012 ss42. All rights reserved. // #ifndef UNIFORM_SEEDER_H_ #define UNIFORM_SEEDER_H_ #include "Random.h" #define MAZE_LCG_A 16807 // 7^5 #define MAZE_LCG_M 2147483647 // 2^31 − 1 #define MAZE_LCG_C 0 // 0 class UniformRandom extends Object implements RandomI implements RandomF { public: UniformRandom(); UniformRandom(unsigned long seed); ~UniformRandom(); virtual int nextInt(); virtual int nextInt(int max); virtual int nextInt(int min, int max); virtual float nextFloat(); virtual float nextFloat(float max); virtual float nextFloat(float min, float max); private: unsigned long x; }; #endif
18.780488
50
0.679221
[ "object" ]
7d8d3a433496527d788562e2c090800a1dfd9dc9
7,304
h
C
D2CloudKitManager/Classes/D20CloudKitManager.h
2020Deception/D2CloudKitManager
8a6955f516d09e20a82b2385ed19fc40d8c8b417
[ "MIT" ]
1
2016-11-02T19:58:58.000Z
2016-11-02T19:58:58.000Z
D2CloudKitManager/Classes/D20CloudKitManager.h
2020Deception/D2CloudKitManager
8a6955f516d09e20a82b2385ed19fc40d8c8b417
[ "MIT" ]
null
null
null
D2CloudKitManager/Classes/D20CloudKitManager.h
2020Deception/D2CloudKitManager
8a6955f516d09e20a82b2385ed19fc40d8c8b417
[ "MIT" ]
null
null
null
// // D20CloudKitManager.h // Pods // // Created by 2020Deceptiononymous on 10/4/16. // // @import Foundation; @import CloudKit; @import UIKit; NS_ENUM(NSInteger, DatabaseType) { DatabaseTypePublic, DatabaseTypePrivate }; @interface D20CloudKitManager : NSObject + (instancetype _Nonnull)sharedInstance; #pragma mark - database/zone /**returns a CKDatabase*/ + (CKDatabase * _Nonnull)dataBaseFromType:(enum DatabaseType)databaseType; #pragma mark - save/delete /**save a new record to a database*/ - (void)saveRecord:(CKRecord * _Nonnull)record databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(CKRecord * _Nullable record, NSError * _Nullable error))completionHandler; /**delete a record*/ - (void)deleteRecord:(CKRecord * _Nonnull)record databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(CKRecordID * _Nullable recordID, NSError * _Nullable error))completionHandler; #pragma mark - discover records (users) /**request discoverability for the user*/ - (void)requestDiscoverabilityPermission:(void (^ _Nullable)(BOOL discoverable, NSError * _Nullable error))completionHandler; /**discover user info. Passing nil will return info for the current user*/ - (void)discoverUserInfoWithRecordId:(CKRecordID * _Nullable)recordID completionHandler:(void (^ _Nullable)(CKUserIdentity * _Nullable user, NSError * _Nullable error))completionHandler; /**discover friends info*/ - (void)discoverAddressBookUsersInfos:(void (^ _Nullable)(NSArray <CKUserIdentity *> * _Nullable userInfos, NSError * _Nullable error))completionHandler; /**discover info by email*/ - (void)discoverAddressBookUsersEmail:(NSString * _Nonnull)email completionHandler:(void (^ _Nullable)(CKUserIdentity * _Nullable userInfo, NSError * _Nullable error))completionHandler; #pragma mark - fetch/query for records /**fetch records based on type*/ - (void)queryRecordsWithType:(NSString * _Nonnull)recordType databaseType:(enum DatabaseType)databaseType desiredKeys:(NSArray * _Nonnull)desiredKeys resultLimits:(NSUInteger)resultLimits completionHandler:(void (^ _Nullable)(CKQueryCursor * _Nullable cursor, NSArray * _Nullable records, NSError * _Nullable error))completionHandler progressBlock:(void (^ _Nullable)(NSArray * _Nullable records))progressBlock; /**get records based on location*/ - (void)queryForRecordsNearLocation:(CLLocation * _Nonnull)location databaseType:(enum DatabaseType)databaseType recordType:(NSString * _Nonnull)recordType predicate:(NSPredicate * _Nonnull)predicate desiredKeys:(NSArray * _Nonnull)desiredKeys resultLimits:(NSUInteger)resultLimits completionHandler:(void (^ _Nullable)(CKQueryCursor * _Nullable cursor, NSArray * _Nullable records, NSError * _Nullable error))completionHandler progressBlock:(void (^ _Nullable)(NSArray * _Nullable records))progressBlock; /**fetch records based on a predicate and record type*/ - (void)queryForRecordsWithPredicate:(NSPredicate * _Nonnull)predicate recordType:(NSString * _Nonnull)recordType databaseType:(enum DatabaseType)databaseType desiredKeys:(NSArray * _Nonnull)desiredKeys resultLimits:(NSUInteger)resultLimits progressBlock:(void (^ _Nullable)(NSArray * _Nullable records))progressBlock completionHandler:(void (^ _Nullable)(CKQueryCursor * _Nullable cursor, NSArray * _Nullable records, NSError * _Nullable error))completionHandler; /**get a record based on a record Id*/ - (void)fetchRecordWithID:(CKRecordID * _Nonnull)recordID databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(CKRecord * _Nullable record, NSError * _Nullable error))completionHandler; #pragma mark - update records /**update records*/ - (void)updateRecordsWithRecordsToSave:(NSArray * _Nonnull)recordsToSave recordIdsToDelete:(NSArray * _Nonnull)recordIdsToDelete databaseType:(enum DatabaseType)databaseType savePolicy:(CKRecordSavePolicy)savePolicy completionHandler:(void (^ _Nullable)(NSArray * _Nullable savedRecords, NSArray * _Nullable deletedRecords, NSError * _Nullable error))completionHandler; #pragma mark - subscriptions /**fetch subscription with ID*/ - (void)fetchSubscriptionWithID:(NSString * _Nonnull)subscriptionID databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(CKSubscription * _Nullable subscription, NSError * _Nullable error))completionHandler; /**fetch all user subscriptions*/ - (void)fetchAllSubscriptionsForDatabaseType:(enum DatabaseType)databaseType withCompletionHandler:(void (^ _Nullable)(NSArray <CKSubscription *> * _Nullable subscriptions, NSError * _Nullable error))completionHandler; /**creates a subscription*/ - (void)subscribeWithSubscription:(CKSubscription * _Nonnull)subscription databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(CKSubscription * _Nullable subscription, NSError * _Nullable error))completionHandler; /**removes a subscription*/ - (void)unsubscribeWithSubscriptionID:(NSString * _Nonnull)subscriptionID databaseType:(enum DatabaseType)databaseType completionHandler:(void (^ _Nullable)(NSArray * _Nullable savedSubscriptions, NSArray * _Nullable deletedSubscriptionIDs, NSError * _Nullable error))completionHandler; #pragma mark - handleErrors /**handle cloudkit errors @param serverFailureBlock returned if there is conflict saving the record on the server @param retryCallBlock returned if the error contains a retryWaitTime to retry the call @param retryUploadBlock returned if the server returns the more recent record on the server than the one that is to be modified @param partialFailureBlock returned if there was a partial error during an upload. THe dictionary is CKRecordId object as the key and CKRecord as the value @param errorDisplayBlock returned if the error requires some user interaction or display */ - (void)handleError:(NSError * _Nonnull)error serverFailureBlock:(void (^ _Nullable)(BOOL errorAncestorRecordKey, BOOL errorServerRecordKey, BOOL errorClientRecordKey, CKErrorCode code, NSError * _Nullable error))serverFailureBlock retryCallBlock:(void (^ _Nullable)(BOOL retryFromTimeOut, NSNumber * _Nullable retryWaitTime, CKErrorCode code, NSError * _Nullable error))retryCallBlock retryUploadBlock:(void (^ _Nullable)(BOOL retryUpload, CKRecord * _Nullable recordToRetry, CKErrorCode code, NSError * _Nullable error))retryUploadBlock partialFailureBlock:(void (^ _Nullable)(NSDictionary * _Nullable failedItemsInfo, CKErrorCode code, NSError * _Nullable error))partialFailureBlock errorDisplayBlock:(void (^ _Nullable)(CKErrorCode code, NSError * _Nullable error))errorDisplayBlock; @end
53.705882
187
0.732338
[ "object" ]
7d945e01cee51e8caa0158c338e6420b7eb835da
1,932
h
C
saver_id.h
poikilos/golgotha
d3184dea6b061f853423e0666dba23218042e5ba
[ "CC0-1.0" ]
5
2015-12-09T20:37:49.000Z
2021-08-10T08:06:29.000Z
saver_id.h
poikilos/golgotha
d3184dea6b061f853423e0666dba23218042e5ba
[ "CC0-1.0" ]
13
2021-09-20T16:25:30.000Z
2022-03-17T04:59:40.000Z
saver_id.h
poikilos/golgotha
d3184dea6b061f853423e0666dba23218042e5ba
[ "CC0-1.0" ]
5
2016-01-04T22:54:22.000Z
2021-09-20T16:09:03.000Z
/********************************************************************** <BR> This file is part of Crack dot Com's free source code release of Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for information about compiling & licensing issues visit this URL</a> <PRE> If that doesn't help, contact Jonathan Clark at golgotha_source@usa.net (Subject should have "GOLG" in it) ***********************************************************************/ #ifndef G1_SAVER_ID_HH #define G1_SAVER_ID_HH enum { //do NEWER EVER change the order of entries in this list //or you won't be able to load old maps. G1_SECTION_MAP_DIMENSIONS_V1, G1_SECTION_TILE_MATCHUP_V1, OLD_G1_SECTION_CELL_V1, G1_SECTION_OBJECTS_V1, G1_SECTION_OBJECT_BASE_V1, G1_SECTION_PATHS_V1, G1_SECTION_GRAPH_NODES_V1, OLD_G1_SECTION_GRAPH_EDGES_V1, G1_SECTION_GRAPH_WEIRDS_V1, OLD_G1_SECTION_CELL_V2, G1_SECTION_GRAPH_EDGES_V2, OLD_G1_SECTION_CELL_V3, G1_SECTION_TICK, G1_SECTION_MOVIE, OLD_G1_SECTION_CELL_V4, OLD_G1_SECTION_MAP_VERT_V1, OLD_G1_SECTION_MAP_LIGHTS_V1, OLD_G1_SECTION_MAP_VERT_V2, G1_SECTION_MODEL_QUADS, G1_SECTION_MODEL_TEXTURE_NAMES, G1_SECTION_MODEL_VERT_ANIMATION, G1_SECTION_PLAYER_INFO, OLD_G1_SECTION_MAP_VERT_V3, // added flags G1_SECTION_SKY_V1, // sky model and info used for level OLD_G1_SECTION_CELL_V5, OLD_G1_SECTION_CELL_V6, G1_SECTION_OBJECT_TYPES_V1, // saves the name of each object type so dynamic id's are matched G1_SECTION_MAP_SECTIONS_V1, OLD_G1_SECTION_MAP_VERT_V4, // added selected prefix G1_SECTION_CRITICAL_POINTS_V1, G1_SECTION_CRITICAL_GRAPH_V1, G1_SECTION_CRITICAL_MAP_V1, G1_SECTION_PLAYER_INFO_V2, G1_SECTION_MODEL_NAMES_V1, G1_SECTION_TEXTURE_NAMES_V1, G1_SECTION_TEXTURE_NAMES_V2, G1_SECTION_OBJECT_LIST = 0x8000 } ; #endif
23.560976
95
0.712733
[ "object", "model" ]
7d99da5ad71867ed82eda71c02ec99617f87c5af
741
h
C
engine/Math/src/Math.h
AbyteofteA/MiteVox
32cbe2e42f05c68b4f545707ef6df28d73d9dd2a
[ "MIT" ]
null
null
null
engine/Math/src/Math.h
AbyteofteA/MiteVox
32cbe2e42f05c68b4f545707ef6df28d73d9dd2a
[ "MIT" ]
null
null
null
engine/Math/src/Math.h
AbyteofteA/MiteVox
32cbe2e42f05c68b4f545707ef6df28d73d9dd2a
[ "MIT" ]
null
null
null
#ifndef MATH_HEADERS_H #define MATH_HEADERS_H #define _USE_MATH_DEFINES #include <math.h> #include "Calculus/Sequences.h" #include "DataStructures/Buffer.h" #include "DataStructures/HalfTable.h" #include "DataStructures/HyperData.h" #include "DataStructures/Graphs/Octree.h" //#include "DataStructures/Graphs/Math_BinarySearchTree.h" #include "Convertations.h" #include "Generators/RandomNumberGenerators/CongruentialGenerator.h" #include "Generators/UniqueIDGenerator.h" #include "Generators/NoiseGenerators/PerlinNoiseGenerator.h" #include "LinearAlgebra/Point3D.h" #include "LinearAlgebra/Vector3D.h" #include "LinearAlgebra/Transform.h" #include "LinearAlgebra/SquareMatrix.h" #include "NumericalAnalysis/Intertolation.h" #endif
25.551724
68
0.817814
[ "transform" ]
7da0a887499c728936b7f508dd6bc7525dd6a61f
36,969
c
C
lib/dpdk-stable-19.08.2/drivers/net/hinic/base/hinic_pmd_niccfg.c
mjlee34/poseidonos
8eff75c5ba7af8090d3ff4ac51d7507b37571f9b
[ "BSD-3-Clause" ]
null
null
null
lib/dpdk-stable-19.08.2/drivers/net/hinic/base/hinic_pmd_niccfg.c
mjlee34/poseidonos
8eff75c5ba7af8090d3ff4ac51d7507b37571f9b
[ "BSD-3-Clause" ]
null
null
null
lib/dpdk-stable-19.08.2/drivers/net/hinic/base/hinic_pmd_niccfg.c
mjlee34/poseidonos
8eff75c5ba7af8090d3ff4ac51d7507b37571f9b
[ "BSD-3-Clause" ]
null
null
null
/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2017 Huawei Technologies Co., Ltd */ #include "hinic_compat.h" #include "hinic_pmd_hwdev.h" #include "hinic_pmd_hwif.h" #include "hinic_pmd_eqs.h" #include "hinic_pmd_wq.h" #include "hinic_pmd_mgmt.h" #include "hinic_pmd_cmdq.h" #include "hinic_pmd_niccfg.h" #define l2nic_msg_to_mgmt_sync(hwdev, cmd, buf_in, \ in_size, buf_out, out_size) \ hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC, cmd, \ buf_in, in_size, \ buf_out, out_size, 0) int hinic_init_function_table(void *hwdev, u16 rx_buf_sz) { struct hinic_function_table function_table; u16 out_size = sizeof(function_table); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&function_table, 0, sizeof(function_table)); function_table.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; function_table.func_id = hinic_global_func_id(hwdev); function_table.mtu = 0x3FFF; /* default, max mtu */ function_table.rx_wqe_buf_size = rx_buf_sz; err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC, HINIC_PORT_CMD_INIT_FUNC, &function_table, sizeof(function_table), &function_table, &out_size, 0); if (err || function_table.mgmt_msg_head.status || !out_size) { PMD_DRV_LOG(ERR, "Failed to init func table, ret = %d", function_table.mgmt_msg_head.status); return -EFAULT; } return 0; } /** * hinic_get_base_qpn - get global number of queue * @hwdev: the hardware interface of a nic device * @global_qpn: vat page size * @return * 0 on success, * negative error value otherwise. **/ int hinic_get_base_qpn(void *hwdev, u16 *global_qpn) { struct hinic_cmd_qpn cmd_qpn; u16 out_size = sizeof(cmd_qpn); int err; if (!hwdev || !global_qpn) { PMD_DRV_LOG(ERR, "Hwdev or global_qpn is NULL"); return -EINVAL; } memset(&cmd_qpn, 0, sizeof(cmd_qpn)); cmd_qpn.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; cmd_qpn.func_id = hinic_global_func_id(hwdev); err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_L2NIC, HINIC_PORT_CMD_GET_GLOBAL_QPN, &cmd_qpn, sizeof(cmd_qpn), &cmd_qpn, &out_size, 0); if (err || !out_size || cmd_qpn.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get base qpn, status(%d)", cmd_qpn.mgmt_msg_head.status); return -EINVAL; } *global_qpn = cmd_qpn.base_qpn; return 0; } /** * hinic_set_mac - Init mac_vlan table in NIC. * @hwdev: the hardware interface of a nic device * @mac_addr: mac address * @vlan_id: set 0 for mac_vlan table initialization * @func_id: global function id of NIC * @return * 0 on success and stats is filled, * negative error value otherwise. */ int hinic_set_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id) { struct hinic_port_mac_set mac_info; u16 out_size = sizeof(mac_info); int err; if (!hwdev || !mac_addr) { PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL"); return -EINVAL; } memset(&mac_info, 0, sizeof(mac_info)); mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; mac_info.func_id = func_id; mac_info.vlan_id = vlan_id; memmove(mac_info.mac, mac_addr, ETH_ALEN); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_MAC, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || (mac_info.mgmt_msg_head.status && mac_info.mgmt_msg_head.status != HINIC_PF_SET_VF_ALREADY)) { PMD_DRV_LOG(ERR, "Failed to set MAC, err: %d, status: 0x%x, out size: 0x%x", err, mac_info.mgmt_msg_head.status, out_size); return -EINVAL; } if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) { PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore set operation."); return HINIC_PF_SET_VF_ALREADY; } return 0; } /** * hinic_del_mac - Uninit mac_vlan table in NIC. * @hwdev: the hardware interface of a nic device * @mac_addr: mac address * @vlan_id: set 0 for mac_vlan table initialization * @func_id: global function id of NIC * @return * 0 on success and stats is filled, * negative error value otherwise. */ int hinic_del_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id) { struct hinic_port_mac_set mac_info; u16 out_size = sizeof(mac_info); int err; if (!hwdev || !mac_addr) { PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL"); return -EINVAL; } if (vlan_id >= VLAN_N_VID) { PMD_DRV_LOG(ERR, "Invalid VLAN number"); return -EINVAL; } memset(&mac_info, 0, sizeof(mac_info)); mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; mac_info.func_id = func_id; mac_info.vlan_id = vlan_id; memmove(mac_info.mac, mac_addr, ETH_ALEN); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_DEL_MAC, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || (mac_info.mgmt_msg_head.status && mac_info.mgmt_msg_head.status != HINIC_PF_SET_VF_ALREADY)) { PMD_DRV_LOG(ERR, "Failed to delete MAC, err: %d, status: 0x%x, out size: 0x%x", err, mac_info.mgmt_msg_head.status, out_size); return -EINVAL; } if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) { PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore delete operation."); return HINIC_PF_SET_VF_ALREADY; } return 0; } int hinic_get_default_mac(void *hwdev, u8 *mac_addr) { struct hinic_port_mac_set mac_info; u16 out_size = sizeof(mac_info); int err; if (!hwdev || !mac_addr) { PMD_DRV_LOG(ERR, "Hwdev or mac_addr is NULL"); return -EINVAL; } memset(&mac_info, 0, sizeof(mac_info)); mac_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; mac_info.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_MAC, &mac_info, sizeof(mac_info), &mac_info, &out_size); if (err || !out_size || mac_info.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get mac, err: %d, status: 0x%x, out size: 0x%x", err, mac_info.mgmt_msg_head.status, out_size); return -EINVAL; } memmove(mac_addr, mac_info.mac, ETH_ALEN); return 0; } int hinic_set_port_mtu(void *hwdev, u32 new_mtu) { struct hinic_mtu mtu_info; u16 out_size = sizeof(mtu_info); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&mtu_info, 0, sizeof(mtu_info)); mtu_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; mtu_info.func_id = hinic_global_func_id(hwdev); mtu_info.mtu = new_mtu; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CHANGE_MTU, &mtu_info, sizeof(mtu_info), &mtu_info, &out_size); if (err || !out_size || mtu_info.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set mtu, err: %d, status: 0x%x, out size: 0x%x", err, mtu_info.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_get_link_status(void *hwdev, u8 *link_state) { struct hinic_get_link get_link; u16 out_size = sizeof(get_link); int err; if (!hwdev || !link_state) { PMD_DRV_LOG(ERR, "Hwdev or link_state is NULL"); return -EINVAL; } memset(&get_link, 0, sizeof(get_link)); get_link.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; get_link.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_STATE, &get_link, sizeof(get_link), &get_link, &out_size); if (err || !out_size || get_link.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get link state, err: %d, status: 0x%x, out size: 0x%x", err, get_link.mgmt_msg_head.status, out_size); return -EINVAL; } *link_state = get_link.link_status; return 0; } /** * hinic_set_vport_enable - Notify firmware that driver is ready or not. * @hwdev: the hardware interface of a nic device * @enable: 1: driver is ready; 0: driver is not ok. * Return: 0 on success and state is filled, negative error value otherwise. **/ int hinic_set_vport_enable(void *hwdev, bool enable) { struct hinic_vport_state en_state; u16 out_size = sizeof(en_state); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&en_state, 0, sizeof(en_state)); en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; en_state.func_id = hinic_global_func_id(hwdev); en_state.state = (enable ? 1 : 0); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VPORT_ENABLE, &en_state, sizeof(en_state), &en_state, &out_size); if (err || !out_size || en_state.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set vport state, err: %d, status: 0x%x, out size: 0x%x", err, en_state.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } /** * hinic_set_port_enable - open MAG to receive packets. * @hwdev: the hardware interface of a nic device * @enable: 1: open MAG; 0: close MAG. * @return * 0 on success and stats is filled, * negative error value otherwise. */ int hinic_set_port_enable(void *hwdev, bool enable) { struct hinic_port_state en_state; u16 out_size = sizeof(en_state); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&en_state, 0, sizeof(en_state)); en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; en_state.state = (enable ? HINIC_PORT_ENABLE : HINIC_PORT_DISABLE); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PORT_ENABLE, &en_state, sizeof(en_state), &en_state, &out_size); if (err || !out_size || en_state.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set phy port state, err: %d, status: 0x%x, out size: 0x%x", err, en_state.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_get_port_info(void *hwdev, struct nic_port_info *port_info) { struct hinic_port_info port_msg; u16 out_size = sizeof(port_msg); int err; if (!hwdev || !port_info) { PMD_DRV_LOG(ERR, "Hwdev or port_info is NULL"); return -EINVAL; } memset(&port_msg, 0, sizeof(port_msg)); port_msg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; port_msg.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_INFO, &port_msg, sizeof(port_msg), &port_msg, &out_size); if (err || !out_size || port_msg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get port info, err: %d, status: 0x%x, out size: 0x%x", err, port_msg.mgmt_msg_head.status, out_size); return err; } port_info->autoneg_cap = port_msg.autoneg_cap; port_info->autoneg_state = port_msg.autoneg_state; port_info->duplex = port_msg.duplex; port_info->port_type = port_msg.port_type; port_info->speed = port_msg.speed; return 0; } int hinic_set_pause_config(void *hwdev, struct nic_pause_config nic_pause) { struct hinic_pause_config pause_info; u16 out_size = sizeof(pause_info); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&pause_info, 0, sizeof(pause_info)); pause_info.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; pause_info.func_id = hinic_global_func_id(hwdev); pause_info.auto_neg = nic_pause.auto_neg; pause_info.rx_pause = nic_pause.rx_pause; pause_info.tx_pause = nic_pause.tx_pause; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_PAUSE_INFO, &pause_info, sizeof(pause_info), &pause_info, &out_size); if (err || !out_size || pause_info.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set pause info, err: %d, status: 0x%x, out size: 0x%x", err, pause_info.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_dcb_set_ets(void *hwdev, u8 *up_tc, u8 *pg_bw, u8 *pgid, u8 *up_bw, u8 *prio) { struct hinic_up_ets_cfg ets; u16 out_size = sizeof(ets); u16 up_bw_t = 0; u8 pg_bw_t = 0; int i, err; if (!hwdev || !up_tc || !pg_bw || !pgid || !up_bw || !prio) { PMD_DRV_LOG(ERR, "Hwdev, up_tc, pg_bw, pgid, up_bw or prio is NULL"); return -EINVAL; } for (i = 0; i < HINIC_DCB_TC_MAX; i++) { up_bw_t += *(up_bw + i); pg_bw_t += *(pg_bw + i); if (*(up_tc + i) > HINIC_DCB_TC_MAX) { PMD_DRV_LOG(ERR, "Invalid up %d mapping tc: %d", i, *(up_tc + i)); return -EINVAL; } } if (pg_bw_t != 100 || (up_bw_t % 100) != 0) { PMD_DRV_LOG(ERR, "Invalid pg_bw: %d or up_bw: %d", pg_bw_t, up_bw_t); return -EINVAL; } memset(&ets, 0, sizeof(ets)); ets.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; ets.port_id = 0; /* reserved */ memcpy(ets.up_tc, up_tc, HINIC_DCB_TC_MAX); memcpy(ets.pg_bw, pg_bw, HINIC_DCB_UP_MAX); memcpy(ets.pgid, pgid, HINIC_DCB_UP_MAX); memcpy(ets.up_bw, up_bw, HINIC_DCB_UP_MAX); memcpy(ets.prio, prio, HINIC_DCB_UP_MAX); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ETS, &ets, sizeof(ets), &ets, &out_size); if (err || ets.mgmt_msg_head.status || !out_size) { PMD_DRV_LOG(ERR, "Failed to set ets, err: %d, status: 0x%x, out size: 0x%x", err, ets.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_get_vport_stats(void *hwdev, struct hinic_vport_stats *stats) { struct hinic_port_stats_info vport_stats_cmd; struct hinic_cmd_vport_stats vport_stats_rsp; u16 out_size = sizeof(vport_stats_rsp); int err; if (!hwdev || !stats) { PMD_DRV_LOG(ERR, "Hwdev or stats is NULL"); return -EINVAL; } memset(&vport_stats_rsp, 0, sizeof(vport_stats_rsp)); memset(&vport_stats_cmd, 0, sizeof(vport_stats_cmd)); vport_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; vport_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION; vport_stats_cmd.func_id = hinic_global_func_id(hwdev); vport_stats_cmd.stats_size = sizeof(vport_stats_rsp); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_VPORT_STAT, &vport_stats_cmd, sizeof(vport_stats_cmd), &vport_stats_rsp, &out_size); if (err || !out_size || vport_stats_rsp.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Get vport stats from fw failed, err: %d, status: 0x%x, out size: 0x%x", err, vport_stats_rsp.mgmt_msg_head.status, out_size); return -EFAULT; } memcpy(stats, &vport_stats_rsp.stats, sizeof(*stats)); return 0; } int hinic_get_phy_port_stats(void *hwdev, struct hinic_phy_port_stats *stats) { struct hinic_port_stats_info port_stats_cmd; struct hinic_port_stats port_stats_rsp; u16 out_size = sizeof(port_stats_rsp); int err; if (!hwdev || !stats) { PMD_DRV_LOG(ERR, "Hwdev or stats is NULL"); return -EINVAL; } memset(&port_stats_rsp, 0, sizeof(port_stats_rsp)); memset(&port_stats_cmd, 0, sizeof(port_stats_cmd)); port_stats_cmd.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; port_stats_cmd.stats_version = HINIC_PORT_STATS_VERSION; port_stats_cmd.stats_size = sizeof(port_stats_rsp); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_PORT_STATISTICS, &port_stats_cmd, sizeof(port_stats_cmd), &port_stats_rsp, &out_size); if (err || !out_size || port_stats_rsp.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get port statistics, err: %d, status: 0x%x, out size: 0x%x", err, port_stats_rsp.mgmt_msg_head.status, out_size); return -EFAULT; } memcpy(stats, &port_stats_rsp.stats, sizeof(*stats)); return 0; } int hinic_set_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type rss_type) { struct nic_rss_context_tbl *ctx_tbl; struct hinic_cmd_buf *cmd_buf; u32 ctx = 0; u64 out_param; int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } cmd_buf = hinic_alloc_cmd_buf(hwdev); if (!cmd_buf) { PMD_DRV_LOG(ERR, "Failed to allocate cmd buf"); return -ENOMEM; } ctx |= HINIC_RSS_TYPE_SET(1, VALID) | HINIC_RSS_TYPE_SET(rss_type.ipv4, IPV4) | HINIC_RSS_TYPE_SET(rss_type.ipv6, IPV6) | HINIC_RSS_TYPE_SET(rss_type.ipv6_ext, IPV6_EXT) | HINIC_RSS_TYPE_SET(rss_type.tcp_ipv4, TCP_IPV4) | HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6, TCP_IPV6) | HINIC_RSS_TYPE_SET(rss_type.tcp_ipv6_ext, TCP_IPV6_EXT) | HINIC_RSS_TYPE_SET(rss_type.udp_ipv4, UDP_IPV4) | HINIC_RSS_TYPE_SET(rss_type.udp_ipv6, UDP_IPV6); cmd_buf->size = sizeof(struct nic_rss_context_tbl); ctx_tbl = (struct nic_rss_context_tbl *)cmd_buf->buf; ctx_tbl->group_index = cpu_to_be32(tmpl_idx); ctx_tbl->offset = 0; ctx_tbl->size = sizeof(u32); ctx_tbl->size = cpu_to_be32(ctx_tbl->size); ctx_tbl->rsvd = 0; ctx_tbl->ctx = cpu_to_be32(ctx); /* cfg the rss context table by command queue */ err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ, HINIC_MOD_L2NIC, HINIC_UCODE_CMD_SET_RSS_CONTEXT_TABLE, cmd_buf, &out_param, 0); hinic_free_cmd_buf(hwdev, cmd_buf); if (err || out_param != 0) { PMD_DRV_LOG(ERR, "Failed to set rss context table"); return -EFAULT; } return 0; } int hinic_get_rss_type(void *hwdev, u32 tmpl_idx, struct nic_rss_type *rss_type) { struct hinic_rss_context_table ctx_tbl; u16 out_size = sizeof(ctx_tbl); int err; if (!hwdev || !rss_type) { PMD_DRV_LOG(ERR, "Hwdev or rss_type is NULL"); return -EINVAL; } ctx_tbl.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; ctx_tbl.func_id = hinic_global_func_id(hwdev); ctx_tbl.template_id = (u8)tmpl_idx; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_CTX_TBL, &ctx_tbl, sizeof(ctx_tbl), &ctx_tbl, &out_size); if (err || !out_size || ctx_tbl.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get hash type, err: %d, status: 0x%x, out size: 0x%x", err, ctx_tbl.mgmt_msg_head.status, out_size); return -EINVAL; } rss_type->ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV4); rss_type->ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6); rss_type->ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, IPV6_EXT); rss_type->tcp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV4); rss_type->tcp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6); rss_type->tcp_ipv6_ext = HINIC_RSS_TYPE_GET(ctx_tbl.context, TCP_IPV6_EXT); rss_type->udp_ipv4 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV4); rss_type->udp_ipv6 = HINIC_RSS_TYPE_GET(ctx_tbl.context, UDP_IPV6); return 0; } int hinic_rss_set_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp) { struct hinic_rss_template_key temp_key; u16 out_size = sizeof(temp_key); int err; if (!hwdev || !temp) { PMD_DRV_LOG(ERR, "Hwdev or temp is NULL"); return -EINVAL; } memset(&temp_key, 0, sizeof(temp_key)); temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; temp_key.func_id = hinic_global_func_id(hwdev); temp_key.template_id = (u8)tmpl_idx; memcpy(temp_key.key, temp, HINIC_RSS_KEY_SIZE); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_TEMPLATE_TBL, &temp_key, sizeof(temp_key), &temp_key, &out_size); if (err || !out_size || temp_key.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set hash key, err: %d, status: 0x%x, out size: 0x%x", err, temp_key.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_rss_get_template_tbl(void *hwdev, u32 tmpl_idx, u8 *temp) { struct hinic_rss_template_key temp_key; u16 out_size = sizeof(temp_key); int err; if (!hwdev || !temp) { PMD_DRV_LOG(ERR, "Hwdev or temp is NULL"); return -EINVAL; } memset(&temp_key, 0, sizeof(temp_key)); temp_key.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; temp_key.func_id = hinic_global_func_id(hwdev); temp_key.template_id = (u8)tmpl_idx; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_TBL, &temp_key, sizeof(temp_key), &temp_key, &out_size); if (err || !out_size || temp_key.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get hash key, err: %d, status: 0x%x, out size: 0x%x", err, temp_key.mgmt_msg_head.status, out_size); return -EINVAL; } memcpy(temp, temp_key.key, HINIC_RSS_KEY_SIZE); return 0; } /** * hinic_rss_set_hash_engine - Init rss hash function . * @hwdev: the hardware interface of a nic device * @tmpl_idx: index of rss template from NIC. * @type: hash function, such as Toeplitz or XOR. * @return * 0 on success and stats is filled, * negative error value otherwise. */ int hinic_rss_set_hash_engine(void *hwdev, u8 tmpl_idx, u8 type) { struct hinic_rss_engine_type hash_type; u16 out_size = sizeof(hash_type); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&hash_type, 0, sizeof(hash_type)); hash_type.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; hash_type.func_id = hinic_global_func_id(hwdev); hash_type.hash_engine = type; hash_type.template_id = tmpl_idx; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RSS_HASH_ENGINE, &hash_type, sizeof(hash_type), &hash_type, &out_size); if (err || !out_size || hash_type.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get hash engine, err: %d, status: 0x%x, out size: 0x%x", err, hash_type.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_rss_set_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table) { struct nic_rss_indirect_tbl *indir_tbl; struct hinic_cmd_buf *cmd_buf; int i; u32 *temp; u32 indir_size; u64 out_param; int err; if (!hwdev || !indir_table) { PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL"); return -EINVAL; } cmd_buf = hinic_alloc_cmd_buf(hwdev); if (!cmd_buf) { PMD_DRV_LOG(ERR, "Failed to allocate cmd buf"); return -ENOMEM; } cmd_buf->size = sizeof(struct nic_rss_indirect_tbl); indir_tbl = cmd_buf->buf; indir_tbl->group_index = cpu_to_be32(tmpl_idx); for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) { indir_tbl->entry[i] = (u8)(*(indir_table + i)); if (0x3 == (i & 0x3)) { temp = (u32 *)&indir_tbl->entry[i - 3]; *temp = cpu_to_be32(*temp); } } /* configure the rss indirect table by command queue */ indir_size = HINIC_RSS_INDIR_SIZE / 2; indir_tbl->offset = 0; indir_tbl->size = cpu_to_be32(indir_size); err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ, HINIC_MOD_L2NIC, HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE, cmd_buf, &out_param, 0); if (err || out_param != 0) { PMD_DRV_LOG(ERR, "Failed to set rss indir table"); err = -EFAULT; goto free_buf; } indir_tbl->offset = cpu_to_be32(indir_size); indir_tbl->size = cpu_to_be32(indir_size); memcpy(indir_tbl->entry, &indir_tbl->entry[indir_size], indir_size); err = hinic_cmdq_direct_resp(hwdev, HINIC_ACK_TYPE_CMDQ, HINIC_MOD_L2NIC, HINIC_UCODE_CMD_SET_RSS_INDIR_TABLE, cmd_buf, &out_param, 0); if (err || out_param != 0) { PMD_DRV_LOG(ERR, "Failed to set rss indir table"); err = -EFAULT; } free_buf: hinic_free_cmd_buf(hwdev, cmd_buf); return err; } int hinic_rss_get_indir_tbl(void *hwdev, u32 tmpl_idx, u32 *indir_table) { struct hinic_rss_indir_table rss_cfg; u16 out_size = sizeof(rss_cfg); int err = 0, i; if (!hwdev || !indir_table) { PMD_DRV_LOG(ERR, "Hwdev or indir_table is NULL"); return -EINVAL; } memset(&rss_cfg, 0, sizeof(rss_cfg)); rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; rss_cfg.func_id = hinic_global_func_id(hwdev); rss_cfg.template_id = (u8)tmpl_idx; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_RSS_TEMPLATE_INDIR_TBL, &rss_cfg, sizeof(rss_cfg), &rss_cfg, &out_size); if (err || !out_size || rss_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get indir table, err: %d, status: 0x%x, out size: 0x%x", err, rss_cfg.mgmt_msg_head.status, out_size); return -EINVAL; } hinic_be32_to_cpu(rss_cfg.indir, HINIC_RSS_INDIR_SIZE); for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) indir_table[i] = rss_cfg.indir[i]; return 0; } int hinic_rss_cfg(void *hwdev, u8 rss_en, u8 tmpl_idx, u8 tc_num, u8 *prio_tc) { struct hinic_rss_config rss_cfg; u16 out_size = sizeof(rss_cfg); int err; /* micro code required: number of TC should be power of 2 */ if (!hwdev || !prio_tc || (tc_num & (tc_num - 1))) { PMD_DRV_LOG(ERR, "Hwdev or prio_tc is NULL, or tc_num: %u Not power of 2", tc_num); return -EINVAL; } memset(&rss_cfg, 0, sizeof(rss_cfg)); rss_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; rss_cfg.func_id = hinic_global_func_id(hwdev); rss_cfg.rss_en = rss_en; rss_cfg.template_id = tmpl_idx; rss_cfg.rq_priority_number = tc_num ? (u8)ilog2(tc_num) : 0; memcpy(rss_cfg.prio_tc, prio_tc, HINIC_DCB_UP_MAX); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_CFG, &rss_cfg, sizeof(rss_cfg), &rss_cfg, &out_size); if (err || !out_size || rss_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set rss cfg, err: %d, status: 0x%x, out size: 0x%x", err, rss_cfg.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } /** * hinic_rss_template_alloc - get rss template id from the chip, * all functions share 96 templates. * @hwdev: the pointer to the private hardware device object * @tmpl_idx: index of rss template from chip. * Return: 0 on success and stats is filled, negative error value otherwise. **/ int hinic_rss_template_alloc(void *hwdev, u8 *tmpl_idx) { struct hinic_rss_template_mgmt template_mgmt; u16 out_size = sizeof(template_mgmt); int err; if (!hwdev || !tmpl_idx) { PMD_DRV_LOG(ERR, "Hwdev or tmpl_idx is NULL"); return -EINVAL; } memset(&template_mgmt, 0, sizeof(template_mgmt)); template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; template_mgmt.func_id = hinic_global_func_id(hwdev); template_mgmt.cmd = NIC_RSS_CMD_TEMP_ALLOC; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR, &template_mgmt, sizeof(template_mgmt), &template_mgmt, &out_size); if (err || !out_size || template_mgmt.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to alloc rss template, err: %d, status: 0x%x, out size: 0x%x", err, template_mgmt.mgmt_msg_head.status, out_size); return -EINVAL; } *tmpl_idx = template_mgmt.template_id; return 0; } /** * hinic_rss_template_alloc - free rss template id to the chip * @hwdev: the hardware interface of a nic device * @tmpl_idx: index of rss template from NIC. * Return: 0 on success and stats is filled, negative error value otherwise. **/ int hinic_rss_template_free(void *hwdev, u8 tmpl_idx) { struct hinic_rss_template_mgmt template_mgmt; u16 out_size = sizeof(template_mgmt); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&template_mgmt, 0, sizeof(template_mgmt)); template_mgmt.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; template_mgmt.func_id = hinic_global_func_id(hwdev); template_mgmt.template_id = tmpl_idx; template_mgmt.cmd = NIC_RSS_CMD_TEMP_FREE; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RSS_TEMP_MGR, &template_mgmt, sizeof(template_mgmt), &template_mgmt, &out_size); if (err || !out_size || template_mgmt.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to free rss template, err: %d, status: 0x%x, out size: 0x%x", err, template_mgmt.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } /** * hinic_set_rx_vhd_mode - change rx buffer size after initialization, * @hwdev: the hardware interface of a nic device * @mode: not needed. * @rx_buf_sz: receive buffer size. * @return * 0 on success and stats is filled, * negative error value otherwise. */ int hinic_set_rx_vhd_mode(void *hwdev, u16 vhd_mode, u16 rx_buf_sz) { struct hinic_set_vhd_mode vhd_mode_cfg; u16 out_size = sizeof(vhd_mode_cfg); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&vhd_mode_cfg, 0, sizeof(vhd_mode_cfg)); vhd_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; vhd_mode_cfg.func_id = hinic_global_func_id(hwdev); vhd_mode_cfg.vhd_type = vhd_mode; vhd_mode_cfg.rx_wqe_buffer_size = rx_buf_sz; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_VHD_CFG, &vhd_mode_cfg, sizeof(vhd_mode_cfg), &vhd_mode_cfg, &out_size); if (err || !out_size || vhd_mode_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set vhd mode, err: %d, status: 0x%x, out size: 0x%x", err, vhd_mode_cfg.mgmt_msg_head.status, out_size); return -EIO; } return 0; } int hinic_set_rx_mode(void *hwdev, u32 enable) { struct hinic_rx_mode_config rx_mode_cfg; u16 out_size = sizeof(rx_mode_cfg); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&rx_mode_cfg, 0, sizeof(rx_mode_cfg)); rx_mode_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; rx_mode_cfg.func_id = hinic_global_func_id(hwdev); rx_mode_cfg.rx_mode = enable; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_MODE, &rx_mode_cfg, sizeof(rx_mode_cfg), &rx_mode_cfg, &out_size); if (err || !out_size || rx_mode_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set rx mode, err: %d, status: 0x%x, out size: 0x%x", err, rx_mode_cfg.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_set_rx_csum_offload(void *hwdev, u32 en) { struct hinic_checksum_offload rx_csum_cfg; u16 out_size = sizeof(rx_csum_cfg); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&rx_csum_cfg, 0, sizeof(rx_csum_cfg)); rx_csum_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; rx_csum_cfg.func_id = hinic_global_func_id(hwdev); rx_csum_cfg.rx_csum_offload = en; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RX_CSUM, &rx_csum_cfg, sizeof(rx_csum_cfg), &rx_csum_cfg, &out_size); if (err || !out_size || rx_csum_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set rx csum offload, err: %d, status: 0x%x, out size: 0x%x", err, rx_csum_cfg.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_set_rx_lro(void *hwdev, u8 ipv4_en, u8 ipv6_en, u8 max_wqe_num) { struct hinic_lro_config lro_cfg; u16 out_size = sizeof(lro_cfg); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&lro_cfg, 0, sizeof(lro_cfg)); lro_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; lro_cfg.func_id = hinic_global_func_id(hwdev); lro_cfg.lro_ipv4_en = ipv4_en; lro_cfg.lro_ipv6_en = ipv6_en; lro_cfg.lro_max_wqe_num = max_wqe_num; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LRO, &lro_cfg, sizeof(lro_cfg), &lro_cfg, &out_size); if (err || !out_size || lro_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x", err, lro_cfg.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } int hinic_set_anti_attack(void *hwdev, bool enable) { struct hinic_port_anti_attack_rate rate; u16 out_size = sizeof(rate); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&rate, 0, sizeof(rate)); rate.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; rate.func_id = hinic_global_func_id(hwdev); rate.enable = enable; rate.cir = ANTI_ATTACK_DEFAULT_CIR; rate.xir = ANTI_ATTACK_DEFAULT_XIR; rate.cbs = ANTI_ATTACK_DEFAULT_CBS; rate.xbs = ANTI_ATTACK_DEFAULT_XBS; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_ANTI_ATTACK_RATE, &rate, sizeof(rate), &rate, &out_size); if (err || !out_size || rate.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "can't %s port Anti-Attack rate limit, err: %d, status: 0x%x, out size: 0x%x", (enable ? "enable" : "disable"), err, rate.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; } /* Set autoneg status and restart port link status */ int hinic_reset_port_link_cfg(void *hwdev) { struct hinic_reset_link_cfg reset_cfg; u16 out_size = sizeof(reset_cfg); int err; memset(&reset_cfg, 0, sizeof(reset_cfg)); reset_cfg.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; reset_cfg.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_RESET_LINK_CFG, &reset_cfg, sizeof(reset_cfg), &reset_cfg, &out_size); if (err || !out_size || reset_cfg.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Reset port link configure failed, err: %d, status: 0x%x, out size: 0x%x", err, reset_cfg.mgmt_msg_head.status, out_size); return -EFAULT; } return 0; } int hinic_set_fast_recycle_mode(void *hwdev, u8 mode) { struct hinic_fast_recycled_mode fast_recycled_mode; u16 out_size = sizeof(fast_recycled_mode); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return -EINVAL; } memset(&fast_recycled_mode, 0, sizeof(fast_recycled_mode)); fast_recycled_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; fast_recycled_mode.func_id = hinic_global_func_id(hwdev); fast_recycled_mode.fast_recycled_mode = mode; err = hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_COMM, HINIC_MGMT_CMD_FAST_RECYCLE_MODE_SET, &fast_recycled_mode, sizeof(fast_recycled_mode), &fast_recycled_mode, &out_size, 0); if (err || fast_recycled_mode.mgmt_msg_head.status || !out_size) { PMD_DRV_LOG(ERR, "Failed to set recycle mode, ret = %d", fast_recycled_mode.mgmt_msg_head.status); return -EFAULT; } return 0; } void hinic_clear_vport_stats(struct hinic_hwdev *hwdev) { struct hinic_clear_vport_stats clear_vport_stats; u16 out_size = sizeof(clear_vport_stats); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return; } memset(&clear_vport_stats, 0, sizeof(clear_vport_stats)); clear_vport_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; clear_vport_stats.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAN_VPORT_STAT, &clear_vport_stats, sizeof(clear_vport_stats), &clear_vport_stats, &out_size); if (err || !out_size || clear_vport_stats.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to clear vport statistics, err: %d, status: 0x%x, out size: 0x%x", err, clear_vport_stats.mgmt_msg_head.status, out_size); } } void hinic_clear_phy_port_stats(struct hinic_hwdev *hwdev) { struct hinic_clear_port_stats clear_phy_port_stats; u16 out_size = sizeof(clear_phy_port_stats); int err; if (!hwdev) { PMD_DRV_LOG(ERR, "Hwdev is NULL"); return; } memset(&clear_phy_port_stats, 0, sizeof(clear_phy_port_stats)); clear_phy_port_stats.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; clear_phy_port_stats.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAR_PORT_STATISTICS, &clear_phy_port_stats, sizeof(clear_phy_port_stats), &clear_phy_port_stats, &out_size); if (err || !out_size || clear_phy_port_stats.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to clear phy port statistics, err: %d, status: 0x%x, out size: 0x%x", err, clear_phy_port_stats.mgmt_msg_head.status, out_size); } } int hinic_set_link_status_follow(void *hwdev, enum hinic_link_follow_status status) { struct hinic_set_link_follow follow; u16 out_size = sizeof(follow); int err; if (!hwdev) return -EINVAL; if (status >= HINIC_LINK_FOLLOW_STATUS_MAX) { PMD_DRV_LOG(ERR, "Invalid link follow status: %d", status); return -EINVAL; } memset(&follow, 0, sizeof(follow)); follow.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; follow.func_id = hinic_global_func_id(hwdev); follow.follow_status = status; err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_LINK_FOLLOW, &follow, sizeof(follow), &follow, &out_size); if ((follow.mgmt_msg_head.status != HINIC_MGMT_CMD_UNSUPPORTED && follow.mgmt_msg_head.status) || err || !out_size) { PMD_DRV_LOG(ERR, "Failed to set link status follow phy port status, err: %d, status: 0x%x, out size: 0x%x", err, follow.mgmt_msg_head.status, out_size); return -EFAULT; } return follow.mgmt_msg_head.status; } int hinic_get_link_mode(void *hwdev, u32 *supported, u32 *advertised) { struct hinic_link_mode_cmd link_mode; u16 out_size = sizeof(link_mode); int err; if (!hwdev || !supported || !advertised) return -EINVAL; memset(&link_mode, 0, sizeof(link_mode)); link_mode.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; link_mode.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_GET_LINK_MODE, &link_mode, sizeof(link_mode), &link_mode, &out_size); if (err || !out_size || link_mode.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to get link mode, err: %d, status: 0x%x, out size: 0x%x", err, link_mode.mgmt_msg_head.status, out_size); return -EINVAL; } *supported = link_mode.supported; *advertised = link_mode.advertised; return 0; } /** * hinic_flush_qp_res - Flush tx && rx chip resources in case of set vport fake * failed when device start. * @hwdev: the hardware interface of a nic device * Return: 0 on success, negative error value otherwise. **/ int hinic_flush_qp_res(void *hwdev) { struct hinic_clear_qp_resource qp_res; u16 out_size = sizeof(qp_res); int err; memset(&qp_res, 0, sizeof(qp_res)); qp_res.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1; qp_res.func_id = hinic_global_func_id(hwdev); err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_CLEAR_QP_RES, &qp_res, sizeof(qp_res), &qp_res, &out_size); if (err || !out_size || qp_res.mgmt_msg_head.status) { PMD_DRV_LOG(ERR, "Failed to clear sq resources, err: %d, status: 0x%x, out size: 0x%x", err, qp_res.mgmt_msg_head.status, out_size); return -EINVAL; } return 0; }
28.949883
97
0.721686
[ "object" ]
7dbebb5f8fa6f8ed7fb0fc762c70ff4549b53f21
4,003
h
C
google/cloud/internal/source_ready_token.h
EdvardD/google-cloud-cpp
024c43839c9528c1fd61fecf141c9b8f1e0d4b58
[ "Apache-2.0" ]
null
null
null
google/cloud/internal/source_ready_token.h
EdvardD/google-cloud-cpp
024c43839c9528c1fd61fecf141c9b8f1e0d4b58
[ "Apache-2.0" ]
null
null
null
google/cloud/internal/source_ready_token.h
EdvardD/google-cloud-cpp
024c43839c9528c1fd61fecf141c9b8f1e0d4b58
[ "Apache-2.0" ]
null
null
null
// Copyright 2020 Google LLC // // 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. #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_SOURCE_READY_TOKEN_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_SOURCE_READY_TOKEN_H #include "google/cloud/future.h" #include "google/cloud/version.h" #include <deque> namespace google { namespace cloud { inline namespace GOOGLE_CLOUD_CPP_NS { namespace internal { /** * A token to request more data from a `source<T, E>`. * * Some instances of `source<T, E>` can have at most N (typically 1) calls * outstanding. Users of these `source<T, E>` objects must obtain a token before * calling `next()`. These tokens are returned as futures only satisfied when * the number of outstanding requests is within limits. * * This is a move-only class and the move constructor and move assignments * invalidate the source object. */ class ReadyToken { public: ReadyToken() = default; ReadyToken(ReadyToken const&) = delete; ReadyToken& operator=(ReadyToken const&) = delete; /// Move constructor, invalidates @p rhs ReadyToken(ReadyToken&& rhs) noexcept : value_(rhs.value_) { rhs.value_ = nullptr; } /// Move assignment, invalidates @p rhs ReadyToken& operator=(ReadyToken&& rhs) noexcept { value_ = rhs.value_; rhs.value_ = nullptr; return *this; } bool valid() const { return value_ != nullptr; } explicit operator bool() const { return valid(); } private: friend class ReadyTokenFlowControl; explicit ReadyToken(void const* v) : value_(v) {} void const* value_ = nullptr; }; /** * Helper class to flow control based on `ReadyToken`. * * This class is used by `source<T, E>` implementations when they want to flow * control the number of outstanding `ReadyToken()` objects. * * @par Thread Safety * * The move constructor and move assignment operations are *not* thread-safe, * neither the source nor the destination object (for assignment) may be used * by more than one thread. * * Other member functions are thread-safe, more than one thread may call these * functions simultaneously. */ class ReadyTokenFlowControl { public: explicit ReadyTokenFlowControl(int max_outstanding = 1) : max_outstanding_(max_outstanding) {} ReadyTokenFlowControl(ReadyTokenFlowControl&& rhs) noexcept : current_outstanding_(rhs.current_outstanding_), max_outstanding_(rhs.max_outstanding_), pending_(std::move(rhs.pending_)) {} ReadyTokenFlowControl& operator=(ReadyTokenFlowControl&& rhs) noexcept { ReadyTokenFlowControl tmp(std::move(rhs)); using std::swap; swap(current_outstanding_, tmp.current_outstanding_); swap(max_outstanding_, tmp.max_outstanding_); swap(pending_, tmp.pending_); return *this; } /// The maximum number of outstanding tokens. int max_outstanding() const { return max_outstanding_; } /** * Asynchronously acquire a new `ReadyToken`. * * The returned future is satisfied when/if there are less outstanding tokens * than max_outstanding(). */ future<ReadyToken> Acquire(); /// Reclaim a token, return false if it was not created by this object. bool Release(ReadyToken token); private: std::mutex mu_; int current_outstanding_ = 0; int max_outstanding_ = 1; std::deque<promise<ReadyToken>> pending_; }; } // namespace internal } // namespace GOOGLE_CLOUD_CPP_NS } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_INTERNAL_SOURCE_READY_TOKEN_H
31.519685
80
0.732451
[ "object" ]
7dbf1ff4b2bb5f3f842ee7acbdf9336a7984d0f1
2,273
h
C
Rosewood/src/Rosewood/Graphics/2D/Sprite.h
dovker/Rosewood
5131a061632732222ce68e5da5a257b8bda36ea5
[ "Apache-2.0" ]
1
2020-10-02T15:59:00.000Z
2020-10-02T15:59:00.000Z
Rosewood/src/Rosewood/Graphics/2D/Sprite.h
dovker/Rosewood
5131a061632732222ce68e5da5a257b8bda36ea5
[ "Apache-2.0" ]
null
null
null
Rosewood/src/Rosewood/Graphics/2D/Sprite.h
dovker/Rosewood
5131a061632732222ce68e5da5a257b8bda36ea5
[ "Apache-2.0" ]
null
null
null
#pragma once #include "rwpch.h" #include <glm/glm.hpp> #include "Rosewood/Graphics/2D/RenderItem2D.h" namespace Rosewood { struct Animation2D { float Speed = 1; //Seconds Per Frame TODO: FIX THIS uint32_t Frame = 0; uint32_t TotalFrames = 1; bool Playing = false; bool Loops = true; Animation2D() {} Animation2D(float speed, uint32_t frames, bool loops = true, bool playing = true) : Speed(speed), TotalFrames(frames), Loops(loops), Playing(playing){} }; struct Offset2D { glm::vec2 Pivot = {0.0f, 0.0f}; bool FlippedX = false; bool FlippedY = false; Offset2D() {} }; // struct NineSlice2D //TODO: IMPLEMENT THIS // { // bool Enabled = false; // Rect SourceRect; // }; class Sprite : public RenderItem2D { public: Ref<Texture> SpriteTexture; Rect SourceRect; Animation2D Animation; Offset2D Offset; Rect GetBounds(const Transform& transform) { glm::vec2 scale = {transform.Scale.x, transform.Scale.y}; return Rect(glm::vec2(transform.Position.x, transform.Position.y) + (SourceRect.RelativeWidth() * scale) * Offset.Pivot, SourceRect.RelativeWidth() * scale);//TODO: FIXXXXXX } Sprite() : SpriteTexture(nullptr), RenderItem2D(glm::vec4(1.0f), false) {} Sprite(Ref<Rosewood::Texture> texture, glm::vec4 color = glm::vec4(1.0f), bool transparent = false) :SpriteTexture(texture), RenderItem2D(color, transparent), SourceRect(Rect(texture)) {} Sprite(const std::string& spriteName); Sprite(Ref<Rosewood::Texture> texture, glm::vec4 color, bool transparent, Rect sourceRect, Offset2D offset, Animation2D animation) :SpriteTexture(texture), RenderItem2D(color, transparent), SourceRect(sourceRect), Offset(offset), Animation(animation) {} virtual void Draw(Transform transform) override; void ReloadTexture(const std::string& textureName); void ResetSourceRect() { SourceRect = Rect(SpriteTexture); } private: float timer = 0.0f; }; }
30.716216
138
0.601848
[ "transform" ]
7dc9241bad71f0030fc9f48f94489e5763e62356
4,294
c
C
scripts/HiCorrector_1.2/src/export_norm_data.c
Princeton-LSI-ResearchComputing/sprite-pipeline
5e11a588df9a70a98d167956af471880669a18f5
[ "MIT" ]
15
2018-05-04T16:15:30.000Z
2022-02-07T20:15:11.000Z
scripts/HiCorrector_1.2/src/export_norm_data.c
Princeton-LSI-ResearchComputing/sprite-pipeline
5e11a588df9a70a98d167956af471880669a18f5
[ "MIT" ]
3
2018-07-03T19:30:10.000Z
2020-03-25T18:29:51.000Z
scripts/HiCorrector_1.2/src/export_norm_data.c
Princeton-LSI-ResearchComputing/sprite-pipeline
5e11a588df9a70a98d167956af471880669a18f5
[ "MIT" ]
4
2018-11-05T12:40:06.000Z
2022-02-07T20:15:29.000Z
/* * export_norm_data.c * * Created on: March 24, 2015 * Author: Wenyuan Li */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "matutils.h" void print_usage(FILE* stream) { fprintf(stream, "Usage:\n"); fprintf(stream, "\texport_norm_data <input raw matrix file> <#rows/columns> <has header line in input file?> <has header column input file?> <memory size (MB)> <input bias vector file> <fixed row sum after normalization> <output normalized matrix file>\n"); // fprintf(stream, "\nOptions:\n\t<output file format>: FULL_MATRIX_TEXT\n"); fprintf(stream, "\nVersion: 1.2\n"); fprintf(stream, "\nAuthor: Wenyuan Li\n"); fprintf(stream, "Date: March 24, 2015\n"); } int main(int argc, char *argv[]) { int ret, i; char input_mat_file[MAXCHAR], input_bias_vec_file[MAXCHAR]; float mem_size_of_task; int part_size; float x; float row_sum_=1.0; float row_sum_after_norm=1.0; int total_column; int has_header_line; int has_header_column; char output_file[MAXCHAR]; VEC_FLOAT bias_vec; VEC_INT part_sizes; int start_row, end_row; MATRIX_FLOAT mat; // submatrix loaded, its size is "4*part_size*total_column" bytes (float is 4 bytes in both 32bit and 64bit machine: see http://docs.oracle.com/cd/E18752_01/html/817-6223/chp-typeopexpr-2.html) if (argc!=9) { fprintf(stderr,"Error: export_norm_data arguments are insufficient.\n\n"); print_usage(stderr); exit(EXIT_FAILURE); } strcpy(input_mat_file, argv[1]); total_column = atoi(argv[2]); has_header_line = atoi(argv[3]); has_header_column = atoi(argv[4]); mem_size_of_task = (float)atof(argv[5]); strcpy(input_bias_vec_file, argv[6]); row_sum_after_norm = (float)atof(argv[7]); strcpy(output_file, argv[8]); printf("export_norm_data arguments:\n"); printf("\tinput raw matrix file: %s\n", input_mat_file); printf("\t\thas header line: %d\n", has_header_line); printf("\t\thas header column: %d\n", has_header_column); printf("\ttotal_rows: %d\n", total_column); printf("\tinput bias vector file: %s\n", input_bias_vec_file); printf("\tmemory size for this job: %g MB\n", mem_size_of_task); printf("\trow sum after normalization: %f\n", row_sum_after_norm); printf("\toutput file: %s\n", output_file); fflush( stdout ); ret = quick_check_partitions_by_mem_size(total_column, total_column, mem_size_of_task, &x); if (ret==FALSE) { fprintf(stderr, "Error: max_memory_size (%gMB) for this task cannot afford to load the matrix (size=%d rows X %d columns, each row as a partition needs %lf MB memory)\n", mem_size_of_task, total_column, total_column, x); exit(EXIT_FAILURE); } calc_partitions_by_mem_size(total_column, total_column, mem_size_of_task, &part_sizes); part_size = max_VEC_INT(part_sizes); printf("All data is divided to %d parts: ", part_sizes.n); put_VEC_INT(stdout, part_sizes, ", "); printf("\npartition sizes (%d partitions): ", part_sizes.n); put_VEC_INT(stdout, part_sizes, ", "); printf("\n"); init_VEC_FLOAT( &bias_vec ); ret = read_VEC_FLOAT( &bias_vec, input_bias_vec_file ); if (ret==0) { fprintf(stderr, "Error: Wrong reading %s\n", input_bias_vec_file); exit(EXIT_FAILURE); } init_MATRIX_FLOAT( &mat ); for (i=0, start_row=1; i<part_sizes.n; i++) { // the i-th part // start_row and end_row are 1-based index end_row = start_row + part_sizes.v[i] - 1; printf("\tPart %d:\t%d\t%d\n", i+1, start_row, end_row); ret = read_efficient_MATRIX_FLOAT_with_header(input_mat_file, start_row, end_row, total_column, has_header_line, has_header_column, &mat); if (ret==EXIT_SUCCESS) { // update matrix: B = diag(1./d_save)*A*diag(1./d_save); elementwise_div_vector_MATRIX_FLOAT( &mat, bias_vec); if (i==0) { row_sum_ = norm1_float(mat.v[0], mat.total_column) / row_sum_after_norm; } elementwise_div_value_MATRIX_FLOAT( &mat, row_sum_ ); // append this matrix to file if (i==0) write_MATRIX_FLOAT(output_file, mat); else append_MATRIX_FLOAT_text(output_file, mat); } else { fprintf(stderr, "Error: Wrong reading on lines %d - %d\n", start_row, end_row); exit(EXIT_FAILURE); } start_row = end_row + 1; } // free space free_VEC_INT( &part_sizes ); free_MATRIX_FLOAT( &mat ); free_VEC_FLOAT( &bias_vec ); printf("Done.\n"); return EXIT_SUCCESS; }
35.487603
258
0.714485
[ "vector" ]
7dd8d957c53c3b4e32984115d479b58fb4ae09b7
843
h
C
C&CPP/00-Code/cpp-program-basic/007-oop/friend_class.h
hiloWang/notes
64a637a86f734e4e80975f4aa93ab47e8d7e8b64
[ "Apache-2.0" ]
2
2020-10-08T13:22:08.000Z
2021-07-28T14:45:41.000Z
C&C++/cplusplus-program/007-oop/friend_class.h
flyfire/Programming-Notes-Code
4b1bdd74c1ba0c007c504834e4508ec39f01cd94
[ "Apache-2.0" ]
null
null
null
C&C++/cplusplus-program/007-oop/friend_class.h
flyfire/Programming-Notes-Code
4b1bdd74c1ba0c007c504834e4508ec39f01cd94
[ "Apache-2.0" ]
6
2020-08-20T07:19:17.000Z
2022-03-02T08:16:21.000Z
/* ============================================================================ Author : Ztiany Description : 友元 ============================================================================ */ #ifndef C_BASIC_FRIEND_CLASS_H #define C_BASIC_FRIEND_CLASS_H #include <iostream> #include <vector> class Box { private: double width; public: void setWidth(double wid); public://友元放在一起 friend void printWidth(Box box); friend class Friend; }; // 成员函数定义 void Box::setWidth(double wid) { width = wid; } // 请注意:printWidth() 不是任何类的成员函数 void printWidth(Box box) { /* 因为 printWidth() 是 Box 的友元,它可以直接访问该类的任何成员 */ std::cout << "Width of box : " << box.width << std::endl; } //这是一个友元类 class Friend { public: double getBoxWidth(Box box) { return box.width; } }; #endif //C_BASIC_FRIEND_CLASS_H
17.5625
77
0.534994
[ "vector" ]
7dd91d3de600185bc5616612ed8244dfe91a6ae9
536
h
C
pkg/core/src/atpg_mgr.h
DavidLin2015/AtpgSystem
818b6233cbdfb850c880a328e124e5fde3612f30
[ "CECILL-B" ]
null
null
null
pkg/core/src/atpg_mgr.h
DavidLin2015/AtpgSystem
818b6233cbdfb850c880a328e124e5fde3612f30
[ "CECILL-B" ]
null
null
null
pkg/core/src/atpg_mgr.h
DavidLin2015/AtpgSystem
818b6233cbdfb850c880a328e124e5fde3612f30
[ "CECILL-B" ]
1
2021-01-26T08:26:15.000Z
2021-01-26T08:26:15.000Z
#ifndef _CORE_ATPG_MGR_H_ #define _CORE_ATPG_MGR_H_ #include "atpg.h" namespace CoreNs { typedef std::vector<Atpg*> AtpgVec; class AtpgMgr { public: AtpgMgr(); ~AtpgMgr(); Circuit *cir_; FaultMgr *f_mgr_; PatternMgr *pat_mgr_; private: AtpgVec atpgs_; }; //AtpgMgr inline AtpgMgr::AtpgMgr() { cir_ = NULL; f_mgr_ = NULL; pat_mgr_ = NULL; } inline AtpgMgr::~AtpgMgr() { //TODO } }; //CoreNs #endif //_CORE_CMD_MGR_H_
14.486486
37
0.565299
[ "vector" ]
7de3d812a73db12226b5fd8712369e40f1b59611
9,018
c
C
applications/msPlugin/ms3dsdk184/ms3dsdk/specs/ms3dspec.txt.c
rastullahs-lockenpracht/newton
99b82478f3de9ee7c8d17c8ebefe62e46283d857
[ "Zlib" ]
null
null
null
applications/msPlugin/ms3dsdk184/ms3dsdk/specs/ms3dspec.txt.c
rastullahs-lockenpracht/newton
99b82478f3de9ee7c8d17c8ebefe62e46283d857
[ "Zlib" ]
null
null
null
applications/msPlugin/ms3dsdk184/ms3dsdk/specs/ms3dspec.txt.c
rastullahs-lockenpracht/newton
99b82478f3de9ee7c8d17c8ebefe62e46283d857
[ "Zlib" ]
null
null
null
// // // // MilkShape 3D 1.8.2 File Format Specification // // // This specifcation is written in C style. // // // The data structures are defined in the order as they appear in the .ms3d file. // // // // // // // max values // #define MAX_VERTICES 65534 #define MAX_TRIANGLES 65534 #define MAX_GROUPS 255 #define MAX_MATERIALS 128 #define MAX_JOINTS 128 // // flags // #define SELECTED 1 #define HIDDEN 2 #define SELECTED2 4 #define DIRTY 8 // // types // #ifndef byte typedef unsigned char byte; #endif // byte #ifndef word typedef unsigned short word; #endif // word // force one byte alignment #include <pshpack1.h> // // First comes the header (sizeof(ms3d_header_t) == 14) // typedef struct { char id[10]; // always "MS3D000000" int version; // 4 } ms3d_header_t; // // Then comes the number of vertices // word nNumVertices; // 2 bytes // // Then come nNumVertices times ms3d_vertex_t structs (sizeof(ms3d_vertex_t) == 15) // typedef struct { byte flags; // SELECTED | SELECTED2 | HIDDEN float vertex[3]; // char boneId; // -1 = no bone byte referenceCount; } ms3d_vertex_t; // // Then comes the number of triangles // word nNumTriangles; // 2 bytes // // Then come nNumTriangles times ms3d_triangle_t structs (sizeof(ms3d_triangle_t) == 70) // typedef struct { word flags; // SELECTED | SELECTED2 | HIDDEN word vertexIndices[3]; // float vertexNormals[3][3]; // float s[3]; // float t[3]; // byte smoothingGroup; // 1 - 32 byte groupIndex; // } ms3d_triangle_t; // // Then comes the number of groups // word nNumGroups; // 2 bytes // // Then come nNumGroups times groups (the sizeof a group is dynamic, because of triangleIndices is numtriangles long) // typedef struct { byte flags; // SELECTED | HIDDEN char name[32]; // word numtriangles; // word triangleIndices[numtriangles]; // the groups group the triangles char materialIndex; // -1 = no material } ms3d_group_t; // // number of materials // word nNumMaterials; // 2 bytes // // Then come nNumMaterials times ms3d_material_t structs (sizeof(ms3d_material_t) == 361) // typedef struct { char name[32]; // float ambient[4]; // float diffuse[4]; // float specular[4]; // float emissive[4]; // float shininess; // 0.0f - 128.0f float transparency; // 0.0f - 1.0f char mode; // 0, 1, 2 is unused now char texture[128]; // texture.bmp char alphamap[128]; // alpha.bmp } ms3d_material_t; // // save some keyframer data // float fAnimationFPS; // 4 bytes float fCurrentTime; // 4 bytes int iTotalFrames; // 4 bytes // // number of joints // word nNumJoints; // 2 bytes // // Then come nNumJoints joints (the size of joints are dynamic, because each joint has a differnt count of keys // typedef struct // 16 bytes { float time; // time in seconds float rotation[3]; // x, y, z angles } ms3d_keyframe_rot_t; typedef struct // 16 bytes { float time; // time in seconds float position[3]; // local position } ms3d_keyframe_pos_t; typedef struct { byte flags; // SELECTED | DIRTY char name[32]; // char parentName[32]; // float rotation[3]; // local reference matrix float position[3]; word numKeyFramesRot; // word numKeyFramesTrans; // ms3d_keyframe_rot_t keyFramesRot[numKeyFramesRot]; // local animation matrices ms3d_keyframe_pos_t keyFramesTrans[numKeyFramesTrans]; // local animation matrices } ms3d_joint_t; // // Then comes the subVersion of the comments part, which is not available in older files // int subVersion; // subVersion is = 1, 4 bytes // Then comes the numer of group comments unsigned int nNumGroupComments; // 4 bytes // // Then come nNumGroupComments times group comments, which are dynamic, because the comment can be any length // typedef struct { int index; // index of group, material or joint int commentLength; // length of comment (terminating '\0' is not saved), "MC" has comment length of 2 (not 3) char comment[commentLength]; // comment } ms3d_comment_t; // Then comes the number of material comments int nNumMaterialComments; // 4 bytes // // Then come nNumMaterialComments times material comments, which are dynamic, because the comment can be any length // // Then comes the number of joint comments int nNumJointComments; // 4 bytes // // Then come nNumJointComments times joint comments, which are dynamic, because the comment can be any length // // Then comes the number of model comments, which is always 0 or 1 int nHasModelComment; // 4 bytes // // Then come nHasModelComment times model comments, which are dynamic, because the comment can be any length // // Then comes the subversion of the vertex extra information like bone weights, extra etc. int subVersion; // subVersion is = 2, 4 bytes // ms3d_vertex_ex_t for subVersion == 1 typedef struct { char boneIds[3]; // index of joint or -1, if -1, then that weight is ignored, since subVersion 1 byte weights[3]; // vertex weight ranging from 0 - 255, last weight is computed by 1.0 - sum(all weights), since subVersion 1 // weight[0] is the weight for boneId in ms3d_vertex_t // weight[1] is the weight for boneIds[0] // weight[2] is the weight for boneIds[1] // 1.0f - weight[0] - weight[1] - weight[2] is the weight for boneIds[2] } ms3d_vertex_ex_t; // ms3d_vertex_ex_t for subVersion == 2 typedef struct { char boneIds[3]; // index of joint or -1, if -1, then that weight is ignored, since subVersion 1 byte weights[3]; // vertex weight ranging from 0 - 100, last weight is computed by 1.0 - sum(all weights), since subVersion 1 // weight[0] is the weight for boneId in ms3d_vertex_t // weight[1] is the weight for boneIds[0] // weight[2] is the weight for boneIds[1] // 1.0f - weight[0] - weight[1] - weight[2] is the weight for boneIds[2] unsigned int extra; // vertex extra, which can be used as color or anything else, since subVersion 2 } ms3d_vertex_ex_t; // Then comes nNumVertices times ms3d_vertex_ex_t structs (sizeof(ms3d_vertex_ex_t) == 10) // Then comes the subversion of the joint extra information like color etc. int subVersion; // subVersion is = 2, 4 bytes // ms3d_joint_ex_t for subVersion == 1 typedef struct { float color[3]; // joint color, since subVersion == 1 } ms3d_joint_ex_t; // Then comes nNumJoints times ms3d_joint_ex_t structs (sizeof(ms3d_joint_ex_t) == 12) // Then comes the subversion of the model extra information int subVersion; // subVersion is = 1, 4 bytes // ms3d_model_ex_t for subVersion == 1 typedef struct { float jointSize; // joint size, since subVersion == 1 int transparencyMode; // 0 = simple, 1 = depth buffered with alpha ref, 2 = depth sorted triangles, since subVersion == 1 float alphaRef; // alpha reference value for transparencyMode = 1, since subVersion == 1 } ms3d_model_ex_t; #include <poppack.h> // // Mesh Transformation: // // 0. Build the transformation matrices from the rotation and position // 1. Multiply the vertices by the inverse of local reference matrix (lmatrix0) // 2. then translate the result by (lmatrix0 * keyFramesTrans) // 3. then multiply the result by (lmatrix0 * keyFramesRot) // // For normals skip step 2. // // // // NOTE: this file format may change in future versions! // // // - Mete Ciragan //
31.096552
135
0.567753
[ "mesh", "model", "3d" ]
7de9a0dd30ae1e3c2252d46cf1a82f32fc466afc
1,808
h
C
GL1/src/Shader.h
FUHUZHENSUNBO/GL1
b4344b710926e9d9052eec445ea948fabd79ff32
[ "Apache-2.0" ]
null
null
null
GL1/src/Shader.h
FUHUZHENSUNBO/GL1
b4344b710926e9d9052eec445ea948fabd79ff32
[ "Apache-2.0" ]
null
null
null
GL1/src/Shader.h
FUHUZHENSUNBO/GL1
b4344b710926e9d9052eec445ea948fabd79ff32
[ "Apache-2.0" ]
null
null
null
#pragma once #include<iostream> #include<cstring> #include<unordered_map> #include<vector> #include<GL/glew.h> #include <glm/gtc/matrix_transform.hpp> struct ShaderProgaramSource { std::string VertexSource; std::string FragmentSource; }; class Shader { private: std::string m_FilePath; unsigned int m_RendererID; std::unordered_map<std::string, int> m_UniformLocationCache; public: Shader(const std::string& filepath); ~Shader(); void Bind()const; void UnBind()const; //Set Uniform void SetUniform1i(const std::string& name, int value); void SetUniform1f(const std::string& name, float value); void SetUniform2f(const std::string& name, float v0, float v1); void SetUniform2f(const std::string& name, const glm::vec2& value); void SetUniform3f(const std::string& name, float v0, float v1, float v2); void SetUniform3f(const std::string& name, const glm::vec3& value); void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3); void SetUniform4f(const std::string& name, const glm::vec4& value); void SetUniformMat3(const std::string& name, const glm::mat3& proMat); void SetUniformMat4(const std::string& name, const glm::mat4& proMat); private: /// <summary> /// /// </summary> /// <param name="filepath"></param> /// <returns></returns> ShaderProgaramSource ParseShader(const std::string& filepath); /// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="type"></param> /// <returns></returns> unsigned int CompileShader(const std::string& src, unsigned int type); /// <summary> /// /// </summary> unsigned int CreateShader(const std::string& SourceOfVertexShader, const std::string& SourceOfFragmentShader); /// <summary> /// /// </summary> int GetUniformLocation(const std::string& name); };
24.432432
111
0.706305
[ "vector" ]
7deee6661bc0a5963893f0693249e588a199b6b3
3,262
c
C
d/avatars/nienne/fatedomain.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/avatars/nienne/fatedomain.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
null
null
null
d/avatars/nienne/fatedomain.c
gesslar/shadowgate
97ce5d33a2275bb75c0cf6556602564b7870bc77
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> inherit OBJECT; void create() { ::create(); set_name("woven tapestry"); set_id(({"tapestry","woven tapestry","tapestry of fate","tapestry of stars"})); set_short("%^RESET%^%^BLUE%^Tapestry of %^YELLOW%^S%^BOLD%^%^WHITE%^t%^YELLOW%^a%^BOLD%^%^WHITE%^r%^YELLOW%^s%^RESET%^"); set_long("%^RESET%^%^CYAN%^This small, beautiful work of art is only a little wider than a handspan. Set upon a light %^ORANGE%^timber %^CYAN%^frame, " "lines of soft thread weave back and forth across its surface to shape a %^BLUE%^velvety backdrop %^CYAN%^of night spotted with %^RESET%^pale stars" "%^CYAN%^. Metallic traces have been incorporated to lend faint %^BOLD%^%^WHITE%^s%^RESET%^p%^BOLD%^%^BLACK%^a%^RESET%^r%^BOLD%^%^WHITE%^k%^RESET%^l" "%^BOLD%^%^BLACK%^e%^RESET%^s %^CYAN%^to each of the stars in turn, gleaming brightly with any motion. As you watch, a faint %^BOLD%^%^CYAN%^aura " "%^RESET%^%^CYAN%^seems to pulse forth from the tapestry itself, giving you a desire to simply abandon the trophy and begone from its presence.%^RESET%^"); set_lore("Tales tell of such talismans as this, in the possession of " "the very gods themselves. Each contains the power of a domain of " "influence, and is bound to the deity that controls that domain. The gods " "guard these jealously, with intense magics to ward them, including " "protections that would cause any mere mortal who finds them to stop at " "nothing to be rid of their presence. Generally the only ones who can " "bear to hold such an item are the gods themselves, or the chosen of the " "deity who possesses the domain in question. But, for some rare few mortals " "whose hearts are in true attunement, they may also take up such relics " "and in doing so, become something more than mortal themselves.\n\n" "This particular relic is known as the Tapestry of Stars, and is said to " "grant power over the domain of fate and destiny.\n"); set_property("lore difficulty",45); set_weight(0); set_value(0); set_heart_beat(1); } void heart_beat(){ if(!userp(ETO)) return; if(!interactive(ETO)) return; if((string)ETO->query_name() != "sadhara" && !avatarp(ETO)) { tell_object(ETO,"%^CYAN%^As you take up the tapestry, a vision of " "%^BLUE%^velvet darkness %^CYAN%^fills your senses and obscures the world " "around you. %^RESET%^Stars %^CYAN%^are born upon the blanket of night, as " "dust collects around them and forms rock, water and air, and your mind " "whirls to try and comprehend the countless formations. %^GREEN%^Life " "%^CYAN%^blossoms across the constellations, its myriad forms taking shape " "and it is all you can do to retain consciousness as the immensity of it all " "threatens to overwhelm you.\n\n%^GREEN%^And then quite suddenly the world " "around you reasserts itself, and you realise you have dropped the tapestry.%^RESET%^"); tell_room(EETO,"%^CYAN%^"+ETO->QCN+"'s eyes grow glazed as " +ETO->QP+" breathing grows shallow, and "+ETO->QP+" pupils dart sightlessly " "to and fro. "+capitalize(ETO->QP)+" lips part, hands twitching until " "the tapestry falls from "+ETO->QP+" fingers, and suddenly "+ETO->QS+ " is normal again!%^RESET%^",ETO); ETO->force_me("drop tapestry of fate"); } } int isMagic(){ return 8; }
58.25
155
0.707848
[ "object", "shape" ]
7df495565da0012ba2b2c50bda3d69dd97d5498e
1,870
h
C
source/mono/MonoLibLoader.h
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
source/mono/MonoLibLoader.h
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
source/mono/MonoLibLoader.h
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
#pragma once #include <Windows.h> #include <TlHelp32.h> #include <thread> #include <iostream> #include <winnt.h> #include <queue> typedef DWORD(*LP_mono_security_get_mode)(); typedef void*(*LP_mono_security_set_mode)(DWORD mode); typedef void*(*LP_mono_domain_get)(); typedef void*(*LP_mono_domain_assembly_open)(void* domain, const char* file); typedef void*(*LP_mono_assembly_get_image)(void* assembly); typedef void*(*LP_mono_class_from_name)(void* image, const char* _namespace, const char* name); typedef void*(*LP_mono_class_get_method_from_name)(void* _class, const char* name, DWORD params); typedef void*(*LP_mono_runtime_invoke)(void* method, void* object, void* arguments, void* exception); struct MonoDLL { HMODULE dll; LP_mono_security_get_mode mono_security_get_mode; LP_mono_security_set_mode mono_security_set_mode; LP_mono_domain_get mono_domain_get; LP_mono_domain_assembly_open mono_domain_assembly_open; LP_mono_assembly_get_image mono_assembly_get_image; LP_mono_class_from_name mono_class_from_name; LP_mono_class_get_method_from_name mono_class_get_method_from_name; LP_mono_runtime_invoke mono_runtime_invoke; }; struct LibInfo { std::string library; std::string nameSpace; std::string className; std::string initializerMethodName; LibInfo(std::string library, std::string nameSpace, std::string className, std::string initializerMethodName) { this->library = library; this->nameSpace = nameSpace; this->className = className; this->initializerMethodName = initializerMethodName; } }; class MonoLibLoader { public: static MonoLibLoader* GetInstance(); MonoDLL monoDll; std::vector<LibInfo> LibsToLoad; void StartThread(); void DoThreadWork(MonoLibLoader* object) { object->Inject(); }; void Deinject(const WCHAR* text); private: void Inject(); static MonoLibLoader* instance; std::thread loaderThread; };
29.68254
110
0.796257
[ "object", "vector" ]
7df54f8643933650bd58c09349a1bcfc7ec002e1
4,279
h
C
minisam/utils/testAssertions.h
versatran01/minisam
b3840d2629551fdfa287df8aac2e7956873d2b0e
[ "BSD-3-Clause" ]
338
2019-09-03T10:44:08.000Z
2022-03-31T12:12:08.000Z
minisam/utils/testAssertions.h
bhsphd/minisam
ef84796fa11ac6e5e4d4aa9d60d9b94a99a973fb
[ "BSD-3-Clause" ]
23
2019-09-26T09:00:43.000Z
2022-01-04T06:04:02.000Z
minisam/utils/testAssertions.h
bhsphd/minisam
ef84796fa11ac6e5e4d4aa9d60d9b94a99a973fb
[ "BSD-3-Clause" ]
87
2019-09-04T05:17:07.000Z
2022-02-23T09:47:23.000Z
/** * @file testAssertions.h * @brief Utils for calculating numerical Jacobians * @author Jing Dong * @date Sep 14, 2018 */ #pragma once // Eigen/scalar traits implementation needed for assert_equal #include <minisam/core/Eigen.h> #include <minisam/core/Traits.h> #include <minisam/core/Variables.h> #include <Eigen/Core> #include <Eigen/SparseCore> #include <cmath> #include <iostream> #include <type_traits> #include <vector> namespace minisam { /// equal of intergers template <class T, class = typename std::enable_if<std::is_integral<T>::value>::type> bool assert_equal(T expected, T actual) { if (expected != actual) { std::cout << "Not equal:" << std::endl << "expected: " << expected << std::endl << "actual: " << actual << std::endl; return false; } return true; } /// equal of manifold types given tolerance template <class T, class = typename std::enable_if<!std::is_integral<T>::value>::type> bool assert_equal(const T& expected, const T& actual, double tol = 1e-9) { static_assert(is_manifold<T>::value, "assert_equal<T> request input T type must be a manifold"); // check dim if (traits<T>::Dim(expected) != traits<T>::Dim(actual)) { std::cout << "Not equal:" << std::endl << "expected dimension: " << traits<T>::Dim(expected) << std::endl << "actual dimension: " << traits<T>::Dim(actual) << std::endl; return false; } // check values typename traits<T>::TangentVector diff = traits<T>::Local(expected, actual); if (diff.norm() > tol) { std::cout << "Not equal:" << std::endl << "expected: "; traits<T>::Print(expected); std::cout << std::endl << "actual: "; traits<T>::Print(actual); std::cout << std::endl; return false; } return true; } /// specializations of non-traits type matrix template <> bool assert_equal(const Eigen::MatrixXd& expected, const Eigen::MatrixXd& actual, double tol); template <> bool assert_equal(const Eigen::SparseMatrix<double>& expected, const Eigen::SparseMatrix<double>& actual, double tol); /// specializations of non-traits type Variables template <> bool assert_equal(const Variables& expected, const Variables& actual, double tol); /// matrix assert_equal for fixed-size and mixing cases bool assert_equal_matrix(const Eigen::MatrixXd& expected, const Eigen::MatrixXd& actual, double tol = 1e-6); /// compare vector of interger types template <class T, class = typename std::enable_if<std::is_integral<T>::value>::type> bool assert_equal_vector(const std::vector<T>& expected, const std::vector<T>& actual) { // check size if (expected.size() != actual.size()) { std::cout << "Not equal:" << std::endl << "expected size: " << expected.size() << std::endl << "actual size: " << actual.size() << std::endl; return false; } // check values for (size_t i = 0; i < expected.size(); i++) { if (expected[i] != actual[i]) { std::cout << "Not equal:" << std::endl; std::cout << "expected: "; for (size_t j = 0; j < expected.size(); j++) std::cout << expected[j] << ","; std::cout << std::endl; std::cout << "actual: "; for (size_t j = 0; j < actual.size(); j++) std::cout << actual[j] << ","; std::cout << std::endl; return false; } } return true; } /// compare vector of manifold types template <class T, class = typename std::enable_if<!std::is_integral<T>::value>::type> bool assert_equal_vector(const std::vector<T>& expected, const std::vector<T>& actual, double tol = 1e-9) { // check size if (expected.size() != actual.size()) { std::cout << "Not equal:" << std::endl << "expected size: " << expected.size() << std::endl << "actual size: " << actual.size() << std::endl; return false; } // check values for (size_t i = 0; i < expected.size(); i++) { if (!assert_equal<T>(expected[i], actual[i], tol)) { std::cout << "Not equal index: " << i << std::endl; return false; } } return true; } } // namespace minisam
31.696296
80
0.594999
[ "vector" ]
b405a2e88dbcce5b40df47077e49d8eaaa2cba86
5,937
h
C
cpp/expressionsLib/inc/ExprValue.h
RA-Consulting-GmbH/openscenario.api.test
4b8aa781fc51862cac382b312855d520ea61aaa7
[ "Apache-2.0" ]
27
2020-08-13T11:39:24.000Z
2022-02-13T06:21:16.000Z
cpp/expressionsLib/inc/ExprValue.h
RA-Consulting-GmbH/openscenario.api.test
4b8aa781fc51862cac382b312855d520ea61aaa7
[ "Apache-2.0" ]
62
2020-08-12T14:53:29.000Z
2022-02-21T14:39:23.000Z
cpp/expressionsLib/inc/ExprValue.h
ahege/openscenario.api.test
94cc39a6caad0418c71aadc6567fa200ded0ac65
[ "Apache-2.0" ]
4
2021-07-08T03:04:14.000Z
2022-01-11T11:16:43.000Z
/* * Copyright 2021 RA Consulting * * RA Consulting GmbH licenses this file 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. */ #pragma once #include <string> #include <map> #include <vector> #include "ExprType.h" #include "OscExprExportDefs.h" #include <memory> namespace OscExpression { /** * This class represents a value in an expression with the type and value. */ class ExprValue { private: double doubleValue; std::string stringValue; bool boolValue; std::shared_ptr<ExprType> exprType; static std::string dateTimeRegEx; private: /** Private constructor */ ExprValue(); public: /** * @param doubleValueString initial double value in its string Representation * @return the created double value */ OSC_EXPR_EXP static std::shared_ptr<double> CreatePrimitiveDouble(std::string doubleValueString); /** * @param doubleValue initial double value * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateDoubleValue(double doubleValue); /** * @param unsignedShortValue * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateUnsignedShortValue(double unsignedShortValue); /** * @param unsignedIntValue * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateUnsignedIntValue(double unsignedIntValue); /** * @param intValue * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateIntValue(double intValue); /** * @param stringValue * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateStringValue(std::string stringValue); /** * Creates the typed Value or returns nullptr when the value cannot be created * @param stringValue the value of the expression * @param exprType the type of the expression * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateTypedValue(std::string stringValue, std::shared_ptr<ExprType> exprType); /** * @param dateTimeStringValue string representation of the dateTime value * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateDateTimeValue(std::string dateTimeStringValue); /** * @param boolStringValue string representation of the boolean value * @return the created ExprValue */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateBooleanValue(std::string boolStringValue); /** * @param boolValue boolean value * @return the created ExprValue */OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateBooleanValue(bool boolValue); /** * Returns the value in double * @return the double value */ OSC_EXPR_EXP double getDoubleValue(); /** * @return the expression type */ OSC_EXPR_EXP std::shared_ptr<ExprType> GetExprType(); /** * Determines wether the expression type of this object's expression type is in types * @param types a list of types handed over. * @return true, if object's expression type is in types */ OSC_EXPR_EXP bool IsOfType(std::vector<std::shared_ptr<ExprType>> types); /** * @return true if object's expression type is floating numeric */ OSC_EXPR_EXP bool IsFloatingPointNumeric(); /** * @return true if object's expression type is string based */ OSC_EXPR_EXP bool IsTypeStringBased(); /** * @return true if object's expression type is numeric */ OSC_EXPR_EXP bool IsTypeNumeric(); /** * @return the int value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToInt(); /** * @return the int value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToString(); /** * @return the int value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToBoolean(); /** * @return the int value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToDateTime(); /** * @return the unsigned int expression value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToUnsignedInt(); /** * @return the unsigned short expression value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToUnsignedShort(); /** * @return the double expression value or nullptr if conversion is not possible */ OSC_EXPR_EXP std::shared_ptr <ExprValue> ConvertToDouble(); /** * @return the string representation of the value */ OSC_EXPR_EXP std::string ToString(); /** * @return the parameter name */ OSC_EXPR_EXP std::string GetParameterName(); /** * for non BOOLEAN type this will return false * @return boolean Value */ OSC_EXPR_EXP bool GetBoolValue(); std::shared_ptr<ExprValue> ConvertToTargetType(std::shared_ptr<OscExpression::ExprType> type); /** * Creates a double value from a string * @return the double value or nullptr if the doubleStringValue cannot be parsed into a double */ OSC_EXPR_EXP static std::shared_ptr<ExprValue> CreateDoubleValueFromString(std::string doubleStringValue); }; }
28.137441
128
0.702543
[ "object", "vector" ]
b40934ae234815b62c3d00e124c10e1b833b2519
1,313
h
C
tests/testvectors/rc/rc2rfc2268.h
calccrypto/Encryptions
ed1a02aebbb783128c77a0a4881e7ecb8a335842
[ "MIT" ]
113
2015-04-26T16:48:54.000Z
2022-03-25T23:15:21.000Z
thirdparty/Encryptions/tests/testvectors/rc/rc2rfc2268.h
Muller-Castro/Minesweeper
e4c3fb48e7181aff9637dc77cb829d16d293afdb
[ "Zlib", "MIT" ]
5
2019-01-24T02:46:15.000Z
2021-05-09T14:06:25.000Z
thirdparty/Encryptions/tests/testvectors/rc/rc2rfc2268.h
Muller-Castro/Minesweeper
e4c3fb48e7181aff9637dc77cb829d16d293afdb
[ "Zlib", "MIT" ]
44
2015-12-17T02:29:19.000Z
2022-03-31T21:39:13.000Z
#ifndef __RC2RFC2268__ #define __RC2RFC2268__ #include "../plainkeycipher.h" // Test vectors from <https://tools.ietf.org/html/rfc2268> static const std::vector <PlainKeyCipher> RC2_RFC2268 = { // std::make_tuple("0000000000000000", "0000000000000000", "ebb773f993278eff"), // std::make_tuple("ffffffffffffffff", "ffffffffffffffff", "278b27e42e2f0d49"), // std::make_tuple("1000000000000001", "3000000000000000", "30649edf9be7d2c2"), // std::make_tuple("0000000000000000", "88", "61a8a244adacccf0"), // std::make_tuple("0000000000000000", "88bca90e90875a", "6ccf4308974c267f"), // std::make_tuple("0000000000000000", "88bca90e90875a7f0f79c384627bafb2", "1a807d272bbe5db1"), // std::make_tuple("0000000000000000", "88bca90e90875a7f0f79c384627bafb2", "2269552ab0f85ca6"), // std::make_tuple("0000000000000000", "88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e", "5b78d3a43dfff1f1"), }; #endif // __RC2RFC2268__
69.105263
135
0.550647
[ "vector" ]
b411d58c2c07614ec25c19e850c63a148035970c
364
c
C
main.c
olivierbloch/Azure-RTOS-GUIX-Flip-Dot-Display-Driver
10026819d6831964ebb91554b52a86d98da72755
[ "MIT" ]
3
2020-12-18T11:53:39.000Z
2021-01-14T18:44:43.000Z
main.c
olivierbloch/AzureSRFlipdot
10026819d6831964ebb91554b52a86d98da72755
[ "MIT" ]
null
null
null
main.c
olivierbloch/AzureSRFlipdot
10026819d6831964ebb91554b52a86d98da72755
[ "MIT" ]
1
2021-09-24T17:12:33.000Z
2021-09-24T17:12:33.000Z
/* Copyright (c) Microsoft Corporation. Licensed under the MIT License. */ #include "CPUFreq.h" #include "VectorTable.h" extern int main(void); _Noreturn void RTCoreMain(void) { // Init Vector Table VectorTableInit(); // Set CPU clock CPUFreq_Set(197600000); // Invoke ThreadX main main(); for (;;) { __asm__("wfi"); } }
15.166667
39
0.629121
[ "vector" ]
b41ca241d7f1d796fec37be263eb73df32742b5c
2,010
h
C
src/opossum.h
aeolus-project/opossum
1854a27c6f83762c8e74243db2df378e7759223a
[ "BSD-3-Clause" ]
1
2015-07-01T19:43:06.000Z
2015-07-01T19:43:06.000Z
src/opossum.h
aeolus-project/opossum
1854a27c6f83762c8e74243db2df378e7759223a
[ "BSD-3-Clause" ]
null
null
null
src/opossum.h
aeolus-project/opossum
1854a27c6f83762c8e74243db2df378e7759223a
[ "BSD-3-Clause" ]
null
null
null
/*******************************************************/ /* oPoSSuM solver: cudf.h */ /* Handling of PSL problem files */ /* (c) Arnaud Malapert I3S (UNS-CNRS) 2012 */ /*******************************************************/ // main include file #ifndef _CUDF_H #define _CUDF_H #include <stdio.h> #include <string.h> #include <stdlib.h> #include <vector> #include <set> #include <map> #include <string> #include <iostream> #include "network.hpp" using namespace std; // Handling the time limit per subproblem extern double time_limit; ; //Solver status #define ERROR 0 #define UNKNOWN 1 #define UNSAT 2 #define SAT 3 #define OPTIMUM 4 #define C_STR( text ) ((char*)std::string( text ).c_str()) // current CUDF problem extern PSLProblem *the_problem; extern PSLProblem *current_problem; // // parse the CUDF problem from input_file extern int parse_pslp(istream& in); //cudf_tools.c //------------------------------------------------------------------ // Handling verbosity level extern int verbosity; //Logging Levels and messages #define SILENT -1 //XCSP Status and Objective #define QUIET 0 //XCSP solution, diagnostics, configurations #define DEFAULT 1 //Print generator and export problems and solutions (graphviz + solver) #define VERBOSE 2 //MIP node log display information #define SEARCH 3 //Print network info #define ALL 4 // Print out a PSL problem // requires the file descriptor of the targeted file and a pointer to the PSL problem extern void print_problem(ostream& out, PSLProblem *pbs); // Export the PSL problem as a graphivz file (.dot) // requires the file descriptor of the targeted file and a pointer to the PSL problem extern void export_problem(PSLProblem *problem); // Print out a generator (expected children, nodes, clients, raw data ...); // requires the file descriptor of the targeted file and a pointer to the PSL problem extern void print_generator_summary(ostream& out, PSLProblem *pbs); #endif
25.769231
85
0.658706
[ "vector" ]
f1d2f634fb0526701d2b1df06e7038d5c3164b6b
486
h
C
src/app/camera.h
ugozapad/pbr-sandbox
07417cc68b9422ff01b4c293a42d8ce65f9297ca
[ "BSD-2-Clause" ]
null
null
null
src/app/camera.h
ugozapad/pbr-sandbox
07417cc68b9422ff01b4c293a42d8ce65f9297ca
[ "BSD-2-Clause" ]
null
null
null
src/app/camera.h
ugozapad/pbr-sandbox
07417cc68b9422ff01b4c293a42d8ce65f9297ca
[ "BSD-2-Clause" ]
null
null
null
#pragma once #include "render/render_common.h" class Camera { public: enum MovmentDir { None, Forward, Backward, Left, Right }; public: Camera(); ~Camera(); void update(MovmentDir dir, float x, float y, int width, int height, float dt); glm::mat4 get_view_matr(); glm::vec3 get_pos() { return m_pos; } void set_pos(glm::vec3& pos) { m_pos = pos; } public: glm::vec3 m_pos; glm::vec3 m_front; glm::vec3 m_up; glm::vec3 m_dir; float m_yaw; float m_pitch; };
14.294118
80
0.666667
[ "render" ]
f1eb5fbe0576c12851d5c4940c2f79fd241fe1df
1,976
h
C
swarmros/include/swarmros/bridge/TelemetryForwarder.h
codavide/swarmros
2c08c0ea7ee4d67a213edd8a27d5515f31c4d341
[ "Apache-2.0" ]
4
2019-08-01T12:49:14.000Z
2022-01-24T12:48:54.000Z
swarmros/include/swarmros/bridge/TelemetryForwarder.h
codavide/swarmros
2c08c0ea7ee4d67a213edd8a27d5515f31c4d341
[ "Apache-2.0" ]
1
2019-09-17T12:11:48.000Z
2019-09-17T12:11:48.000Z
swarmros/include/swarmros/bridge/TelemetryForwarder.h
codavide/swarmros
2c08c0ea7ee4d67a213edd8a27d5515f31c4d341
[ "Apache-2.0" ]
1
2020-02-12T15:30:44.000Z
2020-02-12T15:30:44.000Z
#pragma once #include <swarmros/bridge/Pylon.h> #include <swarmros/introspection/VariantMessage.h> #include <swarmio/services/telemetry/Service.h> #include <ros/ros.h> namespace swarmros::bridge { /** * @brief A ROS topic subscriber that bridges * telemetry data to ROS topics. * */ class TelemetryForwarder final : public Pylon { private: /** * @brief ROS topic subscriber * */ ros::Subscriber _subscriber; /** * @brief Message type * */ std::string _message; /** * @brief Telemetry service * */ swarmio::services::telemetry::Service& _telemetryService; /** * @brief Telemetry key * */ std::string _name; /** * @brief Called whenever the topic is updated * * @param message Message */ void UpdateReceived(const introspection::VariantMessage::ConstPtr& message); public: /** * @brief Construct a new TelemetryForwarder object * * @param nodeHandle Node handle * @param source ROS topic * @param message Message type * @param telemetryService Telemetry service * @param name Telemetry key * @param includeInStatus Include in status broadcast */ TelemetryForwarder(ros::NodeHandle& nodeHandle, const std::string& source, const std::string& message, swarmio::services::telemetry::Service& telemetryService, const std::string& name, bool includeInStatus); /** * @brief Destroy the TelemetryForwarder object * */ virtual ~TelemetryForwarder() override; }; }
27.444444
219
0.51417
[ "object" ]
7b0184f206ea68fe13df33ba042d2770677bcc78
243
h
C
common/eeprom/pc/eepromPc.h
f4deb/cen-electronic
74302fb38cf41e060ccaf9435ccd8e8792f3e565
[ "MIT" ]
1
2019-07-24T08:30:33.000Z
2019-07-24T08:30:33.000Z
common/eeprom/pc/eepromPc.h
f4deb/cen-electronic
74302fb38cf41e060ccaf9435ccd8e8792f3e565
[ "MIT" ]
126
2015-01-01T20:03:57.000Z
2018-05-06T19:55:31.000Z
common/eeprom/pc/eepromPc.h
f4deb/cen-electronic
74302fb38cf41e060ccaf9435ccd8e8792f3e565
[ "MIT" ]
9
2015-04-10T07:18:04.000Z
2020-11-04T11:40:21.000Z
#ifndef EEPROM_PC_H #define EEPROM_PC_H #include "../eeprom.h" /** * Initializes an eeprom linked to a file for PC. * @param eepromPc a pointer on eeprom object */ void initEepromPc(Eeprom* eepromPc, char* fileName); #endif
17.357143
53
0.687243
[ "object" ]
7b0894b42dae88280e5043d3efb542b517922d69
1,807
h
C
src/mavlink-router/controller.h
FishsemiCode/mavlink-router
f5d896d364e8f12bf19d7c019d1a8df0eef1d9e6
[ "Apache-2.0" ]
1
2019-04-15T02:04:11.000Z
2019-04-15T02:04:11.000Z
src/mavlink-router/controller.h
FishsemiCode/mavlink-router
f5d896d364e8f12bf19d7c019d1a8df0eef1d9e6
[ "Apache-2.0" ]
null
null
null
src/mavlink-router/controller.h
FishsemiCode/mavlink-router
f5d896d364e8f12bf19d7c019d1a8df0eef1d9e6
[ "Apache-2.0" ]
1
2019-04-14T05:20:17.000Z
2019-04-14T05:20:17.000Z
/* * This file is part of the MAVLink Router project * * Copyright (C) 2019 FishSemi Inc. All rights reserved. * * 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. */ #pragma once #include "pollable.h" class Controller: public Pollable { public: Controller(); int handle_read() override; bool handle_canwrite() override { return false; } static void open(struct options *opt); bool _handle_add_endpoint(char *payload); bool _handle_remove_endpoint(char *payload); private: int _open_socket(const char *name); void _load_options(struct options *opt); bool _process_message(char *msg, ssize_t len, struct sockaddr *src_addr, socklen_t addrlen); void _send_ack(const char *key, bool success, struct sockaddr *addr, socklen_t addrlen); bool _add_dynamic_udp_endpoint(const char *ipaddr, unsigned long port); bool _remove_dynamic_udp_endpoint(const char *ipaddr, unsigned long port); bool _parse_endpoint_info(char *payload, char **pIpaddress, int* pPort); static Controller _instance; char *_endpoint_name = nullptr; int _endpoint_group = 0; int _endpoint_default_port = -1; filter_type _endpoint_filter_type = NoFilter; std::vector<uint32_t> _endpoint_msg_filter; std::vector<uint16_t> _endpoint_sys_comp_filter; };
36.877551
96
0.740454
[ "vector" ]
7b0fb8576950b9be9020f7d0b6ecff1f5501c4ac
7,556
h
C
src/vendor/mariadb-10.6.7/tpool/tpool_structs.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
null
null
null
src/vendor/mariadb-10.6.7/tpool/tpool_structs.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
null
null
null
src/vendor/mariadb-10.6.7/tpool/tpool_structs.h
zettadb/zettalib
3d5f96dc9e3e4aa255f4e6105489758944d37cc4
[ "Apache-2.0" ]
2
2022-02-27T14:00:01.000Z
2022-03-31T06:24:22.000Z
/* Copyright(C) 2019 MariaDB Corporation This program is free software; you can redistribute itand /or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/ #pragma once #include <vector> #include <stack> #include <mutex> #include <condition_variable> #include <assert.h> #include <algorithm> /* Suppress TSAN warnings, that we believe are not critical. */ #if defined(__has_feature) #define TPOOL_HAS_FEATURE(...) __has_feature(__VA_ARGS__) #else #define TPOOL_HAS_FEATURE(...) 0 #endif #if TPOOL_HAS_FEATURE(address_sanitizer) #define TPOOL_SUPPRESS_TSAN __attribute__((no_sanitize("thread"),noinline)) #elif defined(__GNUC__) && defined (__SANITIZE_THREAD__) #define TPOOL_SUPPRESS_TSAN __attribute__((no_sanitize_thread,noinline)) #else #define TPOOL_SUPPRESS_TSAN #endif namespace tpool { enum cache_notification_mode { NOTIFY_ONE, NOTIFY_ALL }; /** Generic "pointer" cache of a fixed size with fast put/get operations. Compared to STL containers, is faster/does not do allocations. However, put() operation will wait if there is no free items. */ template<typename T> class cache { std::mutex m_mtx; std::condition_variable m_cv; std::vector<T> m_base; std::vector<T*> m_cache; cache_notification_mode m_notification_mode; int m_waiters; bool is_full() { return m_cache.size() == m_base.size(); } public: cache(size_t count, cache_notification_mode mode= tpool::cache_notification_mode::NOTIFY_ALL): m_mtx(), m_cv(), m_base(count),m_cache(count), m_notification_mode(mode),m_waiters() { for(size_t i = 0 ; i < count; i++) m_cache[i]=&m_base[i]; } T* get(bool blocking=true) { std::unique_lock<std::mutex> lk(m_mtx); if (blocking) { while(m_cache.empty()) m_cv.wait(lk); } else { if(m_cache.empty()) return nullptr; } T* ret = m_cache.back(); m_cache.pop_back(); return ret; } void put(T *ele) { std::unique_lock<std::mutex> lk(m_mtx); m_cache.push_back(ele); if (m_notification_mode == NOTIFY_ONE) m_cv.notify_one(); else if(m_cache.size() == 1) m_cv.notify_all(); // Signal cache is not empty else if(m_waiters && is_full()) m_cv.notify_all(); // Signal cache is full } bool contains(T* ele) { return ele >= &m_base[0] && ele <= &m_base[m_base.size() -1]; } /* Wait until cache is full.*/ void wait() { std::unique_lock<std::mutex> lk(m_mtx); m_waiters++; while(!is_full()) m_cv.wait(lk); m_waiters--; } TPOOL_SUPPRESS_TSAN size_t size() { return m_cache.size(); } }; /** Circular, fixed size queue used for the task queue. Compared to STL queue, this one is faster, and does not do memory allocations */ template <typename T> class circular_queue { public: circular_queue(size_t N = 16) : m_capacity(N + 1), m_buffer(m_capacity), m_head(), m_tail() { } bool empty() { return m_head == m_tail; } bool full() { return (m_head + 1) % m_capacity == m_tail; } void clear() { m_head = m_tail = 0; } void resize(size_t new_size) { auto current_size = size(); if (new_size <= current_size) return; size_t new_capacity = new_size - 1; std::vector<T> new_buffer(new_capacity); /* Figure out faster way to copy*/ size_t i = 0; while (!empty()) { T& ele = front(); pop(); new_buffer[i++] = ele; } m_buffer = new_buffer; m_capacity = new_capacity; m_tail = 0; m_head = current_size; } void push(T ele) { if (full()) { assert(size() == m_capacity - 1); resize(size() + 1024); } m_buffer[m_head] = ele; m_head = (m_head + 1) % m_capacity; } void push_front(T ele) { if (full()) { resize(size() + 1024); } if (m_tail == 0) m_tail = m_capacity - 1; else m_tail--; m_buffer[m_tail] = ele; } T& front() { assert(!empty()); return m_buffer[m_tail]; } void pop() { assert(!empty()); m_tail = (m_tail + 1) % m_capacity; } size_t size() { if (m_head < m_tail) { return m_capacity - m_tail + m_head; } else { return m_head - m_tail; } } /*Iterator over elements in queue.*/ class iterator { size_t m_pos; circular_queue<T>* m_queue; public: explicit iterator(size_t pos , circular_queue<T>* q) : m_pos(pos), m_queue(q) {} iterator& operator++() { m_pos= (m_pos + 1) % m_queue->m_capacity; return *this; } iterator operator++(int) { iterator retval= *this; ++*this; return retval; } bool operator==(iterator other) const { return m_pos == other.m_pos; } bool operator!=(iterator other) const { return !(*this == other); } T& operator*() const { return m_queue->m_buffer[m_pos]; } }; iterator begin() { return iterator(m_tail, this); } iterator end() { return iterator(m_head, this); } private: size_t m_capacity; std::vector<T> m_buffer; size_t m_head; size_t m_tail; }; /* Doubly linked list. Intrusive, requires element to have m_next and m_prev pointers. */ template<typename T> class doubly_linked_list { public: T* m_first; T* m_last; size_t m_count; doubly_linked_list():m_first(),m_last(),m_count() {} void check() { assert(!m_first || !m_first->m_prev); assert(!m_last || !m_last->m_next); assert((!m_first && !m_last && m_count == 0) || (m_first != 0 && m_last != 0 && m_count > 0)); T* current = m_first; for(size_t i=1; i< m_count;i++) { current = current->m_next; } assert(current == m_last); current = m_last; for (size_t i = 1; i < m_count; i++) { current = current->m_prev; } assert(current == m_first); } T* front() { return m_first; } size_t size() { return m_count; } void push_back(T* ele) { ele->m_prev = m_last; if (m_last) m_last->m_next = ele; ele->m_next = 0; m_last = ele; if (!m_first) m_first = m_last; m_count++; } T* back() { return m_last; } bool empty() { return m_count == 0; } void pop_back() { m_last = m_last->m_prev; if (m_last) m_last->m_next = 0; else m_first = 0; m_count--; } bool contains(T* ele) { if (!ele) return false; T* current = m_first; while(current) { if(current == ele) return true; current = current->m_next; } return false; } void erase(T* ele) { assert(contains(ele)); if (ele == m_first) { m_first = ele->m_next; if (m_first) m_first->m_prev = 0; else m_last = 0; } else if (ele == m_last) { assert(ele->m_prev); m_last = ele->m_prev; m_last->m_next = 0; } else { assert(ele->m_next); assert(ele->m_prev); ele->m_next->m_prev = ele->m_prev; ele->m_prev->m_next = ele->m_next; } m_count--; } }; }
21.106145
96
0.613684
[ "vector" ]
7b137669128017959fd3e90aebbd29ac077520f6
53,051
c
C
src/graphics/patch/g_glist.c
jogawebb/Spaghettis
78f21ba3065ce316ef0cb84e94aecc9e8787343d
[ "Zlib", "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
src/graphics/patch/g_glist.c
jogawebb/Spaghettis
78f21ba3065ce316ef0cb84e94aecc9e8787343d
[ "Zlib", "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
src/graphics/patch/g_glist.c
jogawebb/Spaghettis
78f21ba3065ce316ef0cb84e94aecc9e8787343d
[ "Zlib", "BSD-2-Clause", "BSD-3-Clause" ]
null
null
null
/* Copyright (c) 1997-2020 Miller Puckette and others. */ /* < https://opensource.org/licenses/BSD-3-Clause > */ // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - #include "../../m_spaghettis.h" #include "../../m_core.h" #include "../../s_system.h" #include "../../g_graphics.h" #include "../../d_dsp.h" // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- t_outlet *outlet_newUndefined (t_object *); // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- void gobj_changeSource (t_gobj *, t_id); // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- static void glist_unbindAll (t_glist *); // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_taskRedraw (t_glist *glist) { glist_redraw (glist); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - /* Note that an expanded name is expected (with or without the file extension). */ /* At load it can be temporarly set with the unexpanded form. */ static t_glist *glist_new (t_glist *owner, t_symbol *name, t_bounds *bounds, t_rectangle *graph, t_rectangle *window) { t_glist *x = (t_glist *)pd_new (canvas_class); x->gl_holder = gmaster_createWithGlist (x); x->gl_parent = owner; x->gl_environment = instance_environmentFetchIfAny(); x->gl_abstractions = NULL; x->gl_undomanager = undomanager_new (x); x->gl_name = (name != &s_ ? name : environment_getFileName (x->gl_environment)); x->gl_editor = editor_new (x); x->gl_sorterObjects = buffer_new(); x->gl_sorterIndexes = buffer_new(); x->gl_clockRedraw = clock_new ((void *)x, (t_method)glist_taskRedraw); x->gl_clockUndo = clock_new ((void *)x, (t_method)glist_updateUndo); x->gl_uniqueIdentifier = utils_unique(); glist_setFontSize (x, (owner ? glist_getFontSize (owner) : font_getDefaultSize())); if (bounds) { bounds_setCopy (&x->gl_bounds, bounds); } if (graph) { rectangle_setCopy (&x->gl_geometryGraph, graph); } if (window) { rectangle_setCopy (&x->gl_geometryWindow, window); } rectangle_setNothing (&x->gl_geometryPatch); if (glist_isRoot (x)) { x->gl_abstractions = abstractions_new(); } glist_bind (x); if (glist_isRoot (x)) { instance_rootsAdd (x); } return x; } void glist_free (t_glist *glist) { PD_ASSERT (!glist_objectGetNumberOf (glist)); if (glist_isRoot (glist)) { instance_rootsRemove (glist); } glist_unbind (glist); clock_free (glist->gl_clockRedraw); clock_free (glist->gl_clockUndo); buffer_free (glist->gl_sorterIndexes); buffer_free (glist->gl_sorterObjects); editor_free (glist_getEditor (glist)); environment_free (glist->gl_environment); gmaster_reset (glist_getMaster (glist)); undomanager_free (glist->gl_undomanager); abstractions_free (glist->gl_abstractions); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_glist *glist_newPatchPop (t_symbol *name, t_bounds *bounds, t_rectangle *graph, t_rectangle *window, int isOpened, int isEditMode, int isGOP, int fontSize) { if (!utils_isNameAllowedForWindow (name)) { warning_badName (sym_pd, name); } { // t_glist *x = glist_newPatch (name, bounds, graph, window, isOpened, isEditMode, isGOP, fontSize); PD_ASSERT (instance_contextGetCurrent() == x); instance_stackPopPatch (x, glist_isOpenedAtLoad (x)); return x; // } } t_glist *glist_newPatch (t_symbol *name, t_bounds *bounds, t_rectangle *graph, t_rectangle *window, int isOpened, int isEditMode, int isGOP, int fontSize) { t_glist *owner = instance_contextGetCurrent(); t_bounds t1; t_rectangle t2, t3; bounds_set (&t1, 0, 0, 1, 1); rectangle_set (&t2, 0, 0, GLIST_WIDTH / 2, GLIST_HEIGHT / 2); rectangle_set (&t3, GLIST_X, GLIST_Y, GLIST_X + GLIST_WIDTH, GLIST_Y + GLIST_HEIGHT); if (bounds) { bounds_setCopy (&t1, bounds); } if (graph) { rectangle_setCopy (&t2, graph); } if (window) { rectangle_setCopy (&t3, window); } { // t_glist *x = glist_new (owner, name, &t1, &t2, &t3); object_setBuffer (cast_object (x), buffer_new()); object_setX (cast_object (x), 0); object_setY (cast_object (x), 0); object_setWidth (cast_object (x), 0); object_setType (cast_object (x), TYPE_OBJECT); glist_setFontSize (x, fontSize); glist_setGraphOnParent (x, (isGOP != 0)); glist_setEditMode (x, isEditMode); glist_setOpenedAtLoad (x, isOpened); glist_loadBegin (x); instance_stackPush (x); return x; // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - /* A root has no parent and an environment. */ /* An abstraction has a parent and an environment. */ /* A subpatch has a parent also but no environment. */ /* A top patch is either a root or an abstraction. */ // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- int glist_isRoot (t_glist *glist) { return (!glist_hasParent (glist)); } int glist_isTop (t_glist *glist) { int k = (glist_isRoot (glist) || glist_isAbstraction (glist)); return k; } int glist_isAbstraction (t_glist *glist) { return (glist_hasParent (glist) && (glist->gl_environment != NULL)); } int glist_isAbstractionOrInside (t_glist *glist) { return (glist_isAbstraction (glist_getTop (glist))); } int glist_isInvisibleOrInside (t_glist *glist) { return (glist_getRoot (glist)->gl_isInvisible); } int glist_isSubpatchOrGraphicArray (t_glist *glist) { return (!glist_isTop (glist)); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- /* Array is a GOP patch that contains only a scalar. */ /* This scalar has an array of numbers as unique field. */ /* Dirty bit is always owned by the top patch. */ /* For GOP the view to draw is owned by a parent. */ /* Note that a GOP can be opened in its own window on demand. */ // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- int glist_isSubpatch (t_glist *glist) { return (glist_isSubpatchOrGraphicArray (glist) && !glist_isGraphicArray (glist)); } int glist_isGraphicArray (t_glist *glist) { return (utils_getFirstAtomOfObjectAsSymbol (cast_object (glist)) == sym_graph); } int glist_isDirty (t_glist *glist) { return (glist_getTop (glist)->gl_isDirty != 0); } int glist_isFrozen (t_glist *glist) { return (glist_getTop (glist)->gl_isFrozen != 0); } int glist_isOnScreen (t_glist *glist) { return (!glist_isLoading (glist) && glist_getView (glist)->gl_isMapped); } int glist_isParentOnScreen (t_glist *g) { return (!glist_isLoading (g) && glist_hasParent (g) && glist_isOnScreen (glist_getParent (g))); } int glist_isWindowable (t_glist *glist) { return (!glist_isGraphOnParent (glist) || glist_hasWindow (glist)); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_glist *glist_getRoot (t_glist *glist) { if (glist_isRoot (glist)) { return glist; } else { return glist_getRoot (glist_getParent (glist)); } } t_glist *glist_getTop (t_glist *glist) { if (glist_isTop (glist)) { return glist; } else { return glist_getTop (glist_getParent (glist)); } } t_environment *glist_getEnvironment (t_glist *glist) { return (glist_getTop (glist)->gl_environment); } t_undomanager *glist_getUndoManager (t_glist *glist) { return glist->gl_undomanager; } t_glist *glist_getView (t_glist *glist) { while (glist_hasParent (glist) && !glist_isWindowable (glist)) { glist = glist_getParent (glist); } return glist; } t_garray *glist_getGraphicArray (t_glist *glist) { t_gobj *y = glist->gl_graphics; if (y && gobj_isGraphicArray (y)) { return (t_garray *)y; } else { return NULL; /* Could be NULL in legacy patches or at release time. */ } } /* Code below is required to fetch the unexpanded form. */ t_symbol *glist_getUnexpandedName (t_glist *glist) { t_buffer *z = buffer_new(); buffer_serialize (z, object_getBuffer (cast_object (glist))); t_symbol *s = atom_getSymbolAtIndex (1, buffer_getSize (z), buffer_getAtoms (z)); buffer_free (z); return s; } t_abstractions *glist_getAbstractions (t_glist *glist) { return glist_getRoot (glist)->gl_abstractions; } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_point glist_getPositionForNewObject (t_glist *glist) { t_rectangle *r = glist_getPatchGeometry (glist); int a = rectangle_isNothing (r) ? 0 : rectangle_getTopLeftX (r) + (rectangle_getWidth (r) / 4.0); int b = rectangle_isNothing (r) ? 0 : rectangle_getTopLeftY (r) + (rectangle_getHeight (r) / 4.0); return point_make (a, b); } t_point glist_getPositionMiddle (t_glist *glist) { t_rectangle *r = glist_getPatchGeometry (glist); int a = rectangle_isNothing (r) ? 0 : rectangle_getMiddleX (r); int b = rectangle_isNothing (r) ? 0 : rectangle_getMiddleY (r); return point_make (a, b); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_updatePatchGeometry (t_glist *glist) { int w = rectangle_getWidth (glist_getWindowGeometry (glist)); int h = rectangle_getHeight (glist_getWindowGeometry (glist)); int a = glist_getScrollX (glist); int b = glist_getScrollY (glist); rectangle_setByWidthAndHeight (&glist->gl_geometryPatch, a, b, w, h); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_setName (t_glist *glist, t_symbol *name) { if (!utils_isNameAllowedForWindow (name)) { warning_badName (sym_pd, name); } if (name == &s_) { name = glist_isGraphicArray (glist) ? sym_Array : sym_Patch; } if (name != glist->gl_name) { // glist_unbind (glist); glist->gl_name = name; glist_bind (glist); glist_updateTitle (glist); if (glist_isTop (glist)) { environment_setFileName (glist_getEnvironment (glist), name); } // } } void glist_setDirty (t_glist *glist, int n) { int isDirty = (n != 0); t_glist *y = glist_getTop (glist); int isAbstraction = glist_isAbstraction (y); if (!isAbstraction) { // if (y->gl_isDirty != isDirty) { // y->gl_isDirty = isDirty; glist_updateTitle (y); // } // } } void glist_setFrozen (t_glist *glist, int n) { glist_getTop (glist)->gl_isFrozen = (n != 0); } void glist_setInvisible (t_glist *glist) { glist->gl_isInvisible = 1; glist_unbindAll (glist); } void glist_setFontSize (t_glist *g, int n) { if (n > 0) { g->gl_fontSize = font_getValidSize (n); } } void glist_setMotion (t_glist *glist, t_gobj *y, t_motionfn callback, int a, int b) { editor_motionSet (glist_getEditor (glist_getView (glist)), y, glist, callback, a, b); } void glist_setBounds (t_glist *glist, t_bounds *bounds) { bounds_setCopy (glist_getBounds (glist), bounds); } void glist_setGraphGeometry (t_glist *glist, t_rectangle *r, t_bounds *bounds, int isGOP) { int update = glist_isParentOnScreen (glist); if (update) { // gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 0); // } rectangle_setCopy (glist_getGraphGeometry (glist), r); bounds_setCopy (glist_getBounds (glist), bounds); glist_setGraphOnParent (glist, isGOP); if (update) { // gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 1); glist_updateLinesForObject (glist_getParent (glist), cast_object (glist)); // } } void glist_setWindowGeometry (t_glist *glist, t_rectangle *r) { rectangle_setCopy (glist_getWindowGeometry (glist), r); glist_updatePatchGeometry (glist); } void glist_setScroll (t_glist *glist, int a, int b) { glist->gl_scrollX = a; glist->gl_scrollY = b; glist_updatePatchGeometry (glist); } void glist_setIdentifiers (t_glist *glist, int argc, t_atom *argv) { t_id u; t_error err = utils_uniqueWithAtoms (argc, argv, &u); PD_ASSERT (!err); PD_UNUSED (err); gobj_changeIdentifiers (cast_gobj (glist), u); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_setDollarZero (t_glist *glist, int n) { environment_setDollarZero (glist_getEnvironment (glist), n); } int glist_getDollarZero (t_glist *glist) { return environment_getDollarZero (glist_getEnvironment (glist)); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_bindProceed (t_glist *glist) { t_symbol *s = symbol_removeExtension (glist_getName (glist)); if (utils_isNameAllowedForWindow (s)) { pd_bind (cast_pd (glist), symbol_makeBind (s)); } } void glist_bind (t_glist *glist) { if (!glist_isInvisibleOrInside (glist)) { glist_bindProceed (glist); } } static void glist_unbindProceed (t_glist *glist) { t_symbol *s = symbol_removeExtension (glist_getName (glist)); if (utils_isNameAllowedForWindow (s)) { pd_unbind (cast_pd (glist), symbol_makeBind (s)); } } void glist_unbind (t_glist *glist) { if (!glist_isInvisibleOrInside (glist)) { glist_unbindProceed (glist); } } static void glist_unbindAllRecursive (t_glist *glist) { t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (gobj_isCanvas (y)) { glist_unbindAllRecursive (cast_glist (y)); } else if (pd_class (y) == namecanvas_class) { pd_message (cast_pd (y), sym_set, 0, NULL); } } glist_unbindProceed (cast_glist (glist)); } static void glist_unbindAll (t_glist *glist) { glist_unbindAllRecursive (glist); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_rename (t_glist *glist, int argc, t_atom *argv) { t_symbol *s = atom_getSymbolOrDollarSymbolAtIndex (0, argc, argv); if (argc > 1) { warning_unusedArguments (sym_pd, argc - 1, argv + 1); } glist_setName (glist, dollar_expandSymbol (s, glist)); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_loadbangAbstractions (t_glist *glist) { t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (gobj_isCanvas (y)) { if (glist_isAbstraction (cast_glist (y))) { glist_loadbang (cast_glist (y)); } else { glist_loadbangAbstractions (cast_glist (y)); } } } } static void glist_loadbangSubpatches (t_glist *glist) { t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (gobj_isCanvas (y)) { if (!glist_isAbstraction (cast_glist (y))) { glist_loadbangSubpatches (cast_glist (y)); } } } for (y = glist->gl_graphics; y; y = y->g_next) { if (!gobj_isCanvas (y) && class_hasMethod (pd_class (y), sym_loadbang)) { pd_message (cast_pd (y), sym_loadbang, 0, NULL); } } } void glist_loadbang (t_glist *glist) { glist_loadbangAbstractions (glist); glist_loadbangSubpatches (glist); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_closebangAbstractions (t_glist *glist) { t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (gobj_isCanvas (y)) { if (glist_isAbstraction (cast_glist (y))) { glist_closebang (cast_glist (y)); } else { glist_closebangAbstractions (cast_glist (y)); } } } } static void glist_closebangSubpatches (t_glist *glist) { t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (gobj_isCanvas (y)) { if (!glist_isAbstraction (cast_glist (y))) { glist_closebangSubpatches (cast_glist (y)); } } } for (y = glist->gl_graphics; y; y = y->g_next) { if (!gobj_isCanvas (y) && class_hasMethod (pd_class (y), sym_closebang)) { pd_message (cast_pd (y), sym_closebang, 0, NULL); } } glist->gl_hasBeenCloseBanged = 1; } void glist_closebang (t_glist *glist) { if (!glist->gl_hasBeenCloseBanged) { // glist_closebangAbstractions (glist); glist_closebangSubpatches (glist); glist->gl_hasBeenCloseBanged = 1; // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- /* Files are searching in the directory of the patch first. */ /* Without success it tries to find it using the search path. */ // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - int glist_fileExist (t_glist *glist, const char *name, const char *extension, t_fileproperties *p) { int f = glist_fileOpen (glist, name, extension, p); if (f >= 0) { close (f); return 1; } return 0; } /* Caller is responsible to close the file. */ int glist_fileOpen (t_glist *glist, const char *name, const char *extension, t_fileproperties *p) { const char *directory = glist ? environment_getDirectoryAsString (glist_getEnvironment (glist)) : "."; int f = file_openReadConsideringSearchPath (directory, name, extension, p); return f; } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - int glist_undoIsOk (t_glist *glist) { if (glist_isAbstractionOrInside (glist) || glist_isGraphicArray (glist)) { return 0; } else if (editor_hasSelectedBox (glist_getEditor (glist))) { return 0; } return (glist_hasUndo (glist) && !instance_undoIsRecursive()); } int glist_undoHasSeparatorAtLast (t_glist *glist) { return (undomanager_hasSeparatorAtLast (glist_getUndoManager (glist))); } /* Raw function to use with care. */ t_undomanager *glist_undoReplaceManager (t_glist *glist, t_undomanager *undo) { t_undomanager *t = glist->gl_undomanager; glist->gl_undomanager = undo; return t; } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- void glist_undoAppendSeparator (t_glist *glist) { if (!glist_undoHasSeparatorAtLast (glist)) { // undomanager_appendSeparator (glist_getUndoManager (glist)); glist_updateUndo (glist); // } } static void glist_undoAppendProceed (t_glist *glist, t_undoaction *a, int scheduled) { t_undomanager *undo = glist_getUndoManager (glist); undomanager_append (undo, a); if (scheduled) { undomanager_appendSeparatorLater (undo); } glist_updateUndo (glist); } void glist_undoAppendUnscheduled (t_glist *glist, t_undoaction *a) { glist_undoAppendProceed (glist, a, 0); } void glist_undoAppend (t_glist *glist, t_undoaction *a) { glist_undoAppendProceed (glist, a, 1); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_objectMake (t_glist *glist, int a, int b, int w, int isSelected, t_buffer *t) { instance_setNewestObject (NULL); instance_stackPush (glist); { // t_environment *e = glist_getEnvironment (instance_contextGetCurrent()); t_object *x = NULL; eval_buffer (t, instance_getMakerObject(), environment_getNumberOfArguments (e), environment_getArguments (e)); if (instance_getNewestObject()) { x = cast_objectIfConnectable (instance_getNewestObject()); } if (!x) { x = (t_object *)pd_new (text_class); /* If failed create a dummy box. */ if (buffer_getSize (t)) { error_canNotMake (buffer_getSize (t), buffer_getAtoms (t)); } } /* Replace original name of an abstraction created from snippet (e.g. encapsulation). */ if (buffer_getSize (t) && IS_SYMBOL (buffer_getAtomAtIndex (t, 0))) { // t_symbol *key = buffer_getSymbolAt (t, 0); if (pool_check (key)) { // t_symbol *name = abstractions_getName (glist_getAbstractions (instance_contextGetCurrent()), key); if (name) { buffer_setSymbolAtIndex (t, 0, name); } // } // } object_setBuffer (x, t); if (isSelected) { object_setSnappedX (x, a); /* Interactive creation. */ object_setSnappedY (x, b); } else { object_setX (x, a); /* File creation. */ object_setY (x, b); } object_setWidth (x, w); object_setType (x, TYPE_OBJECT); glist_objectAdd (glist, cast_gobj (x)); if (isSelected) { // glist_objectSelect (glist, cast_gobj (x)); gobj_activated (cast_gobj (x), glist, 1); // } if (pd_class (x) == vinlet_class) { glist_inletSort (glist_getView (glist)); } if (pd_class (x) == voutlet_class) { glist_outletSort (glist_getView (glist)); } if (pd_class (x) == block_class) { dsp_update(); } if (class_hasDataFunction (pd_class (x))) { instance_setBoundA (cast_pd (x)); } // } instance_stackPop (glist); } void glist_objectMakeScalar (t_glist *glist, int argc, t_atom *argv) { if (argc > 0) { // t_atom *expanded = NULL; PD_ATOMS_ALLOCA (expanded, argc); atom_copyAtomsExpanded (argv, argc, expanded, argc, glist); if (IS_SYMBOL (expanded)) { // t_symbol *templateIdentifier = symbol_makeTemplateIdentifier (GET_SYMBOL (expanded)); if (template_isValid (template_findByIdentifier (templateIdentifier))) { // t_scalar *scalar = scalar_new (glist, templateIdentifier); scalar_deserialize (scalar, argc, expanded); glist_objectAdd (glist, cast_gobj (scalar)); // } else { error_noSuch (GET_SYMBOL (expanded), sym_template); } // } PD_ATOMS_FREEA (expanded, argc); // } } void glist_objectSetIdentifiersOfLast (t_glist *glist, int argc, t_atom *argv) { if (glist->gl_graphics) { // t_gobj *g1 = NULL; t_gobj *g2 = NULL; t_id u; t_error err = utils_uniqueWithAtoms (argc, argv, &u); PD_ASSERT (!err); PD_UNUSED (err); for ((g1 = glist->gl_graphics); (g2 = g1->g_next); (g1 = g2)) { } gobj_changeIdentifiers (g1, u); // } } void glist_objectSetSourceOfLast (t_glist *glist, int argc, t_atom *argv) { if (glist->gl_graphics) { // t_gobj *g1 = NULL; t_gobj *g2 = NULL; t_id u; t_error err = utils_uniqueWithAtoms (argc, argv, &u); PD_ASSERT (!err); PD_UNUSED (err); for ((g1 = glist->gl_graphics); (g2 = g1->g_next); (g1 = g2)) { } gobj_changeSource (g1, u); // } } void glist_objectSetWidthOfLast (t_glist *glist, int w) { if (glist->gl_graphics) { // t_gobj *g1 = NULL; t_gobj *g2 = NULL; for ((g1 = glist->gl_graphics); (g2 = g1->g_next); (g1 = g2)) { } if (cast_objectIfConnectable (g1)) { object_setWidth (cast_object (g1), PD_MAX (1, w)); if (glist_isOnScreen (glist)) { gobj_visibilityChanged (g1, glist, 0); gobj_visibilityChanged (g1, glist, 1); } } // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static void glist_objectAddProceed (t_glist *glist, t_gobj *y, t_gobj *first, int prepend) { y->g_next = NULL; if (first != NULL) { y->g_next = first->g_next; first->g_next = y; } else { // if (prepend || !glist->gl_graphics) { y->g_next = glist->gl_graphics; glist->gl_graphics = y; } else { t_gobj *t = NULL; for (t = glist->gl_graphics; t->g_next; t = t->g_next) { } t->g_next = y; } // } instance_registerAdd (y, glist); } void glist_objectAddNextProceed (t_glist *glist, t_gobj *y, t_gobj *first) { int needToRepaint = class_hasPainterBehavior (pd_class (y)); if (needToRepaint) { paint_erase(); } glist_objectAddProceed (glist, y, first, 0); if (cast_objectIfConnectable (y)) { editor_boxAdd (glist_getEditor (glist), cast_object (y)); } if (glist_isOnScreen (glist_getView (glist))) { gobj_visibilityChanged (y, glist, 1); } if (needToRepaint) { paint_draw(); } } void glist_objectAddUndoProceed (t_glist *glist, t_gobj *y) { if (glist_undoIsOk (glist)) { t_undosnippet *snippet = undosnippet_newSave (y, glist); if (glist_undoHasSeparatorAtLast (glist)) { glist_undoAppend (glist, undoadd_new()); } if (obj_isDummy (y)) { glist_undoAppendUnscheduled (glist, undocreate_new (y, snippet)); } else { glist_undoAppend (glist, undocreate_new (y, snippet)); } } } void glist_objectAddNext (t_glist *glist, t_gobj *y, t_gobj *first) { glist_objectAddNextProceed (glist, y, first); glist_objectAddUndoProceed (glist, y); } void glist_objectAdd (t_glist *glist, t_gobj *y) { glist_objectAddNextProceed (glist, y, NULL); glist_objectAddUndoProceed (glist, y); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- static void glist_objectRemoveProceed (t_glist *glist, t_gobj *y) { instance_registerRemove (y); if (gobj_isScalar (y)) { glist_setChangeTag (glist); } if (glist->gl_graphics == y) { glist->gl_graphics = y->g_next; } else { t_gobj *t = NULL; for (t = glist->gl_graphics; t; t = t->g_next) { if (t->g_next == y) { t->g_next = y->g_next; break; } } } } static void glist_objectRemoveFree (t_glist *glist, t_gobj *y) { if (gobj_hasDSP (y) && !gobj_isCanvas (y)) { if (garbage_newObject (y)) { return; } } if (instance_pendingRequired (y)) { instance_pendingAdd (y); return; } pd_free (cast_pd (y)); } void glist_objectRemove (t_glist *glist, t_gobj *y) { int needToInvalidate = gobj_isScalar (y); int needToRebuild = gobj_hasDSP (y); int needToRepaint = class_hasPainterBehavior (pd_class (y)) || (pd_class (y) == struct_class); int undoable = glist_undoIsOk (glist); int state = 0; glist_deleteBegin (glist); editor_motionUnset (glist_getEditor (glist), y); if (glist_objectIsSelected (glist, y)) { glist_objectDeselect (glist, y, 0); } if (needToRepaint) { paint_erase(); } if (glist_isOnScreen (glist)) { gobj_visibilityChanged (y, glist, 0); } if (gobj_isCanvas (y)) { glist_closebang (cast_glist (y)); } if (needToRebuild) { state = dsp_suspend(); } { t_box *box = NULL; if (cast_objectIfConnectable (y)) { box = box_fetch (glist, cast_object (y)); } if (undoable && glist_undoHasSeparatorAtLast (glist)) { glist_undoAppend (glist, undoremove_new()); } { t_undosnippet *snippet = NULL; if (undoable) { snippet = undosnippet_newSave (y, glist); } /* MUST be before call below. */ gobj_deleted (y, glist); if (undoable) { glist_undoAppend (glist, undodelete_new (y, snippet)); } } glist_objectRemoveProceed (glist, y); glist_objectRemoveFree (glist, y); if (box) { editor_boxRemove (glist_getEditor (glist), box); } } if (needToRebuild) { dsp_resume (state); } if (needToRepaint) { paint_draw(); } if (needToInvalidate) { glist->gl_uniqueIdentifier = utils_unique(); } /* Invalidate all pointers. */ glist_deleteEnd (glist); } /* Inlets and outlets must be deleted from right to left to handle Undo/Redo properly. */ static void glist_objectRemoveCacheInletsProceed (t_glist *glist, t_gobj *y, int isVinlet) { int i, n = isVinlet ? vinlet_getIndex ((t_vinlet *)y) : voutlet_getIndex ((t_voutlet *)y); t_atom a; for (i = 0; i < buffer_getSize (glist->gl_sorterIndexes); i++) { if (buffer_getFloatAtIndex (glist->gl_sorterIndexes, i) < n) { break; } } SET_FLOAT (&a, n); buffer_insertAtIndex (glist->gl_sorterIndexes, i, &a); SET_OBJECT (&a, y); buffer_insertAtIndex (glist->gl_sorterObjects, i, &a); } void glist_objectRemoveCacheInlets (t_glist *glist, t_gobj *y) { if (pd_class (y) == vinlet_class) { glist_objectRemoveCacheInletsProceed (glist, y, 1); } else if (pd_class (y) == voutlet_class) { glist_objectRemoveCacheInletsProceed (glist, y, 0); } else { glist_objectRemove (glist, y); } } void glist_objectRemovePurgeInlets (t_glist *glist) { int i; for (i = 0; i < buffer_getSize (glist->gl_sorterObjects); i++) { glist_objectRemove (glist, buffer_getObjectAt (glist->gl_sorterObjects, i)); } buffer_clear (glist->gl_sorterIndexes); buffer_clear (glist->gl_sorterObjects); } t_error glist_objectRemoveByUnique (t_id u) { t_gobj *object = instance_registerGetObject (u); t_glist *glist = instance_registerGetOwner (u); if (object && glist) { // glist_objectRemove (glist, object); return PD_ERROR_NONE; // } return PD_ERROR; } /* If needed the DSP is suspended to avoid multiple rebuilds of DSP graph. */ void glist_objectRemoveAll (t_glist *glist) { t_gobj *t1 = NULL; t_gobj *t2 = NULL; int dspState = 0; int dspSuspended = 0; for (t1 = glist->gl_graphics; t1; t1 = t2) { // t2 = t1->g_next; if (!dspSuspended) { if (gobj_hasDSP (t1)) { dspState = dsp_suspend(); dspSuspended = 1; } } glist_objectRemoveCacheInlets (glist, t1); // } glist_objectRemovePurgeInlets (glist); if (dspSuspended) { dsp_resume (dspState); } } void glist_objectRemoveAllByTemplate (t_glist *glist, t_template *tmpl) { t_gobj *t1 = NULL; t_gobj *t2 = NULL; for (t1 = glist->gl_graphics; t1; t1 = t2) { // t2 = t1->g_next; if (gobj_isScalar (t1)) { if (scalar_containsTemplate (cast_scalar (t1), template_getTemplateIdentifier (tmpl))) { glist_objectRemove (glist, t1); } } if (gobj_isCanvas (t1)) { glist_objectRemoveAllByTemplate (cast_glist (t1), tmpl); } // } } void glist_objectRemoveAllScalars (t_glist *glist) { t_gobj *t1 = NULL; t_gobj *t2 = NULL; for (t1 = glist->gl_graphics; t1; t1 = t2) { // t2 = t1->g_next; if (gobj_isScalar (t1)) { glist_objectRemove (glist, t1); } // } } void glist_objectRemoveInletsAndOutlets (t_glist *glist) { t_gobj *t1 = NULL; t_gobj *t2 = NULL; for (t1 = glist->gl_graphics; t1; t1 = t2) { // t_class *c = pd_class (t1); t2 = t1->g_next; if (c == vinlet_class || c == voutlet_class) { glist_objectRemoveCacheInlets (glist, t1); } // } glist_objectRemovePurgeInlets (glist); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_gobj *glist_objectGetAt (t_glist *glist, int n) { t_gobj *t = NULL; int i = 0; for (t = glist->gl_graphics; t; t = t->g_next) { if (i == n) { return t; } i++; } return NULL; } int glist_objectGetIndexOf (t_glist *glist, t_gobj *y) { t_gobj *t = NULL; int n = 0; for (t = glist->gl_graphics; t && t != y; t = t->g_next) { n++; } return n; } int glist_objectGetNumberOf (t_glist *glist) { return glist_objectGetIndexOf (glist, NULL); } int glist_objectMoveGetPosition (t_glist *glist, t_gobj *y) { return glist_objectGetIndexOf (glist, y); } void glist_objectMoveAtFirst (t_glist *glist, t_gobj *y) { glist_objectRemoveProceed (glist, y); glist_objectAddProceed (glist, y, NULL, 1); } void glist_objectMoveAtLast (t_glist *glist, t_gobj *y) { glist_objectRemoveProceed (glist, y); glist_objectAddProceed (glist, y, NULL, 0); } void glist_objectMoveAt (t_glist *glist, t_gobj *y, int n) { if (n < 1) { glist_objectMoveAtFirst (glist, y); } else { // glist_objectRemoveProceed (glist, y); glist_objectAddProceed (glist, y, glist_objectGetAt (glist, (n - 1)), 0); // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- t_error glist_objectMoveAtFirstByUnique (t_id u) { t_gobj *object = instance_registerGetObject (u); t_glist *glist = instance_registerGetOwner (u); if (object && glist) { // glist_objectMoveAtFirst (glist, object); glist_redrawRequired (glist); return PD_ERROR_NONE; // } return PD_ERROR; } t_error glist_objectMoveAtLastByUnique (t_id u) { t_gobj *object = instance_registerGetObject (u); t_glist *glist = instance_registerGetOwner (u); if (object && glist) { // glist_objectMoveAtLast (glist, object); glist_redrawRequired (glist); return PD_ERROR_NONE; // } return PD_ERROR; } t_error glist_objectMoveAtByUnique (t_id u, int n) { t_gobj *object = instance_registerGetObject (u); t_glist *glist = instance_registerGetOwner (u); if (object && glist) { // glist_objectMoveAt (glist, object, n); glist_redrawRequired (glist); return PD_ERROR_NONE; // } return PD_ERROR; } t_error glist_objectGetIndexOfByUnique (t_id u, int *n) { t_gobj *object = instance_registerGetObject (u); t_glist *glist = instance_registerGetOwner (u); if (object && glist) { // (*n) = glist_objectGetIndexOf (glist, object); return PD_ERROR_NONE; // } return PD_ERROR; } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_objectDeleteLines (t_glist *glist, t_object *o) { t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, glist); while ((connection = traverser_next (&t))) { // int m = (traverser_getSource (&t) == o); int n = (traverser_getDestination (&t) == o); if (m || n) { // glist_eraseLine (glist, traverser_getCord (&t)); traverser_disconnect (&t, glist); // } // } } static void glist_objectDeleteLinesByInlets (t_glist *glist, t_object *o, t_inlet *inlet, t_outlet *outlet) { t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, glist); while ((connection = traverser_next (&t))) { // int m = (traverser_getSource (&t) == o && traverser_getOutlet (&t) == outlet); int n = (traverser_getDestination (&t) == o && traverser_getInlet (&t) == inlet); if (m || n) { // glist_eraseLine (glist, traverser_getCord (&t)); traverser_disconnect (&t, glist); // } // } } void glist_objectDeleteLinesByInlet (t_glist *glist, t_object *o, t_inlet *inlet) { glist_objectDeleteLinesByInlets (glist, o, inlet, NULL); } void glist_objectDeleteLinesByOutlet (t_glist *glist, t_object *o, t_outlet *outlet) { glist_objectDeleteLinesByInlets (glist, o, NULL, outlet); } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_error glist_objectConnect (t_glist *glist, t_object *src, int m, t_object *dest, int n) { t_outconnect *connection = NULL; if ((connection = object_connect (src, m, dest, n))) { // if (glist_isOnScreen (glist)) { t_cord t; cord_make (&t, connection, src, m, dest, n, glist); glist_drawLine (glist, &t); } if (glist_undoIsOk (glist)) { glist_undoAppend (glist, undoconnect_new (src, m, dest, n)); } return PD_ERROR_NONE; // } return PD_ERROR; } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - t_inlet *glist_inletAdd (t_glist *glist, t_pd *receiver, int isSignal) { t_inlet *inlet = inlet_new (cast_object (glist), receiver, (isSignal ? &s_signal : NULL), NULL); if (!glist_isLoading (glist)) { // if (glist_isParentOnScreen (glist)) { gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 0); gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 1); glist_updateLinesForObject (glist_getParent (glist), cast_object (glist)); } glist_inletSort (glist); // } return inlet; } void glist_inletRemove (t_glist *glist, t_inlet *inlet) { t_glist *owner = glist_getParent (glist); int redraw = (owner && !glist_isDeleting (owner) && glist_isOnScreen (owner)); if (owner) { glist_objectDeleteLinesByInlet (owner, cast_object (glist), inlet); } if (redraw) { gobj_visibilityChanged (cast_gobj (glist), owner, 0); } inlet_free (inlet); if (redraw) { gobj_visibilityChanged (cast_gobj (glist), owner, 1); } if (owner) { glist_updateLinesForObject (owner, cast_object (glist)); } } int glist_inletNumberOf (t_glist *glist) { int n = 0; t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (pd_class (y) == vinlet_class) { n++; } } return n; } void glist_inletSort (t_glist *glist) { int numberOfInlets = glist_inletNumberOf (glist); if (numberOfInlets > 1) { // int i; t_gobj *y = NULL; /* Fetch all inlets into a list. */ t_gobj **inlets = (t_gobj **)PD_MEMORY_GET (numberOfInlets * sizeof (t_gobj *)); t_rectangle *boxes = (t_rectangle *)PD_MEMORY_GET (numberOfInlets * sizeof (t_rectangle)); t_gobj **t = inlets; t_rectangle *b = boxes; for (y = glist->gl_graphics; y; y = y->g_next) { // if (pd_class (y) == vinlet_class) { *t = y; gobj_getRectangle (y, glist, b); t++; b++; } // } /* Take the most right inlet and put it first. */ /* Remove it from the list. */ /* Do it again. */ for (i = numberOfInlets; i > 0; i--) { // int j = numberOfInlets; int maximumX = -PD_INT_MAX; t_gobj **mostRightInlet = NULL; for (t = inlets, b = boxes; j--; t++, b++) { if (*t && rectangle_getTopLeftX (b) > maximumX) { maximumX = rectangle_getTopLeftX (b); mostRightInlet = t; } } if (mostRightInlet) { inlet_moveFirst (vinlet_getInlet (cast_pd (*mostRightInlet))); *mostRightInlet = NULL; } // } PD_MEMORY_FREE (boxes); PD_MEMORY_FREE (inlets); if (glist_isParentOnScreen (glist)) { glist_updateLinesForObject (glist_getParent (glist), cast_object (glist)); } // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - static t_outlet *glist_outletAddProceed (t_glist *glist, t_outlet *outlet) { if (!glist_isLoading (glist)) { // if (glist_isParentOnScreen (glist)) { gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 0); gobj_visibilityChanged (cast_gobj (glist), glist_getParent (glist), 1); glist_updateLinesForObject (glist_getParent (glist), cast_object (glist)); } glist_outletSort (glist); // } return outlet; } t_outlet *glist_outletAddSignal (t_glist *glist) { return glist_outletAddProceed (glist, outlet_newSignal (cast_object (glist))); } t_outlet *glist_outletAdd (t_glist *glist) { return glist_outletAddProceed (glist, outlet_newMixed (cast_object (glist))); } void glist_outletRemove (t_glist *glist, t_outlet *outlet) { t_glist *owner = glist_getParent (glist); int redraw = (owner && !glist_isDeleting (owner) && glist_isOnScreen (owner)); if (owner) { glist_objectDeleteLinesByOutlet (owner, cast_object (glist), outlet); } if (redraw) { gobj_visibilityChanged (cast_gobj (glist), owner, 0); } outlet_free (outlet); if (redraw) { gobj_visibilityChanged (cast_gobj (glist), owner, 1); } if (owner) { glist_updateLinesForObject (owner, cast_object (glist)); } } int glist_outletNumberOf (t_glist *glist) { int n = 0; t_gobj *y = NULL; for (y = glist->gl_graphics; y; y = y->g_next) { if (pd_class (y) == voutlet_class) { n++; } } return n; } void glist_outletSort (t_glist *glist) { int numberOfOutlets = glist_outletNumberOf (glist); if (numberOfOutlets > 1) { // int i; t_gobj *y = NULL; /* Fetch all outlets into a list. */ t_gobj **outlets = (t_gobj **)PD_MEMORY_GET (numberOfOutlets * sizeof (t_gobj *)); t_rectangle *boxes = (t_rectangle *)PD_MEMORY_GET (numberOfOutlets * sizeof (t_rectangle)); t_gobj **t = outlets; t_rectangle *b = boxes; for (y = glist->gl_graphics; y; y = y->g_next) { // if (pd_class (y) == voutlet_class) { *t = y; gobj_getRectangle (y, glist, b); t++; b++; } // } /* Take the most right outlet and put it first. */ /* Remove it from the list. */ /* Do it again. */ for (i = numberOfOutlets; i > 0; i--) { // int j = numberOfOutlets; int maximumX = -PD_INT_MAX; t_gobj **mostRightOutlet = NULL; for (t = outlets, b = boxes; j--; t++, b++) { if (*t && rectangle_getTopLeftX (b) > maximumX) { maximumX = rectangle_getTopLeftX (b); mostRightOutlet = t; } } if (mostRightOutlet) { outlet_moveFirst (voutlet_getOutlet (cast_pd (*mostRightOutlet))); *mostRightOutlet = NULL; } // } PD_MEMORY_FREE (boxes); PD_MEMORY_FREE (outlets); if (glist_isParentOnScreen (glist)) { glist_updateLinesForObject (glist_getParent (glist), cast_object (glist)); } // } } // ----------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------- // MARK: - void glist_lineSelect (t_glist *glist, t_traverser *t) { glist_deselectAll (glist); editor_selectedLineSet (glist_getEditor (glist), cord_getConnection (traverser_getCord (t)), glist_objectGetIndexOf (glist, cast_gobj (traverser_getSource (t))), traverser_getIndexOfOutlet (t), glist_objectGetIndexOf (glist, cast_gobj (traverser_getDestination (t))), traverser_getIndexOfInlet (t)); glist_updateLineSelected (glist, 1); } void glist_lineDeselect (t_glist *glist) { glist_updateLineSelected (glist, 0); editor_selectedLineReset (glist_getEditor (glist)); } int glist_lineExist (t_glist *glist, t_object *o, int m, t_object *i, int n) { t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, glist); while ((connection = traverser_next (&t))) { if (traverser_isLineBetween (&t, o, m, i, n)) { return 1; } } return 0; } t_error glist_lineConnect (t_glist *glist, int indexOfObjectOut, int indexOfOutlet, int indexOfObjectIn, int indexOfInlet) { t_gobj *src = glist_objectGetAt (glist, indexOfObjectOut); t_gobj *dest = glist_objectGetAt (glist, indexOfObjectIn); PD_ASSERT (src); PD_ASSERT (dest); if (src && dest) { // t_object *srcObject = cast_objectIfConnectable (src); t_object *destObject = cast_objectIfConnectable (dest); if (srcObject && destObject) { // int m = indexOfOutlet; int n = indexOfInlet; /* Creates dummy outlets and inlets. */ /* It is required in case of failure at object creation. */ if (object_isDummy (srcObject)) { while (m >= object_getNumberOfOutlets (srcObject)) { outlet_newUndefined (srcObject); } } if (object_isDummy (destObject)) { while (n >= object_getNumberOfInlets (destObject)) { inlet_new (destObject, cast_pd (destObject), NULL, NULL); } } return glist_objectConnect (glist, srcObject, m, destObject, n); // } // } return PD_ERROR; } t_error glist_lineConnectByUnique (t_id u, int indexOfOutlet, t_id v, int indexOfInlet) { t_gobj *src = instance_registerGetObject (u); t_gobj *dest = instance_registerGetObject (v); if (src && dest) { // t_object *srcObject = cast_objectIfConnectable (src); t_object *destObject = cast_objectIfConnectable (dest); if (srcObject && destObject) { // t_glist *srcOwner = instance_registerGetOwner (u); t_glist *destOwner = instance_registerGetOwner (v); if (srcOwner && (srcOwner == destOwner)) { return glist_objectConnect (srcOwner, srcObject, indexOfOutlet, destObject, indexOfInlet); } // } // } return PD_ERROR; } t_error glist_lineDisconnect (t_glist *glist, int indexOfObjectOut, int indexOfOutlet, int indexOfObjectIn, int indexOfInlet) { t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, glist); while ((connection = traverser_next (&t))) { // if ((traverser_getIndexOfOutlet (&t) == indexOfOutlet)) { if ((traverser_getIndexOfInlet (&t) == indexOfInlet)) { int m = glist_objectGetIndexOf (glist, cast_gobj (traverser_getSource (&t))); int n = glist_objectGetIndexOf (glist, cast_gobj (traverser_getDestination (&t))); if (m == indexOfObjectOut && n == indexOfObjectIn) { glist_eraseLine (glist, traverser_getCord (&t)); traverser_disconnect (&t, glist); return PD_ERROR_NONE; } } } // } return PD_ERROR; } t_error glist_lineDisconnectByUnique (t_id u, int indexOfOutlet, t_id v, int indexOfInlet) { t_glist *srcOwner = instance_registerGetOwner (u); t_glist *destOwner = instance_registerGetOwner (v); if (srcOwner && (srcOwner == destOwner)) { // t_gobj *src = instance_registerGetObject (u); t_gobj *dest = instance_registerGetObject (v); if (src && dest) { // t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, srcOwner); while ((connection = traverser_next (&t))) { // if (indexOfOutlet == traverser_getIndexOfOutlet (&t)) { if (indexOfInlet == traverser_getIndexOfInlet (&t)) { if (src == cast_gobj (traverser_getSource (&t))) { if (dest == cast_gobj (traverser_getDestination (&t))) { // glist_eraseLine (srcOwner, traverser_getCord (&t)); return traverser_disconnect (&t, srcOwner); // } } } } // } // } // } return PD_ERROR; } void glist_lineDeleteSelected (t_glist *glist) { if (editor_hasSelectedLine (glist_getEditor (glist))) { editor_selectedLineDisconnect (glist_getEditor (glist)); glist_setDirty (glist, 1); if (glist_undoIsOk (glist)) { glist_undoAppendSeparator (glist); } } } void glist_lineCheck (t_glist *glist, t_object *o) { t_outconnect *connection = NULL; t_traverser t; traverser_start (&t, glist); while ((connection = traverser_next (&t))) { // t_object *o1 = traverser_getSource (&t); t_object *o2 = traverser_getDestination (&t); if (!object_isDummy (o1) && !object_isDummy (o2)) { if (o1 == o || o2 == o) { int m = traverser_getIndexOfOutlet (&t); int n = traverser_getIndexOfInlet (&t); if (object_isSignalOutlet (o1, m) && !object_isSignalInlet (o2, n)) { traverser_disconnect (&t, NULL); error_failed (sym_connect); } } } // } } // ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------
29.309945
110
0.536578
[ "object" ]
7b218fd0a2dea2af3360a5f3b977c94fecf71332
759
h
C
DFCache/Private/DFCachePrivate.h
logaritmdev/DFCache
8dcfc9c075319b853a16b4d1eb1221be5dbc687d
[ "MIT" ]
163
2015-02-03T03:08:58.000Z
2021-09-05T11:42:46.000Z
DFCache/Private/DFCachePrivate.h
logaritmdev/DFCache
8dcfc9c075319b853a16b4d1eb1221be5dbc687d
[ "MIT" ]
5
2015-04-03T08:33:46.000Z
2017-12-17T18:54:09.000Z
DFCache/Private/DFCachePrivate.h
logaritmdev/DFCache
8dcfc9c075319b853a16b4d1eb1221be5dbc687d
[ "MIT" ]
27
2015-02-08T14:02:44.000Z
2020-02-04T09:45:20.000Z
// The MIT License (MIT) // // Copyright (c) 2015 Alexander Grebenyuk (github.com/kean). #import <Foundation/Foundation.h> #pragma mark - Functions - static inline void _dwarf_cache_callback(void (^block)(id), id object) { if (block != nil) { dispatch_async(dispatch_get_main_queue(), ^{ block(object); }); } } /*! Produces 160-bit hash value using SHA-1 algorithm. @return String containing 160-bit hash value expressed as a 40 digit hexadecimal number. */ extern NSString * _dwarf_cache_sha1(const char *data, uint32_t length); /*! Returns user-friendly string with bytes. */ extern NSString * _dwarf_bytes_to_str(unsigned long long bytes); #pragma mark - Types - typedef unsigned long long _dwarf_cache_bytes;
23.71875
89
0.70751
[ "object" ]
7e2347a8ea28cc7606c9f5f4ae4d4e8e96fcaba3
40,236
h
C
SRC/engine/cskeleton2.h
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
31
2015-04-01T15:59:36.000Z
2022-03-18T20:21:47.000Z
SRC/engine/cskeleton2.h
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
3
2015-02-06T19:30:24.000Z
2017-05-25T14:14:31.000Z
SRC/engine/cskeleton2.h
usnistgov/OOF3D
4fd423a48aea9c5dc207520f02de53ae184be74c
[ "X11" ]
7
2015-01-23T15:19:22.000Z
2021-06-09T09:03:59.000Z
// -*- C++ -*- /* This software was produced by NIST, an agency of the U.S. government, * and by statute is not subject to copyright in the United States. * Recipients of this software assume all responsibilities associated * with its operation, modification and maintenance. However, to * facilitate maintenance we ask that before distributing modified * versions of this software, you first contact the authors at * oof_manager@nist.gov. */ #include <oofconfig.h> #ifndef CSKELETON2_H #define CSKELETON2_H #include "common/coord_i.h" #include "common/geometry.h" #include "common/pythonexportable.h" #include "common/VSB/cplane.h" #include "common/VSB/cprism.h" #include "engine/catvoldata.h" #include "engine/cskeleton2_i.h" #include "engine/cskeletonboundary.h" #include "engine/cskeletonface.h" #include "engine/cskeletonselectable_i.h" #include "engine/homogeneity.h" #include <vtkSmartPointer.h> #include <set> #include <map> class FEMesh; class FaceSubstitution; class GhostOOFCanvas; class HomogeneityData; class LineSegmentLayer; class MasterElement; class Material; class ProvisionalMerge; class SegmentSubstitution; class SkeletonFilter; class TimeStamp; class VoxelSetBoundary; class vtkCellLocator; class vtkDataArray; class vtkMergePoints; class vtkPoints; class vtkUnstructuredGrid; // TODO 3.1: make everything const that should be const. #ifdef DEBUG typedef std::set<Coord3D> NodePositionSet; typedef std::map<Coord3D, int> NodePositionMap; typedef std::map<const NodePositionSet, unsigned int> ElNodesMap; // g++ on Linux complains if NodePosSetSet is defined as // std::set<const NodePositionSet> for some reason. clang++ on Mac is // ok with it. typedef std::set<NodePositionSet> NodePosSetSet; #endif // DEBUG //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// // Tetrahedron arrangements for the initial Skeleton. The members of // this class must correspond to members of the Python Arrangement // Enum class, which is defined in cskeleton2.spy. The correspondence // is defined in the TetArrangement* typemap in cskeleton2.swg. //* TODO 3.1: This is ugly. Somehow make the Python and C++ enums agree //* automatically. enum TetArrangement { MODERATE_ARRANGEMENT, MIDDLING_ARRANGEMENT }; //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// // OuterFaceID and OuterEdgeID objects are used to identify the face // boudaries and edge boundaries when doing certain manipulations, // such as detecting different situations in the rationalization // process. // TODO 3.1: These classes hold the same information as the predefined // skeleton boundary definitions. Probably they should be unified // somehow. Perhaps the skeleton boundaries can use these classes to // determine the boundary geometry. Eventually it might be a good // idea to have an abstract way of determining which objects are on // which boundaries. class OuterFaceID { private: const int dir; // 0, 1, or 2, for x, y, z. const int id; const std::string name; public: OuterFaceID(int d, int id, const std::string &n) : dir(d), id(id), name(n) {} int direction() const { return dir; } bool operator==(const OuterFaceID &other) const { return id == other.id; } bool operator!=(const OuterFaceID &other) const { return id != other.id; } operator bool() const { return id >= 0; } // OUTERFACE_NONE has id==-1 bool contains(const Coord&, const CSkeletonBase*) const; friend std::ostream &operator<<(std::ostream&, const OuterFaceID&); friend class OuterEdgeID; }; extern const OuterFaceID OUTERFACE_NONE, OUTERFACE_XMIN, OUTERFACE_XMAX, OUTERFACE_YMIN, OUTERFACE_YMAX, OUTERFACE_ZMIN, OUTERFACE_ZMAX; typedef std::map<CSkeletonNode*, Coord> NodePositionsMap; typedef std::list<CDeputySkeleton*> CDeputySkeletonList; class OuterEdgeID { private: const OuterFaceID face0, face1; public: OuterEdgeID(const OuterFaceID&, const OuterFaceID&); bool operator==(const OuterEdgeID &other) const { return face0==other.face0 && face1==other.face1; } bool operator!=(const OuterEdgeID &other) const { return face0!=other.face0 || face1!=other.face1; } bool contains(const Coord &pt, const CSkeletonBase *skel) const { return face0.contains(pt, skel) && face1.contains(pt, skel); } operator bool() const { return face0 != OUTERFACE_NONE; } friend std::ostream &operator<<(std::ostream&, const OuterEdgeID&); }; extern const OuterEdgeID OUTEREDGE_NONE, OUTEREDGE_XMINYMIN, OUTEREDGE_XMINYMAX, OUTEREDGE_XMINZMIN, OUTEREDGE_XMINZMAX, OUTEREDGE_XMAXYMIN, OUTEREDGE_XMAXYMAX, OUTEREDGE_XMAXZMIN, OUTEREDGE_XMAXZMAX, OUTEREDGE_YMINZMIN, OUTEREDGE_YMINZMAX, OUTEREDGE_YMAXZMIN, OUTEREDGE_YMAXZMAX; //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// // CSkeletonBase is the base class for CSkeleton and CDeputySkeleton. class CSkeletonBase : public PythonExportable<CSkeletonBase> { protected: static uidtype uidbase; uidtype uid; bool illegal_; // TODO: Is too much mutable here? The methods that compute // homogeneities are const, so the data that they use has to be // mutable. mutable int illegalCount; mutable int suspectCount; mutable double homogeneityIndex; mutable double unweightedHomogIndex; mutable double unweightedShapeEnergy; mutable double weightedShapeEnergy; mutable TimeStamp homogeneity_index_computation_time; mutable TimeStamp unweighted_homogeneity_computation_time; mutable TimeStamp unweighted_shape_energy_computation_time; mutable TimeStamp weighted_shape_energy_computation_time; mutable TimeStamp illegality_computation_time; mutable TimeStamp illegal_count_computation_time; mutable TimeStamp suspect_count_computation_time; TimeStamp geometry_timestamp; // If more timestamps and other such data is added here, make sure // that CSkeleton::completeCopy() copies them. static const std::string modulename_; OuterFaceID onOuterFace_(const CSkeletonNodeVector*, bool boundary[6]) const; // The voxel set boundary data is stored in the Skeleton because its // bin size is matched to the average Skeleton element size. mutable std::vector<VoxelSetBoundary*> voxelSetBdys; // one for each category. // The prisms that define the subregions are stored here in the // skeleton because they're shared by all VoxelSetBoundaries. mutable std::vector<ICRectPrism<ICoord3D>> vsbBins; mutable ICoord3D vsbBinSize; // nominal size of bins. // defaultVSBbin is the size used when there's not enough // information to determine a good bin size. It's set by the // constructor to DEFAULT_VSB_BIN, and reset by // setDefaultVSBbinSize(), which is called by routines that copy // CSkeletons. ICoord3D defaultVSBbin; mutable TimeStamp vsbTimeStamp; public: CSkeletonBase(); virtual ~CSkeletonBase(); virtual void destroy() = 0; uidtype getUid() const { return uid; } virtual const std::string &modulename() const { return modulename_; } // void updateGeometry() { // ++timestamp; // } void incrementTimestamp(); const TimeStamp &getTimeStamp() const; // basic get methods // TODO: There's no good reason for getMicrostructure() to be virtual. // Move the MS pointer to CSkeletonBase. virtual CMicrostructure *getMicrostructure() const = 0; virtual vtkSmartPointer<vtkUnstructuredGrid> getGrid() const = 0; virtual void getVtkCells(SkeletonFilter*, vtkSmartPointer<vtkUnstructuredGrid>) = 0; #ifdef DEBUG virtual void getVtkSegments(SkeletonFilter*, vtkSmartPointer<vtkUnstructuredGrid>) = 0; virtual void getExtraVtkSegments(CSkeletonBase*, vtkSmartPointer<vtkUnstructuredGrid>) = 0; #endif // DEBUG const std::string &getElementType(int eidx); virtual vtkSmartPointer<vtkDataArray> getMaterialCellData( const SkeletonFilter*) const = 0; virtual vtkSmartPointer<vtkDataArray> getEnergyCellData( double alpha, const SkeletonFilter*) const = 0; virtual vtkSmartPointer<vtkPoints> getPoints() const = 0; virtual CSkeletonNode *getNode(unsigned int nidx) const = 0; virtual bool hasNode(CSkeletonNode *) const = 0; virtual CSkeletonElement *getElement(unsigned int eidx) const = 0; virtual bool hasElement(CSkeletonElement *) const = 0; virtual CSkeletonSegment *getSegment(const CSkeletonMultiNodeKey &h) const=0; virtual CSkeletonFace *getFace(const CSkeletonMultiNodeKey &h) const = 0; virtual CSkeletonSegment *getSegmentByUid(uidtype) const = 0; virtual CSkeletonFace *getFaceByUid(uidtype) const = 0; virtual CSkeletonNodeIterator beginNodes() const = 0; virtual CSkeletonNodeIterator endNodes() const = 0; virtual CSkeletonElementIterator beginElements() const = 0; virtual CSkeletonElementIterator endElements() const = 0; virtual CSkeletonSegmentIterator beginSegments() const = 0; virtual CSkeletonSegmentIterator endSegments() const = 0; virtual CSkeletonFaceIterator beginFaces() const = 0; virtual CSkeletonFaceIterator endFaces() const = 0; // basic info virtual unsigned int nnodes() const = 0; virtual unsigned int nelements() const = 0; virtual unsigned int nsegments() const = 0; virtual unsigned int nfaces() const = 0; virtual double volume() const = 0; virtual bool getPeriodicity(int dim) const = 0; bool illegal() const { return illegal_; } void setIllegal() { illegal_= true; } bool checkIllegality(); void backdateIllegalityTimeStamp(); int getIllegalCount(); void getIllegalElements(CSkeletonElementVector &) const; int getSuspectCount(); void getSuspectElements(CSkeletonElementVector &) const; virtual int nDeputies() const = 0; // TODO 3.1: Change these names. These methods are called only by the // GenericGroupSet.impliedAddDown methods when building groups for // new CSkeletons and CDeputySkeletons. virtual void nodesAddGroupsDown(CGroupTrackerVector*) = 0; virtual void segmentsAddGroupsDown(CGroupTrackerVector*) = 0; virtual void facesAddGroupsDown(CGroupTrackerVector*) = 0; virtual void elementsAddGroupsDown(CGroupTrackerVector*) = 0; // connectivity // TODO: Many of these methods should be rewritten to just // return a std container, instead of returning the result in an // argument. void getSegmentElements(const CSkeletonSegment *segment, CSkeletonElementVector &) const; void getConstSegmentElements(const CSkeletonSegment *segment, ConstCSkeletonElementVector &) const; CSkeletonElementVector getSegmentElements(const CSkeletonSegment*) const; void getSegmentFaces(const CSkeletonSegment*, CSkeletonFaceVector&) const; void getFaceElements(const CSkeletonFace*, CSkeletonElementVector&) const; void getFaceElements(const CSkeletonFace*, ConstCSkeletonElementVector&) const; void getNeighborNodes(const CSkeletonNode *, CSkeletonNodeSet &) const; void getNodeSegments(const CSkeletonNode *, CSkeletonSegmentSet &) const; void getNodeFaces(const CSkeletonNode *, CSkeletonFaceSet &) const; CSkeletonSegment *getFaceSegment(const CSkeletonFace*, int idx) const; void getFaceSegments(const CSkeletonFace*, CSkeletonSegmentSet&) const; CSkeletonSegment *getElementSegment(const CSkeletonElement*, int idx) const; CSkeletonSegmentVector *getElementSegments(const CSkeletonElement*) const; CSkeletonFace *getElementFace(const CSkeletonElement*, int idx) const; CSkeletonFaceVector *getElementFaces(const CSkeletonElement*) const; CSkeletonElement *getSister(const CSkeletonElement*, const CSkeletonFace*) const; //CSkeletonElement *getSisterPeriodic(int face) const; void getInternalBoundaryNodes(CSkeletonNodeSet &nodes) const; ConstCSkeletonElementSet *getElementNeighbors(const CSkeletonElement*) const; Coord averageNeighborPosition(const CSkeletonNode*) const; Coord averageNeighborPosition(const CSkeletonNode*, const CSkeletonNodeSet&) const; Coord averageConstrainedNbrPosition(const CSkeletonNode*) const; Coord averageConstrainedNbrPosition(const CSkeletonNode*, const CSkeletonNodeSet&) const; // convenience functions for boundary building CSkeletonElement *getOrientedSegmentElement(OrientedCSkeletonSegment *seg); CSkeletonElement *getOrientedFaceElement(OrientedCSkeletonFace *face); // finding things virtual const Coord nodePositionForSkeleton(CSkeletonNode *n) = 0; const CSkeletonElement* enclosingElement(Coord *point); CSkeletonElement *findElement(vtkSmartPointer<vtkCell>) const; virtual vtkSmartPointer<vtkCellLocator> get_element_locator() = 0; const CSkeletonNode* nearestNode(Coord *point); virtual vtkSmartPointer<vtkMergePoints> get_point_locator() = 0; //virtual vtkPointLocator* get_point_locator() = 0; const CSkeletonSegment* nearestSegment(Coord *point); CSkeletonSegment* findExistingSegment(const CSkeletonNode *n1, const CSkeletonNode *n2) const; CSkeletonSegment *findExistingSegmentByIds(const std::vector<int>*) const; bool doesSegmentExist(const CSkeletonNode *n1, const CSkeletonNode *n2) const; virtual bool inSegmentMap(const CSkeletonMultiNodeKey &h) const = 0; const CSkeletonFace* nearestFace(Coord *point); CSkeletonFace* findExistingFace(CSkeletonNode *n1, CSkeletonNode *n2, CSkeletonNode *n3) const; CSkeletonFace *findExistingFaceByIds(const std::vector<int>*) const; OrientedCSkeletonFace *createOrientedFace(CSkeletonNode *n1, CSkeletonNode *n2, CSkeletonNode *n3) const; OuterFaceID onOuterFace(const CSkeletonNodeVector*) const; OuterFaceID onSameOuterFace(const CSkeletonNodeVector*, const CSkeletonNodeVector*) const; bool onOuterFace(const OuterFaceID, const CSkeletonNodeVector*) const; OuterEdgeID onOuterEdge(const CSkeletonNodeVector*) const; // OuterEdgeID onOuterEdge(const CSkeletonNode*, const CSkeletonNode*, // const CSkeletonNode*) const; bool checkExteriorSegments(const CSkeletonSegmentVector*) const; bool checkExteriorFaces(const CSkeletonFaceVector*) const; // homogeneity and shape energy double getHomogeneityIndex() const; void calculateHomogeneityIndex() const; double getUnweightedHomogeneity() const; void calculateUnweightedHomogeneity() const; double getUnweightedShapeEnergy() const; double getWeightedShapeEnergy() const; double energyTotal(double alpha) const; double clippedCategoryVolume(unsigned int, const CRectangularPrism&, const std::vector<VSBPlane<Coord3D>>&) const; void setDefaultVSBbinSize(const CSkeletonBase*); void buildVSBs() const; void clearVSBs() const; const VoxelSetBoundary *getVoxelSetBoundary(int cat) const { return voxelSetBdys[cat]; } ICoord3D getDefaultVSBbinSize() const; // guesses a reasonable size // Routines for testing and debugging VSBs CategoryVolumesData *checkCategoryVolumes() const; bool checkVSB(int) const; void dumpVSB(int, const std::string&) const;// save VSB graph to file void dumpVSBLines(int, const std::string&) const; // plot VSB edge void drawVoxelSetBoundary(LineSegmentLayer*, int) const; void saveClippedVSB(int, const std::vector<VSBPlane<Coord3D>>&, const std::string&) const; void saveClippedVSB(int, const VSBPlane<Coord3D>&, const std::string&) const; double clipVSBVol(int, const VSBPlane<Coord3D>&) const; // methods related to deputies and copying virtual CSkeleton *sheriffSkeleton() = 0; virtual const CSkeleton *sheriffSkeleton() const = 0; virtual NodePositionsMap *getMovedNodes() const = 0; virtual void activate() = 0; CDeputySkeleton *deputyCopy(); virtual CSkeleton *nodeOnlyCopy() = 0; virtual CSkeleton *completeCopy() = 0; virtual void needsHash() = 0; virtual CSkeletonPointBoundary *getPointBoundary(const std::string &name, bool exterior) = 0; virtual CSkeletonPointBoundary *makePointBoundary(const std::string &name, CSkeletonNodeVector *nodes, bool exterior=false) = 0; virtual CSkeletonEdgeBoundary *getEdgeBoundary(const std::string &name, bool exterior) = 0; virtual CSkeletonEdgeBoundary *makeEdgeBoundary( const std::string &name, const CSkeletonSegmentVector *segs, const CSkeletonNode *start_node, bool exterior=false) = 0; virtual CSkeletonEdgeBoundary *makeEdgeBoundary3D( const std::string &name, const SegmentSequence*, bool exterior=false) = 0; virtual CSkeletonFaceBoundary *getFaceBoundary(const std::string &name, OrientedSurface*, bool exterior) = 0; virtual CSkeletonFaceBoundary *makeFaceBoundary(const std::string &name, OrientedSurface*, bool exterior=false) = 0; virtual CSkeletonPointBoundaryMap *getPointBoundaries() = 0; virtual CSkeletonEdgeBoundaryMap *getEdgeBoundaries() = 0; virtual CSkeletonFaceBoundaryMap *getFaceBoundaries() = 0; virtual std::string *compare(CSkeletonBase *other, double tolerance) const = 0; // real meshes //virtual FEMesh* femesh() = 0; virtual void populate_femesh(FEMesh *fem, const MasterElement*, Material *mat=NULL) = 0; virtual void cleanUp() = 0; virtual void printSelf(std::ostream&) const = 0; const std::string *sanityCheck() const; #ifdef DEBUG // Code for checking that the differences between two Skeletons are // understood. Used to check that changes in reference files in the // test suite aren't significant after changes to exactly how the // homogeneity is computed, and roundoff error is causing the // refinment routines to make different choices. virtual std::string *compare2(const CSkeletonBase *other) const = 0; NodePosSetSet unmatchedSixNodeGroups(const NodePosSetSet&, const ElNodesMap&) const; #endif // DEBUG // TODO 3.1: 3D need to move more functions below to the base? }; // CSkeletonBase //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// class CSkeleton : public CSkeletonBase { private: CMicrostructure *MS; Coord size; double volume_; bool *periodicity; vtkSmartPointer<vtkUnstructuredGrid> grid; vtkSmartPointer<vtkPoints> points; CSkeletonNodeVector nodes; CSkeletonElementVector elements; CSkeletonSegmentMap segments; CSkeletonFaceMap faces; vtkSmartPointer<vtkCellLocator> element_locator; // TODO 3.1: is this thread safe? vtkSmartPointer<vtkMergePoints> point_locator; // TODO 3.1: is this thread safe? CDeputySkeleton *deputy; // The currently active deputy. CDeputySkeletonList deputy_list; // All deputies. bool washMe; int numDefunctNodes; static const std::string classname_; CSkeletonPointBoundaryMap pointBoundaries; CSkeletonEdgeBoundaryMap edgeBoundaries; CSkeletonFaceBoundaryMap faceBoundaries; // zombie is true if this CSkeleton has been pushed off the // SkeletonContext's undobuffer but still has deputies. bool zombie; public: CSkeleton(CMicrostructure *ms, bool prdcty[DIM]); virtual ~CSkeleton(); virtual void destroy(); void destroyZombie(); virtual const std::string &classname() const { return classname_; } // initialization members - TODO MER: add the 2D methods void createPointGrid(int m, int n, int l); void createTetra(const TetArrangement*, int m, int n, int l); CSkeletonNode *addNode(const Coord&); void addElement(CSkeletonElement *element, vtkIdType *ids); void createElement(vtkIdType type, vtkIdType numpts, vtkIdType *ids); void acceptProvisionalElement(CSkeletonElement *element); CSkeletonSegment *getOrCreateSegment(CSkeletonNode *n1, CSkeletonNode *n2); CSkeletonFace *getOrCreateFace(CSkeletonNode *n1, CSkeletonNode *n2, CSkeletonNode *n3); void addGridSegmentsToBoundaries(const ICoord &, const ICoord &); void addGridFacesToBoundaries(const ICoord &idx, const ICoord &nml, bool flip); // basic get methods virtual CMicrostructure *getMicrostructure() const { return MS; } virtual vtkSmartPointer<vtkUnstructuredGrid> getGrid() const { return grid; } virtual void getVtkCells(SkeletonFilter*, vtkSmartPointer<vtkUnstructuredGrid>); #ifdef DEBUG virtual void getVtkSegments(SkeletonFilter*, vtkSmartPointer<vtkUnstructuredGrid>); virtual void getExtraVtkSegments(CSkeletonBase*, vtkSmartPointer<vtkUnstructuredGrid>); #endif // DEBUG virtual vtkSmartPointer<vtkDataArray> getMaterialCellData( const SkeletonFilter*) const; virtual vtkSmartPointer<vtkDataArray> getEnergyCellData( double alpha, const SkeletonFilter*) const; virtual vtkSmartPointer<vtkPoints> getPoints() const { return points; } virtual CSkeletonNode *getNode(unsigned int nidx) const; virtual bool hasNode(CSkeletonNode *) const; virtual CSkeletonElement *getElement(unsigned int eidx) const; virtual bool hasElement(CSkeletonElement *) const; virtual CSkeletonSegment *getSegment(const CSkeletonMultiNodeKey &h) const; virtual CSkeletonFace *getFace(const CSkeletonMultiNodeKey &h) const; virtual CSkeletonSegment *getSegmentByUid(uidtype) const; virtual CSkeletonFace *getFaceByUid(uidtype) const; virtual CSkeletonNodeIterator beginNodes() const { return nodes.begin(); } virtual CSkeletonNodeIterator endNodes() const { return nodes.end(); } virtual CSkeletonElementIterator beginElements() const { return elements.begin(); } virtual CSkeletonElementIterator endElements() const { return elements.end(); } virtual CSkeletonSegmentIterator beginSegments() const { return segments.begin(); } virtual CSkeletonSegmentIterator endSegments() const { return segments.end(); } virtual CSkeletonFaceIterator beginFaces() const { return faces.begin(); } virtual CSkeletonFaceIterator endFaces() const { return faces.end(); } // information and calculation methods // TODO 3.1: need to subtract defunct things? Not subtracting // doesn't seem to be causing a problem... virtual unsigned int nnodes() const { return nodes.size(); } virtual unsigned int nelements() const { return elements.size(); } virtual unsigned int nsegments() const { return segments.size(); } virtual unsigned int nfaces() const { return faces.size(); } virtual double volume() const { return volume_; } virtual bool getPeriodicity(int dim) const { return periodicity[dim]; } //vtkPoints *getElementPoints(int eidx); uidtype getNodeUid(int nidx) const; uidtype getElementUid(int eidx) const; virtual const Coord nodePositionForSkeleton(CSkeletonNode *n); virtual vtkSmartPointer<vtkCellLocator> get_element_locator(); virtual vtkSmartPointer<vtkMergePoints> get_point_locator(); virtual bool inSegmentMap(const CSkeletonMultiNodeKey &h) const; virtual std::string *compare(CSkeletonBase *other, double tolerance) const; #ifdef DEBUG virtual std::string *compare2(const CSkeletonBase *other) const; #endif // DEBUG // boundaries void checkBoundaryNames(const std::string &name); virtual CSkeletonPointBoundary *getPointBoundary(const std::string &name, bool exterior); virtual CSkeletonPointBoundary *makePointBoundary(const std::string &name, CSkeletonNodeVector *nodes, bool exterior=false); virtual CSkeletonEdgeBoundary *getEdgeBoundary(const std::string &name, bool exterior); virtual CSkeletonEdgeBoundary *makeEdgeBoundary( const std::string &name, const CSkeletonSegmentVector *segs, const CSkeletonNode *start_node, bool exterior=false); virtual CSkeletonEdgeBoundary *makeEdgeBoundary3D(const std::string &name, const SegmentSequence*, bool exterior=false); virtual CSkeletonFaceBoundary *getFaceBoundary(const std::string &name, OrientedSurface*, bool exterior); virtual CSkeletonFaceBoundary *makeFaceBoundary(const std::string &name, OrientedSurface*, bool exterior=false); void removeBoundary(const std::string &name); void renameBoundary(const std::string &oldname, const std::string &newname); virtual CSkeletonPointBoundaryMap *getPointBoundaries() { return &pointBoundaries; } virtual CSkeletonEdgeBoundaryMap *getEdgeBoundaries() { return &edgeBoundaries; } virtual CSkeletonFaceBoundaryMap *getFaceBoundaries() { return &faceBoundaries; } // methods related to deputies and sheriffs virtual CSkeleton* sheriffSkeleton(); virtual const CSkeleton* sheriffSkeleton() const; void addDeputy(CDeputySkeleton* dep); virtual NodePositionsMap *getMovedNodes() const; virtual void activate(); void deputize(CDeputySkeleton* deputy); virtual void needsHash(); CDeputySkeleton* deputySkeleton() { return deputy; } const CDeputySkeletonList *getDeputyList() const { return &deputy_list; } void removeDeputy(CDeputySkeleton *dep); virtual int nDeputies() const { return deputy_list.size(); } void copyNodes(CSkeleton *) const; virtual CSkeleton *nodeOnlyCopy(); virtual CSkeleton *completeCopy(); ProvisionalMerge *mergeNode(CSkeletonNode *n0, CSkeletonNode *n1); ProvisionalMerge *addElementsToMerge(CSkeletonNode *n0, CSkeletonNode *n1, ProvisionalMerge *merge); void removeElements(const CSkeletonElementSet&); void removeElement(CSkeletonElement*); void removeNode(CSkeletonNode*); void dirty() { washMe = true; } virtual void cleanUp(); bool moveNodeTo(CSkeletonNode *node, const Coord &position); bool moveNodeBy(CSkeletonNode *node, const Coord &position); virtual void nodesAddGroupsDown(CGroupTrackerVector*); virtual void segmentsAddGroupsDown(CGroupTrackerVector*); virtual void facesAddGroupsDown(CGroupTrackerVector*); virtual void elementsAddGroupsDown(CGroupTrackerVector*); // real meshes //virtual FEMesh* femesh(); virtual void populate_femesh(FEMesh *fem, const MasterElement*, Material *mat=NULL); virtual void printSelf(std::ostream&) const; friend class CDeputySkeleton; }; // end CSkeleton CSkeleton *newCSkeleton(CMicrostructure*, bool[DIM]); //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// // A deputy Skeleton is a Skeleton that differs from another (its // "sheriff") only in the positions of its nodes. The deputy only // stores the positions of the nodes. It refers to the sheriff for // all other Skeleton data. class CDeputySkeleton : public CSkeletonBase { private: CSkeleton *skeleton; NodePositionsMap *nodePositions; bool active; static const std::string classname_; public: CDeputySkeleton(CSkeletonBase *skel); virtual ~CDeputySkeleton(); virtual const std::string &classname() const { return classname_; } virtual void destroy(); // basic get methods virtual CMicrostructure *getMicrostructure() const { return skeleton->MS; } virtual vtkSmartPointer<vtkUnstructuredGrid> getGrid() const { return skeleton->grid; } virtual void getVtkCells(SkeletonFilter *f, vtkSmartPointer<vtkUnstructuredGrid> g) { skeleton->getVtkCells(f, g); } #ifdef DEBUG virtual void getVtkSegments(SkeletonFilter *f, vtkSmartPointer<vtkUnstructuredGrid> g) { skeleton->getVtkSegments(f, g); } virtual void getExtraVtkSegments(CSkeletonBase *other, vtkSmartPointer<vtkUnstructuredGrid> g) { skeleton->getExtraVtkSegments(other, g); } #endif // DEBUG virtual vtkSmartPointer<vtkDataArray> getMaterialCellData( const SkeletonFilter *filter) const { return skeleton->getMaterialCellData(filter); } virtual vtkSmartPointer<vtkDataArray> getEnergyCellData( double alpha, const SkeletonFilter *filter) const { return skeleton->getEnergyCellData(alpha, filter); } virtual vtkSmartPointer<vtkPoints> getPoints() const { return skeleton->points; } virtual CSkeletonNode *getNode(unsigned int nidx) const { return skeleton->getNode(nidx); } virtual bool hasNode(CSkeletonNode *n) const { return skeleton->hasNode(n); } virtual CSkeletonElement *getElement(unsigned int eidx) const { return skeleton->getElement(eidx); } virtual bool hasElement(CSkeletonElement *e) const { return skeleton->hasElement(e); } virtual CSkeletonSegment *getSegment(const CSkeletonMultiNodeKey &h) const { return skeleton->getSegment(h); } virtual CSkeletonFace *getFace(const CSkeletonMultiNodeKey &h) const { return skeleton->getFace(h); } virtual CSkeletonSegment *getSegmentByUid(uidtype i) const { return skeleton->getSegmentByUid(i); } virtual CSkeletonFace *getFaceByUid(uidtype i) const { return skeleton->getFaceByUid(i); } virtual CSkeletonNodeIterator beginNodes() const { return skeleton->nodes.begin(); } virtual CSkeletonNodeIterator endNodes() const { return skeleton->nodes.end(); } virtual CSkeletonElementIterator beginElements() const { return skeleton->elements.begin(); } virtual CSkeletonElementIterator endElements() const { return skeleton->elements.end(); } virtual CSkeletonSegmentIterator beginSegments() const { return skeleton->segments.begin(); } virtual CSkeletonSegmentIterator endSegments() const { return skeleton->segments.end(); } virtual CSkeletonFaceIterator beginFaces() const { return skeleton->faces.begin(); } virtual CSkeletonFaceIterator endFaces() const { return skeleton->faces.end(); } virtual int nDeputies() const { return 0; } // basic info virtual unsigned int nnodes() const { return skeleton->nnodes(); } virtual unsigned int nelements() const { return skeleton->nelements(); } virtual unsigned int nsegments() const { return skeleton->nsegments(); } virtual unsigned int nfaces() const { return skeleton->nfaces(); } virtual double volume() const { return skeleton->volume(); } virtual void nodesAddGroupsDown(CGroupTrackerVector* v) { skeleton->nodesAddGroupsDown(v); } virtual void segmentsAddGroupsDown(CGroupTrackerVector* v) { skeleton->segmentsAddGroupsDown(v); } virtual void facesAddGroupsDown(CGroupTrackerVector* v) { skeleton->facesAddGroupsDown(v); } virtual void elementsAddGroupsDown(CGroupTrackerVector* v) { skeleton->elementsAddGroupsDown(v); } virtual bool getPeriodicity(int dim) const { return skeleton->getPeriodicity(dim); } // virtual void getIllegalElements(CSkeletonElementVector &ills) const { // skeleton->getIllegalElements(ills); // } virtual const Coord nodePositionForSkeleton(CSkeletonNode *n); const Coord originalPosition(CSkeletonNode *n); // virtual methods needed for calculating stuff virtual vtkSmartPointer<vtkCellLocator> get_element_locator() { return skeleton->get_element_locator(); } virtual vtkSmartPointer<vtkMergePoints> get_point_locator() { return skeleton->get_point_locator(); } virtual bool inSegmentMap(const CSkeletonMultiNodeKey &h) const { return skeleton->inSegmentMap(h); } virtual CSkeletonPointBoundary *getPointBoundary(const std::string &name, bool exterior) { return skeleton->getPointBoundary(name, exterior); } virtual CSkeletonPointBoundary *makePointBoundary(const std::string &name, CSkeletonNodeVector *nodes, bool exterior=false) { return skeleton->makePointBoundary(name, nodes, exterior); } virtual CSkeletonEdgeBoundary *getEdgeBoundary(const std::string &name, bool exterior) { return skeleton->getEdgeBoundary(name, exterior); } virtual CSkeletonEdgeBoundary *makeEdgeBoundary( const std::string &name, const CSkeletonSegmentVector *segs, const CSkeletonNode *start_node, bool exterior=false) { return skeleton->makeEdgeBoundary(name, segs, start_node, exterior); } virtual CSkeletonEdgeBoundary *makeEdgeBoundary3D(const std::string &name, const SegmentSequence *seq, bool exterior=false) { return skeleton->makeEdgeBoundary3D(name, seq, exterior); } virtual CSkeletonFaceBoundary *getFaceBoundary(const std::string &name, OrientedSurface *surf, bool exterior) { return skeleton->getFaceBoundary(name, surf, exterior); } virtual CSkeletonFaceBoundary *makeFaceBoundary(const std::string &name, OrientedSurface *surf, bool exterior=false) { return skeleton->makeFaceBoundary(name, surf, exterior); } virtual std::string *compare(CSkeletonBase *other, double tolerance) const { return skeleton->compare(other, tolerance); } #ifdef DEBUG virtual std::string *compare2(const CSkeletonBase *other) const { return skeleton->compare2(other); } #endif // DEBUG // stuff related to deputies virtual CSkeleton *sheriffSkeleton(); virtual const CSkeleton *sheriffSkeleton() const; virtual NodePositionsMap *getMovedNodes() const; virtual void activate(); virtual void deactivate(); virtual CSkeleton *nodeOnlyCopy() { return skeleton->nodeOnlyCopy(); } virtual CSkeleton *completeCopy() { return skeleton->completeCopy(); } virtual void needsHash() { skeleton->needsHash(); } // moving nodes void swapPositions(); bool moveNodeTo(CSkeletonNode *node, const Coord &position); bool moveNodeBy(CSkeletonNode *node, const Coord &position); void moveNodeBack(CSkeletonNode *node); virtual CSkeletonPointBoundaryMap *getPointBoundaries() { return skeleton->getPointBoundaries(); } virtual CSkeletonEdgeBoundaryMap *getEdgeBoundaries() { return skeleton->getEdgeBoundaries(); } virtual CSkeletonFaceBoundaryMap *getFaceBoundaries() { return skeleton->getFaceBoundaries(); } // real meshes //virtual FEMesh* femesh() {return skeleton->femesh();} virtual void populate_femesh(FEMesh *fem, const MasterElement *me, Material *mat=NULL) { skeleton->populate_femesh(fem, me, mat); } virtual void cleanUp() { skeleton->cleanUp(); } virtual void printSelf(std::ostream&) const; }; // end CDeputySkeleton CDeputySkeleton *newCDeputySkeleton(CSkeletonBase *); std::ostream &operator<<(std::ostream&, const CSkeletonBase&); //=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=//=\\=// // TODO OPT: Move ProvisionalChanges classes to a separate file. This one // is too big. struct MoveNode { CSkeletonNode *node; Coord position; bool mobility[3]; }; class SkeletonSubstitutionBase { protected: CSkeletonMultiNodeSelectable *substitutee; public: SkeletonSubstitutionBase(CSkeletonMultiNodeSelectable *s) : substitutee(s) {} virtual ~SkeletonSubstitutionBase() {} void substitute(CSkeleton*) const; virtual CSkeletonMultiNodeSelectable *getSubstitute(CSkeleton*) const = 0; }; struct SegSubstitutionLT { bool operator()(const SegmentSubstitution&, const SegmentSubstitution&) const; }; class SegmentSubstitution : public SkeletonSubstitutionBase { private: CSkeletonNode *node0, *node1; public: SegmentSubstitution(CSkeletonSegment *s, CSkeletonNode *n0, CSkeletonNode *n1) : SkeletonSubstitutionBase(s), node0(n0), node1(n1) {} virtual CSkeletonMultiNodeSelectable *getSubstitute(CSkeleton*) const; friend struct SegSubstitutionLT; }; typedef std::set<SegmentSubstitution, SegSubstitutionLT> SegmentSubstitutionSet; struct FaceSubstitutionLT { bool operator()(const FaceSubstitution&, const FaceSubstitution&) const; }; class FaceSubstitution : public SkeletonSubstitutionBase { private: CSkeletonNode *node0, *node1, *node2; public: FaceSubstitution(CSkeletonFace *f, CSkeletonNode *n0, CSkeletonNode *n1, CSkeletonNode *n2) : SkeletonSubstitutionBase(f), node0(n0), node1(n1), node2(n2) {} virtual CSkeletonMultiNodeSelectable *getSubstitute(CSkeleton*) const; friend struct FaceSubstitutionLT; }; typedef std::set<FaceSubstitution, FaceSubstitutionLT> FaceSubstitutionSet; typedef std::vector<MoveNode> MoveNodeVector; typedef std::map<CSkeletonElement*, HomogeneityData> HomogeneityDataMap; #ifndef HAVE_SSTREAM #include <strstream.h> #else #include <sstream> #endif class ProvisionalChangesBase { protected: MoveNodeVector movednodes; double cachedDeltaE; // the cached value bool deltaECached; // whether it was cached public: ProvisionalChangesBase(const std::string &n) : deltaECached(false), name(n) {} const std::string name; // useful for debugging virtual ~ProvisionalChangesBase() {}; // Strings added by annotate can be printed by accept() to help // debug the skeleton modification process, without cluttering the // debugging output with details of rejected ProvisionalChanges. // #ifndef HAVE_SSTREAM // std::ostrstream annotate; // #else // std::ostringstream annotate; // #endif virtual bool illegal() = 0; virtual bool suspect() = 0; // deltaE() is not const because it may need to call moveNode. virtual double deltaE(double alpha) = 0; virtual void moveNode(CSkeletonNode *node, const Coord &x, bool *mob=NULL) = 0; virtual void accept() = 0; MoveNodeVector::const_iterator getMovedNodesBegin() { return movednodes.begin(); } MoveNodeVector::const_iterator getMovedNodesEnd() { return movednodes.end(); } virtual void removeAddedNodes() = 0; }; class DeputyProvisionalChanges : public ProvisionalChangesBase { protected: CDeputySkeleton *deputy; CSkeletonElementVector elements; bool cachedIllegal; // the cached value bool illegalCached; // whether it was cached HomogeneityDataMap cachedNewHomogeneity; public: DeputyProvisionalChanges(CDeputySkeleton*, const std::string &); virtual ~DeputyProvisionalChanges() {}; virtual void moveNode(CSkeletonNode *node, const Coord &x, bool *mob=NULL); virtual void accept(); virtual bool illegal(); virtual bool suspect(); void makeNodeMove(); void moveNodeBack(); virtual void removeAddedNodes() {}; virtual double deltaE(double alpha); }; class ProvisionalChanges : public ProvisionalChangesBase { protected: CSkeleton *skeleton; CSkeletonElementSet removed; CSkeletonElementSet inserted; CSkeletonSelectablePairSet substitutions; SegmentSubstitutionSet seg_substitutions; FaceSubstitutionSet face_substitutions; // CSkeletonSelectablePairSet seg_substitutions; // CSkeletonSelectablePairSet face_substitutions; //MoveNodeVector movednodes; ConstCSkeletonElementSet before; CSkeletonElementSet after; public: ProvisionalChanges(CSkeleton *skel, const std::string &n); virtual ~ProvisionalChanges(); virtual void removeAddedNodes() {} void removeElement(CSkeletonElement*); void removeElements(const CSkeletonElementVector &); void insertElement(CSkeletonElement *); void substituteElement(CSkeletonElement *, CSkeletonElement *); void substituteSegment(CSkeletonSegment*, CSkeletonNode*, CSkeletonNode*); void substituteSegment(CSkeletonSegment*, CSkeletonSegment*); void substituteFace(CSkeletonFace*, CSkeletonNode*, CSkeletonNode*, CSkeletonNode*); void substituteFace(CSkeletonFace*, CSkeletonFace*); int nRemoved() { return removed.size(); } // nInserted // elBefore CSkeletonSelectablePairSet& getSubstitutions() { return substitutions; } CSkeletonElementSet& getRemoved() { return removed; } virtual bool illegal(); virtual bool suspect(); virtual void moveNode(CSkeletonNode *node, const Coord &x, bool *mob=NULL); virtual void makeNodeMove(); virtual void moveNodeBack(); virtual double deltaE(double alpha); // deltaEBound virtual void accept(); void checkVolume(); void sanityCheck(); }; class ProvisionalMerge : public ProvisionalChanges { protected: CSkeletonNode *node0; CSkeletonNode *node1; public: ProvisionalMerge(CSkeleton *skel, CSkeletonNode *n0, CSkeletonNode *n1, const std::string &n) : ProvisionalChanges(skel, n), node0(n0), node1(n1) {} virtual ~ProvisionalMerge() {} virtual void accept(); }; // changes that can add nodes class ProvisionalInsertion : public ProvisionalChanges { protected: CSkeletonNodeVector added_nodes; public: ProvisionalInsertion(CSkeleton *skel, const std::string &n) : ProvisionalChanges(skel, n) {} virtual ~ProvisionalInsertion() {} void addNode(CSkeletonNode *n) { added_nodes.push_back(n); } virtual void removeAddedNodes(); }; #endif //CSKELETON2_H
35.765333
84
0.744607
[ "geometry", "shape", "vector", "3d" ]
7e2eca8d897bffbedae82caf3cf3e642ea6f084a
7,495
c
C
src/calendon/main-detail.c
pyjarrett/calendon
be9cd39f94fbff3699176498b680b8e4a734ccfa
[ "MIT" ]
5
2020-04-03T22:32:05.000Z
2020-05-04T23:27:41.000Z
src/calendon/main-detail.c
pyjarrett/knell
be9cd39f94fbff3699176498b680b8e4a734ccfa
[ "MIT" ]
7
2020-06-22T02:43:59.000Z
2020-08-29T16:02:59.000Z
src/calendon/main-detail.c
pyjarrett/knell
be9cd39f94fbff3699176498b680b8e4a734ccfa
[ "MIT" ]
null
null
null
#include "main-detail.h" #include <calendon/assets.h> #include <calendon/assets-fileio.h> #include <calendon/crash.h> #include <calendon/log.h> #include <calendon/log-system.h> #include <calendon/main-config.h> #include <calendon/memory.h> #include <calendon/behavior.h> #ifdef _WIN32 #include <calendon/process.h> #endif #include <calendon/system.h> #include <calendon/tick-limits.h> #include <calendon/time.h> #include <calendon/render.h> #include <calendon/ui.h> #include <time.h> CnTime s_lastTick; CnSystem s_coreSystems[CnMaxNumCoreSystems]; uint32_t s_numCoreSystems = 0; static bool cnMain_Init(void) { CnMainConfig* config = (CnMainConfig*)cnMain_Config(); if (config->tickLimit != 0) { cnMain_SetTickLimit(config->tickLimit); } return true; } const char* cnMain_Name(void) { return "Main"; } static CnSystem cnMain_System(void) { return (CnSystem) { .name = cnMain_Name, .options = cnMain_CommandLineOptionList, .config = cnMain_Config, .setDefaultConfig = cnMain_SetDefaultConfig, .init = cnMain_Init, .shutdown = NULL, .sharedLibrary = NULL, .behavior = cnSystem_NoBehavior() }; } CnSystem* cnMain_AddCoreSystem(CnSystem system) { if (s_numCoreSystems >= CnMaxNumCoreSystems) { CN_FATAL_ERROR("Too many core systems added."); } CnSystem* assigned = &s_coreSystems[s_numCoreSystems]; *assigned = system; ++s_numCoreSystems; return assigned; } void cnMain_BuildCoreSystemList(void) { CnSystem_SystemFn systems[] = { cnMain_System, cnLog_System, cnCrash_System, cnMemory_System, cnTime_System, cnAssets_System }; for (uint32_t i = 0; i < CN_ARRAY_SIZE(systems); ++i) { cnMain_AddCoreSystem(systems[i]()); } } void cnMain_InitCoreSystems(void) { for (uint32_t i = 0; i < s_numCoreSystems; ++i) { if (!s_coreSystems[i].init()) { CN_FATAL_ERROR("Unable to initialize core system: %d", i); } } } void cnMain_LoadPayload(CnMainConfig* config) { CN_ASSERT_PTR(config); if (!cnPath_IsFile(config->gameLibPath.str)) { CN_FATAL_ERROR("Cannot load game. '%s' is not a game library.", config->gameLibPath.str); } const char* sharedLibraryName = config->gameLibPath.str; CN_ASSERT(sharedLibraryName, "Cannot use a null shared library name to load a payload."); uint64_t gameLibModified; if (!cnAssets_LastModifiedTime(sharedLibraryName, &gameLibModified)) { CN_FATAL_ERROR("Unable to determine last modified time of '%s'", sharedLibraryName); } struct tm *lt = localtime((time_t*)&gameLibModified); char timeBuffer[80]; strftime(timeBuffer, sizeof(timeBuffer), "%c", lt); CN_TRACE(LogSysMain, "Last modified time: %s", timeBuffer); const CnSharedLibrary sharedLib = cnSharedLibrary_Load(sharedLibraryName); if (!sharedLib) { CN_FATAL_ERROR("Unable to load game module: %s", sharedLibraryName); } if (s_numCoreSystems >= CnMaxNumCoreSystems) { CN_FATAL_ERROR("Too many core systems, cannot load demo."); } CnSystem loaded; if (!cnSystem_LoadFromSharedLibrary(&loaded, "Demo", sharedLib)) { CN_FATAL_ERROR("Unable to load demo."); } CnSystem* demo = cnMain_AddCoreSystem(loaded); demo->init(); } void cnMain_PrintUsage(int argc, char** argv) { // Print core systems. for (uint32_t i = 0; i < s_numCoreSystems; ++i) { CnSystem* system = &s_coreSystems[i]; CnCommandLineOptionList optionList = system->options(); if (system->name && optionList.numOptions > 0) { cnPrint("%s\n", system->name); } for (uint32_t optionIndex = 0; optionIndex < optionList.numOptions; ++optionIndex) { CnCommandLineOption* option = &optionList.options[optionIndex]; const char* help = option->help ? option->help : ""; cnPrint("%s\n", help); } } // Print the provided arguments. cnPrint("Arguments provided:\n"); for (int i = 0; i < argc; ++i) { cnPrint("%4d: \"%s\"\n", i, argv[i]); } } /** * Attempt to parse the next command line option with a given system. */ int32_t cnMain_RunSystemParsers(CnCommandLineParse* commandLineParse, CnSystem* system) { CN_ASSERT_PTR(commandLineParse); CN_ASSERT_PTR(system); const CnCommandLineOptionList options = system->options(); for (uint32_t parserIndex = 0; parserIndex < options.numOptions; ++parserIndex) { CnCommandLineOption *option = &options.options[parserIndex]; if (cnCommandLineOption_Matches(option, commandLineParse)) { return option->parser(commandLineParse, system->config()); } } return 0; } /** * Parses the raw input, as such received by `int main(int argc, char** argv)`. */ bool cnMain_ParseCommandLine(int argc, char** argv) { CN_ASSERT(argc >= 1, "Argument count must at least include the executable."); CN_ASSERT_PTR(argv); // Default the configs for systems before they begin receiving changes from // the command line. for (uint32_t i = 0; i < s_numCoreSystems; ++i) { if (s_coreSystems[i].setDefaultConfig == NULL) { CN_ERROR(LogSysMain, "%s is missing a default config.", s_coreSystems[i].name()); } CN_ASSERT_PTR(s_coreSystems[i].setDefaultConfig); s_coreSystems[i].setDefaultConfig(s_coreSystems[i].config()); } CnCommandLineParse commandLineParse = cnCommandLineParse_Make(argc, argv); while (cnCommandLineParse_ShouldContinue(&commandLineParse)) { int argsParsed = 0; uint32_t systemIndex = 0; while (systemIndex < s_numCoreSystems && argsParsed == 0) { CnSystem* system = &s_coreSystems[systemIndex]; argsParsed = cnMain_RunSystemParsers(&commandLineParse, system); if (argsParsed != 0) { break; } ++systemIndex; } if (argsParsed <= 0) { cnPrint("Unable to parse argument: \"%s\" at index %d\n", cnCommandLineParse_LookAhead(&commandLineParse, 1), cnCommandLineParse_LookAheadIndex(&commandLineParse, 1)); cnMain_PrintUsage(argc, argv); return false; } cnCommandLineParse_Advance(&commandLineParse, argsParsed); } return true; } /** * Possibly generate a delta time for the next game update. If the time since * the previous tick is too small or very large, no tick will be generated. * Small ticks do needless work, and large ticks might be due to resuming from * the debugger. * * @param[out] outDt delta time if a tick is generated (returns true), not set otherwise * @return true if a tick should occur */ bool cnMain_GenerateTick(CnTime* outDt) { const CnTime current = cnTime_Max(s_lastTick, cnTime_MakeNow()); // Prevent updating too rapidly. Maintaining a relatively consistent // timestep limits stored state and prevents precision errors due to // extremely small dt. // // Since Calendon is single-threaded, VSync will probably ensure that the // minimum tick size is never missed. const CnTime minTickSize = cnTime_MakeMilli(8); const CnTime dt = cnTime_SubtractMonotonic(current, s_lastTick); if (cnTime_LessThan(dt, minTickSize)) { return false; } s_lastTick = current; // Ignore huge ticks, such as when resuming in the debugger. const CnTime maxTickSize = cnTime_MakeMilli(5000); if (cnTime_LessThan(maxTickSize, dt)) { CN_TRACE(LogSysMain, "Skipping large tick: %" PRIu64 " ms", cnTime_Milli(dt)); return false; } *outDt = dt; return true; } void cnMain_StartUpUI(void) { // TODO: Resolution should be read from config or as a a configuration option. const uint32_t width = 1024; const uint32_t height = 768; CnUIInitParams uiInitParams; uiInitParams.resolution = (CnDimension2u32) { .width = width, .height = height }; cnUI_Init(&uiInitParams); cnR_Init(uiInitParams.resolution); }
28.716475
91
0.722748
[ "render" ]
7e30cefab24749e901362c6b11154f9d5b15e8e4
798
h
C
cases/tracers/param/post/mesh/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/tracers/param/post/mesh/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
cases/tracers/param/post/mesh/parameters.h
C0PEP0D/sheld0n
497d4ee8b6b1815cd5fa1b378d1b947ee259f4bc
[ "MIT" ]
null
null
null
#ifndef C0P_PARAM_POST_MESH_PARAMETERS_H #define C0P_PARAM_POST_MESH_PARAMETERS_H #pragma once // THIS FILE SHOULD NOT BE EDITED DIRECTLY BY THE USERS. // THIS FILE WILL BE AUTOMATICALLY EDITED WHEN THE // COPY/REMOVE COMMANDS ARE USED // std include #include <memory> // shared_ptr #include <vector> #include <string> // app include #include "core/post/mesh/post/core.h" // FLAG: INCLUDE POST BEGIN #include "param/post/mesh/pos/choice.h" // FLAG: INCLUDE POST END namespace c0p { struct PostMeshParameters { // make data std::vector<std::shared_ptr<PostMeshPost>> data; PostMeshParameters(std::shared_ptr<PostMeshMesh::Type> sMesh) { // FLAG: MAKE POST BEGIN data.push_back(std::make_shared<PostMeshPos>(sMesh)); // FLAG: MAKE POST END } }; } #endif
23.470588
67
0.718045
[ "mesh", "vector" ]
7e3743296e77465d1e2c6f45be3cf9c51c65873a
5,160
h
C
src/ccdl/ast/Pool.h
sparkoss/ccm
9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d
[ "Apache-2.0" ]
6
2018-05-08T10:08:21.000Z
2021-11-13T13:22:58.000Z
src/ccdl/ast/Pool.h
sparkoss/ccm
9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d
[ "Apache-2.0" ]
1
2018-05-08T10:20:17.000Z
2018-07-23T05:19:19.000Z
src/ccdl/ast/Pool.h
sparkoss/ccm
9ed67a7cbdc9c69f4182e72be8e8b6b23d7c3c8d
[ "Apache-2.0" ]
4
2018-03-13T06:21:11.000Z
2021-06-19T02:48:07.000Z
//========================================================================= // Copyright (C) 2018 The C++ Component Model(CCM) 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. //========================================================================= #ifndef __CCDL_AST_POOL_H__ #define __CCDL_AST_POOL_H__ #include "Coclass.h" #include "Constant.h" #include "Enumeration.h" #include "Interface.h" #include "Namespace.h" #include "../util/ArrayList.h" #include "../util/StringMap.h" #include "../util/String.h" namespace ccdl { namespace ast { class Pool { public: Pool(); ~Pool(); bool AddEnumerationPredeclaration( /* [in] */ Enumeration* enumn); bool AddEnumeration( /* [in] */ Enumeration* enumeration); inline int GetEnumerationNumber(); inline Enumeration* GetEnumeration( /* [in] */ int index); Enumeration* FindEnumeration( /* [in] */ const String& enumFullName); inline int IndexOf( /* [in] */ Enumeration* enumn); bool AddInterfacePredeclaration( /* [in] */ Interface* interface); bool AddInterface( /* [in] */ Interface* interface); inline int GetInterfaceNumber(); inline Interface* GetInterface( /* [in] */ int index); Interface* FindInterface( /* [in] */ const String& itfFullName); inline int IndexOf( /* [in] */ Interface* interface); bool AddCoclass( /* [in] */ Coclass* klass); inline int GetCoclassNumber(); inline Coclass* GetCoclass( /* [in] */ int index); Coclass* FindClass( /* [in] */ const String& klassName); inline int IndexOf( /* [in] */ Coclass* klass); bool AddConstant( /* [in] */ Constant* constant); inline int GetConstantNumber(); inline Constant* GetConstant( /* [in] */ int index); Constant* FindConstant( /* [in] */ const String& constantName); inline int IndexOf( /* [in] */ Constant* constant); bool AddNamespace( /* [in] */ Namespace* ns); inline int GetNamespaceNumber(); inline Namespace* GetNamespace( /* [in] */ int index); Namespace* FindNamespace( /* [in] */ const String& nsString); Namespace* ParseNamespace( /* [in] */ const String& nsString); bool AddTemporaryType( /* [in] */ Type* type); inline int GetTypeNumber(); Type* GetType( /* [in] */ int index); Type* FindType( /* [in] */ const String& typeName); inline std::shared_ptr< ArrayList<StringMap<Type*>::Pair*> > GetTypes(); int IndexOf( /* [in] */ Type* type); Type* DeepCopyType( /* [in] */ Type* type); Type* ShallowCopyType( /* [in] */ Type* type); virtual Type* ResolveType( /* [in] */ const String& fullName) = 0; virtual String Dump( /* [in] */ const String& prefix); protected: ArrayList<Coclass*> mCoclasses; ArrayList<Constant*> mConstants; ArrayList<Enumeration*> mEnumerations; ArrayList<Interface*> mInterfaces; ArrayList<Namespace*> mNamespaces; ArrayList<Type*> mTempTypes; StringMap<Type*> mTypes; }; int Pool::GetEnumerationNumber() { return mEnumerations.GetSize(); } Enumeration* Pool::GetEnumeration( /* [in] */ int index) { return mEnumerations.Get(index); } int Pool::IndexOf( /* [in] */ Enumeration* enumn) { return mEnumerations.IndexOf(enumn); } int Pool::GetInterfaceNumber() { return mInterfaces.GetSize(); } Interface* Pool::GetInterface( /* [in] */ int index) { return mInterfaces.Get(index); } int Pool::IndexOf( /* [in] */ Interface* interface) { return mInterfaces.IndexOf(interface); } int Pool::GetCoclassNumber() { return mCoclasses.GetSize(); } Coclass* Pool::GetCoclass( /* [in] */ int index) { return mCoclasses.Get(index); } int Pool::IndexOf( /* [in] */ Coclass* klass) { return mCoclasses.IndexOf(klass); } int Pool::GetConstantNumber() { return mConstants.GetSize(); } Constant* Pool::GetConstant( /* [in] */ int index) { return mConstants.Get(index); } int Pool::IndexOf( /* [in] */ Constant* constant) { return mConstants.IndexOf(constant); } int Pool::GetNamespaceNumber() { return mNamespaces.GetSize(); } Namespace* Pool::GetNamespace( /* [in] */ int index) { return mNamespaces.Get(index); } int Pool::GetTypeNumber() { return mTypes.GetSize(); } std::shared_ptr< ArrayList<StringMap<Type*>::Pair*> > Pool::GetTypes() { return mTypes.GetKeyValues(); } } } #endif // __CCDL_AST_POOL_H__
20.806452
75
0.607364
[ "model" ]
7e39f6fe0889411050d352f0999823fd157180ad
2,694
c
C
src/prime/scheme_load.c
autobsd/autoscheme
f2e09b02a6021ada6f3a9335059c90047db8255a
[ "BSD-2-Clause" ]
null
null
null
src/prime/scheme_load.c
autobsd/autoscheme
f2e09b02a6021ada6f3a9335059c90047db8255a
[ "BSD-2-Clause" ]
null
null
null
src/prime/scheme_load.c
autobsd/autoscheme
f2e09b02a6021ada6f3a9335059c90047db8255a
[ "BSD-2-Clause" ]
null
null
null
/* This file is part of the 'AutoScheme' project. * Copyright 2021 Steven Wiley <s.wiley@katchitek.com> * SPDX-License-Identifier: BSD-2-Clause */ #include "autoscheme.h" pointer LOAD_MODULE__scheme_load(pointer environment); foreign_function ff_path_make_absolute; foreign_function ff_path_directory; pointer LOAD_MODULE__scheme_load(pointer environment) { pointer return_value = T; autoscheme_eval(T, environment); return_value = autoscheme_eval(cons(mk_symbol("define-library"),cons(cons(mk_symbol("scheme"),cons(mk_symbol("load"),NIL)),cons(cons(mk_symbol("import"),cons(cons(mk_symbol("auto"),cons(mk_symbol("scheme"),cons(mk_symbol("base"),NIL))),cons(cons(mk_symbol("scheme"),cons(mk_symbol("eval"),NIL)),cons(cons(mk_symbol("scheme"),cons(mk_symbol("file"),NIL)),cons(cons(mk_symbol("scheme"),cons(mk_symbol("read"),NIL)),NIL))))),cons(cons(mk_symbol("export"),cons(mk_symbol("load"),NIL)),cons(cons(mk_symbol("begin"),cons(cons(mk_symbol("define"),cons(mk_symbol("current-source"),cons(mk_operation(LOC_CURR_SOURCE,&NIL),NIL))),cons(cons(mk_symbol("define"),cons(mk_symbol("path-make-absolute"),cons(mk_function(ff_path_make_absolute,&NIL),NIL))),cons(cons(mk_symbol("define"),cons(mk_symbol("path-directory"),cons(mk_function(ff_path_directory,&NIL),NIL))),cons(cons(mk_symbol("define"),cons(mk_symbol("load"),cons(cons(mk_symbol("lambda"),cons(cons(mk_symbol("filename"),mk_symbol("rest")),cons(cons(mk_symbol("define"),cons(mk_symbol("load-environment"),cons(cons(mk_symbol("if"),cons(cons(mk_symbol("null?"),cons(mk_symbol("rest"),NIL)),cons(cons(mk_symbol("interaction-environment"),NIL),cons(cons(mk_symbol("car"),cons(mk_symbol("rest"),NIL)),NIL)))),NIL))),cons(cons(mk_symbol("parameterize"),cons(cons(cons(mk_symbol("current-source"),cons(cons(mk_symbol("path-make-absolute"),cons(mk_symbol("filename"),NIL)),NIL)),NIL),cons(cons(mk_symbol("with-input-from-file"),cons(mk_symbol("filename"),cons(cons(mk_symbol("lambda"),cons(NIL,cons(cons(mk_symbol("if"),cons(cons(mk_symbol("char=?"),cons(cons(mk_symbol("peek-char"),NIL),cons(mk_character(35),NIL))),cons(cons(mk_symbol("read-line"),NIL),NIL))),cons(cons(mk_symbol("let"),cons(mk_symbol("load-expression"),cons(cons(cons(mk_symbol("expression"),cons(cons(mk_symbol("read"),NIL),NIL)),NIL),cons(cons(mk_symbol("cond"),cons(cons(cons(mk_symbol("not"),cons(cons(mk_symbol("eof-object?"),cons(mk_symbol("expression"),NIL)),NIL)),cons(cons(mk_symbol("eval"),cons(mk_symbol("expression"),cons(mk_symbol("load-environment"),NIL))),cons(cons(mk_symbol("load-expression"),cons(cons(mk_symbol("read"),NIL),NIL)),NIL))),NIL)),NIL)))),NIL)))),NIL))),NIL))),NIL)))),NIL))),NIL))))),NIL))))), environment); return return_value; }
168.375
2,246
0.74833
[ "object" ]
7e3e4eef51efc238fed418acd90e71a56237b29a
8,568
h
C
include/coutvector.h
eniac/parallel-inet-omnet
810ed40aecac89efbd0b6a05ee10f44a09417178
[ "Xnet", "X11" ]
15
2021-08-20T08:10:01.000Z
2022-03-24T21:24:50.000Z
include/coutvector.h
eniac/parallel-inet-omnet
810ed40aecac89efbd0b6a05ee10f44a09417178
[ "Xnet", "X11" ]
1
2022-03-30T09:03:39.000Z
2022-03-30T09:03:39.000Z
include/coutvector.h
eniac/parallel-inet-omnet
810ed40aecac89efbd0b6a05ee10f44a09417178
[ "Xnet", "X11" ]
3
2021-08-20T08:10:34.000Z
2021-12-02T06:15:02.000Z
//========================================================================== // COUTVECTOR.H - part of // OMNeT++/OMNEST // Discrete System Simulation in C++ // // // Declaration of the following classes: // cOutVector : represents an output vector // //========================================================================== /*--------------------------------------------------------------* Copyright (C) 1992-2008 Andras Varga Copyright (C) 2006-2008 OpenSim Ltd. This file is distributed WITHOUT ANY WARRANTY. See the file `license' for details on this and other legal matters. *--------------------------------------------------------------*/ #ifndef __COUTVECTOR_H #define __COUTVECTOR_H #include <stdio.h> #include "cownedobject.h" #include "simtime_t.h" NAMESPACE_BEGIN /** * Prototype for callback functions that are used to notify graphical user * interfaces when values are recorded to an output vector (see cOutVector). * @ingroup EnumsTypes */ typedef void (*RecordFunc)(void *, simtime_t, double, double); class cEnum; /** * Responsible for recording vector simulation results (an output vector). * A cOutVector object can write doubles to the output vector file * (or any another device determined by the current cOutputVectorManager). * * @ingroup Statistics */ class SIM_API cOutVector : public cNoncopyableOwnedObject { protected: enum { FL_ENABLED = 4, // flag: when false, record() method will do nothing FL_RECORDWARMUP = 8, // flag: when set, object records data during warmup period as well }; void *handle; // identifies output vector for the output vector manager simtime_t last_t; // last timestamp written, needed to ensure increasing timestamp order long num_received; // total number of values passed to the output vector object long num_stored; // number of values actually stored // the following members will be used directly by inspectors RecordFunc record_in_inspector; // to notify inspector about file writes void *data_for_inspector; public: // internal: called from behind cEnvir void setCallback(RecordFunc f, void *d) {record_in_inspector=f; data_for_inspector=d;} public: enum Type { TYPE_INT, TYPE_DOUBLE, TYPE_ENUM }; enum InterpolationMode { NONE, SAMPLE_HOLD, BACKWARD_SAMPLE_HOLD, LINEAR }; public: /** @name Constructors, destructor, assignment */ //@{ /** * Constructor. */ explicit cOutVector(const char *name=NULL); /** * Destructor. */ virtual ~cOutVector(); //@} /** @name Redefined cObject member functions. */ //@{ /** * Sets the name of the object. It is not possible to call this method after the * first call to record(). */ virtual void setName(const char *name); /** * Produces a one-line description of the object's contents. * See cObject for more details. */ virtual std::string info() const; /** * Packing and unpacking cannot be supported with this class. * This methods raises an error. */ virtual void parsimPack(cCommBuffer *buffer); /** * Packing and unpacking cannot be supported with this class. * This methods raises an error. */ virtual void parsimUnpack(cCommBuffer *buffer); //@} /** @name Metadata annotations. */ //@{ /** * Associate the vector with an enum defined in a msg file. * This information gets recorded into the output vector file and * may be used by result analysis tools. * cOutVector does not verify that recorded values actually comply * with this annotation. */ virtual void setEnum(const char *registeredEnumName); /** * Associate the vector with an enum. The enum name as well as the * symbols and their integer values will get recorded into the output * vector file, and may be used by result analysis tools. * cOutVector does not verify that recorded values actually comply * with this annotation. */ virtual void setEnum(cEnum *enumDecl); /** * Annotate the vector with a physical unit (like "s", "mW" or "bytes"). * This information gets recorded into the output vector file, and * may be used by result analysis tools. */ virtual void setUnit(const char *unit); /** * Annotate the vector with a data type. This information gets recorded * into the output vector file, and may be used by result analysis tools. * cOutVector does not verify that recorded values actually comply with * this annotation. */ virtual void setType(Type type); /** * Annotate the vector with an interpolation mode. This information * gets recorded into the output vector file, and may be used * by result analysis tools as a hint for choosing a plotting style. */ virtual void setInterpolationMode(InterpolationMode mode); /** * Annotate the vector with a minimum value. This information gets * recorded into the output vector file and may be used * by result analysis tools. cOutVector does not verify that * recorded values actually comply with this annotation. */ virtual void setMin(double minValue); /** * Annotate the vector with a maximum value. This information gets * recorded into the output vector file and may be used * by result analysis tools. cOutVector does not verify that * recorded values actually comply with this annotation. */ virtual void setMax(double maxValue); //@} /** @name Writing to output vectors. */ //@{ /** * Records the value with the current simulation time as timestamp. * * The return value is true if the data was actually recorded, and false * if it was not recorded (because of filtering, etc.) */ virtual bool record(double value); /** * Convenience method, delegates to record(double). */ virtual bool record(SimTime value) {return record(value.dbl());} /** * Records the value with the given time as timestamp. Values must be * recorded in increasing timestamp order, that is, it is not possible * to record a value with a timestamp that is less than that of the * last recorded value. * * The return value is true if the data was actually recorded, and false * if it was not recorded (because of filtering, etc.) */ virtual bool recordWithTimestamp(simtime_t t, double value); /** * Convenience method, delegates to recordWithTimestamp(simtime_t, double). */ virtual bool recordWithTimestamp(simtime_t t, SimTime value) {return recordWithTimestamp(t, value.dbl());} /** * Enables recording data via this object. (It is enabled by default.) */ virtual void enable() {setFlag(FL_ENABLED,true);} /** * Disables recording data via this object. record() methods will return * false without doing anything. */ virtual void disable() {setFlag(FL_ENABLED,false);} /** * Enables/disables recording data via this object. * @see enable(), disable() */ virtual void setEnabled(bool b) {setFlag(FL_ENABLED,b);} /** * Returns true if recording the data is enabled, false otherwise. */ virtual bool isEnabled() const {return flags&FL_ENABLED;} /** * Enables/disables recording data during the warm-up period. * When set to false, record() calls will be ignored during * warm-up period. * * @see cSimulation::getWarmupPeriod() */ virtual void setRecordDuringWarmupPeriod(bool b) {setFlag(FL_RECORDWARMUP,b);} /** * Returns true if the object will record data during the warm-up period. * @see cSimulation::getWarmupPeriod() */ virtual bool getRecordDuringWarmupPeriod() const {return flags&FL_RECORDWARMUP;} /** * Returns the total number of values passed to the record() method of * this output vector object. This includes the values passed while * the object was disabled (see disable()). */ long getValuesReceived() const {return num_received;} /** * Returns the number of values actually stored by this output vector object. * The values passed while the object was disabled (via disable(), * environment configuration, filtering, etc.) do not count. */ long getValuesStored() const {return num_stored;} //@} }; NAMESPACE_END #endif
32.577947
110
0.650093
[ "object", "vector" ]
7e4cf1d9bf3e3e71a0c365c200fcc8e32198c8a4
348
h
C
source/vanilla_extract/vec_rw.h
Hypexion/HamSandwich
e5adb6b45d822cbef1be1a52d0ce51513dc24bc8
[ "MIT" ]
24
2019-05-12T12:03:21.000Z
2022-03-30T01:05:46.000Z
source/vanilla_extract/vec_rw.h
Hypexion/HamSandwich
e5adb6b45d822cbef1be1a52d0ce51513dc24bc8
[ "MIT" ]
6
2019-05-12T11:54:54.000Z
2022-02-26T11:47:20.000Z
source/vanilla_extract/vec_rw.h
Hypexion/HamSandwich
e5adb6b45d822cbef1be1a52d0ce51513dc24bc8
[ "MIT" ]
12
2019-05-12T13:48:57.000Z
2022-02-25T15:25:24.000Z
#ifndef VANILLA_EXTRACT_VEC_RW_H #define VANILLA_EXTRACT_VEC_RW_H #include <vector> #include <stdint.h> struct SDL_RWops; namespace vanilla { // Create an SDL_RWops from an owned byte buffer. It will be freed when closed. SDL_RWops* create_vec_rwops(std::vector<uint8_t>&& buffer); } // namespace vanilla #endif // VANILLA_EXTRACT_VEC_RW_H
20.470588
79
0.778736
[ "vector" ]
4751fbaff2496c82134b9a0e225440d23b7ec1eb
2,471
c
C
src/download-provider-main.c
tizenorg/platform.framework.web.download-provider
758f1928838c7e32d46fee00b534873927cc1094
[ "Apache-2.0" ]
null
null
null
src/download-provider-main.c
tizenorg/platform.framework.web.download-provider
758f1928838c7e32d46fee00b534873927cc1094
[ "Apache-2.0" ]
null
null
null
src/download-provider-main.c
tizenorg/platform.framework.web.download-provider
758f1928838c7e32d46fee00b534873927cc1094
[ "Apache-2.0" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <glib.h> #include <glib-object.h> #include <pthread.h> #include "download-provider-config.h" #include "download-provider-log.h" GMainLoop *gMainLoop = 0; // need for libsoup, decided the life-time by mainloop. int lock_download_provider_pid(char *path); void *run_manage_download_server(void *args); void TerminateDaemon(int signo) { TRACE_DEBUG_INFO_MSG("Received SIGTERM"); if (g_main_loop_is_running(gMainLoop)) g_main_loop_quit(gMainLoop); } static gboolean CreateThreadFunc(void *data) { pthread_t thread_pid; pthread_attr_t thread_attr; if (pthread_attr_init(&thread_attr) != 0) { TRACE_DEBUG_MSG("failed to init pthread attr"); TerminateDaemon(SIGTERM); return FALSE; } if (pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED) != 0) { TRACE_DEBUG_MSG("failed to set detach option"); TerminateDaemon(SIGTERM); return 0; } // create thread for receiving the client request. if (pthread_create (&thread_pid, &thread_attr, run_manage_download_server, data) != 0) { TRACE_DEBUG_MSG ("failed to create pthread for run_manage_download_server"); TerminateDaemon(SIGTERM); } return FALSE; } int main() { if (chdir("/") < 0) { TRACE_DEBUG_MSG("failed to call setsid or chdir"); exit(EXIT_FAILURE); } #if 0 // close all console I/O close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); #endif if (signal(SIGTERM, TerminateDaemon) == SIG_ERR) { TRACE_DEBUG_MSG("failed to register signal callback"); exit(EXIT_FAILURE); } // write IPC_FD_PATH. and lock if (lock_download_provider_pid(DOWNLOAD_PROVIDER_LOCK_PID) < 0) { TRACE_DEBUG_MSG ("It need to check download-provider is already alive"); TRACE_DEBUG_MSG("Or fail to create pid file in (%s)", DOWNLOAD_PROVIDER_LOCK_PID); exit(EXIT_FAILURE); } // if exit socket file, delete it if (access(DOWNLOAD_PROVIDER_IPC, F_OK) == 0) { unlink(DOWNLOAD_PROVIDER_IPC); } // libsoup need mainloop. gMainLoop = g_main_loop_new(NULL, 0); g_type_init(); g_idle_add(CreateThreadFunc, gMainLoop); g_main_loop_run(gMainLoop); TRACE_DEBUG_INFO_MSG("Download-Provider will be terminated."); // if exit socket file, delete it if (access(DOWNLOAD_PROVIDER_IPC, F_OK) == 0) { unlink(DOWNLOAD_PROVIDER_IPC); } // delete pid file if (access(DOWNLOAD_PROVIDER_LOCK_PID, F_OK) == 0) { unlink(DOWNLOAD_PROVIDER_LOCK_PID); } exit(EXIT_SUCCESS); }
24.71
81
0.738163
[ "object" ]
4755ff1e4fbc0e9c78b7e375d4ddc904cf15675a
467
h
C
src/arith.h
shoarai/arith
e5cafc7bc137732ba3bd6c787cbbe18d4d834a3f
[ "MIT" ]
1
2018-03-13T06:52:36.000Z
2018-03-13T06:52:36.000Z
src/arith.h
shoarai/arith
e5cafc7bc137732ba3bd6c787cbbe18d4d834a3f
[ "MIT" ]
null
null
null
src/arith.h
shoarai/arith
e5cafc7bc137732ba3bd6c787cbbe18d4d834a3f
[ "MIT" ]
null
null
null
//--------------------------------------------------// // File Name: Arith.h // // Function: arithmetic calculation // // Copyright(C) 2016 shoarai // // The MIT License (MIT) // //--------------------------------------------------// #ifndef _ARITH_H_ #define _ARITH_H_ #include "Vector.h" #include "Matrix.h" #include "SquareMatrix.h" #endif // _ARITH_
31.133333
55
0.364026
[ "vector" ]
475a6b14eb2a3c99957ef77001c44943942d93b1
40,991
h
C
tem/include/tencentcloud/tem/v20210701/model/DeployApplicationRequest.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
1
2022-01-27T09:27:34.000Z
2022-01-27T09:27:34.000Z
tem/include/tencentcloud/tem/v20210701/model/DeployApplicationRequest.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
tem/include/tencentcloud/tem/v20210701/model/DeployApplicationRequest.h
TencentCloud/tencentcloud-sdk-cpp-intl-en
752c031f5ad2c96868183c5931eae3a42dd5ae6c
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * 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. */ #ifndef TENCENTCLOUD_TEM_V20210701_MODEL_DEPLOYAPPLICATIONREQUEST_H_ #define TENCENTCLOUD_TEM_V20210701_MODEL_DEPLOYAPPLICATIONREQUEST_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/tem/v20210701/model/EsInfo.h> #include <tencentcloud/tem/v20210701/model/Pair.h> #include <tencentcloud/tem/v20210701/model/StorageConf.h> #include <tencentcloud/tem/v20210701/model/StorageMountConf.h> #include <tencentcloud/tem/v20210701/model/LogOutputConf.h> #include <tencentcloud/tem/v20210701/model/MountedSettingConf.h> #include <tencentcloud/tem/v20210701/model/EksService.h> #include <tencentcloud/tem/v20210701/model/HealthCheckConfig.h> #include <tencentcloud/tem/v20210701/model/DeployStrategyConf.h> #include <tencentcloud/tem/v20210701/model/HorizontalAutoscaler.h> #include <tencentcloud/tem/v20210701/model/CronHorizontalAutoscaler.h> #include <tencentcloud/tem/v20210701/model/EnablePrometheusConf.h> namespace TencentCloud { namespace Tem { namespace V20210701 { namespace Model { /** * DeployApplication request structure. */ class DeployApplicationRequest : public AbstractModel { public: DeployApplicationRequest(); ~DeployApplicationRequest() = default; std::string ToJsonString() const; /** * 获取Application ID * @return ApplicationId Application ID */ std::string GetApplicationId() const; /** * 设置Application ID * @param ApplicationId Application ID */ void SetApplicationId(const std::string& _applicationId); /** * 判断参数 ApplicationId 是否已赋值 * @return ApplicationId 是否已赋值 */ bool ApplicationIdHasBeenSet() const; /** * 获取Number of initialized pods * @return InitPodNum Number of initialized pods */ uint64_t GetInitPodNum() const; /** * 设置Number of initialized pods * @param InitPodNum Number of initialized pods */ void SetInitPodNum(const uint64_t& _initPodNum); /** * 判断参数 InitPodNum 是否已赋值 * @return InitPodNum 是否已赋值 */ bool InitPodNumHasBeenSet() const; /** * 获取CPU specification * @return CpuSpec CPU specification */ double GetCpuSpec() const; /** * 设置CPU specification * @param CpuSpec CPU specification */ void SetCpuSpec(const double& _cpuSpec); /** * 判断参数 CpuSpec 是否已赋值 * @return CpuSpec 是否已赋值 */ bool CpuSpecHasBeenSet() const; /** * 获取Memory specification * @return MemorySpec Memory specification */ double GetMemorySpec() const; /** * 设置Memory specification * @param MemorySpec Memory specification */ void SetMemorySpec(const double& _memorySpec); /** * 判断参数 MemorySpec 是否已赋值 * @return MemorySpec 是否已赋值 */ bool MemorySpecHasBeenSet() const; /** * 获取Environment ID * @return EnvironmentId Environment ID */ std::string GetEnvironmentId() const; /** * 设置Environment ID * @param EnvironmentId Environment ID */ void SetEnvironmentId(const std::string& _environmentId); /** * 判断参数 EnvironmentId 是否已赋值 * @return EnvironmentId 是否已赋值 */ bool EnvironmentIdHasBeenSet() const; /** * 获取Image repository * @return ImgRepo Image repository */ std::string GetImgRepo() const; /** * 设置Image repository * @param ImgRepo Image repository */ void SetImgRepo(const std::string& _imgRepo); /** * 判断参数 ImgRepo 是否已赋值 * @return ImgRepo 是否已赋值 */ bool ImgRepoHasBeenSet() const; /** * 获取Version description * @return VersionDesc Version description */ std::string GetVersionDesc() const; /** * 设置Version description * @param VersionDesc Version description */ void SetVersionDesc(const std::string& _versionDesc); /** * 判断参数 VersionDesc 是否已赋值 * @return VersionDesc 是否已赋值 */ bool VersionDescHasBeenSet() const; /** * 获取Launch parameters * @return JvmOpts Launch parameters */ std::string GetJvmOpts() const; /** * 设置Launch parameters * @param JvmOpts Launch parameters */ void SetJvmOpts(const std::string& _jvmOpts); /** * 判断参数 JvmOpts 是否已赋值 * @return JvmOpts 是否已赋值 */ bool JvmOptsHasBeenSet() const; /** * 获取Auto scaling configuration (This field is disused. Please use `HorizontalAutoscaler` to set the auto scaling policy.) * @return EsInfo Auto scaling configuration (This field is disused. Please use `HorizontalAutoscaler` to set the auto scaling policy.) */ EsInfo GetEsInfo() const; /** * 设置Auto scaling configuration (This field is disused. Please use `HorizontalAutoscaler` to set the auto scaling policy.) * @param EsInfo Auto scaling configuration (This field is disused. Please use `HorizontalAutoscaler` to set the auto scaling policy.) */ void SetEsInfo(const EsInfo& _esInfo); /** * 判断参数 EsInfo 是否已赋值 * @return EsInfo 是否已赋值 */ bool EsInfoHasBeenSet() const; /** * 获取Environment variable configuration * @return EnvConf Environment variable configuration */ std::vector<Pair> GetEnvConf() const; /** * 设置Environment variable configuration * @param EnvConf Environment variable configuration */ void SetEnvConf(const std::vector<Pair>& _envConf); /** * 判断参数 EnvConf 是否已赋值 * @return EnvConf 是否已赋值 */ bool EnvConfHasBeenSet() const; /** * 获取Log configuration * @return LogConfs Log configuration */ std::vector<std::string> GetLogConfs() const; /** * 设置Log configuration * @param LogConfs Log configuration */ void SetLogConfs(const std::vector<std::string>& _logConfs); /** * 判断参数 LogConfs 是否已赋值 * @return LogConfs 是否已赋值 */ bool LogConfsHasBeenSet() const; /** * 获取Data volume configuration * @return StorageConfs Data volume configuration */ std::vector<StorageConf> GetStorageConfs() const; /** * 设置Data volume configuration * @param StorageConfs Data volume configuration */ void SetStorageConfs(const std::vector<StorageConf>& _storageConfs); /** * 判断参数 StorageConfs 是否已赋值 * @return StorageConfs 是否已赋值 */ bool StorageConfsHasBeenSet() const; /** * 获取Data volume mount configuration * @return StorageMountConfs Data volume mount configuration */ std::vector<StorageMountConf> GetStorageMountConfs() const; /** * 设置Data volume mount configuration * @param StorageMountConfs Data volume mount configuration */ void SetStorageMountConfs(const std::vector<StorageMountConf>& _storageMountConfs); /** * 判断参数 StorageMountConfs 是否已赋值 * @return StorageMountConfs 是否已赋值 */ bool StorageMountConfsHasBeenSet() const; /** * 获取Deployment type - JAR: deployment through JAR package - WAR: deployment through WAR package - IMAGE: deployment through image * @return DeployMode Deployment type - JAR: deployment through JAR package - WAR: deployment through WAR package - IMAGE: deployment through image */ std::string GetDeployMode() const; /** * 设置Deployment type - JAR: deployment through JAR package - WAR: deployment through WAR package - IMAGE: deployment through image * @param DeployMode Deployment type - JAR: deployment through JAR package - WAR: deployment through WAR package - IMAGE: deployment through image */ void SetDeployMode(const std::string& _deployMode); /** * 判断参数 DeployMode 是否已赋值 * @return DeployMode 是否已赋值 */ bool DeployModeHasBeenSet() const; /** * 获取When the deployment type is `IMAGE`, this parameter indicates the image tag When the deployment type is `JAR` or `WAR`, this parameter indicates the package version number * @return DeployVersion When the deployment type is `IMAGE`, this parameter indicates the image tag When the deployment type is `JAR` or `WAR`, this parameter indicates the package version number */ std::string GetDeployVersion() const; /** * 设置When the deployment type is `IMAGE`, this parameter indicates the image tag When the deployment type is `JAR` or `WAR`, this parameter indicates the package version number * @param DeployVersion When the deployment type is `IMAGE`, this parameter indicates the image tag When the deployment type is `JAR` or `WAR`, this parameter indicates the package version number */ void SetDeployVersion(const std::string& _deployVersion); /** * 判断参数 DeployVersion 是否已赋值 * @return DeployVersion 是否已赋值 */ bool DeployVersionHasBeenSet() const; /** * 获取Package name, which is required when using JAR or WAR packages for deployment * @return PkgName Package name, which is required when using JAR or WAR packages for deployment */ std::string GetPkgName() const; /** * 设置Package name, which is required when using JAR or WAR packages for deployment * @param PkgName Package name, which is required when using JAR or WAR packages for deployment */ void SetPkgName(const std::string& _pkgName); /** * 判断参数 PkgName 是否已赋值 * @return PkgName 是否已赋值 */ bool PkgNameHasBeenSet() const; /** * 获取JDK version - KONA: use KONA JDK - OPEN: use open JDK - KONA: use KONA JDK - OPEN: use open JDK * @return JdkVersion JDK version - KONA: use KONA JDK - OPEN: use open JDK - KONA: use KONA JDK - OPEN: use open JDK */ std::string GetJdkVersion() const; /** * 设置JDK version - KONA: use KONA JDK - OPEN: use open JDK - KONA: use KONA JDK - OPEN: use open JDK * @param JdkVersion JDK version - KONA: use KONA JDK - OPEN: use open JDK - KONA: use KONA JDK - OPEN: use open JDK */ void SetJdkVersion(const std::string& _jdkVersion); /** * 判断参数 JdkVersion 是否已赋值 * @return JdkVersion 是否已赋值 */ bool JdkVersionHasBeenSet() const; /** * 获取Security group IDs * @return SecurityGroupIds Security group IDs */ std::vector<std::string> GetSecurityGroupIds() const; /** * 设置Security group IDs * @param SecurityGroupIds Security group IDs */ void SetSecurityGroupIds(const std::vector<std::string>& _securityGroupIds); /** * 判断参数 SecurityGroupIds 是否已赋值 * @return SecurityGroupIds 是否已赋值 */ bool SecurityGroupIdsHasBeenSet() const; /** * 获取Log output configuration * @return LogOutputConf Log output configuration */ LogOutputConf GetLogOutputConf() const; /** * 设置Log output configuration * @param LogOutputConf Log output configuration */ void SetLogOutputConf(const LogOutputConf& _logOutputConf); /** * 判断参数 LogOutputConf 是否已赋值 * @return LogOutputConf 是否已赋值 */ bool LogOutputConfHasBeenSet() const; /** * 获取Source channel * @return SourceChannel Source channel */ int64_t GetSourceChannel() const; /** * 设置Source channel * @param SourceChannel Source channel */ void SetSourceChannel(const int64_t& _sourceChannel); /** * 判断参数 SourceChannel 是否已赋值 * @return SourceChannel 是否已赋值 */ bool SourceChannelHasBeenSet() const; /** * 获取Version description * @return Description Version description */ std::string GetDescription() const; /** * 设置Version description * @param Description Version description */ void SetDescription(const std::string& _description); /** * 判断参数 Description 是否已赋值 * @return Description 是否已赋值 */ bool DescriptionHasBeenSet() const; /** * 获取Image command * @return ImageCommand Image command */ std::string GetImageCommand() const; /** * 设置Image command * @param ImageCommand Image command */ void SetImageCommand(const std::string& _imageCommand); /** * 判断参数 ImageCommand 是否已赋值 * @return ImageCommand 是否已赋值 */ bool ImageCommandHasBeenSet() const; /** * 获取Image command parameters * @return ImageArgs Image command parameters */ std::vector<std::string> GetImageArgs() const; /** * 设置Image command parameters * @param ImageArgs Image command parameters */ void SetImageArgs(const std::vector<std::string>& _imageArgs); /** * 判断参数 ImageArgs 是否已赋值 * @return ImageArgs 是否已赋值 */ bool ImageArgsHasBeenSet() const; /** * 获取Whether to add the registry's default configurations * @return UseRegistryDefaultConfig Whether to add the registry's default configurations */ bool GetUseRegistryDefaultConfig() const; /** * 设置Whether to add the registry's default configurations * @param UseRegistryDefaultConfig Whether to add the registry's default configurations */ void SetUseRegistryDefaultConfig(const bool& _useRegistryDefaultConfig); /** * 判断参数 UseRegistryDefaultConfig 是否已赋值 * @return UseRegistryDefaultConfig 是否已赋值 */ bool UseRegistryDefaultConfigHasBeenSet() const; /** * 获取Mounting configurations * @return SettingConfs Mounting configurations */ std::vector<MountedSettingConf> GetSettingConfs() const; /** * 设置Mounting configurations * @param SettingConfs Mounting configurations */ void SetSettingConfs(const std::vector<MountedSettingConf>& _settingConfs); /** * 判断参数 SettingConfs 是否已赋值 * @return SettingConfs 是否已赋值 */ bool SettingConfsHasBeenSet() const; /** * 获取Application access configuration * @return Service Application access configuration */ EksService GetService() const; /** * 设置Application access configuration * @param Service Application access configuration */ void SetService(const EksService& _service); /** * 判断参数 Service 是否已赋值 * @return Service 是否已赋值 */ bool ServiceHasBeenSet() const; /** * 获取ID of the version that you want to roll back to * @return VersionId ID of the version that you want to roll back to */ std::string GetVersionId() const; /** * 设置ID of the version that you want to roll back to * @param VersionId ID of the version that you want to roll back to */ void SetVersionId(const std::string& _versionId); /** * 判断参数 VersionId 是否已赋值 * @return VersionId 是否已赋值 */ bool VersionIdHasBeenSet() const; /** * 获取The script to run after startup * @return PostStart The script to run after startup */ std::string GetPostStart() const; /** * 设置The script to run after startup * @param PostStart The script to run after startup */ void SetPostStart(const std::string& _postStart); /** * 判断参数 PostStart 是否已赋值 * @return PostStart 是否已赋值 */ bool PostStartHasBeenSet() const; /** * 获取The script to run before stop * @return PreStop The script to run before stop */ std::string GetPreStop() const; /** * 设置The script to run before stop * @param PreStop The script to run before stop */ void SetPreStop(const std::string& _preStop); /** * 判断参数 PreStop 是否已赋值 * @return PreStop 是否已赋值 */ bool PreStopHasBeenSet() const; /** * 获取Configuration of aliveness probe * @return Liveness Configuration of aliveness probe */ HealthCheckConfig GetLiveness() const; /** * 设置Configuration of aliveness probe * @param Liveness Configuration of aliveness probe */ void SetLiveness(const HealthCheckConfig& _liveness); /** * 判断参数 Liveness 是否已赋值 * @return Liveness 是否已赋值 */ bool LivenessHasBeenSet() const; /** * 获取Configuration of readiness probe * @return Readiness Configuration of readiness probe */ HealthCheckConfig GetReadiness() const; /** * 设置Configuration of readiness probe * @param Readiness Configuration of readiness probe */ void SetReadiness(const HealthCheckConfig& _readiness); /** * 判断参数 Readiness 是否已赋值 * @return Readiness 是否已赋值 */ bool ReadinessHasBeenSet() const; /** * 获取Configuration of batch release policies * @return DeployStrategyConf Configuration of batch release policies */ DeployStrategyConf GetDeployStrategyConf() const; /** * 设置Configuration of batch release policies * @param DeployStrategyConf Configuration of batch release policies */ void SetDeployStrategyConf(const DeployStrategyConf& _deployStrategyConf); /** * 判断参数 DeployStrategyConf 是否已赋值 * @return DeployStrategyConf 是否已赋值 */ bool DeployStrategyConfHasBeenSet() const; /** * 获取Auto scaling policy * @return HorizontalAutoscaler Auto scaling policy */ std::vector<HorizontalAutoscaler> GetHorizontalAutoscaler() const; /** * 设置Auto scaling policy * @param HorizontalAutoscaler Auto scaling policy */ void SetHorizontalAutoscaler(const std::vector<HorizontalAutoscaler>& _horizontalAutoscaler); /** * 判断参数 HorizontalAutoscaler 是否已赋值 * @return HorizontalAutoscaler 是否已赋值 */ bool HorizontalAutoscalerHasBeenSet() const; /** * 获取Scheduled auto scaling policy * @return CronHorizontalAutoscaler Scheduled auto scaling policy */ std::vector<CronHorizontalAutoscaler> GetCronHorizontalAutoscaler() const; /** * 设置Scheduled auto scaling policy * @param CronHorizontalAutoscaler Scheduled auto scaling policy */ void SetCronHorizontalAutoscaler(const std::vector<CronHorizontalAutoscaler>& _cronHorizontalAutoscaler); /** * 判断参数 CronHorizontalAutoscaler 是否已赋值 * @return CronHorizontalAutoscaler 是否已赋值 */ bool CronHorizontalAutoscalerHasBeenSet() const; /** * 获取Specifies whether to enable logging. `1`: enable; `0`: do not enable * @return LogEnable Specifies whether to enable logging. `1`: enable; `0`: do not enable */ int64_t GetLogEnable() const; /** * 设置Specifies whether to enable logging. `1`: enable; `0`: do not enable * @param LogEnable Specifies whether to enable logging. `1`: enable; `0`: do not enable */ void SetLogEnable(const int64_t& _logEnable); /** * 判断参数 LogEnable 是否已赋值 * @return LogEnable 是否已赋值 */ bool LogEnableHasBeenSet() const; /** * 获取Whether the configuration is modified (except for the image configuration) * @return ConfEdited Whether the configuration is modified (except for the image configuration) */ bool GetConfEdited() const; /** * 设置Whether the configuration is modified (except for the image configuration) * @param ConfEdited Whether the configuration is modified (except for the image configuration) */ void SetConfEdited(const bool& _confEdited); /** * 判断参数 ConfEdited 是否已赋值 * @return ConfEdited 是否已赋值 */ bool ConfEditedHasBeenSet() const; /** * 获取Whether the application acceleration is enabled * @return SpeedUp Whether the application acceleration is enabled */ bool GetSpeedUp() const; /** * 设置Whether the application acceleration is enabled * @param SpeedUp Whether the application acceleration is enabled */ void SetSpeedUp(const bool& _speedUp); /** * 判断参数 SpeedUp 是否已赋值 * @return SpeedUp 是否已赋值 */ bool SpeedUpHasBeenSet() const; /** * 获取Whether to enable probing * @return StartupProbe Whether to enable probing */ HealthCheckConfig GetStartupProbe() const; /** * 设置Whether to enable probing * @param StartupProbe Whether to enable probing */ void SetStartupProbe(const HealthCheckConfig& _startupProbe); /** * 判断参数 StartupProbe 是否已赋值 * @return StartupProbe 是否已赋值 */ bool StartupProbeHasBeenSet() const; /** * 获取The version of the operating system If `openjdk` is selected, the value can be: - ALPINE - CENTOS If `konajdk` is selected, the value can be: - ALPINE - TENCENTOS * @return OsFlavour The version of the operating system If `openjdk` is selected, the value can be: - ALPINE - CENTOS If `konajdk` is selected, the value can be: - ALPINE - TENCENTOS */ std::string GetOsFlavour() const; /** * 设置The version of the operating system If `openjdk` is selected, the value can be: - ALPINE - CENTOS If `konajdk` is selected, the value can be: - ALPINE - TENCENTOS * @param OsFlavour The version of the operating system If `openjdk` is selected, the value can be: - ALPINE - CENTOS If `konajdk` is selected, the value can be: - ALPINE - TENCENTOS */ void SetOsFlavour(const std::string& _osFlavour); /** * 判断参数 OsFlavour 是否已赋值 * @return OsFlavour 是否已赋值 */ bool OsFlavourHasBeenSet() const; /** * 获取Specifies whether to enable Prometheus metric * @return EnablePrometheusConf Specifies whether to enable Prometheus metric */ EnablePrometheusConf GetEnablePrometheusConf() const; /** * 设置Specifies whether to enable Prometheus metric * @param EnablePrometheusConf Specifies whether to enable Prometheus metric */ void SetEnablePrometheusConf(const EnablePrometheusConf& _enablePrometheusConf); /** * 判断参数 EnablePrometheusConf 是否已赋值 * @return EnablePrometheusConf 是否已赋值 */ bool EnablePrometheusConfHasBeenSet() const; private: /** * Application ID */ std::string m_applicationId; bool m_applicationIdHasBeenSet; /** * Number of initialized pods */ uint64_t m_initPodNum; bool m_initPodNumHasBeenSet; /** * CPU specification */ double m_cpuSpec; bool m_cpuSpecHasBeenSet; /** * Memory specification */ double m_memorySpec; bool m_memorySpecHasBeenSet; /** * Environment ID */ std::string m_environmentId; bool m_environmentIdHasBeenSet; /** * Image repository */ std::string m_imgRepo; bool m_imgRepoHasBeenSet; /** * Version description */ std::string m_versionDesc; bool m_versionDescHasBeenSet; /** * Launch parameters */ std::string m_jvmOpts; bool m_jvmOptsHasBeenSet; /** * Auto scaling configuration (This field is disused. Please use `HorizontalAutoscaler` to set the auto scaling policy.) */ EsInfo m_esInfo; bool m_esInfoHasBeenSet; /** * Environment variable configuration */ std::vector<Pair> m_envConf; bool m_envConfHasBeenSet; /** * Log configuration */ std::vector<std::string> m_logConfs; bool m_logConfsHasBeenSet; /** * Data volume configuration */ std::vector<StorageConf> m_storageConfs; bool m_storageConfsHasBeenSet; /** * Data volume mount configuration */ std::vector<StorageMountConf> m_storageMountConfs; bool m_storageMountConfsHasBeenSet; /** * Deployment type - JAR: deployment through JAR package - WAR: deployment through WAR package - IMAGE: deployment through image */ std::string m_deployMode; bool m_deployModeHasBeenSet; /** * When the deployment type is `IMAGE`, this parameter indicates the image tag When the deployment type is `JAR` or `WAR`, this parameter indicates the package version number */ std::string m_deployVersion; bool m_deployVersionHasBeenSet; /** * Package name, which is required when using JAR or WAR packages for deployment */ std::string m_pkgName; bool m_pkgNameHasBeenSet; /** * JDK version - KONA: use KONA JDK - OPEN: use open JDK - KONA: use KONA JDK - OPEN: use open JDK */ std::string m_jdkVersion; bool m_jdkVersionHasBeenSet; /** * Security group IDs */ std::vector<std::string> m_securityGroupIds; bool m_securityGroupIdsHasBeenSet; /** * Log output configuration */ LogOutputConf m_logOutputConf; bool m_logOutputConfHasBeenSet; /** * Source channel */ int64_t m_sourceChannel; bool m_sourceChannelHasBeenSet; /** * Version description */ std::string m_description; bool m_descriptionHasBeenSet; /** * Image command */ std::string m_imageCommand; bool m_imageCommandHasBeenSet; /** * Image command parameters */ std::vector<std::string> m_imageArgs; bool m_imageArgsHasBeenSet; /** * Whether to add the registry's default configurations */ bool m_useRegistryDefaultConfig; bool m_useRegistryDefaultConfigHasBeenSet; /** * Mounting configurations */ std::vector<MountedSettingConf> m_settingConfs; bool m_settingConfsHasBeenSet; /** * Application access configuration */ EksService m_service; bool m_serviceHasBeenSet; /** * ID of the version that you want to roll back to */ std::string m_versionId; bool m_versionIdHasBeenSet; /** * The script to run after startup */ std::string m_postStart; bool m_postStartHasBeenSet; /** * The script to run before stop */ std::string m_preStop; bool m_preStopHasBeenSet; /** * Configuration of aliveness probe */ HealthCheckConfig m_liveness; bool m_livenessHasBeenSet; /** * Configuration of readiness probe */ HealthCheckConfig m_readiness; bool m_readinessHasBeenSet; /** * Configuration of batch release policies */ DeployStrategyConf m_deployStrategyConf; bool m_deployStrategyConfHasBeenSet; /** * Auto scaling policy */ std::vector<HorizontalAutoscaler> m_horizontalAutoscaler; bool m_horizontalAutoscalerHasBeenSet; /** * Scheduled auto scaling policy */ std::vector<CronHorizontalAutoscaler> m_cronHorizontalAutoscaler; bool m_cronHorizontalAutoscalerHasBeenSet; /** * Specifies whether to enable logging. `1`: enable; `0`: do not enable */ int64_t m_logEnable; bool m_logEnableHasBeenSet; /** * Whether the configuration is modified (except for the image configuration) */ bool m_confEdited; bool m_confEditedHasBeenSet; /** * Whether the application acceleration is enabled */ bool m_speedUp; bool m_speedUpHasBeenSet; /** * Whether to enable probing */ HealthCheckConfig m_startupProbe; bool m_startupProbeHasBeenSet; /** * The version of the operating system If `openjdk` is selected, the value can be: - ALPINE - CENTOS If `konajdk` is selected, the value can be: - ALPINE - TENCENTOS */ std::string m_osFlavour; bool m_osFlavourHasBeenSet; /** * Specifies whether to enable Prometheus metric */ EnablePrometheusConf m_enablePrometheusConf; bool m_enablePrometheusConfHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_TEM_V20210701_MODEL_DEPLOYAPPLICATIONREQUEST_H_
37.400547
155
0.455588
[ "vector", "model" ]
47656a8c8a2b62e6fb10fec6e31c978028cc0c4b
870
h
C
src/util.h
kukrimate/termsploit
c0e8d2ff5b7a4d5490c90f43f336f33fe4b06d27
[ "0BSD" ]
null
null
null
src/util.h
kukrimate/termsploit
c0e8d2ff5b7a4d5490c90f43f336f33fe4b06d27
[ "0BSD" ]
null
null
null
src/util.h
kukrimate/termsploit
c0e8d2ff5b7a4d5490c90f43f336f33fe4b06d27
[ "0BSD" ]
null
null
null
#ifndef UTIL_H #define UTIL_H /* * Number of elements in an array */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*x)) /* * Open a TCP connection to a host on a port */ int tcpopen(char *host, uint16_t port); /* * Create a master-slave pty pair and set it to raw mode */ int openrawpty(int *master, int *slave); /* * Character vector */ typedef struct { size_t n; size_t size; char *array; } CharVec; /* * Initialize a character vector */ void init_vector(CharVec *vec); /* * Append a character to a vector */ void append_char(CharVec *vec, char ch); /* * Append multiple characters to a vector */ void append_chars(CharVec *vec, char *buf, size_t n); /* * Printf appending to a vector */ void append_printf(CharVec *vec, char *fmt, ...); /* * Pad a vector to n elements */ void pad_vector(CharVec *vec, char val, size_t n); #endif
15.818182
56
0.663218
[ "vector" ]
476ed4d5dfcb9f2f73354b31fcd7b205fc99500b
1,076
h
C
src/MariaRow.h
dpprdan/RMariaDB
0e17617446acf4b66faf19448a12665c7bf3be82
[ "MIT" ]
null
null
null
src/MariaRow.h
dpprdan/RMariaDB
0e17617446acf4b66faf19448a12665c7bf3be82
[ "MIT" ]
null
null
null
src/MariaRow.h
dpprdan/RMariaDB
0e17617446acf4b66faf19448a12665c7bf3be82
[ "MIT" ]
null
null
null
#ifndef __RMARIADB_MARIA_ROW__ #define __RMARIADB_MARIA_ROW__ #include <boost/core/noncopyable.hpp> #include <boost/container/vector.hpp> #include <boost/cstdint.hpp> #include "MariaTypes.h" class MariaRow : public boost::noncopyable { MYSQL_STMT* pStatement_; int n_; std::vector<MYSQL_BIND> bindings_; std::vector<MariaFieldType> types_; std::vector<std::vector<unsigned char> > buffers_; std::vector<unsigned long> lengths_; boost::container::vector<my_bool> nulls_, errors_; public: MariaRow(); ~MariaRow(); public: void setup(MYSQL_STMT* pStatement, const std::vector<MariaFieldType>& types); void set_list_value(SEXP x, int i, int j); private: // Value accessors ----------------------------------------------------------- bool is_null(int j); int value_int(int j); int value_bool(int j); int64_t value_int64(int j); double value_double(int j); SEXP value_string(int j); SEXP value_raw(int j); double value_date_time(int j); double value_date(int j); double value_time(int j); void fetch_buffer(int j); }; #endif
22.893617
80
0.689591
[ "vector" ]
47742cebccfd67c95485b4b14ea2251665234e6a
10,417
c
C
source/util_api/ansc/AnscDaemonEngineUdp/ansc_deuo_recv.c
lgirdk/ccsp-common-library
8d912984e96f960df6dadb4b0e6bc76c76376776
[ "Apache-2.0" ]
4
2018-02-26T05:41:14.000Z
2019-12-20T07:31:39.000Z
source/util_api/ansc/AnscDaemonEngineUdp/ansc_deuo_recv.c
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
null
null
null
source/util_api/ansc/AnscDaemonEngineUdp/ansc_deuo_recv.c
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
3
2017-07-30T15:35:16.000Z
2020-08-18T20:44:08.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * 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. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] 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. **********************************************************************/ /********************************************************************** module: ansc_deuo_recv.c For Advanced Networking Service Container (ANSC), BroadWay Service Delivery System --------------------------------------------------------------- description: This module implements the advanced async-task functions of the Ansc Daemon Engine Udp Object. * AnscDeuoRecvTask --------------------------------------------------------------- environment: platform independent --------------------------------------------------------------- author: Xuechen Yang --------------------------------------------------------------- revision: 12/10/01 initial revision. **********************************************************************/ #include "ansc_deuo_global.h" /********************************************************************** caller: owner of this object prototype: ANSC_STATUS AnscDeuoRecvTask ( ANSC_HANDLE hThisObject ); description: This function is a task thread created by the start() function call to contain async packet-recv processing. argument: ANSC_HANDLE hThisObject This handle is actually the pointer of this object itself. return: status of operation. **********************************************************************/ ANSC_STATUS AnscDeuoRecvTask ( ANSC_HANDLE hThisObject ) { PANSC_DAEMON_ENGINE_UDP_OBJECT pMyObject = (PANSC_DAEMON_ENGINE_UDP_OBJECT)hThisObject; PANSC_DAEMON_SERVER_UDP_OBJECT pServer = (PANSC_DAEMON_SERVER_UDP_OBJECT)pMyObject->hDaemonServer; PANSC_DSUO_WORKER_OBJECT pWorker = (PANSC_DSUO_WORKER_OBJECT )pServer->hWorker; PANSC_DAEMON_SOCKET_UDP_OBJECT pSocket = NULL; PANSC_DSUO_PACKET_OBJECT pPacket = NULL; ULONG ulLastCleanAt = AnscGetTickInSeconds(); AnscTrace("AnscDeuoRecvTask is activated ...!\n"); /* * As a scalable server implemention, we shall accept as many incoming client connections as * possible and can only be limited by the system resources. Once the listening socket becomes * readable, which means an incoming connection attempt has arrived. We create a new socket * object and associate it with the client. This is a repeated process until the socket owner * closes the socket. */ while ( pMyObject->bStarted ) { ANSC_COMMIT_TASK(); /* * To avoid letting the old half-dead sockets hogging up the system resource, we need to * periodically invoke the cleaning routine. The default interval is 10 seconds, and the * idle timeout value is 90 seconds. */ if ( (AnscGetTickInSeconds() - ulLastCleanAt) >= ANSC_DEUO_CLEAN_TASK_INTERVAL ) { pMyObject->Clean((ANSC_HANDLE)pMyObject); ulLastCleanAt = AnscGetTickInSeconds(); } /* * If the reason we're there is that we run of packet objects to serve, we shall stop and * take a nap. Unlike the Daemon Server Tcp Object, where engines are balanced via round- * robin scheduling, Udp Server uses address-hashing to pick an engine. There're some slim * chances that some engines may be overloaded while the others have nothing to do. By * sleeping for very short time, idle engines can release the underlying OS scheduler from * switching back and forth. */ if ( AnscQueueQueryDepth(&pMyObject->PacketQueue) == 0 ) { if ( pServer->Mode & ANSC_DSUO_MODE_EVENT_SYNC ) { AnscWaitEvent (&pMyObject->NewPacketEvent, ANSC_DEUO_WAIT_EVENT_INTERVAL); AnscResetEvent(&pMyObject->NewPacketEvent); if ( AnscQueueQueryDepth(&pMyObject->PacketQueue) == 0 ) { AnscTaskRelinquish(); continue; } } else { AnscSleep(ANSC_DEUO_TASK_BREAK_INTERVAL); continue; } } /* * Every engine maintains its own packet waiting queue. The main accept() task controlled * by the server is responsible for consistently pumping packet objects and distributing * them equally among engines. To obey the first-come-first-serve rule, we pop packet out * of the waiting queue from the head and associate it with a socket object. */ while (( pPacket = (PANSC_DSUO_PACKET_OBJECT)pMyObject->GetPacket ( (ANSC_HANDLE)pMyObject )) ) { if ( (AnscGetTickInSeconds() - pPacket->RecvAt) > pMyObject->PacketTimeOut ) { pServer->ReleasePacket ( (ANSC_HANDLE)pServer, (ANSC_HANDLE)pPacket ); continue; } pSocket = (PANSC_DAEMON_SOCKET_UDP_OBJECT)pMyObject->GetSocket ( (ANSC_HANDLE)pMyObject, pPacket->PeerAddress.Dot, pPacket->PeerPort ); if ( !pSocket ) { pSocket = (PANSC_DAEMON_SOCKET_UDP_OBJECT)pServer->AcquireSocket ( (ANSC_HANDLE)pServer ); if ( !pSocket ) { pServer->ReleasePacket ( (ANSC_HANDLE)pServer, (ANSC_HANDLE)pPacket ); break; } pSocket->Socket = pServer->Socket; pSocket->HostAddress.Value = pServer->HostAddress.Value; pSocket->HostPort = pServer->HostPort; pSocket->PeerAddress.Value = pPacket->PeerAddress.Value; pSocket->PeerPort = pPacket->PeerPort; pSocket->LastRecvAt = AnscGetTickInSeconds(); /* * Before we hand this socket object to one of the daemon engines, we SHALL give the worker * object a chance to examine the incoming socket request. A bunch of features can further * be implemented within this call: * * $ authentication based on the IP address and port number * $ establish session relationships * * However, the original intention was to give the worker an opportunity to associate some * session-specific information with this socket. */ if ( !pWorker->Accept ( pWorker->hWorkerContext, (ANSC_HANDLE)pSocket, &pSocket->hClientContext ) ) { pSocket->Close ((ANSC_HANDLE)pSocket); pSocket->Return((ANSC_HANDLE)pSocket); pServer->ReleasePacket ( (ANSC_HANDLE)pServer, (ANSC_HANDLE)pPacket ); continue; } pMyObject->AddSocket ( (ANSC_HANDLE)pMyObject, (ANSC_HANDLE)pSocket ); } if ( pSocket->bRecvEnabled ) { pSocket->SetPacket ( (ANSC_HANDLE)pSocket, (ANSC_HANDLE)pPacket ); pMyObject->Recv ( (ANSC_HANDLE)pMyObject, (ANSC_HANDLE)pSocket ); } else { pServer->ReleasePacket ( (ANSC_HANDLE)pServer, (ANSC_HANDLE)pPacket ); } if ( !pMyObject->bStarted ) { break; } } } AnscSetEvent(&pMyObject->RecvEvent); return ANSC_STATUS_SUCCESS; }
34.956376
109
0.493712
[ "object" ]
4776b5a503f11b63177a9a4686736d330a0eefd4
12,794
c
C
source/chapter7/7.6/7.6.2/jnimethods/jni/jnimethods.c
TopGuo/android_learn_nixiang
da1876e1949ae9f40a7222dd1ca9eb13916a35a9
[ "MIT" ]
null
null
null
source/chapter7/7.6/7.6.2/jnimethods/jni/jnimethods.c
TopGuo/android_learn_nixiang
da1876e1949ae9f40a7222dd1ca9eb13916a35a9
[ "MIT" ]
null
null
null
source/chapter7/7.6/7.6.2/jnimethods/jni/jnimethods.c
TopGuo/android_learn_nixiang
da1876e1949ae9f40a7222dd1ca9eb13916a35a9
[ "MIT" ]
null
null
null
/* * Copyright (C) 2009 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. * */ #include <string.h> #include <jni.h> #include <android/log.h> #include <pthread.h> #include "jniMethods.h" #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "com.droider.jnimethods", __VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "com.droider.jnimethods", __VA_ARGS__) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "com.droider.jnimethods", __VA_ARGS__) #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "com.droider.jnimethods", __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "com.droider.jnimethods", __VA_ARGS__) JNIEnv *g_env; JavaVM *g_vm; //下面多线程程序用到 pthread_mutex_t thread_mutex; jclass native_class; #ifndef NELEM //计算结构元素个数 # define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) #endif /* jint getJcharLength(const jchar* jStr){ jint jiLen = 0; while (1){ if ( jStr[jiLen++] == L'\0') break; } return jiLen; } */ JNIEXPORT jstring nativeMethod(JNIEnv* env, jclass clazz){ const char * chs = "你好!NativeMethod"; return (*env)->NewStringUTF(env, chs); } JNIEXPORT void Java_com_droider_jnimethods_TestJniMethods_test(JNIEnv* env, jobject object) { int version = (*env)->GetVersion(env); LOGV("GetVersion() --> jni version:%2x", version); jclass build_class = (*env)->FindClass(env, "android/os/Build"); //加载一个本地类 jfieldID brand_id = (*env)->GetStaticFieldID(env, //获取类的静态字段ID build_class, "MODEL", "Ljava/lang/String;"); jstring brand_obj = (jstring)(*env)->GetStaticObjectField(env, //获取类的静态字段的值ֵ build_class, brand_id); //__asm__ ("bkpt"); //raise(SIGTRAP); const char *nativeString = (*env)->GetStringUTFChars(env, brand_obj, 0); //通过jstring生成char* LOGV("GetStringUTFChars() --> MODEL:%s", nativeString); LOGV("GetStaticFieldID() --> %s", nativeString); LOGV("ReleaseStringUTFChars() --> %s", nativeString); (*env)->ReleaseStringUTFChars(env, brand_obj, nativeString); //释放GetStringUTFChars()生成的char* jclass test_class = (*env)->FindClass(env, "com/droider/jnimethods/TestClass"); if((*env)->ExceptionCheck(env)){ (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); LOGE("ExceptionCheck()"); LOGE("ExceptionDescribe()"); LOGE("ExceptionClear()"); } jmethodID constructor = (*env)->GetMethodID(env, test_class, "<init>", "()V"); //获取构造函数 jobject obj = (*env)->NewObject(env, test_class, constructor); //创建一个对象 jthrowable throwable = (*env)->ExceptionOccurred(env); if (throwable){ //有异常发生,还可以使用ExceptionCheck()函数来判断 (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); LOGE("ExceptionOccurred()"); } if (obj){ (*env)->MonitorEnter(env, obj); //同步操作 jfieldID stringfieldID = (*env)->GetFieldID(env, //获取String类型的字段 test_class, "aStringField", "Ljava/lang/String;"); jstring stringfieldValue = (jstring)(*env)->GetObjectField(env, //获取String字段的值ֵ obj, stringfieldID); const char *stringValue = (*env)->GetStringUTFChars(env, stringfieldValue, 0); LOGV("GetObjectField() --> aStringField:%s", stringValue); const char *myValue = "def"; //设置字段的值 (*env)->SetObjectField(env, obj, stringfieldID, (*env)->NewStringUTF(env, myValue)); LOGV("SetObjectField() --> aStringField:def"); (*env)->ReleaseStringUTFChars(env, stringfieldValue, stringValue); jfieldID intfieldID = (*env)->GetFieldID(env, //获取int类型的字段 test_class, "aIntField", "I"); jint fieldValue = (*env)->GetIntField(env, obj, intfieldID); //获取int字段的值ֵ LOGV("GetIntField() --> aField:%d", fieldValue); (*env)->SetIntField(env, obj, intfieldID, (jint)123); // 设置int字段的值ֵ fieldValue = (*env)->GetIntField(env, obj, intfieldID); LOGV("SetIntField() --> aField:%d", fieldValue); jclass parent_class = (*env)->GetSuperclass(env, test_class); LOGV("GetSuperclass() --> "); if(JNI_OK == (*env)->EnsureLocalCapacity(env, 5)){ //检测是否还可以创建5个局部引用 LOGV("EnsureLocalCapacity() --> ensure 5 locals"); jmethodID obj2_voidmethod = (*env)->GetMethodID(env, //获取一个void方法 test_class, "aVoidMethod", "()V"); (*env)->CallVoidMethod(env, obj, obj2_voidmethod); LOGV("CallVoidMethod()"); jmethodID obj2_Staticmethod = (*env)->GetStaticMethodID(env, //获取static方法 test_class, "aStaticMethod", "(Ljava/lang/String;)V"); LOGV("GetStaticMethodID()"); const char *fromJni = "this string from jni"; jstring jstr_static = (*env)->NewStringUTF(env, fromJni); (*env)->CallStaticVoidMethod(env, test_class, obj2_Staticmethod, jstr_static); //调用一个静态方法 jmethodID obj2_chinesemethod = (*env)->GetMethodID(env, //传递中文字符串 test_class, "getChineseString", "()Ljava/lang/String;"); jstring obj2_chinesejstring = (jstring)(*env)->CallObjectMethod(env, obj, obj2_chinesemethod); jsize chinese_size = (*env)->GetStringLength(env, obj2_chinesejstring); //获取UTF-16字符串长度 LOGV("GetStringLength() --> %d", chinese_size); jchar buff_jchar[4] = {0}; (*env)->GetStringRegion(env, obj2_chinesejstring, 0, 3, buff_jchar); LOGV("GetStringRegion() -->"); const jchar * obj2_chinesechars = (*env)->GetStringChars(env, obj2_chinesejstring, NULL); jstring new_chinesestring = (*env)->NewString(env, obj2_chinesechars, chinese_size); (*env)->CallStaticVoidMethod(env, test_class, obj2_Staticmethod, new_chinesestring); //调用一个静态方法 (*env)->ReleaseStringChars(env, obj2_chinesejstring, obj2_chinesechars); //释放GetStringChars获取的jchar* LOGV("CallStaticVoidMethod()"); jmethodID obj2_sqrtmethod = (*env)->GetStaticMethodID(env, //获取一个static方法 test_class, "sqrt", "(I)I"); jint int_sqrt = (*env)->CallStaticIntMethod(env, //计算5的平方 test_class, obj2_sqrtmethod, (jint)5); LOGV("CallStaticIntMethod() -->5 sqrt is:%d", int_sqrt); } if(JNI_TRUE == (*env)->IsAssignableFrom(env, test_class, parent_class)){ LOGV("IsAssignableFrom() --> yes"); } else { jclass newExceptionClazz = (*env)->FindClass(env,"java/lang/RuntimeException"); //实例化一个异常 if(newExceptionClazz != NULL) (*env)->ThrowNew(env, newExceptionClazz,"这里永远不会被执行的!"); LOGE("ThrowNew()"); } jclass obj_clazz = (*env)->GetObjectClass(env, obj); //获取对象的类 if(JNI_TRUE == (*env)->IsInstanceOf(env, obj, obj_clazz)){ LOGV("IsInstanceOf() --> Yes"); } else { (*env)->FatalError(env, "fatal error!"); //抛出致命错误 LOGE("FatalError()"); } (*env)->PushLocalFrame(env, 2); //申请局部引用空间,增加局部引用的管理 jobject obj_localref = (*env)->NewLocalRef(env, obj); //创建一个局部引用 jobject obj_globalref = (*env)->NewGlobalRef(env, obj); //创建一个全局引用 LOGV("PushLocalFrame()"); LOGV("NewLocalRef()"); LOGV("NewGlobalRef()"); if (JNI_TRUE == (*env)->IsSameObject(env, obj_localref, obj_globalref)){ LOGV("IsSameObject() --> Yes"); } (*env)->DeleteLocalRef(env, obj_localref); //删除一个局部引用 (*env)->DeleteGlobalRef(env, obj_globalref); //删除一个全局引用 (*env)->PopLocalFrame(env, NULL); LOGV("DeleteLocalRef()"); LOGV("DeleteGlobalRef()"); LOGV("PopLocalFrame()"); (*env)->MonitorExit(env, obj); } jclass sub_class = (*env)->FindClass(env, "com/droider/jnimethods/TestSubClass"); //查询子类 jobject sub_obj = (*env)->AllocObject(env, sub_class); jmethodID sub_methodID = (*env)->GetMethodID(env, sub_class, "aVoidMethod", "()V"); (*env)->CallNonvirtualVoidMethod(env, sub_obj, sub_class, sub_methodID); //调用子类的方法 (*env)->CallNonvirtualVoidMethod(env, sub_obj, test_class, sub_methodID); //根据调用类的不同调用父类的方法 jfieldID sub_fieldID = (*env)->GetStaticFieldID(env, //获取子类静态字段 sub_class, "subFloatField", "F"); (*env)->SetStaticFloatField(env, sub_class, sub_fieldID, (jfloat)33.88f); LOGV("SetStaticFloatField() --> %.2f", (*env)->GetStaticFloatField(env, sub_class, sub_fieldID)); jclass class_string = (*env)->FindClass(env, "java/lang/String"); jarray string_array = (*env)->NewObjectArray(env, 3, class_string, 0); //创建String数组 LOGV("NewObjectArray()"); jsize array_size = (*env)->GetArrayLength(env, string_array); LOGV("GetArrayLength() --> %d", array_size); jstring array_string1 = (*env)->NewStringUTF(env, "one"); char buff_char[4] = {0}; (*env)->GetStringUTFRegion(env, array_string1, 0, 3, buff_char); LOGV("GetStringUTFRegion() --> %s", buff_char); (*env)->SetObjectArrayElement(env, string_array, 0, array_string1); //设置数组元素的值 LOGV("SetObjectArrayElement() --> one"); array_string1 = (jstring)(*env)->GetObjectArrayElement(env, string_array, 0); //获取数组元素的值 const char* array_elemchars = (*env)->GetStringUTFChars(env, array_string1, NULL); LOGV("GetObjectArrayElement() --> %s", array_elemchars); (*env)->ReleaseStringUTFChars(env, array_string1, array_elemchars); jintArray int_array = (*env)->NewIntArray(env, 5); //创建int数组 LOGV("NewIntArray() --> %d", (*env)->GetArrayLength(env, int_array)); //获取数组长度 const jint ints[] = {11, 12, 13, 14, 15}; (*env)->SetIntArrayRegion(env, int_array, 0, 5, ints); //设置数组一个范围的值ֵ LOGV("SetIntArrayRegion() --> %d,%d,%d,%d,%d", ints[0], ints[1], ints[2], ints[3], ints[4]); jint ints2[2] = {0, 0}; (*env)->GetIntArrayRegion(env, int_array, 1, 2, ints2); //获取数组一个范围的值 LOGV("GetIntArrayRegion() --> %d,%d", ints2[0], ints2[1]); jint* array_ints = (*env)->GetIntArrayElements(env, int_array, NULL); //获取指向所有元素的指针 LOGV("GetIntArrayElements() --> %d,%d,%d,%d,%d", array_ints[0], array_ints[1], array_ints[2], array_ints[3], array_ints[4]); (*env)->ReleaseIntArrayElements(env, int_array, array_ints, 0); //释放指向所有元素的指针 LOGV("ReleaseIntArrayElements()"); } void *thread_func(void *arg){ JNIEnv *env; pthread_mutex_lock(&thread_mutex); if (JNI_OK != (*g_vm)->AttachCurrentThread(g_vm, &env, NULL)){ LOGE("AttachCurrentThread() failed"); return NULL; } LOGV("AttachCurrentThread() --> thread:%d", (jint)arg); (*g_vm)->DetachCurrentThread(g_vm); LOGV("DetachCurrentThread() --> thread:%d", (jint)arg); pthread_mutex_unlock(&thread_mutex); pthread_exit(0); return NULL; } JNIEXPORT void newJniThreads(JNIEnv* env, jobject obj, jint nums){ (*env)->GetJavaVM(env, &g_vm); //保存全局JavaVM LOGV("GetJavaVM()"); pthread_t* pt = (pthread_t*)malloc(sizeof(pthread_t)* nums); pthread_mutex_init(&thread_mutex, NULL); int i; for (i = 0 ; i < nums; i++){ pthread_create(&pt[i], NULL, &thread_func, (void*)i); //创建线程 } free(pt); } JNIEXPORT jobject allocNativeBuffer(JNIEnv* env, jobject obj, jlong size){ void* buffer = malloc(size); jobject directBuffer = (*env)->NewDirectByteBuffer(env, buffer, size); LOGV("NewDirectByteBuffer() --> %d", (int)size); return directBuffer; } JNIEXPORT void freeNativeBuffer(JNIEnv* env, jobject obj, jobject bufferRef) { void *buffer = (*env)->GetDirectBufferAddress(env, bufferRef); strcpy(buffer, "123"); LOGV("GetDirectBufferAddress() --> %s", buffer); free(buffer); } static JNINativeMethod methods[] = { {"nativeMethod", "()Ljava/lang/String;", (void*)nativeMethod}, {"newJniThreads", "(I)V", (void*)newJniThreads}, {"allocNativeBuffer", "(J)Ljava/lang/Object;", (void*)allocNativeBuffer}, {"freeNativeBuffer", "(Ljava/lang/Object;)V", (void*)freeNativeBuffer} }; jint JNI_OnLoad(JavaVM* vm, void* reserved){ if(JNI_OK != (*vm)->GetEnv(vm, (void**)&g_env, JNI_VERSION_1_6)){ //加载指定版本的JNI return -1; } LOGV("JNI_OnLoad()"); native_class = (*g_env)->FindClass(g_env, "com/droider/jnimethods/TestJniMethods"); if (JNI_OK ==(*g_env)->RegisterNatives(g_env, //注册未声明的本地方法 native_class, methods, NELEM(methods))){ LOGV("RegisterNatives() --> nativeMethod() ok"); } else { LOGE("RegisterNatives() --> nativeMethod() failed"); return -1; } return JNI_VERSION_1_6; } jstring stoJstring( JNIEnv* env, const char* pat ) { jclass strClass = (*env)->FindClass(env, "java/lang/String"); jmethodID ctorID = (*env)->GetMethodID(env, strClass, "<init>", "([BLjava/lang/String;)V"); jbyteArray bytes = (*env)->NewByteArray(env, strlen(pat)); (*env)->SetByteArrayRegion(env, bytes, 0, strlen(pat), pat); jstring encoding = (*env)->NewStringUTF(env, "GB2312"); return (jstring)(*env)->NewObject(env, strClass, ctorID, bytes, encoding); } void JNI_OnUnLoad(JavaVM* vm, void* reserved){ LOGV("JNI_OnUnLoad()"); (*g_env)->UnregisterNatives(g_env, native_class); LOGV("UnregisterNatives()"); } int main(int argc, char *argv[]){ return 0; }
40.106583
104
0.69259
[ "object", "model" ]
4776da281063b64a59f387745b7675ee44488a4f
1,014
h
C
src/analyses/local_cfg.h
dan-blank/yogar-cbmc
05b4f056b585b65828acf39546c866379dca6549
[ "MIT" ]
1
2017-07-25T02:44:56.000Z
2017-07-25T02:44:56.000Z
src/analyses/local_cfg.h
dan-blank/yogar-cbmc
05b4f056b585b65828acf39546c866379dca6549
[ "MIT" ]
1
2017-02-22T14:35:19.000Z
2017-02-27T08:49:58.000Z
src/analyses/local_cfg.h
dan-blank/yogar-cbmc
05b4f056b585b65828acf39546c866379dca6549
[ "MIT" ]
4
2019-01-19T03:32:21.000Z
2021-12-20T14:25:19.000Z
/*******************************************************************\ Module: CFG for One Function Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ #ifndef CPROVER_LOCAL_CFG_H #define CPROVER_LOCAL_CFG_H #include <util/numbering.h> #include <goto-programs/goto_functions.h> /*******************************************************************\ Class: local_cfgt Purpose: \*******************************************************************/ class local_cfgt { public: typedef std::vector<unsigned> successorst; class loct { public: goto_programt::const_targett t; successorst successors; }; typedef std::map<goto_programt::const_targett, unsigned> loc_mapt; loc_mapt loc_map; typedef std::vector<loct> locst; locst locs; inline explicit local_cfgt(const goto_programt &_goto_program) { build(_goto_program); } protected: void build(const goto_programt &goto_program); }; #endif
19.5
69
0.530572
[ "vector" ]
477f14213f3ec5fc634a0c53bb10d2f0fc2e21a9
8,322
c
C
main.c
SpacePirate/eecs101-hough-transform
234bff533f39b7448143ba5c4c851e7a69dff782
[ "MIT" ]
1
2021-01-03T16:13:09.000Z
2021-01-03T16:13:09.000Z
main.c
SpacePirate/eecs101-hough-transform
234bff533f39b7448143ba5c4c851e7a69dff782
[ "MIT" ]
null
null
null
main.c
SpacePirate/eecs101-hough-transform
234bff533f39b7448143ba5c4c851e7a69dff782
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define ROWS 480 #define COLS 640 #define DEGREES(radians) ((radians) * 57.29577951308232087679815481410517033240) #define RADIANS(degrees) ((degrees) * 0.017453292519943295769236907684886127134) void clear(unsigned char image[][COLS]); void read_image(char *fname, unsigned char image[][COLS]); void DIP(unsigned char image[][COLS], char *fname, unsigned char t); void threshold(unsigned char image[][COLS], unsigned char t); void header( int row, int col, unsigned char head[32] ); void save_image(char *fname, unsigned char image[][COLS]); int find_edge(int x, int y, int rho, int theta); int main() { unsigned char image[ROWS][COLS]; clear(image); read_image("image.raw", image); DIP(image, "image", 100); clear(image); return 0; } void clear( unsigned char image[][COLS] ) { int i,j; for ( i = 0 ; i < ROWS ; i++ ) for ( j = 0 ; j < COLS ; j++ ) image[i][j] = 0; } void read_image(char *fname, unsigned char image[][COLS]) { int i; FILE *fp; /* Read in a raw image */ /* Open the file */ if (( fp = fopen( fname, "rb" )) == NULL ) { fprintf( stderr, "error: couldn't open %s\n", fname ); exit( 1 ); } /* Read the file */ for ( i = 0; i < ROWS ; i++ ) if ( fread( image[i], 1, COLS, fp ) != COLS ) { fprintf( stderr, "error: couldn't read enough stuff\n" ); exit( 1 ); } /* Close the file */ fclose( fp ); printf("Image %s read successfully!\n", fname); } void save_image(char *fname, unsigned char image[][COLS]) { int i; unsigned char head[32]; FILE *fp; /* Save it into a ras image */ /* Open the file */ if (!( fp = fopen( fname, "wb" ))) fprintf( stderr, "error: could not open %s\n", fname ), exit(1); /* Create a header */ header(ROWS, COLS, head); /* Write the header */ fwrite( head, 4, 8, fp ); /* Write the image */ for ( i = 0; i < ROWS; i++ ) fwrite( image[i], 1, COLS, fp ); /* Close the file */ fclose( fp ); } void DIP(unsigned char image[][COLS], char *fname, unsigned char t) { int x, y, i, j, k; int sobelx, sobely, sgmval; int xmax = 0, ymax = 0, sgm_max = 0; int rho, theta; int minr = 0, maxr = 0; unsigned char edgex[ROWS][COLS]; unsigned char edgey[ROWS][COLS]; unsigned char SGM[ROWS][COLS]; unsigned char hough[ROWS][COLS]; static int bins[1600][180]; char exname[100], eyname[100], sgmname[100], bname[100]; clear(edgex); clear(edgey); clear(SGM); clear(hough); strcpy(exname, fname); strcpy(eyname, fname); strcpy(sgmname, fname); strcpy(bname, fname); strcat(exname, "_dx.ras"); strcat(eyname, "_dy.ras"); strcat(sgmname, "_sgm.ras"); strcat(bname, "_binary.ras"); for(y = 1; y < ROWS-1; y++) { for(x = 1; x < COLS-1; x++) { /* dE/dx */ sobelx = (-(image[y+1][x-1] + 2*image[y][x-1] + image[y-1][x-1]) + image[y+1][x+1] + 2*image[y][x+1] + image[y-1][x+1]); edgex[y][x] = sobelx; if(sobelx > xmax) { xmax = sobelx; } /* dE/dy */ sobely = (-(image[y+1][x-1] + 2*image[y+1][x] + image[y+1][x+1]) + image[y-1][x-1] + 2*image[y-1][x] + image[y-1][x+1]); edgey[y][x] = sobely; if(sobely > ymax) { ymax = sobely; } /* SGM */ sgmval = pow(pow(edgex[y][x], 2) + pow(edgey[y][x], 2), 0.5); SGM[y][x] = sgmval; if(sgmval > sgm_max) { sgm_max = sgmval;} } } /* Normalize */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { edgex[y][x] = 255*edgex[y][x]/xmax; edgey[y][x] = 255*edgey[y][x]/ymax; SGM[y][x] = 255*SGM[y][x]/sgm_max; } } save_image(exname, edgex); save_image(eyname, edgey); save_image(sgmname, SGM); threshold(SGM, t); save_image(bname, SGM); /* Hough transform */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { for(theta = 0; theta <= 180; theta++) { rho = -(x*sin(RADIANS(theta)) - y*cos(RADIANS(theta))); if (rho > maxr) {maxr = rho;} if (rho < minr) {minr = rho;} if (SGM[y][x] == 255) { /* printf("For [%d, %d] and theta, rho is: %d, %d\n", x, y, theta, rho); */ bins[rho + 800][theta]++; } } } } printf("Rho ranges from [%d, %d]\n", minr, maxr); /* Threshold bins */ for(j = 0; j < 1600; j++) { for(i = 0; i < 180; i++) { if(bins[j][i] > 100) { k = j - 800; printf("[%d, %d] = %d\n", k, i, bins[j][i]); } } } /* From above, rho and theta are estimated to be: Line 1: rho[-289, -302], theta[126, 131], peak @ -295, 129 Line 2: rho[-169, -171], theta[51], peak @ -171, 51 Line 3: rho[312, 321], theta[13, 14], peak @ 312, 14 */ for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { /* Line 1 */ if(find_edge(x, y, -295, 129)) {hough[y][x]=255;} /* Line 2 */ if(find_edge(x, y, -171, 51)) {hough[y][x]=255;} /* Line 3 */ if(find_edge(x, y, 312, 14)) {hough[y][x]=255;} } } save_image("hough.ras",hough); } int find_edge(int x, int y, int rho, int theta) { int a; a = ((x*sin(RADIANS(theta))) - (y*cos(RADIANS(theta))) + rho); if (a < 1 && a > -1) {return 1;} else {return 0;} } void threshold(unsigned char image[][COLS], unsigned char t) { int x, y; int a = 0; int cx = 0, cy = 0; for(y = 0; y < ROWS; y++) { for(x = 0; x < COLS; x++) { /* Thresholding */ if (image[y][x] >= t) { image[y][x] = 255; } /* Disregard background */ else { image[y][x] = 0; cx += x; cy += y; a += 1; } } } cx = cx/a; cy = cy/a; /* Re-color 5x5 center area */ for(y = cy - 2; y < cy + 3; y++) { for(x = cx - 2; x < cx + 3; x++) { image[y][x] = 128; } } printf("The area of the image is: %d pixels\n", a); printf("The center of the image is (x, y): (%d, %d)\n", cx, cy); } void header( int row, int col, unsigned char head[32] ) { int *p = (int *)head; char *ch; int num = row * col; /* Choose little-endian or big-endian header depending on the machine. Don't modify this */ /* Little-endian for PC */ *p = 0x956aa659; *(p + 3) = 0x08000000; *(p + 5) = 0x01000000; *(p + 6) = 0x0; *(p + 7) = 0xf8000000; ch = (char*)&col; head[7] = *ch; ch ++; head[6] = *ch; ch ++; head[5] = *ch; ch ++; head[4] = *ch; ch = (char*)&row; head[11] = *ch; ch ++; head[10] = *ch; ch ++; head[9] = *ch; ch ++; head[8] = *ch; ch = (char*)&num; head[19] = *ch; ch ++; head[18] = *ch; ch ++; head[17] = *ch; ch ++; head[16] = *ch; /* // Big-endian for unix *p = 0x59a66a95; *(p + 1) = col; *(p + 2) = row; *(p + 3) = 0x8; *(p + 4) = num; *(p + 5) = 0x1; *(p + 6) = 0x0; *(p + 7) = 0xf8; */ }
24.990991
96
0.425619
[ "transform" ]
4789ebd03c58db5fb0bd2e354fe404823fc91a09
3,402
h
C
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_System_Array_InternalEnumerator_1_gen2235177892MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_System_Array_InternalEnumerator_1_gen2235177892MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
Project/Temp/StagingArea/Data/il2cppOutput/mscorlib_System_Array_InternalEnumerator_1_gen2235177892MethodDeclarations.h
Yuunagi-Yu/NumberDisk
f1cf414dbfe8d0094d3ef11b37839f6caf58ae9f
[ "MIT" ]
null
null
null
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // System.Array struct Il2CppArray; // System.Object struct Il2CppObject; #include "codegen/il2cpp-codegen.h" #include "mscorlib_System_Array_InternalEnumerator_1_gen2235177892.h" #include "mscorlib_System_Array3829468939.h" #include "UnityEngine_UnityEngine_ContactPoint1376425630.h" // System.Void System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::.ctor(System.Array) extern "C" void InternalEnumerator_1__ctor_m3210262878_gshared (InternalEnumerator_1_t2235177892 * __this, Il2CppArray * ___array0, const MethodInfo* method); #define InternalEnumerator_1__ctor_m3210262878(__this, ___array0, method) (( void (*) (InternalEnumerator_1_t2235177892 *, Il2CppArray *, const MethodInfo*))InternalEnumerator_1__ctor_m3210262878_gshared)(__this, ___array0, method) // System.Void System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::System.Collections.IEnumerator.Reset() extern "C" void InternalEnumerator_1_System_Collections_IEnumerator_Reset_m2564106794_gshared (InternalEnumerator_1_t2235177892 * __this, const MethodInfo* method); #define InternalEnumerator_1_System_Collections_IEnumerator_Reset_m2564106794(__this, method) (( void (*) (InternalEnumerator_1_t2235177892 *, const MethodInfo*))InternalEnumerator_1_System_Collections_IEnumerator_Reset_m2564106794_gshared)(__this, method) // System.Object System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::System.Collections.IEnumerator.get_Current() extern "C" Il2CppObject * InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m1497708066_gshared (InternalEnumerator_1_t2235177892 * __this, const MethodInfo* method); #define InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m1497708066(__this, method) (( Il2CppObject * (*) (InternalEnumerator_1_t2235177892 *, const MethodInfo*))InternalEnumerator_1_System_Collections_IEnumerator_get_Current_m1497708066_gshared)(__this, method) // System.Void System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::Dispose() extern "C" void InternalEnumerator_1_Dispose_m3715403693_gshared (InternalEnumerator_1_t2235177892 * __this, const MethodInfo* method); #define InternalEnumerator_1_Dispose_m3715403693(__this, method) (( void (*) (InternalEnumerator_1_t2235177892 *, const MethodInfo*))InternalEnumerator_1_Dispose_m3715403693_gshared)(__this, method) // System.Boolean System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::MoveNext() extern "C" bool InternalEnumerator_1_MoveNext_m3299881374_gshared (InternalEnumerator_1_t2235177892 * __this, const MethodInfo* method); #define InternalEnumerator_1_MoveNext_m3299881374(__this, method) (( bool (*) (InternalEnumerator_1_t2235177892 *, const MethodInfo*))InternalEnumerator_1_MoveNext_m3299881374_gshared)(__this, method) // T System.Array/InternalEnumerator`1<UnityEngine.ContactPoint>::get_Current() extern "C" ContactPoint_t1376425630 InternalEnumerator_1_get_Current_m3035290781_gshared (InternalEnumerator_1_t2235177892 * __this, const MethodInfo* method); #define InternalEnumerator_1_get_Current_m3035290781(__this, method) (( ContactPoint_t1376425630 (*) (InternalEnumerator_1_t2235177892 *, const MethodInfo*))InternalEnumerator_1_get_Current_m3035290781_gshared)(__this, method)
79.116279
279
0.847443
[ "object" ]
478c5e1a0401217cb7f67ef47818d5f49ece693c
10,297
h
C
Layer.h
WKBae/MNIST-Trainer
756dc247b652d5e701f33976d0498efa50dbf98f
[ "MIT" ]
null
null
null
Layer.h
WKBae/MNIST-Trainer
756dc247b652d5e701f33976d0498efa50dbf98f
[ "MIT" ]
null
null
null
Layer.h
WKBae/MNIST-Trainer
756dc247b652d5e701f33976d0498efa50dbf98f
[ "MIT" ]
null
null
null
#pragma once #include "Config.h" #include <cstdlib> #include <cstring> #include <cassert> #include <vector> #ifdef XAVIER_INITIALIZATION #include <limits> #endif namespace nn { /** Abstract interface for a layer of a neural network */ class Layer { public: Layer(unsigned int inputs, unsigned int outputs) : inputs(inputs), outputs(outputs) {} virtual ~Layer() {} const int inputs, outputs; virtual NUM_TYPE* forward(NUM_TYPE* prev_f, bool train = false) = 0; virtual NUM_TYPE* backward(NUM_TYPE* prev_delta) = 0; virtual void initialize_weights() = 0; virtual void update_weights(NUM_TYPE* prev_f) = 0; #ifdef BATCH_TRAIN virtual void clear_delta() = 0; #endif virtual char getActivationType() = 0; virtual std::vector<NUM_TYPE> dump_weights() { return std::vector<NUM_TYPE>(); } virtual int load_weights(NUM_TYPE* begin, int limit = -1) { return 0; } }; /** Real implementation of the layer, abstracted to add capability to use activation functions per layer. */ template<typename Activation> class LayerImpl : public Layer { public: LayerImpl(unsigned int inputs, unsigned int outputs) : Layer(inputs, outputs), weights(new NUM_TYPE[(inputs + 1) * outputs]), #if defined(OPTIMIZE_ADAM) last_m(new NUM_TYPE[(inputs + 1) * outputs]()), last_v(new NUM_TYPE[(inputs + 1) * outputs]()), lr_t(0), beta1_sq(1), beta2_sq(1), #elif defined(OPTIMIZE_ADAGRAD) || defined(OPTIMIZE_RMSPROP) last_g(new NUM_TYPE[(inputs + 1) * outputs]()), #elif defined(OPTIMIZE_MOMENTUM) || defined(OPTIMIZE_NESTEROV) last_v(new NUM_TYPE[(inputs + 1) * outputs]()), #endif last_f(new NUM_TYPE[outputs]), last_delta(new NUM_TYPE[outputs]), last_prop_delta(new NUM_TYPE[inputs]), #ifdef BATCH_TRAIN delta_sum(new NUM_TYPE[outputs]), batch_count(0), #endif activation() { } ~LayerImpl() { #ifdef BATCH_TRAIN delete[] delta_sum; #endif delete[] last_prop_delta; delete[] last_delta; delete[] last_f; #if defined(OPTIMIZE_RMSPROP) delete[] last_g; #elif defined(OPTIMIZE_MOMENTUM) delete[] last_v; #endif delete[] weights; } /** * Forward propagate with given input. * @returns Calculated output of length same as the output of this layer. Should not be deleted or modified. */ NUM_TYPE* forward(NUM_TYPE* prev_f, bool train = false) override { #pragma omp parallel for for (int j = 0; j < outputs; j++) { #ifdef DROPOUT_RATE if (train && rand() * (1.0 / RAND_MAX) <= DROPOUT_RATE) { last_f[j] = 0; continue; } #endif NUM_TYPE sum = 0; for (int i = 0; i < inputs; i++) { sum += prev_f[i] * weight(i, j); } /* Bias(weight from constant-one) is just added with no multiplication */ last_f[j] = activation.calculate(sum + weight(inputs, j)); } return last_f; } #ifdef BATCH_TRAIN void clear_delta() override { for(int i = 0; i < outputs; i++) { delta_sum[i] = 0; } batch_count = 0; } #endif /** * Backpropagate with error from the top layer. * This method calculates and keeps the loss. This will be used on weight update, and is overwritten on future `backward()` call. * TODO: To enable batch weight update, the loss have to be sumed up * @returns Error to propagate to lower layer, length of this layer's input. This array should not be deleted. */ NUM_TYPE* backward(NUM_TYPE* prev_delta) override { /* Calculate the loss derivative from the backpropagated delta */ #pragma omp parallel for for(int i = 0; i < outputs; i++) { last_delta[i] = activation.derivative(last_f[i]) * prev_delta[i]; #ifdef BATCH_TRAIN delta_sum[i] += last_delta[i]; #endif } #ifdef BATCH_TRAIN batch_count++; #endif /* Calculate delta to propagate, to keep from this layer's weight to be used outside of this instance. */ #pragma omp parallel for for(int i = 0; i < inputs; i++) { NUM_TYPE sum = 0; for(int j = 0; j < outputs; j++) { sum += last_delta[j] * weight(i, j); } last_prop_delta[i] = sum; } return last_prop_delta; } void initialize_weights() override { for(int i = 0; i <= inputs; i++) { for(int j = 0; j < outputs; j++) { weight(i, j) = #ifdef ZERO_BIAS_INITIALIZATION (i == inputs) ? /* bias */ 0 : #endif #ifdef XAVIER_INITIALIZATION //generateGaussianNoise(0, sqrt(3.0 / (inputs + outputs))) // use uniform version instead of normal(gaussian) dist. rand() * (1.0 / RAND_MAX) * (2 * 4.0 * sqrt(6.0 / (inputs + outputs))) - (4.0 * sqrt(6.0 / (inputs + outputs))) #else ((double)rand() / RAND_MAX) - 0.5 #endif ; } } } void update_weights(NUM_TYPE* prev_f) override { #ifdef LEARNING_RATE_DECAY learning_rate = INITIAL_LEARNING_RATE * decay_factor; decay_factor *= LEARNING_RATE_DECAY; #endif #if defined(OPTIMIZE_ADAM) beta1_sq *= ADAM_BETA1; beta2_sq *= ADAM_BETA2; lr_t = learning_rate * sqrt(1.0 - beta2_sq) / (1.0 - beta1_sq); #endif #pragma omp parallel for for (int j = 0; j < outputs; j++) { #ifdef BATCH_TRAIN NUM_TYPE delta = delta_sum[j] / batch_count; #else NUM_TYPE delta = last_delta[j]; #endif for (int i = 0; i < inputs; i++) { NUM_TYPE loss = delta * prev_f[i]; weight(i, j) += weight_diff(i, j, loss) #ifdef WEIGHT_DECAY - WEIGHT_DECAY * weight(i, j) #endif ; } weight(inputs, j) += weight_diff(inputs, j, delta) #ifdef WEIGHT_DECAY - WEIGHT_DECAY * weight(inputs, j) #endif ; } } char getActivationType() override { return (char) activation.getId(); } std::vector<NUM_TYPE> dump_weights() override { std::vector<NUM_TYPE> buf; buf.reserve((inputs + 1) * outputs); for (int i = 0; i <= inputs; i++) { for (int j = 0; j < outputs; j++) { buf.push_back(weight(i, j)); } } return buf; } int load_weights(NUM_TYPE* begin, int limit = -1) override { int idx = 0; for (int i = 0; i <= inputs; i++) { for (int j = 0; j < outputs; j++) { if (limit >= 0 && idx >= limit) goto fail_too_short; weight(i, j) = begin[idx++]; } } return idx; fail_too_short: return -1; } private: NUM_TYPE& weight(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); /* Column-order to increase cache hit. Forward propagation and weight update are affected by this optimization. */ return weights[to * inputs + from]; } NUM_TYPE* weights; /* Optimizer implementation */ #if defined(OPTIMIZE_ADAM) NUM_TYPE& m(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_m[to * inputs + from]; } NUM_TYPE* last_m; NUM_TYPE& v(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_v[to * inputs + from]; } NUM_TYPE* last_v; NUM_TYPE lr_t; NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE beta1_sq, beta2_sq; //const NUM_TYPE beta1 = ADAM_BETA1, beta2 = ADAM_BETA2; //const NUM_TYPE epsilon = ADAM_EPSILON; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { // small performance boost by storing the values temporary NUM_TYPE m_ = m(i, j) = ADAM_BETA1 * m(i, j) + (1.0 - ADAM_BETA1) * loss; NUM_TYPE v_ = v(i, j) = ADAM_BETA2 * v(i, j) + (1.0 - ADAM_BETA2) * (loss * loss); return lr_t * m_ / (sqrt(v_) + ADAM_EPSILON); } #elif defined(OPTIMIZE_RMSPROP) NUM_TYPE& g(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_g[to * inputs + from]; } NUM_TYPE* last_g; NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { NUM_TYPE g_ = g(i, j) = RMSPROP_RHO * g(i, j) + (1.0 - RMSPROP_RHO) * (loss * loss); return learning_rate * loss / (sqrt(g_) + RMSPROP_EPSILON); } #elif defined(OPTIMIZE_ADAGRAD) NUM_TYPE& g(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_g[to * inputs + from]; } NUM_TYPE* last_g; NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { NUM_TYPE g_ = g(i, j) += loss * loss; return learning_rate * loss / (sqrt(g_) + ADAGRAD_EPSILON); } #elif defined(OPTIMIZE_NESTEROV) NUM_TYPE& v(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_v[to * inputs + from]; } NUM_TYPE* last_v; NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { NUM_TYPE prev_v = v(i, j); NUM_TYPE v_ = v(i, j) = NESTEROV_MOMENTUM_FACTOR * prev_v - learning_rate * loss; return NESTEROV_MOMENTUM_FACTOR * prev_v - (1 + NESTEROV_MOMENTUM_FACTOR) * v_; } #elif defined(OPTIMIZE_MOMENTUM) NUM_TYPE& velocity(unsigned int from, unsigned int to) const { assert(from <= inputs && to < outputs); return last_v[to * inputs + from]; } NUM_TYPE* last_v; NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { return velocity(i, j) = MOMENTUM_MOMENTUM_FACTOR * velocity(i, j) + learning_rate * loss; } #else NUM_TYPE learning_rate = INITIAL_LEARNING_RATE; NUM_TYPE weight_diff(int i, int j, NUM_TYPE loss) { return learning_rate * loss; } #endif #ifdef LEARNING_RATE_DECAY NUM_TYPE decay_factor = 1; #endif /* End optimizer implementation */ NUM_TYPE* last_f; NUM_TYPE* last_delta; NUM_TYPE* last_prop_delta; #ifdef BATCH_TRAIN NUM_TYPE* delta_sum; int batch_count; #endif Activation activation; #ifdef XAVIER_INITIALIZATION /* Gaussian distribution generator, from Wikipedia "Box-Muller transform" implementation */ static double generateGaussianNoise(double mu, double sigma) { static const double epsilon = std::numeric_limits<double>::min(); static const double two_pi = 2.0*3.14159265358979323846; thread_local double z1; thread_local bool generate; generate = !generate; if (!generate) return z1 * sigma + mu; double u1, u2; do { u1 = rand() * (1.0 / RAND_MAX); u2 = rand() * (1.0 / RAND_MAX); } while (u1 <= epsilon); double z0; z0 = sqrt(-2.0 * log(u1)) * cos(two_pi * u2); z1 = sqrt(-2.0 * log(u1)) * sin(two_pi * u2); return z0 * sigma + mu; } #endif }; }
28.288462
130
0.660969
[ "vector", "transform" ]
479592ae7a85d6c69d825d46d19eaf756bc4cb9a
2,640
h
C
ios/list-sync/macOS/CouchbaseLiteSwift.framework/Versions/A/PrivateHeaders/CBLURLEndpointListener.h
badaldesai/couchbase-lite-peer-to-peer-sync-examples
9ab02c12f47511462a164fe12b28269964528473
[ "MIT" ]
3
2021-04-26T22:09:50.000Z
2021-07-28T10:18:40.000Z
ios/list-sync/macOS/CouchbaseLiteSwift.framework/Versions/A/PrivateHeaders/CBLURLEndpointListener.h
badaldesai/couchbase-lite-peer-to-peer-sync-examples
9ab02c12f47511462a164fe12b28269964528473
[ "MIT" ]
1
2021-04-26T09:15:17.000Z
2021-04-26T09:15:17.000Z
ios/list-sync/macOS/CouchbaseLiteSwift.framework/Versions/A/PrivateHeaders/CBLURLEndpointListener.h
badaldesai/couchbase-lite-peer-to-peer-sync-examples
9ab02c12f47511462a164fe12b28269964528473
[ "MIT" ]
3
2020-12-01T10:20:44.000Z
2021-07-12T14:51:20.000Z
// // CBLURLEndpointListener.h // CouchbaseLite // // Copyright (c) 2020 Couchbase, Inc. All rights reserved. // // Licensed under the Couchbase License Agreement (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // https://info.couchbase.com/rs/302-GJY-034/images/2017-10-30_License_Agreement.pdf // // 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. // #import <Foundation/Foundation.h> @class CBLURLEndpointListenerConfiguration; @class CBLTLSIdentity; NS_ASSUME_NONNULL_BEGIN /** ENTERPRISE EDITION ONLY. CBLConnectionStatus provides the information about the connections from the replicators to the listener. */ typedef struct { uint64_t connectionCount; ///< The total number of connections. uint64_t activeConnectionCount; ///< The number of the connections that are in active or busy state. } CBLConnectionStatus; /** ENTERPRISE EDITION ONLY. A listener to provide websocket based endpoint for peer-to-peer replication. Once the listener is started, peer replicators can connect to the listener by using CBLURLEndpoint. */ API_AVAILABLE(macos(10.12), ios(10.0)) @interface CBLURLEndpointListener : NSObject /** The read-only configuration. */ @property (nonatomic, readonly) CBLURLEndpointListenerConfiguration* config; /** The port that the listener is listening to. If the listener is not started, the port property will be zero. */ @property (nonatomic, readonly) unsigned short port; /** The TLS identity used by the listener to provide TLS communication. If the listener is not started or the TLS is disabled, the property value will be nil. */ @property (nonatomic, readonly, nullable) CBLTLSIdentity* tlsIdentity; /** The possible URLs of the listener. If the listener is not started, the urls property will be nil. */ @property (nonatomic, readonly, nullable) NSArray<NSURL*>* urls; /** The current connection status of the listener. */ @property (nonatomic, readonly) CBLConnectionStatus status; /** Initializes a listener with the given configuration object. */ - (instancetype) initWithConfig: (CBLURLEndpointListenerConfiguration*)config; /** Starts the listener. */ - (BOOL) startWithError: (NSError**)error; /** Stop the listener. */ - (void) stop; - (instancetype) init NS_UNAVAILABLE; @end NS_ASSUME_NONNULL_END
34.736842
114
0.759848
[ "object" ]
479acb5c40f4f6b88551528fd13923fd23f47dbd
3,454
h
C
Parts/roles/common/include/mle/2dimgd.h
magic-lantern-studio/mle-parts
551cdb0757fcd6623cd5c7572dca681165b43a29
[ "MIT" ]
1
2021-02-04T22:44:16.000Z
2021-02-04T22:44:16.000Z
Parts/roles/common/include/mle/2dimgd.h
magic-lantern-studio/mle-parts
551cdb0757fcd6623cd5c7572dca681165b43a29
[ "MIT" ]
null
null
null
Parts/roles/common/include/mle/2dimgd.h
magic-lantern-studio/mle-parts
551cdb0757fcd6623cd5c7572dca681165b43a29
[ "MIT" ]
null
null
null
/** @defgroup MleParts Magic Lantern Parts */ /** * @file MleIv2dImageRole.h * @ingroup MleParts * * This file defines the class for a 2D Image Role. * * @author Mark S. Millard * @date February 22, 2011 */ // COPYRIGHT_BEGIN // // The MIT License (MIT) // // Copyright (c) 2017-2018 Wizzer Works // // 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. // // For information concerning this header file, contact Mark S. Millard, // of Wizzer Works at msm@wizzerworks.com. // // More information concerning Wizzer Works may be found at // // http://www.wizzerworks.com // // COPYRIGHT_END #ifndef __MLE_2DIMGD_H_ #define __MLE_2DIMGD_H_ // Include system header files. #if defined(MLE_REHEARSAL) || defined(__linux__) // Include files for image processing library. #include <FreeImage.h> #elif defined(WIN32) // Include files for image processing library. #include "mle/dib.h" #endif /* MLE_REHEARSAL */ // Include Magic Lantern header files. #include "mle/mlTypes.h" #include "math/vector.h" #include "mle/2drole.h" #include "mle/Mle2dImageRole.h" // Declare external classes. class MleActor; /** * This class defines a Role for displaying 2D images. */ class MLE_2DIMAGEROLE_API Mle2dImgRole : public Mle2dRole { MLE_ROLE_HEADER(Mle2dImgRole); public: Mle2dImgRole(MleActor *actor); virtual ~Mle2dImgRole(void); // Update the position where the image is drawn. The position is // in screen coordinate and lower left is the image origin. void screenLocation(MlVector2 &pos); // This will read in a single pixelmap image. It can also be used to // read in a different pixelmap image during runtime. void load(MlMediaRef img); void load(MleMediaRef *img); // The display of the image can be toggle on (with TRUE) or off // (with FALSE). void display(int state); // The render() function of the 2D Set calls this function to update // this role every cycle. virtual void draw(void *data); protected: // Image origin (lower left) in screen coordinate. MlVector2 screenPosition; // TRUE for on, FALSE for off int displayState; #if defined(MLE_REHEARSAL) || defined(__linux__) unsigned char *imageData; private: // The FreeImage DIB object. FIBITMAP *inImg; FIBITMAP *imageOp; #elif defined(WIN32) // The Microsoft DIB object. MleDIB dib; #endif /* MLE_REHEARSAL */ }; #endif /* __MLE_2DIMGD_H_ */
26.166667
81
0.721772
[ "render", "object", "vector" ]
47a4f7841e6d91401fe9da7c1609d34343e607d7
4,820
c
C
d/deku/mausoleum/rooms/hidden27.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/deku/mausoleum/rooms/hidden27.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/deku/mausoleum/rooms/hidden27.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include "../inherits/area_stuff.h" inherit HID; string ret; int opened; void create() { ::create(); set_exits(([ "south" : MROOMS"hidden26", ] )); set_long((:TO, "get_my_long":)); add_items(({"indentation", "circular indentation"}), "%^RESET%^%^ORANGE%^"+ "This small indentation catches your eye. It is directly in the center "+ "of the northern wall. It is completely smooth and not all that deep but "+ "it radiates with a faint magic. "+ "You realize that if you had an object that would fit you could likely "+ "insert it into the indentation.%^RESET%^"); opened = 0; } string get_my_long() { if(opened){ return("%^BOLD%^%^BLACK%^You are within what you recognize instantly as " "an unfinished section of the '%^BOLD%^%^RED%^mausoleum of the damned" "%^BOLD%^%^BLACK%^'. There are portions of %^BOLD%^%^WHITE%^white stone" "%^BOLD%^%^BLACK%^ which attaches roughly with a much older %^RESET%^" "%^RED%^red stone%^BOLD%^%^BLACK%^. It appears that someone or " "something had started replacing the old stone at some distance point " "in the past before abruptly stopping. A %^RESET%^%^CYAN%^faint magic" "%^BOLD%^%^BLACK%^ radiates outward from the %^RESET%^%^RED%^red stone" "%^BOLD%^%^BLACK%^ providing a slightly disconcerting warmth. You are " "not sure what this place used to be, but there is an almost overwhelming " "sense of dr%^RESET%^%^RED%^ea%^BOLD%^%^BLACK%^d here. The walls are " "very close together and the floor is rough. Surprising though this portion of " "the mausoleum is withstanding the continous onslaught from the " "dirt above remarkably well. The tunnel continues to the north and south.%^RESET%^"); }else{ return("%^BOLD%^%^BLACK%^You are within what you recognize instantly as " "an unfinished section of the '%^BOLD%^%^RED%^mausoleum of the damned" "%^BOLD%^%^BLACK%^'. There are portions of %^BOLD%^%^WHITE%^white stone" "%^BOLD%^%^BLACK%^ which attaches roughly with a much older %^RESET%^" "%^RED%^red stone%^BOLD%^%^BLACK%^. It appears that someone or " "something had started replacing the old stone at some distance point " "in the past before abruptly stopping. A %^RESET%^%^CYAN%^faint magic" "%^BOLD%^%^BLACK%^ radiates outward from the %^RESET%^%^RED%^red stone" "%^BOLD%^%^BLACK%^ providing a slightly disconcerting warmth. You are " "not sure what this place used to be, but there is an almost overwhelming " "sense of dr%^RESET%^%^RED%^ea%^BOLD%^%^BLACK%^d here. The walls are " "very close together and the floor is rough. Surprising though this portion of " "the mausoleum is withstanding the continous onslaught from the " "dirt above remarkably well. The tunnel continues to the south. " "There is a %^RESET%^%^CYAN%^circular indentation%^BOLD%^%^BLACK%^ " "in the dead center of the northern wall.%^RESET%^"); } } void init() { ::init(); add_action("insert_act", "insert"); } void do_opening() { if(!opened) return; tell_room(TO, "%^BOLD%^%^BLACK%^A section of the northern wall "+ "shimmers and disappears!%^RESET%^"); TO->set_long((:TO, "get_my_long":)); add_exit(MROOMS"hidden28", "north"); return; } int insert_act(string str) { object Ob; string what; if(!objectp(TO)) return 0; if(!objectp(TP)) return 0; if(opened) return 0; if(!stringp(str)) { tell_object(TP, "Try <insert ob into indentation>."); return 1; } if(sscanf(str, "%s into indentation", what) != 1) { tell_object(TP, "Try <insert ob into indentation>."); return 1; } if(!objectp(Ob = present(what, TP))) { tell_object(TP, "You have no "+what+"!"); return 1; } if(!Ob->id("mausoleum_of_the_damned_sphere_keyxxx71")) { tell_object(TP, "No matter how hard you try you "+ "cannot get the "+what+" to fit into the indentation."); return 1; } tell_object(TP, "%^BOLD%^%^WHITE%^You insert the "+what+" into "+ "the indentation... "); tell_room(TO, TPQCN+"%^BOLD%^%^WHITE%^ inserts "+what+ " into the indentation!", TP); Ob->remove(); opened = 1; call_out("do_opening", 10); add_items(({"indentation", "circular indentation"}), "%^RESET%^%^ORANGE%^"+ "This small indentation catches your eye. It is directly in the center "+ "of the northern wall. It radiates with a faint magic. "+ "There is a small hollow sphere inset into it.%^RESET%^"); return 1; }
41.913043
96
0.607054
[ "object" ]
47ab70f8d326561a902d76bd46e1d61eb9066a68
999
h
C
Culqi/CLQToken.h
culqi/culqi-ios
cb0c10d41e3975c22ceead46ea0d7529459c8aea
[ "MIT" ]
7
2016-09-18T05:29:41.000Z
2020-11-03T16:26:38.000Z
Culqi/CLQToken.h
culqi/culqi-ios
cb0c10d41e3975c22ceead46ea0d7529459c8aea
[ "MIT" ]
5
2016-10-13T01:09:22.000Z
2021-09-23T23:49:14.000Z
Culqi/CLQToken.h
culqi/culqi-ios
cb0c10d41e3975c22ceead46ea0d7529459c8aea
[ "MIT" ]
5
2016-09-18T05:59:26.000Z
2021-12-01T23:40:11.000Z
// // CLQToken.h // Culqi // // Created by Guillermo Sáenz on 5/2/17. // Copyright (c) 2017 Guillermo Sáenz. All rights reserved. // #import "CLQBaseModelObject.h" @class CLQIssuerIdentificationNumber, CLQClient; NS_ASSUME_NONNULL_BEGIN @interface CLQToken : CLQBaseModelObject @property (nonatomic, copy, readonly) NSString *object; @property (nonatomic, copy, readonly) NSString *identifier; @property (nonatomic, copy, readonly) NSString *type; @property (nonatomic, copy, readonly) NSString *email; @property (nonatomic, strong, readonly) NSDate *creationDate; @property (nonatomic, copy, readonly) NSString *cardNumber; @property (nonatomic, copy, readonly) NSString *cardLastFourNumbers; @property (nonatomic, assign, readonly, getter=isActive) BOOL active; @property (nonatomic, strong, readonly) CLQIssuerIdentificationNumber *iin; @property (nonatomic, strong, readonly) CLQClient *client; @property (nonatomic, strong, readonly) NSDictionary *metadata; @end NS_ASSUME_NONNULL_END
33.3
75
0.778779
[ "object" ]
47b12d55589e0a5ad02e63879bcf19e2529a63ac
5,308
h
C
src/kudu/client/scanner-internal.h
kv-zuiwanyuan/kudu
251defb69b1a252cedd5d707d9c84b67cf63726d
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
src/kudu/client/scanner-internal.h
kv-zuiwanyuan/kudu
251defb69b1a252cedd5d707d9c84b67cf63726d
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
src/kudu/client/scanner-internal.h
kv-zuiwanyuan/kudu
251defb69b1a252cedd5d707d9c84b67cf63726d
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
// Copyright 2014 Cloudera, Inc. // // 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. #ifndef KUDU_CLIENT_SCANNER_INTERNAL_H #define KUDU_CLIENT_SCANNER_INTERNAL_H #include <set> #include <string> #include <vector> #include "kudu/gutil/macros.h" #include "kudu/client/client.h" #include "kudu/common/scan_spec.h" #include "kudu/common/predicate_encoder.h" #include "kudu/tserver/tserver_service.proxy.h" namespace kudu { namespace client { class KuduScanner::Data { public: explicit Data(KuduTable* table); ~Data(); Status CheckForErrors(); // Copies a predicate lower or upper bound from 'bound_src' into // 'bound_dst'. void CopyPredicateBound(const ColumnSchema& col, const void* bound_src, std::string* bound_dst); // Called when KuduScanner::NextBatch or KuduScanner::Data::OpenTablet result in an RPC or // server error. Returns the error status if the call cannot be retried. // // The number of parameters reflects the complexity of handling retries. // We must respect the overall scan 'deadline', as well as the 'blacklist' of servers // experiencing transient failures. See the implementation for more details. Status CanBeRetried(const bool isNewScan, const Status& rpc_status, const Status& server_status, const MonoTime& actual_deadline, const MonoTime& deadline, const std::vector<internal::RemoteTabletServer*>& candidates, std::set<std::string>* blacklist); // Open a tablet. // The deadline is the time budget for this operation. // The blacklist is used to temporarily filter out nodes that are experiencing transient errors. // This blacklist may be modified by the callee. Status OpenTablet(const std::string& partition_key, const MonoTime& deadline, std::set<std::string>* blacklist); // Extracts data from the last scan response and adds them to 'rows'. Status ExtractRows(std::vector<KuduRowResult>* rows); // Static implementation of ExtractRows. This is used by some external // tools. static Status ExtractRows(const rpc::RpcController& controller, const Schema* projection, tserver::ScanResponsePB* resp, std::vector<KuduRowResult>* rows); Status KeepAlive(); // Returns whether there exist more tablets we should scan. // // Note: there may not be any actual matching rows in subsequent tablets, // but we won't know until we scan them. bool MoreTablets() const; // Possible scan requests. enum RequestType { // A new scan of a particular tablet. NEW, // A continuation of an existing scan (to read more rows). CONTINUE, // A close of a partially-completed scan. Complete scans are closed // automatically by the tablet server. CLOSE }; // Modifies fields in 'next_req_' in preparation for a new request. void PrepareRequest(RequestType state); // Returns the size of a row for the given projection 'proj'. static size_t CalculateProjectedRowSize(const Schema& proj); bool open_; bool data_in_open_; bool has_batch_size_bytes_; uint32 batch_size_bytes_; KuduClient::ReplicaSelection selection_; ReadMode read_mode_; bool is_fault_tolerant_; int64_t snapshot_timestamp_; // The encoded last primary key from the most recent tablet scan response. std::string last_primary_key_; internal::RemoteTabletServer* ts_; // The proxy can be derived from the RemoteTabletServer, but this involves retaking the // meta cache lock. Keeping our own shared_ptr avoids this overhead. std::tr1::shared_ptr<tserver::TabletServerServiceProxy> proxy_; // The next scan request to be sent. This is cached as a field // since most scan requests will share the scanner ID with the previous // request. tserver::ScanRequestPB next_req_; // The last response received from the server. Cached for buffer reuse. tserver::ScanResponsePB last_response_; // RPC controller for the last in-flight RPC. rpc::RpcController controller_; // The table we're scanning. KuduTable* table_; // The projection schema used in the scan. const Schema* projection_; Arena arena_; AutoReleasePool pool_; // Machinery to store and encode raw column range predicates into // encoded keys. ScanSpec spec_; RangePredicateEncoder spec_encoder_; // The tablet we're scanning. scoped_refptr<internal::RemoteTablet> remote_; // Timeout for scanner RPCs. MonoDelta timeout_; // Number of attempts since the last successful scan. int scan_attempts_; DISALLOW_COPY_AND_ASSIGN(Data); }; } // namespace client } // namespace kudu #endif
32.968944
98
0.707988
[ "vector" ]
47b2097c696ef32b250dedd4d4ec6c4f1778a66f
729
h
C
Simulink package code/parrotMinidroneHover/work/flightControlSystem_ert_rtw/rtGetNaN.h
debOliveira/parrot-mambo-model-based-design
ecd67c5589532eb2d7469d0a2844c380997cde97
[ "MIT" ]
null
null
null
Simulink package code/parrotMinidroneHover/work/flightControlSystem_ert_rtw/rtGetNaN.h
debOliveira/parrot-mambo-model-based-design
ecd67c5589532eb2d7469d0a2844c380997cde97
[ "MIT" ]
null
null
null
Simulink package code/parrotMinidroneHover/work/flightControlSystem_ert_rtw/rtGetNaN.h
debOliveira/parrot-mambo-model-based-design
ecd67c5589532eb2d7469d0a2844c380997cde97
[ "MIT" ]
null
null
null
/* * rtGetNaN.h * * Code generation for model "flightControlSystem". * * Model version : 1.426 * Simulink Coder version : 9.2 (R2019b) 18-Jul-2019 * C source code generated on : Thu Mar 5 17:17:23 2020 * * Target selection: ert.tlc * Note: GRT includes extra infrastructure and instrumentation for prototyping * Embedded hardware selection: ARM Compatible->ARM 9 * Code generation objectives: Unspecified * Validation result: Not run */ #ifndef RTW_HEADER_rtGetNaN_h_ #define RTW_HEADER_rtGetNaN_h_ #include <stddef.h> #include "rtwtypes.h" #include "rt_nonfinite.h" extern real_T rtGetNaN(void); extern real32_T rtGetNaNF(void); #endif /* RTW_HEADER_rtGetNaN_h_ */
27
78
0.702332
[ "model" ]
47b6abde5a244b271cee7d158f1ac34662ab8afc
1,981
h
C
locomotion_framework/ros/collision_model_ros_extension/include/mwoibn/collision_model/robot_collision_ros.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
1
2019-12-02T07:10:42.000Z
2019-12-02T07:10:42.000Z
locomotion_framework/ros/collision_model_ros_extension/include/mwoibn/collision_model/robot_collision_ros.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
null
null
null
locomotion_framework/ros/collision_model_ros_extension/include/mwoibn/collision_model/robot_collision_ros.h
ADVRHumanoids/DrivingFramework
34715c37bfe3c1f2bd92aeacecc12704a1a7820e
[ "Zlib" ]
2
2020-10-22T19:06:44.000Z
2021-06-07T03:32:52.000Z
#ifndef COLLISION_MODEL_ROBOT_COLLISION_ROS_H #define COLLISION_MODEL_ROBOT_COLLISION_ROS_H #include <ros/ros.h> #include <sch/STP-BV/STP_BV.h> #include <ros/console.h> #include <sch/S_Object/S_Sphere.h> #include <sch/S_Object/S_Box.h> #include "mwoibn/collision_model/robot_collision.h" //#include <gazebo_msgs/LinkStates.h> #include <rbdl/rbdl.h> #include "mwoibn/robot_class/robot.h" #include <ros/package.h> namespace mwoibn{ namespace collision_model { //! The class provides the ros implementation to initializae robot collision with use of ros parameters //model class RobotCollisionRos : public RobotCollision { public: RobotCollisionRos(mwoibn::robot_class::Robot& robot, std::string urdf_topic = "/robot_description", std::string srdf_topic = "/robot_semantic_description", std::string pkg = "") : RobotCollision(robot) { ros::NodeHandle node; std::string srdf_file; std::string urdf_file; std::string package_path = ""; if (!node.getParam(urdf_topic, urdf_file)) throw std::invalid_argument( std::string("Could not retrieve a robot_description - a parameter ") + urdf_topic + std::string(" from parameter server.")); if (!node.getParam(srdf_topic, srdf_file)) LOG_INFO << "didn't find a srdf desription in the parameter " << srdf_topic << " consider all pair valid " << std::endl; // warning if (!pkg.empty()) try { package_path = ros::package::getPath(pkg); } catch (...) { LOG_INFO << "could not find a path to package " << pkg << std::endl; // warning } _readMesh(urdf_file, srdf_file, package_path); _dof = _objects.size(); _pairs_number = _pairs.size(); updatePositions(); } virtual ~RobotCollisionRos() {} //bool valid = false; // TODO remove }; } // namespace package } // namespace library #endif
26.77027
103
0.648662
[ "model" ]
47bf8fef9f58e241fca9590fb93b19b5305b71b5
1,831
h
C
devices/PPU.h
encoded-byte/miniNES
acc564d4a5e425e5a9072809428aacbd77c46bf7
[ "MIT" ]
null
null
null
devices/PPU.h
encoded-byte/miniNES
acc564d4a5e425e5a9072809428aacbd77c46bf7
[ "MIT" ]
null
null
null
devices/PPU.h
encoded-byte/miniNES
acc564d4a5e425e5a9072809428aacbd77c46bf7
[ "MIT" ]
null
null
null
#pragma once #include "devices/Bus.h" #include "machine/Device.h" class PPU : public Device { friend class DMA; private: Bus &bus; static const uint32_t colors[64]; struct Control { bool nametable_x; bool nametable_y; bool vram_increment; bool sprite_pattern; bool bg_pattern; bool sprite_size; bool slave_mode; bool nmi_enable; }; struct Mask { bool greyscale; bool bg_left_render; bool sprite_left_render; bool bg_render; bool sprite_render; bool red_enhance; bool green_enhance; bool blue_enhance; }; struct Status { bool sprite_overflow; bool sprite_hit; bool vblank; }; struct Address { bool nametable_x; bool nametable_y; uint8_t coarse_x : 5; uint8_t coarse_y : 5; uint8_t fine_y : 3; }; struct OAEntry { uint8_t y; uint8_t id; uint8_t attr; uint8_t x; }; // Registers Control ctrl; Mask mask; Status status; Address ppu_addr; Address tmp_addr; uint8_t oam_addr; uint8_t ppu_data; uint8_t fine_x; bool w_latch; // OAM OAEntry oam[64]; uint8_t read_oam(uint8_t addr); void write_oam(uint8_t addr, uint8_t data); // Render uint16_t bg_pattern_lo; uint16_t bg_pattern_hi; uint8_t bg_attr; OAEntry sprite_oam[8]; uint8_t sprite_pattern_lo[8]; uint8_t sprite_pattern_hi[8]; uint8_t sprite_count; bool sprite_zero; void render_background(); void render_sprite(); void render_pixel(); // Status int x; int y; // IO uint32_t output[240][256]; public: PPU(Bus &bus) : bus(bus) {} // Device interface uint8_t read(uint16_t addr) override; void write(uint16_t addr, uint8_t data) override; // Status bool is_nmi() const { return ctrl.nmi_enable && status.vblank; } // IO const uint32_t* get_output() const { return output[0]; } // Signals void reset(); void clock(); };
15.784483
65
0.696341
[ "render" ]
47c4064ab9c8f2d67f08b0f5668f72d7f358fc82
1,041
h
C
cpp/libs/xconfig/Symtab.h
hansewetz/xconfig
d1ee9aa66799ba798767bf9ab7bf393c8db48efa
[ "MIT" ]
null
null
null
cpp/libs/xconfig/Symtab.h
hansewetz/xconfig
d1ee9aa66799ba798767bf9ab7bf393c8db48efa
[ "MIT" ]
null
null
null
cpp/libs/xconfig/Symtab.h
hansewetz/xconfig
d1ee9aa66799ba798767bf9ab7bf393c8db48efa
[ "MIT" ]
null
null
null
// (C) Copyright Hans Ewetz 2018. All rights reserved. #pragma once #include <string> #include <vector> #include <set> #include <optional> #include <iosfwd> namespace xconfig{ // symbol table used during parsing/compilatin class Symtab{ public: // debug print method friend std::ostream&operator<<(std::ostream&os,Symtab const&st); // constants constexpr static char NSSEP='.'; // ctor, assign, dtor Symtab()=default; // ns management void pushns(std::string const&name); void popns(); std::string currentns()const noexcept; // symbol management std::optional<std::string>lookupsym(std::string const&name)const; std::string addsym(std::string const&name); bool isSimpleSymbol(std::string const&name)const; std::string fullyQualifiedName(std::string const&name)const; private: // private data std::vector<std::string>nsstack_; // track current namespace std::set<std::string>nstab_; // all namespaces std::set<std::string>symtab_; // symbol table containing all fully qualified symbols }; }
27.394737
90
0.71854
[ "vector" ]
47cc4c2325dad6c9345d999acd3669f20bc02972
2,525
h
C
zetasql/reference_impl/common.h
decster/zetasql
57651f4f0cf9efa76163bc0282edfcf98dd72414
[ "Apache-2.0" ]
1,779
2019-04-23T19:41:49.000Z
2022-03-31T18:53:18.000Z
zetasql/reference_impl/common.h
decster/zetasql
57651f4f0cf9efa76163bc0282edfcf98dd72414
[ "Apache-2.0" ]
94
2019-05-22T00:30:05.000Z
2022-03-31T06:26:09.000Z
zetasql/reference_impl/common.h
decster/zetasql
57651f4f0cf9efa76163bc0282edfcf98dd72414
[ "Apache-2.0" ]
153
2019-04-23T22:45:41.000Z
2022-02-18T05:44:10.000Z
// // Copyright 2019 Google LLC // // 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. // #ifndef ZETASQL_REFERENCE_IMPL_COMMON_H_ #define ZETASQL_REFERENCE_IMPL_COMMON_H_ #include <memory> #include <string> #include <vector> #include "zetasql/public/collator.h" #include "zetasql/public/type.h" #include "zetasql/resolved_ast/resolved_collation.h" #include "absl/status/status.h" #include "zetasql/base/status.h" namespace zetasql { // Returns OK if 'type' supports equality comparison, error status otherwise. absl::Status ValidateTypeSupportsEqualityComparison(const Type* type); // Returns OK if 'type' supports less/greater comparison, error status // otherwise. absl::Status ValidateTypeSupportsOrderComparison(const Type* type); // Releases the ownership of 'ptrs' in the input vector and returns a regular // vector of pointers. This method takes a non-const reference by design as it // is intended to be used like std::move(), clearing the input vector. template <typename T> static std::vector<T*> ReleaseAll( std::vector<std::unique_ptr<T>>& ptrs) { // NOLINT(runtime/references) std::vector<T*> result; result.reserve(ptrs.size()); for (auto& p : ptrs) { result.push_back(p.release()); } ptrs.clear(); return result; } // Returns a collation name from input <resolved_collation>. absl::StatusOr<std::string> GetCollationNameFromResolvedCollation( const ResolvedCollation& resolved_collation); // Returns a ZetaSqlCollator from input <resolved_collation>. absl::StatusOr<std::unique_ptr<const ZetaSqlCollator>> GetCollatorFromResolvedCollation(const ResolvedCollation& resolved_collation); // Returns a collator from a value representing a ResolvedCollation object. // An error will be returned if the input <collation_value> cannot be converted // to a ResolvedCollation object. absl::StatusOr<std::unique_ptr<const ZetaSqlCollator>> GetCollatorFromResolvedCollationValue(const Value& collation_value); } // namespace zetasql #endif // ZETASQL_REFERENCE_IMPL_COMMON_H_
35.069444
79
0.769505
[ "object", "vector" ]
47d7bde2cba2e0b3eed72082027cbf2c8eb72189
14,176
h
C
source/util_api/asn.1/include/ansc_asn1_base_interface.h
lgirdk/ccsp-common-library
8d912984e96f960df6dadb4b0e6bc76c76376776
[ "Apache-2.0" ]
4
2018-02-26T05:41:14.000Z
2019-12-20T07:31:39.000Z
source/util_api/asn.1/include/ansc_asn1_base_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
null
null
null
source/util_api/asn.1/include/ansc_asn1_base_interface.h
rdkcmf/rdkb-CcspCommonLibrary
3eba76685bbf5eb6656f45eb4b57fdb5c269c2a1
[ "Apache-2.0" ]
3
2017-07-30T15:35:16.000Z
2020-08-18T20:44:08.000Z
/* * If not stated otherwise in this file or this component's Licenses.txt file the * following copyright and licenses apply: * * Copyright 2015 RDK Management * * 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. */ /********************************************************************** Copyright [2014] [Cisco Systems, Inc.] 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. **********************************************************************/ /********************************************************************** module: ansc_asn1_base_interface.h For Abstract Syntax Notation One (ASN.1) of Advanced Networking Service Container (ANSC), BroadWay Service Delivery System --------------------------------------------------------------- description: This header file contains the prototype definition for all the basic ASN.1 objects. --------------------------------------------------------------- environment: platform independent --------------------------------------------------------------- author: Bin Zhu --------------------------------------------------------------- revision: 03/12/02 initial revision. 04/24/02 AnscAsn1GetTagValue() is added as an API. 05/23/02 AnscAsn1GetEncodedData() is added as an API. 05/28/02 AnscAsn1GetMD5FingerPrint() is added as an API. AnscAsn1GetSHA1FingerPrint() is added as an API. 07/22/02 AnscAsn1GetBAOHandle() is added as an API. BAO APIs are defined by Lina for Kerberoes implementation. **********************************************************************/ #ifndef _ANSC_ASN1_BASE_INTERFACE_ #define _ANSC_ASN1_BASE_INTERFACE_ #include "ansc_asn1_attr_interface.h" #ifndef AnscSprintfString #define AnscSprintfString sprintf #endif #define ANSC_ASN1_OBJECT_NAME_SIZE 48 /* * universal types defined in ASN.1 - they're intended to be encoded in 5 bits (BER, CER & DER) */ #define ASN1_ANY_TYPE 0x00 #define ASN1_BOOLEAN_TYPE 0x01 #define ASN1_INTEGER_TYPE 0x02 #define ASN1_BITSTRING_TYPE 0x03 #define ASN1_OCTETSTRING_TYPE 0x04 #define ASN1_NULL_TYPE 0x05 #define ASN1_OID_TYPE 0x06 #define ASN1_OBJECTDESCRIPTOR_TYPE 0x07 #define ASN1_EXTERNAL_TYPE 0x08 #define ASN1_REAL_TYPE 0x09 #define ASN1_ENUMERATE_TYPE 0x0A #define ASN1_UTF8STRING_TYPE 0x0C #define ASN1_SEQUENCE_TYPE 0x10 #define ASN1_SET_TYPE 0x11 #define ASN1_NUMERICSTRING_TYPE 0x12 #define ASN1_PRINTABLESTRING_TYPE 0x13 #define ASN1_TELETEXSTRING_TYPE 0x14 #define ASN1_VIDEOTEXSTRING_TYPE 0x15 #define ASN1_IA5STRING_TYPE 0x16 #define ASN1_UNIVERSALTIME_TYPE 0x17 #define ASN1_GENERALIZEDTIME_TYPE 0x18 #define ASN1_GRAPHICSTRING_TYPE 0x19 #define ASN1_VISIBLESTRING_TYPE 0x1A #define ASN1_GENERALSTRING_TYPE 0x1B #define ASN1_UNIVERSALSTRING_TYPE 0x1C #define ASN1_BMPSTRING_TYPE 0x1E #define ASN1_MSSTRING_TYPE 0x1D #define ASN1_CHOICE_TYPE 0xFF #define ASN1_USER_DEFINED 0xFE /* * encoding forms used in BER encoding rules - primitive / constructed */ #define PRIMITIVE_FORM 0x00 /* 00000000B*/ #define CONSTRUCTED_FORM 0x20 /* 00100000B*/ /* * encoding bit masks used in BER encoding */ #define TAG_MASK 0xC0 /* 11000000B*/ #define FORM_MASK 0x20 /* 00100000B*/ #define TYPE_MASK 0x1F /* 00011111B*/ /*********************************************************** GENERAL OBJECT FUNCTIONS DEFINITION ***********************************************************/ /* * Since we write all kernel modules in C (due to better performance and lack of compiler support), * we have to simulate the C++ object by encapsulating a set of functions inside a data structure. */ typedef ANSC_HANDLE (*PFN_ASN1_CREATE) ( ANSC_HANDLE hContainerContext ); typedef ANSC_STATUS (*PFN_ASN1_FREE) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ASN1_INITIALIZE) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_ASN1_CLONE) ( ANSC_HANDLE hThisObject ); typedef BOOLEAN (*PFN_ASN1_COPY_TO) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hDestObject ); typedef BOOLEAN (*PFN_ASN1_EQUALS_TO) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hOtherObject, BOOLEAN bValueOnly ); typedef ANSC_HANDLE (*PFN_ASN1_GET_OWNER) ( ANSC_HANDLE hThisObject ); typedef ANSC_HANDLE (*PFN_ASN1_GET_BAOHANDLE) ( ANSC_HANDLE hThisObject ); typedef char* (*PFN_ASN1_GET_NAME) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ASN1_SET_NAME) ( ANSC_HANDLE hThisObject, PCHAR pName ); typedef ULONG (*PFN_ASN1_GET_OID) ( ANSC_HANDLE hThisObject ); typedef void (*PFN_ASN1_ADD_ATTRIBUTE) ( ANSC_HANDLE hThisObject, PANSC_ATTR_OBJECT pAttrObject, BOOLEAN bAppend ); typedef ULONG (*PFN_ASN1_GET_RID) ( ANSC_HANDLE hThisObject ); typedef ULONG (*PFN_ASN1_GET_TYPE) ( ANSC_HANDLE hThisObject ); typedef BOOLEAN (*PFN_ASN1_IS_OPTIONAL) ( ANSC_HANDLE hThisObject ); typedef BOOLEAN (*PFN_ASN1_IS_CONSTRUCTIVE) ( ANSC_HANDLE hThisObject ); typedef VOID (*PFN_ASN1_SET_OPTIONAL) ( ANSC_HANDLE hThisObject, BOOLEAN bOptional ); typedef VOID (*PFN_ASN1_SET_OWNER) ( ANSC_HANDLE hThisObject, ANSC_HANDLE hOwnerObject ); typedef UCHAR (*PFN_ASN1_GET_FIRST_OCTET) ( ANSC_HANDLE hThisObject ); typedef BOOLEAN (*PFN_ASN1_READY_TO_ENCODE) ( ANSC_HANDLE hThisObject ); typedef LONG (*PFN_ASN1_GET_SIZE_OF_ENCODED) ( ANSC_HANDLE hThisObject ); typedef ANSC_STATUS (*PFN_ASN1_DECODING_DATA) ( ANSC_HANDLE hThisObject, PVOID* ppEncoding ); typedef ANSC_STATUS (*PFN_ASN1_ENCODING_DATA) ( ANSC_HANDLE hThisObject, PVOID* ppEncoding ); typedef PUCHAR (*PFN_ASN1_GET_ENCODED_DATA) ( ANSC_HANDLE hThisObject, PULONG pLength ); typedef ANSC_STATUS (*PFN_ASN1_GET_FINGERPRINT) ( ANSC_HANDLE hThisObject, ANSC_HANDLE pHashObject ); typedef BOOLEAN (*PFN_ASN1_DUMP_OBJECT) ( ANSC_HANDLE hThisObject, PCHAR pBuffer, PULONG pLength, BOOLEAN bIsRoot, BOOLEAN bShowValue ); typedef BOOLEAN (*PFN_ASN1_TRACE_OBJECT) ( ANSC_HANDLE hThisObject, LONG layer, BOOLEAN bShowValue, BOOLEAN bRecursive ); typedef ANSC_STATUS (*PFN_ASN1_ACTION_FUNCTION) ( ANSC_HANDLE hThisObject, PVOID* ppEncoding ); typedef void (*PFN_ASN1_GET_TAG_VALUE) ( ANSC_HANDLE hThisObject, PASN_OBJECT_FORM_TYPE pAttr, PULONG pTagValue ); /* * Define some const values that will be used in the container object definition. */ #define ANSC_ASN1_OBJECT_NAME "ANSC_ASN1_OBJECT" #define ANSC_ASN1_OBJECT_ID 0xFFFF6000 /* * The ASN.1 Objects are the extensions to the basic container. Any software module that is * shared between two or more extension objects or controller objects shall be implemented as a * Container Object. The container itself actually can leverage some of functionalities provided * by the Container Objects. */ #define ANSC_ASN1_CLASS_CONTENT \ /* start of object class content */ \ SINGLE_LINK_ENTRY Linkage; \ SLIST_HEADER sAttrList; \ ANSC_HANDLE hContainerContext; \ ANSC_HANDLE hOwnerContext; \ PCHAR Name; \ PCHAR ClassName; \ ULONG uBasicSize; \ ULONG Oid; \ ULONG uType; \ BOOLEAN bOptional; \ BOOLEAN bCanBeOptional; \ \ PFN_ASN1_CREATE Create; \ PFN_ASN1_FREE AsnFree; \ \ PFN_ASN1_SET_NAME SetName; \ PFN_ASN1_SET_NAME SetClassName; \ PFN_ASN1_READY_TO_ENCODE ReadyToEncode; \ PFN_ASN1_GET_FIRST_OCTET GetFirstOctet; \ PFN_ASN1_IS_CONSTRUCTIVE IsConstructive; \ PFN_ASN1_ACTION_FUNCTION BeforeDecoding; \ PFN_ASN1_ACTION_FUNCTION AfterDecoding; \ PFN_ASN1_ACTION_FUNCTION BeforeEncoding; \ PFN_ASN1_ACTION_FUNCTION AfterEncoding; \ PFN_ASN1_ADD_ATTRIBUTE AddAttribute; \ PFN_ASN1_GET_TAG_VALUE GetEncodeTagValue; \ PFN_ASN1_DUMP_OBJECT DumpObject; \ \ PFN_ASN1_CLONE Clone; \ PFN_ASN1_COPY_TO CopyTo; \ PFN_ASN1_EQUALS_TO EqualsTo; \ PFN_ASN1_GET_SIZE_OF_ENCODED GetSizeOfEncoded; \ PFN_ASN1_DECODING_DATA DecodingData; \ PFN_ASN1_ENCODING_DATA EncodingData; \ PFN_ASN1_GET_ENCODED_DATA GetEncodedData; \ PFN_ASN1_GET_BAOHANDLE GetBAOHandle; \ /* end of object class content */ \ typedef struct _ANSC_ASN1_OBJECT { ANSC_ASN1_CLASS_CONTENT } ANSC_ASN1_OBJECT, *PANSC_ASN1_OBJECT; #define ACCESS_ANSC_ASN1_OBJECT(p) \ ACCESS_CONTAINER(p, ANSC_ASN1_OBJECT, Linkage) #endif /*_ANSC_ASN1_BASE_INTERFACE_*/
35.089109
99
0.468327
[ "object" ]
fe72afea8819f7a1aa97f32a305c4dff437866d5
555
h
C
Code-robot/include/Robot.h
I-Tocho/Robot-Kinematic
51d16bce8c3053590608043ba2c9949cb501dbca
[ "MIT" ]
1
2021-02-09T06:14:54.000Z
2021-02-09T06:14:54.000Z
Code-robot/include/Robot.h
I-Tocho/Robot-Kinematic
51d16bce8c3053590608043ba2c9949cb501dbca
[ "MIT" ]
null
null
null
Code-robot/include/Robot.h
I-Tocho/Robot-Kinematic
51d16bce8c3053590608043ba2c9949cb501dbca
[ "MIT" ]
null
null
null
#ifndef ROBOT_H #define ROBOT_H #include "object3D.h" #include "vector3d.h" #include "PMatrix.h" #include <vector> #include <cstdlib> #include <cmath> #include <string> #define ITERA 1000 class Robot { public: Robot(std::string name_robot); virtual ~Robot(); void initializar(); void configurationInit(); object3D *load_link; PMatrix TH; std::string name; std::vector<PMatrix> THList; std::vector<object3D*> Links; std::vector<vector3d> Origins; }; #endif // ROBOT_H
19.137931
38
0.625225
[ "vector" ]
fe93ad7fd92e13b87b673e0d449ad316a722f27d
378
h
C
BRTableView/Classes/BRCellProtocol.h
chinabrant/BRTableView
141cdaa3f2bab49dd956c3a7c20c3a748d6e3ea8
[ "MIT" ]
5
2018-05-09T03:49:55.000Z
2019-12-05T06:51:41.000Z
BRTableView/Classes/BRCellProtocol.h
chinabrant/BRTableView
141cdaa3f2bab49dd956c3a7c20c3a748d6e3ea8
[ "MIT" ]
null
null
null
BRTableView/Classes/BRCellProtocol.h
chinabrant/BRTableView
141cdaa3f2bab49dd956c3a7c20c3a748d6e3ea8
[ "MIT" ]
3
2018-05-09T21:25:08.000Z
2020-07-01T07:38:55.000Z
// // YTCellProtocol.h // TableViewDemo // // Created by brant on 2017/12/7. // Copyright © 2017年 Brant. All rights reserved. // #import <Foundation/Foundation.h> @protocol BRCellProtocol <NSObject> @required /** 通过 view model 来配置cell, table view 的数据源里面装的都会是 view model @param viewModel cell 对应的 view model */ - (void)configCellWithViewModel:(id)viewModel; @end
15.12
57
0.714286
[ "model" ]
fe98fb48a7fcb823a43772da0d427c69d96a62cb
5,306
c
C
Alg1/skipList/src/skipList.c
LTKills/College
8f72905f064effd31a712141cfaeda0021390ae8
[ "MIT" ]
null
null
null
Alg1/skipList/src/skipList.c
LTKills/College
8f72905f064effd31a712141cfaeda0021390ae8
[ "MIT" ]
1
2016-04-12T18:55:20.000Z
2016-04-12T18:55:55.000Z
Alg1/skipList/src/skipList.c
LTKills/College
8f72905f064effd31a712141cfaeda0021390ae8
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <stdio.h> #include <time.h> #include <list.h> #include <skipList.h> #include <string.h> scontroler_t *skipCreate(void){ scontroler_t *myControler = malloc(sizeof(scontroler_t)); myControler->starts = NULL; myControler->levels = 0; return myControler; } void printSkipList(scontroler_t *myControler){ skip_t *aux; int i; for(i = 0; i < myControler->levels; i++){ aux = myControler->starts[i]; while(aux != NULL){ printf("%s -> m=%p d=%p) ===> ", aux->address, aux, aux->down); aux = aux->next; } printf("\n"); } } /*Prepares a new level*/ void createNewLevel(scontroler_t *myControler){ skip_t *big = malloc(sizeof(skip_t )), *small = malloc(sizeof(skip_t )), *aux; /*Setting up sentinels*/ big->ip = NULL; big->next = NULL; big->down = NULL; big->address = malloc(sizeof(char)*2); big->address[0] = 130; // 130 cuz 126 is the biggest number on ascii big->address[1] = '\0'; small->ip = NULL; small->next = big; // start -> small -> big small->down = NULL; small->address = malloc(sizeof(char)*2); small->address[0] = -1; // -1 cuz 0 is the smallest number on ascii small->address[1] = '\0'; /*Done*/ // Case it is not the first level if(myControler->levels > 0){ small->down = myControler->starts[myControler->levels-1]; // linking first sentinels aux = small->down; while(strcmp(aux->address, big->address) != 0) aux = aux->next; big->down = aux; // linking last sentinels (tricky) } myControler->starts = realloc(myControler->starts, sizeof(skip_t *) * (myControler->levels+1)); // allocating one more level myControler->starts[myControler->levels] = small; // first sentinel myControler->levels++; } /*Recursive function for inserting on skiplist*/ skip_t *insertPlease(int level, skip_t *starter, skip_t *insert){ skip_t *ohRly, *test, *start = starter; while(strcmp(start->next->address, insert->address) < 0) start = start->next; // Base case (lol that sounds funny) if(level == 0){ // Preparing test test = malloc(sizeof(skip_t)); test->address = malloc(sizeof(char)*(strlen(insert->address)+1)); strcpy(test->address, insert->address); test->ip = malloc(sizeof(char)*(strlen(insert->ip)+1)); strcpy(test->ip, insert->ip); // Done test->next = start->next; start->next = test; test->down = NULL; // Flip a coin if(rand()%2 == TRUE) return test; return NULL; } ohRly = insertPlease(level-1, start->down, insert); // Heads if(ohRly != NULL){ // Preparing test test = malloc(sizeof(skip_t)); test->address = malloc(sizeof(char)*(strlen(insert->address)+1)); strcpy(test->address, insert->address); test->ip = malloc(sizeof(char)*(strlen(insert->ip)+1)); strcpy(test->ip, insert->ip); // Done test->next = start->next; start->next = test; test->down = ohRly; if(rand()%2 == TRUE) return test; } // Tails return NULL; } /*Ordered insertion on skiplist*/ void insertSkip(scontroler_t *myControler, char *address, char *ip){ int i = 0; // Setting up the node to be inserted (insert) skip_t *insert = malloc(sizeof(skip_t)), *aux, *aux2; insert->address = address; insert->ip = ip; insert->next = NULL; insert->down = NULL; // Done // Empty List case if(myControler->starts == NULL){ createNewLevel(myControler); insert->next = myControler->starts[0]->next; myControler->starts[0]->next = insert; return; } // Recursive call aux2 = insertPlease((myControler->levels)-1, myControler->starts[myControler->levels-1], insert); // Add one more level if(aux2 != NULL){ createNewLevel(myControler); insert->next = myControler->starts[myControler->levels-1]->next; myControler->starts[myControler->levels-1]->next = insert; insert->down = aux2; return; } free(insert->address); free(insert->ip); free(insert); return; } /*Fetches an specific address at the skipList*/ skip_t *skipSearch(int level, char *address, skip_t *starter){ skip_t *start = starter; while(strcmp(start->next->address, address) < 0) start = start->next; if(strcmp(start->next->address, address) == 0) return start; // Returns the element before the one we are looking for (for rm) else{ if(level == 0) return NULL; // Search hit bottom else return skipSearch(level-1, address, start->down); } } /*Removes an element from the skiplist*/ void skipRemove(skip_t *skiper, skip_t *aux, scontroler_t *myControler){ // There's a bit of a trick here // Cuz our lists r not double-linked, we need to go through each level till the last element before the one to be removed while(skiper->next != aux) skiper = skiper->next; // And then we call the recursion if(aux->down != NULL) skipRemove(skiper->down, aux->down, myControler); // And we free skiper->next = aux->next; free(aux->ip); free(aux->address); free(aux); return; } /*Deallocates all the skiplist*/ void exterminateSkipList(scontroler_t *myControler){ skip_t *aux, *aux2; int i; // For each level for(i = 0; i < myControler->levels; i++){ aux = myControler->starts[i]; // Beginning of the level aux2 = aux->next; while(aux2 != NULL){ // Start freeing aux2 = aux->next; free(aux->ip); free(aux->address); free(aux); aux = aux2; } } free(myControler->starts); // Free the vector with all the first nodes }
24.118182
127
0.664908
[ "vector" ]
fe9cd2ee287e5dcec70fefdda8cc9d931fe6ab33
1,027
h
C
system/zombie/zombie_factory.h
dnartz/PvZ-Emulator
3954f36f4e0f22cee07d6a86003d3892f0938b8b
[ "BSD-2-Clause" ]
1
2022-03-29T23:49:55.000Z
2022-03-29T23:49:55.000Z
system/zombie/zombie_factory.h
dnartz/PvZ-Emulator
3954f36f4e0f22cee07d6a86003d3892f0938b8b
[ "BSD-2-Clause" ]
2
2021-03-10T18:17:07.000Z
2021-05-11T13:59:22.000Z
system/zombie/zombie_factory.h
dnartz/PvZ-Emulator
3954f36f4e0f22cee07d6a86003d3892f0938b8b
[ "BSD-2-Clause" ]
1
2021-10-18T18:29:47.000Z
2021-10-18T18:29:47.000Z
#pragma once #include "object/scene.h" #include "object/zombie.h" #include "system/rng.h" #include "system/reanim.h" #include "system/zombie/zombie.h" namespace pvz_emulator::system { class zombie_factory { private: object::scene& scene; object::scene::spawn_data& data; system::reanim reanim; system::rng rng; zombie_subsystems subsystems; bool can_spawn_at_row(object::zombie_type type, unsigned int row); unsigned int get_spawn_row(object::zombie_type type); void create_pool_or_night_lurking(object::zombie_type type, unsigned int row, unsigned int col); void create_roof_lurking(object::zombie_type type, unsigned int row, unsigned int col); public: zombie_factory(object::scene& s) : scene(s), data(s.spawn), reanim(s), rng(s), subsystems(s) {} object::zombie& create(object::zombie_type type); void create_lurking(object::zombie_type type, unsigned int row, unsigned int col); void destroy(object::zombie& z); }; }
25.675
100
0.697176
[ "object" ]
fea0981590c9e5f5d045416442dbfa88a8df6bcf
2,981
h
C
indra/newview/llfloatermyenvironment.h
SaladDais/LLUDP-Encryption
8a426cd0dd154e1a10903e0e6383f4deb2a6098a
[ "ISC" ]
1
2022-01-29T07:10:03.000Z
2022-01-29T07:10:03.000Z
indra/newview/llfloatermyenvironment.h
bloomsirenix/Firestorm-manikineko
67e1bb03b2d05ab16ab98097870094a8cc9de2e7
[ "Unlicense" ]
null
null
null
indra/newview/llfloatermyenvironment.h
bloomsirenix/Firestorm-manikineko
67e1bb03b2d05ab16ab98097870094a8cc9de2e7
[ "Unlicense" ]
1
2021-10-01T22:22:27.000Z
2021-10-01T22:22:27.000Z
/** * @file llfloatermyenvironment.h * @brief LLFloaterMyEnvironment class header file * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2019, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #ifndef LL_LLFLOATERMYENVIRONMENT_H #define LL_LLFLOATERMYENVIRONMENT_H #include <vector> #include "llfloater.h" #include "llinventoryobserver.h" #include "llinventoryfilter.h" #include "llfiltereditor.h" class LLInventoryPanel; class LLFloaterMyEnvironment : public LLFloater, LLInventoryFetchDescendentsObserver { LOG_CLASS(LLFloaterMyEnvironment); public: LLFloaterMyEnvironment(const LLSD& key); virtual ~LLFloaterMyEnvironment(); virtual BOOL postBuild() override; virtual void refresh() override; virtual void onOpen(const LLSD& key) override; private: LLInventoryPanel * mInventoryList; LLFilterEditor * mFilterEdit; U64 mTypeFilter; LLInventoryFilter::EFolderShow mShowFolders; LLUUID mSelectedAsset; LLSaveFolderState mSavedFolderState; void onShowFoldersChange(); void onFilterCheckChange(); void onFilterEdit(const std::string& search_string); void onSelectionChange(); void onDeleteSelected(); void onDoCreate(const LLSD &data); void onDoApply(const std::string &context); bool canAction(const std::string &context); bool canApply(const std::string &context); void getSelectedIds(uuid_vec_t& ids) const; void refreshButtonStates(); bool isSettingSelected(LLUUID item_id); static LLUUID findItemByAssetId(LLUUID asset_id, bool copyable_only, bool ignore_library); }; #endif
37.734177
112
0.612882
[ "vector" ]
febf34f5ef0bfcee8b900678d19bc233528ed771
4,315
h
C
src/subscribe.h
1Crazymoney/p2p-dprd
f9a29c2cbb180cef21170c0086cc3a7e14f7478a
[ "BSD-2-Clause" ]
1
2021-06-16T22:50:15.000Z
2021-06-16T22:50:15.000Z
src/subscribe.h
1Crazymoney/p2p-dprd
f9a29c2cbb180cef21170c0086cc3a7e14f7478a
[ "BSD-2-Clause" ]
null
null
null
src/subscribe.h
1Crazymoney/p2p-dprd
f9a29c2cbb180cef21170c0086cc3a7e14f7478a
[ "BSD-2-Clause" ]
null
null
null
/* * Copyright (c) 2012-2014, Magnus Skjegstad / Forsvarets Forskningsinstitutt * 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. * * 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. * */ /* * subscribe.h * * Declaration of datatypes and functions which form the local candidate node subscription-mechanism * * Author: Halvdan Hoem Grelland and Jostein Aardal */ #ifndef INCLUDE_SUBSCRIBE_H_ #define INCLUDE_SUBSCRIBE_H_ #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> /* Hard-coded maximum (allocated) size of subscriber-list. */ #define MAX_NUM_SUBSCRIBERS 25 /* Wrapper object for a subscriber socket address */ typedef struct Subscriber { char* socket_address; /* Path to the subscriber's unix domain listening socket */ unsigned int address_length; /* Byte-size of socket_address */ } Subscriber; /* Wrapper object for list of Subsribers */ typedef struct SubscriberList { Subscriber* subscribers[MAX_NUM_SUBSCRIBERS]; /* Array of subscribers */ unsigned int num_subs; /* Actual number of subscribers */ unsigned int max_num_subs; /* Maximum (allocated) size of subscriber array */ } SubscriberList; /* * Construct a new Subscriber * Arguments: * address - Pointer to path/address of new subscriber * address_length - Byte-size of address (minus null-terminator) * Returns: * Subscriber* - Pointer to new Subscriber * * Subscriber is allocated on heap, use Subscriber_destroy to free memory properly */ Subscriber* Subscriber_new(char* address, unsigned int address_length); /* * Destroy/free a Subscriber * Arguments: * sub - Pointer to a Subscriber instance * Returns: * void * Frees memory. Subscriber should be constructed using Subscriber_new */ void Subscriber_destroy(Subscriber* sub); /* * Construct a new SubscriberList * Arguments: * max_num_subs - Number of Subscriber-instances to allocate on heap * Returns: * SubscriberList* - Pointer to new SubscriberList * * Use SubscriberList_destroy() to properly free memory */ SubscriberList* SubscriberList_new(int max_num_subs); /* * Destroy/free a SubscriberList * Arguments: * sl - SubscriberList to destroy/deconstruct * Returns: * void * * SubscriberList should have been instantiated with Subscriber_new() */ void SubscriberList_destroy(SubscriberList* sl); /* * Add a new Subscriber to a Subscriber-list * Arguments: * subs - Pointer to SubscriberList to add to * new_sub - Pointer to Subscriber to add * Returns: * int - 1 if subscriber is added, 0 if list if full, * -1 if subscriber is already subscribed */ int SubscriberList_addSub(SubscriberList* subs, Subscriber* new_sub); /* * Remove a subscriber from a SubscriberList * Arguments: * subs - Pointer to SubscriberList * rmv_sub - Pointer to Subscriber to remove from subs * Returns: * int - 1 if success (removed), 0 if failure (sub not found in list) */ int SubscriberList_removeSub(SubscriberList* subs, Subscriber* rmv_sub); #endif /* INCLUDE_SUBSCRIBE_H_ */
33.976378
100
0.741136
[ "object" ]
e0acb3772b2bd766dd60abb34c3d706fa28b52b8
8,826
h
C
Code/Tools/Libs/ToolsFoundation/Object/DocumentObjectManager.h
Tekh-ops/ezEngine
d6a5887d8709f267bf8f2943ef15054e29f6d3d5
[ "MIT" ]
703
2015-03-07T15:30:40.000Z
2022-03-30T00:12:40.000Z
Code/Tools/Libs/ToolsFoundation/Object/DocumentObjectManager.h
Tekh-ops/ezEngine
d6a5887d8709f267bf8f2943ef15054e29f6d3d5
[ "MIT" ]
233
2015-01-11T16:54:32.000Z
2022-03-19T18:00:47.000Z
Code/Tools/Libs/ToolsFoundation/Object/DocumentObjectManager.h
Tekh-ops/ezEngine
d6a5887d8709f267bf8f2943ef15054e29f6d3d5
[ "MIT" ]
101
2016-10-28T14:05:10.000Z
2022-03-30T19:00:59.000Z
#pragma once #include <Foundation/Types/RefCounted.h> #include <Foundation/Types/SharedPtr.h> #include <Foundation/Types/Status.h> #include <ToolsFoundation/Object/DocumentObjectBase.h> #include <ToolsFoundation/Reflection/ReflectedType.h> #include <ToolsFoundation/ToolsFoundationDLL.h> class ezDocumentObjectManager; class ezDocument; // Prevent conflicts with windows.h #ifdef GetObject # undef GetObject #endif /// \brief Standard root object for most documents. /// m_RootObjects stores what is in the document and m_TempObjects stores transient data used during editing which is not part of the document. class EZ_TOOLSFOUNDATION_DLL ezDocumentRoot : public ezReflectedClass { EZ_ADD_DYNAMIC_REFLECTION(ezDocumentRoot, ezReflectedClass); ezHybridArray<ezReflectedClass*, 1> m_RootObjects; ezHybridArray<ezReflectedClass*, 1> m_TempObjects; }; /// \brief Implementation detail of ezDocumentObjectManager. class ezDocumentRootObject : public ezDocumentStorageObject { public: ezDocumentRootObject(const ezRTTI* pRootType) : ezDocumentStorageObject(pRootType) { m_Guid = ezUuid::StableUuidForString("DocumentRoot"); } public: virtual void InsertSubObject(ezDocumentObject* pObject, const char* szProperty, const ezVariant& index) override; virtual void RemoveSubObject(ezDocumentObject* pObject) override; }; /// \brief Used by ezDocumentObjectManager::m_StructureEvents. struct ezDocumentObjectStructureEvent { ezDocumentObjectStructureEvent() : m_pObject(nullptr) , m_pPreviousParent(nullptr) , m_pNewParent(nullptr) { } const ezAbstractProperty* GetProperty() const; ezVariant getInsertIndex() const; enum class Type { BeforeReset, AfterReset, BeforeObjectAdded, AfterObjectAdded, BeforeObjectRemoved, AfterObjectRemoved, BeforeObjectMoved, AfterObjectMoved, AfterObjectMoved2, }; Type m_EventType; const ezDocument* m_pDocument = nullptr; const ezDocumentObject* m_pObject = nullptr; const ezDocumentObject* m_pPreviousParent = nullptr; const ezDocumentObject* m_pNewParent = nullptr; ezString m_sParentProperty; ezVariant m_OldPropertyIndex; ezVariant m_NewPropertyIndex; }; /// \brief Used by ezDocumentObjectManager::m_PropertyEvents. struct ezDocumentObjectPropertyEvent { ezDocumentObjectPropertyEvent() { m_pObject = nullptr; } ezVariant getInsertIndex() const; enum class Type { PropertySet, PropertyInserted, PropertyRemoved, PropertyMoved, }; Type m_EventType; const ezDocumentObject* m_pObject; ezVariant m_OldValue; ezVariant m_NewValue; ezString m_sProperty; ezVariant m_OldIndex; ezVariant m_NewIndex; }; /// \brief Used by ezDocumentObjectManager::m_ObjectEvents. struct ezDocumentObjectEvent { ezDocumentObjectEvent() { m_pObject = nullptr; } enum class Type { BeforeObjectDestroyed, AfterObjectCreated, }; Type m_EventType; const ezDocumentObject* m_pObject; }; /// \brief Represents to content of a document. Every document has exactly one root object under which all objects need to be parented. The default root object is ezDocumentRoot. class EZ_TOOLSFOUNDATION_DLL ezDocumentObjectManager { public: // \brief Storage for the object manager so it can be swapped when using multiple sub documents. class Storage : public ezRefCounted { public: Storage(const ezRTTI* pRootType); ezDocument* m_pDocument = nullptr; ezDocumentRootObject m_RootObject; ezHashTable<ezUuid, const ezDocumentObject*> m_GuidToObject; mutable ezCopyOnBroadcastEvent<const ezDocumentObjectStructureEvent&> m_StructureEvents; mutable ezCopyOnBroadcastEvent<const ezDocumentObjectPropertyEvent&> m_PropertyEvents; ezEvent<const ezDocumentObjectEvent&> m_ObjectEvents; }; public: mutable ezCopyOnBroadcastEvent<const ezDocumentObjectStructureEvent&> m_StructureEvents; mutable ezCopyOnBroadcastEvent<const ezDocumentObjectPropertyEvent&> m_PropertyEvents; ezEvent<const ezDocumentObjectEvent&> m_ObjectEvents; ezDocumentObjectManager(const ezRTTI* pRootType = ezDocumentRoot::GetStaticRTTI()); virtual ~ezDocumentObjectManager(); void SetDocument(ezDocument* pDocument) { m_pObjectStorage->m_pDocument = pDocument; } // Object Construction / Destruction // holds object data ezDocumentObject* CreateObject(const ezRTTI* pRtti, ezUuid guid = ezUuid()); void DestroyObject(ezDocumentObject* pObject); virtual void DestroyAllObjects(); virtual void GetCreateableTypes(ezHybridArray<const ezRTTI*, 32>& Types) const {}; /// \brief Allows to annotate types with a category (group), such that things like creator menus can use this to present the types in a more user /// friendly way virtual const char* GetTypeCategory(const ezRTTI* pRtti) const { return nullptr; } void PatchEmbeddedClassObjects(const ezDocumentObject* pObject) const; const ezDocumentObject* GetRootObject() const { return &m_pObjectStorage->m_RootObject; } ezDocumentObject* GetRootObject() { return &m_pObjectStorage->m_RootObject; } const ezDocumentObject* GetObject(const ezUuid& guid) const; ezDocumentObject* GetObject(const ezUuid& guid); const ezDocument* GetDocument() const { return m_pObjectStorage->m_pDocument; } ezDocument* GetDocument() { return m_pObjectStorage->m_pDocument; } // Property Change ezStatus SetValue(ezDocumentObject* pObject, const char* szProperty, const ezVariant& newValue, ezVariant index = ezVariant()); ezStatus InsertValue(ezDocumentObject* pObject, const char* szProperty, const ezVariant& newValue, ezVariant index = ezVariant()); ezStatus RemoveValue(ezDocumentObject* pObject, const char* szProperty, ezVariant index = ezVariant()); ezStatus MoveValue(ezDocumentObject* pObject, const char* szProperty, const ezVariant& oldIndex, const ezVariant& newIndex); // Structure Change void AddObject(ezDocumentObject* pObject, ezDocumentObject* pParent, const char* szParentProperty, ezVariant index); void RemoveObject(ezDocumentObject* pObject); void MoveObject(ezDocumentObject* pObject, ezDocumentObject* pNewParent, const char* szParentProperty, ezVariant index); // Structure Change Test ezStatus CanAdd(const ezRTTI* pRtti, const ezDocumentObject* pParent, const char* szParentProperty, const ezVariant& index) const; ezStatus CanRemove(const ezDocumentObject* pObject) const; ezStatus CanMove(const ezDocumentObject* pObject, const ezDocumentObject* pNewParent, const char* szParentProperty, const ezVariant& index) const; ezStatus CanSelect(const ezDocumentObject* pObject) const; bool IsUnderRootProperty(const char* szRootProperty, const ezDocumentObject* pObject) const; bool IsUnderRootProperty(const char* szRootProperty, const ezDocumentObject* pParent, const char* szParentProperty) const; ezSharedPtr<ezDocumentObjectManager::Storage> SwapStorage(ezSharedPtr<ezDocumentObjectManager::Storage> pNewStorage); ezSharedPtr<ezDocumentObjectManager::Storage> GetStorage() { return m_pObjectStorage; } private: virtual ezDocumentObject* InternalCreateObject(const ezRTTI* pRtti) { return EZ_DEFAULT_NEW(ezDocumentStorageObject, pRtti); } virtual void InternalDestroyObject(ezDocumentObject* pObject) { EZ_DEFAULT_DELETE(pObject); } void InternalAddObject(ezDocumentObject* pObject, ezDocumentObject* pParent, const char* szParentProperty, ezVariant index); void InternalRemoveObject(ezDocumentObject* pObject); void InternalMoveObject(ezDocumentObject* pNewParent, ezDocumentObject* pObject, const char* szParentProperty, ezVariant index); virtual ezStatus InternalCanAdd(const ezRTTI* pRtti, const ezDocumentObject* pParent, const char* szParentProperty, const ezVariant& index) const { return ezStatus(EZ_SUCCESS); }; virtual ezStatus InternalCanRemove(const ezDocumentObject* pObject) const { return ezStatus(EZ_SUCCESS); }; virtual ezStatus InternalCanMove( const ezDocumentObject* pObject, const ezDocumentObject* pNewParent, const char* szParentProperty, const ezVariant& index) const { return ezStatus(EZ_SUCCESS); }; virtual ezStatus InternalCanSelect(const ezDocumentObject* pObject) const { return ezStatus(EZ_SUCCESS); }; void RecursiveAddGuids(ezDocumentObject* pObject); void RecursiveRemoveGuids(ezDocumentObject* pObject); void PatchEmbeddedClassObjectsInternal(ezDocumentObject* pObject, const ezRTTI* pType, bool addToDoc); private: friend class ezObjectAccessorBase; ezSharedPtr<ezDocumentObjectManager::Storage> m_pObjectStorage; ezCopyOnBroadcastEvent<const ezDocumentObjectStructureEvent&>::Unsubscriber m_StructureEventsUnsubscriber; ezCopyOnBroadcastEvent<const ezDocumentObjectPropertyEvent&>::Unsubscriber m_PropertyEventsUnsubscriber; ezEvent<const ezDocumentObjectEvent&>::Unsubscriber m_ObjectEventsUnsubscriber; };
39.936652
178
0.796624
[ "object" ]
e0c7cc866f1568dbe317d7bb5ba1d8d154b27b8d
625
h
C
MRDemo/GlTexture.h
BernLeWal/MultipleReality
438007c5d153815ec004c71f9a6e2a2f8a22c1f4
[ "Apache-2.0" ]
null
null
null
MRDemo/GlTexture.h
BernLeWal/MultipleReality
438007c5d153815ec004c71f9a6e2a2f8a22c1f4
[ "Apache-2.0" ]
null
null
null
MRDemo/GlTexture.h
BernLeWal/MultipleReality
438007c5d153815ec004c71f9a6e2a2f8a22c1f4
[ "Apache-2.0" ]
null
null
null
// License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2015 Intel Corporation. All Rights Reserved. #pragma once #include <librealsense2/rs.hpp> // Include RealSense Cross Platform API #include "GlTypes.h" //////////////////////// // Image display code // //////////////////////// class GlTexture { GLuint gl_handle = 0; rs2_stream stream = RS2_STREAM_ANY; public: void render(const rs2::video_frame& frame, const rect& rect); void upload(const rs2::video_frame& frame); void uploadFile(char const *filename); void show(const rect& r) const; GLuint get_gl_handle() { return gl_handle; } };
23.148148
71
0.6784
[ "render" ]
e0ca161f5287753cad0a59d89ffd99c54e26fdf6
90,617
h
C
Sprayscape/Assets/Plugins/GoogleDrivePlugin/Plugins/iOS/google-api-objectivec-client-for-rest/Source/GeneratedServices/Partners/GTLRPartnersObjects.h
lizhong2016/Sprayscape-VR
6fbcdd215d9ca77b8b997180b6f9feda66ac16f0
[ "Apache-2.0" ]
2
2017-02-22T07:34:43.000Z
2017-08-17T08:24:14.000Z
Sprayscape/Assets/Plugins/GoogleDrivePlugin/Plugins/iOS/google-api-objectivec-client-for-rest/Source/GeneratedServices/Partners/GTLRPartnersObjects.h
lizhong2016/Sprayscape-VR
6fbcdd215d9ca77b8b997180b6f9feda66ac16f0
[ "Apache-2.0" ]
null
null
null
Sprayscape/Assets/Plugins/GoogleDrivePlugin/Plugins/iOS/google-api-objectivec-client-for-rest/Source/GeneratedServices/Partners/GTLRPartnersObjects.h
lizhong2016/Sprayscape-VR
6fbcdd215d9ca77b8b997180b6f9feda66ac16f0
[ "Apache-2.0" ]
null
null
null
// NOTE: This file was generated by the ServiceGenerator. // ---------------------------------------------------------------------------- // API: // Google Partners API (partners/v2) // Description: // Lets advertisers search certified companies and create contact leads with // them, and also audits the usage of clients. // Documentation: // https://developers.google.com/partners/ #if GTLR_BUILT_AS_FRAMEWORK #import "GTLR/GTLRObject.h" #else #import "GTLRObject.h" #endif #if GTLR_RUNTIME_VERSION != 3000 #error This file was generated by a different version of ServiceGenerator which is incompatible with this GTLR library source. #endif @class GTLRPartners_CertificationExamStatus; @class GTLRPartners_CertificationStatus; @class GTLRPartners_Company; @class GTLRPartners_DebugInfo; @class GTLRPartners_EventData; @class GTLRPartners_LatLng; @class GTLRPartners_Lead; @class GTLRPartners_LocalizedCompanyInfo; @class GTLRPartners_Location; @class GTLRPartners_LogMessageRequestClientInfo; @class GTLRPartners_Money; @class GTLRPartners_PublicProfile; @class GTLRPartners_Rank; @class GTLRPartners_RecaptchaChallenge; @class GTLRPartners_RequestMetadata; @class GTLRPartners_ResponseMetadata; @class GTLRPartners_TrafficSource; @class GTLRPartners_UserOverrides; NS_ASSUME_NONNULL_BEGIN // ---------------------------------------------------------------------------- // Constants - For some of the classes' properties below. // ---------------------------------------------------------------------------- // GTLRPartners_CertificationExamStatus.type /** Value: "CERTIFICATION_EXAM_TYPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CertificationExamTypeUnspecified; /** Value: "CET_ADWORDS_ADVANCED_DISPLAY" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetAdwordsAdvancedDisplay; /** Value: "CET_ADWORDS_ADVANCED_SEARCH" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetAdwordsAdvancedSearch; /** Value: "CET_ANALYTICS" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetAnalytics; /** Value: "CET_DOUBLECLICK" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetDoubleclick; /** Value: "CET_MOBILE" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetMobile; /** Value: "CET_SHOPPING" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetShopping; /** Value: "CET_VIDEO_ADS" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationExamStatus_Type_CetVideoAds; // ---------------------------------------------------------------------------- // GTLRPartners_CertificationStatus.type /** Value: "CERTIFICATION_TYPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CertificationTypeUnspecified; /** Value: "CT_ADWORDS" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtAdwords; /** Value: "CT_ANALYTICS" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtAnalytics; /** Value: "CT_DOUBLECLICK" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtDoubleclick; /** Value: "CT_MOBILE" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtMobile; /** Value: "CT_SHOPPING" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtShopping; /** Value: "CT_VIDEOADS" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtVideoads; /** Value: "CT_YOUTUBE" */ GTLR_EXTERN NSString * const kGTLRPartners_CertificationStatus_Type_CtYoutube; // ---------------------------------------------------------------------------- // GTLRPartners_Company.industries /** Value: "I_AUTOMOTIVE" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IAutomotive; /** Value: "I_BUSINESS_TO_BUSINESS" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IBusinessToBusiness; /** Value: "I_CONSUMER_PACKAGED_GOODS" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IConsumerPackagedGoods; /** Value: "I_EDUCATION" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IEducation; /** Value: "I_FINANCE" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IFinance; /** Value: "I_HEALTHCARE" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IHealthcare; /** Value: "I_MEDIA_AND_ENTERTAINMENT" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IMediaAndEntertainment; /** Value: "INDUSTRY_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IndustryUnspecified; /** Value: "I_RETAIL" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_IRetail; /** Value: "I_TECHNOLOGY" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_ITechnology; /** Value: "I_TRAVEL" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Industries_ITravel; // ---------------------------------------------------------------------------- // GTLRPartners_Company.services /** Value: "S_ADVANCED_ADWORDS_SUPPORT" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_SAdvancedAdwordsSupport; /** Value: "S_ADVERTISING_ON_GOOGLE" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_SAdvertisingOnGoogle; /** Value: "S_AN_ENHANCED_WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_SAnEnhancedWebsite; /** Value: "S_AN_ONLINE_MARKETING_PLAN" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_SAnOnlineMarketingPlan; /** Value: "SERVICE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_ServiceUnspecified; /** Value: "S_MOBILE_AND_VIDEO_ADS" */ GTLR_EXTERN NSString * const kGTLRPartners_Company_Services_SMobileAndVideoAds; // ---------------------------------------------------------------------------- // GTLRPartners_CreateLeadResponse.recaptchaStatus /** Value: "RECAPTCHA_STATUS_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RecaptchaStatusUnspecified; /** Value: "RS_FAILED" */ GTLR_EXTERN NSString * const kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsFailed; /** Value: "RS_NOT_NEEDED" */ GTLR_EXTERN NSString * const kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsNotNeeded; /** Value: "RS_PASSED" */ GTLR_EXTERN NSString * const kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsPassed; // ---------------------------------------------------------------------------- // GTLRPartners_EventData.key /** Value: "ACTION" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Action; /** Value: "AGENCY_ID" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_AgencyId; /** Value: "AGENCY_NAME" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_AgencyName; /** Value: "AGENCY_PHONE_NUMBER" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_AgencyPhoneNumber; /** Value: "AGENCY_WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_AgencyWebsite; /** Value: "BUDGET" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Budget; /** Value: "CENTER_POINT" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_CenterPoint; /** Value: "CERTIFICATION" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Certification; /** Value: "COMMENT" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Comment; /** Value: "COUNTRY" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Country; /** Value: "CURRENCY" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Currency; /** Value: "CURRENTLY_VIEWED_AGENCY_ID" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_CurrentlyViewedAgencyId; /** Value: "DETAILS" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Details; /** Value: "DISTANCE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Distance; /** Value: "DISTANCE_TYPE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_DistanceType; /** Value: "ELEMENT_FOCUS" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_ElementFocus; /** Value: "EVENT_DATA_TYPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_EventDataTypeUnspecified; /** Value: "EXAM" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Exam; /** Value: "EXPERIMENT_ID" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_ExperimentId; /** Value: "GPS_MOTIVATION" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_GpsMotivation; /** Value: "HISTORY_TOKEN" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_HistoryToken; /** Value: "IDENTIFIER" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Identifier; /** Value: "INDUSTRY" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Industry; /** Value: "INSIGHT_TAG" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_InsightTag; /** Value: "LANGUAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Language; /** Value: "LOCATION" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Location; /** Value: "MARKETING_OPT_IN" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_MarketingOptIn; /** Value: "PROGRESS" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Progress; /** Value: "QUERY" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Query; /** Value: "SEARCH_START_INDEX" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_SearchStartIndex; /** Value: "SERVICE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Service; /** Value: "SHOW_VOW" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_ShowVow; /** Value: "SOLUTION" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Solution; /** Value: "TRAFFIC_SOURCE_ID" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_TrafficSourceId; /** Value: "TRAFFIC_SUB_ID" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_TrafficSubId; /** Value: "URL" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Url; /** Value: "VIEW_PORT" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_ViewPort; /** Value: "WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_EventData_Key_Website; // ---------------------------------------------------------------------------- // GTLRPartners_Lead.gpsMotivations /** Value: "GPSM_HELP_WITH_ADVERTISING" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_GpsMotivations_GpsmHelpWithAdvertising; /** Value: "GPSM_HELP_WITH_WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_GpsMotivations_GpsmHelpWithWebsite; /** Value: "GPSM_NO_WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_GpsMotivations_GpsmNoWebsite; /** Value: "GPS_MOTIVATION_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_GpsMotivations_GpsMotivationUnspecified; // ---------------------------------------------------------------------------- // GTLRPartners_Lead.type /** Value: "LEAD_TYPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_Type_LeadTypeUnspecified; /** Value: "LT_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_Lead_Type_LtGps; // ---------------------------------------------------------------------------- // GTLRPartners_ListUserStatesResponse.userStates /** Value: "USER_STATE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_ListUserStatesResponse_UserStates_UserStateUnspecified; /** Value: "US_REQUIRES_RECAPTCHA_FOR_GPS_CONTACT" */ GTLR_EXTERN NSString * const kGTLRPartners_ListUserStatesResponse_UserStates_UsRequiresRecaptchaForGpsContact; // ---------------------------------------------------------------------------- // GTLRPartners_LogMessageRequest.level /** Value: "MESSAGE_LEVEL_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogMessageRequest_Level_MessageLevelUnspecified; /** Value: "ML_FINE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogMessageRequest_Level_MlFine; /** Value: "ML_INFO" */ GTLR_EXTERN NSString * const kGTLRPartners_LogMessageRequest_Level_MlInfo; /** Value: "ML_SEVERE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogMessageRequest_Level_MlSevere; /** Value: "ML_WARNING" */ GTLR_EXTERN NSString * const kGTLRPartners_LogMessageRequest_Level_MlWarning; // ---------------------------------------------------------------------------- // GTLRPartners_LogUserEventRequest.eventAction /** Value: "AGECNY_CLICKED_CREATE_MCC_CONNECT_WITH_COMPANY_NOT_FOUND" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedCreateMccConnectWithCompanyNotFound; /** Value: "AGECNY_CLICKED_GIVE_EDIT_ACCESS_CONNECT_WITH_COMPANY_NOT_FOUND" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedGiveEditAccessConnectWithCompanyNotFound; /** Value: "AGECNY_CLICKED_LOG_OUT_CONNECT_WITH_COMPANY_NOT_FOUND" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedLogOutConnectWithCompanyNotFound; /** Value: "AGECNY_FOUND_COMPANY_TO_CONNECT_WITH" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgecnyFoundCompanyToConnectWith; /** Value: "AGENCY_ADDED_ADDRESS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedAddressInMyProfilePortal; /** Value: "AGENCY_ADDED_CHANNELS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedChannelsInMyProfilePortal; /** Value: "AGENCY_ADDED_INDUSTRIES_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedIndustriesInMyProfilePortal; /** Value: "AGENCY_ADDED_JOB_FUNCTION_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedJobFunctionInMyProfilePortal; /** Value: "AGENCY_ADDED_MARKETS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedMarketsInMyProfilePortal; /** Value: "AGENCY_ADDED_NEW_COMPANY_LOCATION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedNewCompanyLocation; /** Value: "AGENCY_ADDED_PHONE_NUMBER_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedPhoneNumberInMyProfilePortal; /** Value: "AGENCY_CHANGED_ADD_INDUSTRIES_DROP_DOWN" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedAddIndustriesDropDown; /** Value: "AGENCY_CHANGED_ADD_MARKETS_DROP_DOWN" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedAddMarketsDropDown; /** Value: "AGENCY_CHANGED_PRIMARY_ACCOUNT_ASSOCIATION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedPrimaryAccountAssociation; /** Value: "AGENCY_CHANGED_PRIMARY_COUNTRY_ASSOCIATION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedPrimaryCountryAssociation; /** Value: "AGENCY_CHANGED_ROLES" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedRoles; /** Value: "AGENCY_CHANGED_TOS_COUNTRY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedTosCountry; /** Value: "AGENCY_CHECKED_RECIEVE_MAIL_PROMOTIONS_MYPROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyCheckedRecieveMailPromotionsMyprofile; /** Value: "AGENCY_CHECKED_RECIEVE_MAIL_PROMOTIONS_SIGNUP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyCheckedRecieveMailPromotionsSignup; /** Value: "AGENCY_CLICKED_ACCEPT_TOS_BUTTON" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedAcceptTosButton; /** Value: "AGENCY_CLICKED_AFFILIATE_BUTTON_IN_MY_PROFILE_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedAffiliateButtonInMyProfileInPortal; /** Value: "AGENCY_CLICKED_BACK_BUTTON_ON_CONNECT_WITH_COMPANY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedBackButtonOnConnectWithCompany; /** Value: "AGENCY_CLICKED_CANCEL_ACCEPT_TOS_BUTTON" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCancelAcceptTosButton; /** Value: "AGENCY_CLICKED_CERTIFICATIONS_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCertificationsLeftNavInPortal; /** Value: "AGENCY_CLICKED_CERTIFICATIONS_PRODUCT_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCertificationsProductLeftNavInPortal; /** Value: "AGENCY_CLICKED_COMMUNITY_JOIN_NOW_LINK_IN_PORTAL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCommunityJoinNowLinkInPortalNotifications; /** Value: "AGENCY_CLICKED_COMMUNITY_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCommunityLeftNavInPortal; /** Value: "AGENCY_CLICKED_CONNECT_TO_COMPANY_LINK_IN_PORTAL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedConnectToCompanyLinkInPortalNotifications; /** Value: "AGENCY_CLICKED_CONTINUE_TO_OVERVIEW_ON_CONNECT_WITH_COMPANY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedContinueToOverviewOnConnectWithCompany; /** Value: "AGENCY_CLICKED_CREATE_MCC_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCreateMccInMyProfilePortal; /** Value: "AGENCY_CLICKED_EXAM_DETAILS_ON_CERT_ADWORDS_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedExamDetailsOnCertAdwordsPage; /** Value: "AGENCY_CLICKED_GET_CERTIFIED_LINK_IN_PORTAL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGetCertifiedLinkInPortalNotifications; /** * Value: "AGENCY_CLICKED_GET_VIDEO_ADS_CERTIFIED_LINK_IN_PORTAL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGetVideoAdsCertifiedLinkInPortalNotifications; /** Value: "AGENCY_CLICKED_GIVE_EDIT_ACCESS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGiveEditAccessInMyProfilePortal; /** Value: "AGENCY_CLICKED_INSIGHT_CONTENT_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightContentInPortal; /** Value: "AGENCY_CLICKED_INSIGHTS_DOWNLOAD_CONTENT" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsDownloadContent; /** Value: "AGENCY_CLICKED_INSIGHTS_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsLeftNavInPortal; /** Value: "AGENCY_CLICKED_INSIGHTS_UPLOAD_CONTENT" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsUploadContent; /** Value: "AGENCY_CLICKED_INSIGHTS_VIEWED_DEPRECATED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsViewedDeprecated; /** Value: "AGENCY_CLICKED_INSIGHTS_VIEW_NOW_PITCH_DECKS_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsViewNowPitchDecksInPortal; /** Value: "AGENCY_CLICKED_JOIN_COMMUNITY_BUTTON_COMMUNITY_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinCommunityButtonCommunityPortal; /** Value: "AGENCY_CLICKED_JOIN_NOW_BUTTON_BOTTOM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinNowButtonBottom; /** Value: "AGENCY_CLICKED_JOIN_NOW_BUTTON_TOP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinNowButtonTop; /** Value: "AGENCY_CLICKED_LEFT_NAV_STORIES" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLeftNavStories; /** Value: "AGENCY_CLICKED_LINK_TO_MCC_LINK_IN_PORTAL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLinkToMccLinkInPortalNotifications; /** Value: "AGENCY_CLICKED_LOG_OUT_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLogOutInMyProfilePortal; /** Value: "AGENCY_CLICKED_MY_PROFILE_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedMyProfileLeftNavInPortal; /** Value: "AGENCY_CLICKED_OFFERS_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedOffersLeftNavInPortal; /** Value: "AGENCY_CLICKED_PARTNER_STATUS_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedPartnerStatusLeftNavInPortal; /** Value: "AGENCY_CLICKED_PARTNER_STATUS_PRODUCT_LEFT_NAV_IN_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedPartnerStatusProductLeftNavInPortal; /** Value: "AGENCY_CLICKED_SAVE_AND_CONTINUE_AT_BOT_OF_COMPLETE_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSaveAndContinueAtBotOfCompleteProfile; /** Value: "AGENCY_CLICKED_SAVE_AND_CONTINUE_AT_BOT_OF_INCOMPLETE_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSaveAndContinueAtBotOfIncompleteProfile; /** Value: "AGENCY_CLICKED_SEE_EXAMS_CERTIFICATION_MAIN_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSeeExamsCertificationMainPage; /** Value: "AGENCY_CLICKED_SEND_BUTTON_ON_OFFERS_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSendButtonOnOffersPage; /** Value: "AGENCY_CLICKED_SIGN_IN_BUTTON_TOP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSignInButtonTop; /** Value: "AGENCY_CLICKED_SKIP_FOR_NOW_ON_CONNECT_WITH_COMPANY_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSkipForNowOnConnectWithCompanyPage; /** Value: "AGENCY_CLICKED_TAKE_EXAM_ON_CERT_EXAM_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedTakeExamOnCertExamPage; /** Value: "AGENCY_CLICKED_UNAFFILIATE_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedUnaffiliateInMyProfilePortal; /** Value: "AGENCY_CLOSED_CONNECTED_TO_COMPANY_X_BUTTON_WRONG_COMPANY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyClosedConnectedToCompanyXButtonWrongCompany; /** Value: "AGENCY_COMPLETED_FIELD_CONNECT_WITH_COMPANY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyCompletedFieldConnectWithCompany; /** Value: "AGENCY_DIDNT_HAVE_AN_MCC_ASSOCIATED_ON_COMPLETE_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyDidntHaveAnMccAssociatedOnCompleteProfile; /** Value: "AGENCY_DISMISSED_AFFILIATION_WIDGET" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyDismissedAffiliationWidget; /** Value: "AGENCY_FAILED_COMPANY_VERIFICATION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyFailedCompanyVerification; /** Value: "AGENCY_FILLED_OUT_COMP_AFFILIATION_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyFilledOutCompAffiliationInMyProfilePortal; /** Value: "AGENCY_HAD_AN_MCC_ASSOCIATED_ON_COMPLETE_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyHadAnMccAssociatedOnCompleteProfile; /** Value: "AGENCY_IGNORED_SUGGESTED_AGENCIES_AND_SEARCHED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyIgnoredSuggestedAgenciesAndSearched; /** Value: "AGENCY_LINKED_INDIVIDUAL_MCC" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyLinkedIndividualMcc; /** Value: "AGENCY_LOOKED_AT_ADD_CHANNEL_DROP_DOWN" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyLookedAtAddChannelDropDown; /** Value: "AGENCY_LOOKED_AT_JOB_FUNCTION_DROP_DOWN" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyLookedAtJobFunctionDropDown; /** Value: "AGENCY_OPENED_DIALOG_WITH_NO_USERS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyOpenedDialogWithNoUsers; /** Value: "AGENCY_OPENED_LAST_ADMIN_DIALOG" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyOpenedLastAdminDialog; /** Value: "AGENCY_PICKED_SEARCHED_AGENCY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyPickedSearchedAgency; /** Value: "AGENCY_PICKED_SUGGESTED_AGENCY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyPickedSuggestedAgency; /** Value: "AGENCY_PROGRESS_INSIGHTS_VIEW_CONTENT" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyProgressInsightsViewContent; /** Value: "AGENCY_PROMOTED_USER_TO_ADMIN" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyPromotedUserToAdmin; /** Value: "AGENCY_SEARCHED_FOR_AGENCIES" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySearchedForAgencies; /** Value: "AGENCY_SELECTED_ACCOUNT_MANAGER_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAccountManagerAsJobFunction; /** Value: "AGENCY_SELECTED_ACCOUNT_PLANNER_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAccountPlannerAsJobFunction; /** Value: "AGENCY_SELECTED_ANALYTICS_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAnalyticsAsJobFunction; /** Value: "AGENCY_SELECTED_CREATIVE_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedCreativeAsJobFunction; /** Value: "AGENCY_SELECTED_CROSS_CHANNEL_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedCrossChannelFromAddChannel; /** Value: "AGENCY_SELECTED_DISPLAY_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedDisplayFromAddChannel; /** Value: "AGENCY_SELECTED_MEDIA_BUYER_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMediaBuyerAsJobFunction; /** Value: "AGENCY_SELECTED_MEDIA_PLANNER_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMediaPlannerAsJobFunction; /** Value: "AGENCY_SELECTED_MOBILE_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMobileFromAddChannel; /** Value: "AGENCY_SELECTED_OPT_IN_BETA_TESTS_AND_MKT_RESEARCH" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInBetaTestsAndMktResearch; /** Value: "AGENCY_SELECTED_OPT_IN_BETA_TESTS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInBetaTestsInMyProfilePortal; /** Value: "AGENCY_SELECTED_OPT_IN_NEWS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInNewsInMyProfilePortal; /** Value: "AGENCY_SELECTED_OPT_IN_NEWS_INVITATIONS_AND_PROMOS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInNewsInvitationsAndPromos; /** Value: "AGENCY_SELECTED_OPT_IN_PERFORMANCE_SUGGESTIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInPerformanceSuggestions; /** Value: "AGENCY_SELECTED_OPT_IN_PERFORMANCE_SUG_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInPerformanceSugInMyProfilePortal; /** Value: "AGENCY_SELECTED_OPT_IN_SELECT_ALL_EMAIL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInSelectAllEmailNotifications; /** Value: "AGENCY_SELECTED_OPT_OUT_UNSELECT_ALL_EMAIL_NOTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptOutUnselectAllEmailNotifications; /** Value: "AGENCY_SELECTED_OTHER_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOtherAsJobFunction; /** Value: "AGENCY_SELECTED_PRODUCTION_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedProductionAsJobFunction; /** Value: "AGENCY_SELECTED_SALES_REP_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSalesRepAsJobFunction; /** Value: "AGENCY_SELECTED_SEARCH_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSearchFromAddChannel; /** Value: "AGENCY_SELECTED_SEARCH_SPECIALIST_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSearchSpecialistAsJobFunction; /** Value: "AGENCY_SELECTED_SELECT_ALL_OPT_INS_IN_MY_PROFILE_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSelectAllOptInsInMyProfilePortal; /** Value: "AGENCY_SELECTED_SEO_AS_JOB_FUNCTION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSeoAsJobFunction; /** Value: "AGENCY_SELECTED_SOCIAL_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSocialFromAddChannel; /** Value: "AGENCY_SELECTED_TOOLS_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedToolsFromAddChannel; /** Value: "AGENCY_SELECTED_YOUTUBE_FROM_ADD_CHANNEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedYoutubeFromAddChannel; /** Value: "AGENCY_SUCCESSFULLY_CONNECTED_WITH_COMPANY_IN_MY_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySuccessfullyConnectedWithCompanyInMyProfile; /** Value: "AGENCY_SUCCESSFULLY_CREATED_COMPANY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySuccessfullyCreatedCompany; /** Value: "AGENCY_SUGGESTED_TO_USER" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencySuggestedToUser; /** Value: "AGENCY_UNAFFILIATED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnaffiliated; /** Value: "AGENCY_UNSELECTED_OPT_IN_BETA_TESTS_AND_MKT_RESEARCH" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInBetaTestsAndMktResearch; /** Value: "AGENCY_UNSELECTED_OPT_IN_NEWS_INVITATIONS_AND_PROMOS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInNewsInvitationsAndPromos; /** Value: "AGENCY_UNSELECTED_OPT_IN_PERFORMANCE_SUGGESTIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInPerformanceSuggestions; /** Value: "CANCELLED_COMPANY_SIGN_UP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_CancelledCompanySignUp; /** Value: "CANCELLED_INDIVIDUAL_SIGN_UP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_CancelledIndividualSignUp; /** Value: "CLICKED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_Clicked; /** Value: "CLICKED_HELP_AT_BOTTOM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_ClickedHelpAtBottom; /** Value: "CLICKED_HELP_AT_TOP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_ClickedHelpAtTop; /** Value: "CLIENT_ERROR" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_ClientError; /** Value: "EVENT_ACTION_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_EventActionUnspecified; /** Value: "PARTNER_VIEWED_BY_SMB" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_PartnerViewedBySmb; /** Value: "SMB_CANCELED_PARTNER_CONTACT_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactForm; /** Value: "SMB_CANCELED_PARTNER_CONTACT_FORM_ON_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactFormOnGps; /** Value: "SMB_CANCELED_PARTNER_CONTACT_FORM_ON_PROFILE_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactFormOnProfilePage; /** Value: "SMB_CHANGED_A_SEARCH_PARAMETER_TOP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbChangedASearchParameterTop; /** Value: "SMB_CLICKED_ADWORDS_CERTIFICATE_HELP_ICON" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedAdwordsCertificateHelpIcon; /** Value: "SMB_CLICKED_COMPANY_NAME_LINK_TO_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedCompanyNameLinkToProfile; /** Value: "SMB_CLICKED_CONTACT_A_PARTNER" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartner; /** Value: "SMB_CLICKED_CONTACT_A_PARTNER_ON_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartnerOnGps; /** Value: "SMB_CLICKED_CONTACT_A_PARTNER_ON_PROFILE_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartnerOnProfilePage; /** Value: "SMB_CLICKED_FIND_A_PARTNER_BUTTON_BOTTOM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedFindAPartnerButtonBottom; /** Value: "SMB_CLICKED_FIND_A_PARTNER_BUTTON_TOP" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedFindAPartnerButtonTop; /** Value: "SMB_CLICKED_PARTNER_WEBSITE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedPartnerWebsite; /** Value: "SMB_CLICKED_SHOW_MORE_PARTNERS_BUTTON_BOTTOM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedShowMorePartnersButtonBottom; /** Value: "SMB_CLICKED_VIDEO_ADS_CERTIFICATE_HELP_ICON" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedVideoAdsCertificateHelpIcon; /** Value: "SMB_COMPLETED_PARTNER_CONTACT_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactForm; /** Value: "SMB_COMPLETED_PARTNER_CONTACT_FORM_ON_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactFormOnGps; /** Value: "SMB_COMPLETED_PARTNER_CONTACT_FORM_ON_PROFILE_PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactFormOnProfilePage; /** Value: "SMB_ENTERED_EMAIL_IN_CONTACT_PARTNER_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredEmailInContactPartnerForm; /** Value: "SMB_ENTERED_NAME_IN_CONTACT_PARTNER_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredNameInContactPartnerForm; /** Value: "SMB_ENTERED_PHONE_IN_CONTACT_PARTNER_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredPhoneInContactPartnerForm; /** Value: "SMB_ENTERED_WEBSITE_IN_CONTACT_PARTNER_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredWebsiteInContactPartnerForm; /** Value: "SMB_FAILED_RECAPTCHA_IN_CONTACT_PARTNER_FORM" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbFailedRecaptchaInContactPartnerForm; /** Value: "SMB_NO_PARTNERS_AVAILABLE_WITH_SEARCH_CRITERIA" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbNoPartnersAvailableWithSearchCriteria; /** Value: "SMB_PERFORMED_SEARCH_ON_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbPerformedSearchOnGps; /** Value: "SMB_VIEWED_ADWORDS_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAdwordsCertificate; /** Value: "SMB_VIEWED_ANALYTICS_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAnalyticsCertificate; /** Value: "SMB_VIEWED_A_PARTNER_ON_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAPartnerOnGps; /** Value: "SMB_VIEWED_A_PARTNER_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAPartnerProfile; /** Value: "SMB_VIEWED_DOUBLECLICK_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedDoubleclickCertificate; /** Value: "SMB_VIEWED_MOBILE_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedMobileCertificate; /** Value: "SMB_VIEWED_SHOPPING_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedShoppingCertificate; /** Value: "SMB_VIEWED_VIDEO_ADS_CERTIFICATE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedVideoAdsCertificate; /** Value: "VISITED_AGENCY_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_VisitedAgencyPortal; /** Value: "VISITED_GPS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_VisitedGps; /** Value: "VISITED_LANDING" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventAction_VisitedLanding; // ---------------------------------------------------------------------------- // GTLRPartners_LogUserEventRequest.eventCategory /** Value: "EVENT_CATEGORY_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_EventCategoryUnspecified; /** Value: "EXTERNAL_LINKS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_ExternalLinks; /** Value: "GOOGLE_PARTNER_CLIENT" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerClient; /** Value: "GOOGLE_PARTNER_LANDING" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerLanding; /** Value: "GOOGLE_PARTNER_PANEL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPanel; /** Value: "GOOGLE_PARTNER_PORTAL" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortal; /** Value: "GOOGLE_PARTNER_PORTAL_CERTIFICATIONS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCertifications; /** Value: "GOOGLE_PARTNER_PORTAL_CLIENTS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalClients; /** Value: "GOOGLE_PARTNER_PORTAL_COMMUNITY" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCommunity; /** Value: "GOOGLE_PARTNER_PORTAL_COMPANY_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCompanyProfile; /** Value: "GOOGLE_PARTNER_PORTAL_INSIGHTS" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalInsights; /** Value: "GOOGLE_PARTNER_PORTAL_LAST_ADMIN_DIALOG" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalLastAdminDialog; /** Value: "GOOGLE_PARTNER_PORTAL_MY_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalMyProfile; /** Value: "GOOGLE_PARTNER_PUBLIC_USER_PROFILE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPublicUserProfile; /** Value: "GOOGLE_PARTNER_SEARCH" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerSearch; /** Value: "GOOGLE_PARTNER_SIGNUP_FLOW" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerSignupFlow; // ---------------------------------------------------------------------------- // GTLRPartners_LogUserEventRequest.eventScope /** Value: "EVENT_SCOPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventScope_EventScopeUnspecified; /** Value: "PAGE" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventScope_Page; /** Value: "SESSION" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventScope_Session; /** Value: "VISITOR" */ GTLR_EXTERN NSString * const kGTLRPartners_LogUserEventRequest_EventScope_Visitor; // ---------------------------------------------------------------------------- // GTLRPartners_Rank.type /** Value: "RANK_TYPE_UNSPECIFIED" */ GTLR_EXTERN NSString * const kGTLRPartners_Rank_Type_RankTypeUnspecified; /** Value: "RT_FINAL_SCORE" */ GTLR_EXTERN NSString * const kGTLRPartners_Rank_Type_RtFinalScore; /** * Status for a Google Partners certification exam. */ @interface GTLRPartners_CertificationExamStatus : GTLRObject /** * The number of people who have passed the certification exam. * * Uses NSNumber of intValue. */ @property(strong, nullable) NSNumber *numberUsersPass; /** * The type of certification exam. * * Likely values: * @arg @c kGTLRPartners_CertificationExamStatus_Type_CertificationExamTypeUnspecified * Value "CERTIFICATION_EXAM_TYPE_UNSPECIFIED" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetAdwordsAdvancedDisplay * Value "CET_ADWORDS_ADVANCED_DISPLAY" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetAdwordsAdvancedSearch * Value "CET_ADWORDS_ADVANCED_SEARCH" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetAnalytics Value * "CET_ANALYTICS" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetDoubleclick Value * "CET_DOUBLECLICK" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetMobile Value * "CET_MOBILE" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetShopping Value * "CET_SHOPPING" * @arg @c kGTLRPartners_CertificationExamStatus_Type_CetVideoAds Value * "CET_VIDEO_ADS" */ @property(copy, nullable) NSString *type; @end /** * Google Partners certification status. */ @interface GTLRPartners_CertificationStatus : GTLRObject /** List of certification exam statuses. */ @property(strong, nullable) NSArray<GTLRPartners_CertificationExamStatus *> *examStatuses; /** * Whether certification is passing. * * Uses NSNumber of boolValue. */ @property(strong, nullable) NSNumber *isCertified; /** * The type of the certification. * * Likely values: * @arg @c kGTLRPartners_CertificationStatus_Type_CertificationTypeUnspecified * Value "CERTIFICATION_TYPE_UNSPECIFIED" * @arg @c kGTLRPartners_CertificationStatus_Type_CtAdwords Value * "CT_ADWORDS" * @arg @c kGTLRPartners_CertificationStatus_Type_CtAnalytics Value * "CT_ANALYTICS" * @arg @c kGTLRPartners_CertificationStatus_Type_CtDoubleclick Value * "CT_DOUBLECLICK" * @arg @c kGTLRPartners_CertificationStatus_Type_CtMobile Value "CT_MOBILE" * @arg @c kGTLRPartners_CertificationStatus_Type_CtShopping Value * "CT_SHOPPING" * @arg @c kGTLRPartners_CertificationStatus_Type_CtVideoads Value * "CT_VIDEOADS" * @arg @c kGTLRPartners_CertificationStatus_Type_CtYoutube Value * "CT_YOUTUBE" */ @property(copy, nullable) NSString *type; @end /** * A company resource in the Google Partners API. Once certified, it qualifies * for being searched by advertisers. */ @interface GTLRPartners_Company : GTLRObject /** The list of Google Partners certification statuses for the company. */ @property(strong, nullable) NSArray<GTLRPartners_CertificationStatus *> *certificationStatuses; /** * The minimum monthly budget that the company accepts for partner business, * converted to the requested currency code. */ @property(strong, nullable) GTLRPartners_Money *convertedMinMonthlyBudget; /** * The ID of the company. * * identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). */ @property(copy, nullable) NSString *identifier; /** Industries the company can help with. */ @property(strong, nullable) NSArray<NSString *> *industries; /** The list of localized info for the company. */ @property(strong, nullable) NSArray<GTLRPartners_LocalizedCompanyInfo *> *localizedInfos; /** The list of company locations. */ @property(strong, nullable) NSArray<GTLRPartners_Location *> *locations; /** The name of the company. */ @property(copy, nullable) NSString *name; /** * The unconverted minimum monthly budget that the company accepts for partner * business. */ @property(strong, nullable) GTLRPartners_Money *originalMinMonthlyBudget; /** Basic information from the company's public profile. */ @property(strong, nullable) GTLRPartners_PublicProfile *publicProfile; /** * Information related to the ranking of the company within the list of * companies. */ @property(strong, nullable) NSArray<GTLRPartners_Rank *> *ranks; /** Services the company can help with. */ @property(strong, nullable) NSArray<NSString *> *services; /** URL of the company's website. */ @property(copy, nullable) NSString *websiteUrl; @end /** * Request message for CreateLead. */ @interface GTLRPartners_CreateLeadRequest : GTLRObject /** * The lead resource. The `LeadType` must not be `LEAD_TYPE_UNSPECIFIED` and * either `email` or `phone_number` must be provided. */ @property(strong, nullable) GTLRPartners_Lead *lead; /** reCaptcha challenge info. */ @property(strong, nullable) GTLRPartners_RecaptchaChallenge *recaptchaChallenge; /** Current request metadata. */ @property(strong, nullable) GTLRPartners_RequestMetadata *requestMetadata; @end /** * Response message for CreateLead. Debug information about this request. */ @interface GTLRPartners_CreateLeadResponse : GTLRObject /** Lead that was created depending on the outcome of reCaptcha validation. */ @property(strong, nullable) GTLRPartners_Lead *lead; /** * The outcome of reCaptcha validation. * * Likely values: * @arg @c kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RecaptchaStatusUnspecified * Value "RECAPTCHA_STATUS_UNSPECIFIED" * @arg @c kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsFailed Value * "RS_FAILED" * @arg @c kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsNotNeeded Value * "RS_NOT_NEEDED" * @arg @c kGTLRPartners_CreateLeadResponse_RecaptchaStatus_RsPassed Value * "RS_PASSED" */ @property(copy, nullable) NSString *recaptchaStatus; /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; @end /** * Debug information about this request. */ @interface GTLRPartners_DebugInfo : GTLRObject /** Info about the server that serviced this request. */ @property(copy, nullable) NSString *serverInfo; /** Server-side debug stack trace. */ @property(copy, nullable) NSString *serverTraceInfo; /** URL of the service that handled this request. */ @property(copy, nullable) NSString *serviceUrl; @end /** * Key value data pair for an event. */ @interface GTLRPartners_EventData : GTLRObject /** * Data type. * * Likely values: * @arg @c kGTLRPartners_EventData_Key_Action Value "ACTION" * @arg @c kGTLRPartners_EventData_Key_AgencyId Value "AGENCY_ID" * @arg @c kGTLRPartners_EventData_Key_AgencyName Value "AGENCY_NAME" * @arg @c kGTLRPartners_EventData_Key_AgencyPhoneNumber Value * "AGENCY_PHONE_NUMBER" * @arg @c kGTLRPartners_EventData_Key_AgencyWebsite Value "AGENCY_WEBSITE" * @arg @c kGTLRPartners_EventData_Key_Budget Value "BUDGET" * @arg @c kGTLRPartners_EventData_Key_CenterPoint Value "CENTER_POINT" * @arg @c kGTLRPartners_EventData_Key_Certification Value "CERTIFICATION" * @arg @c kGTLRPartners_EventData_Key_Comment Value "COMMENT" * @arg @c kGTLRPartners_EventData_Key_Country Value "COUNTRY" * @arg @c kGTLRPartners_EventData_Key_Currency Value "CURRENCY" * @arg @c kGTLRPartners_EventData_Key_CurrentlyViewedAgencyId Value * "CURRENTLY_VIEWED_AGENCY_ID" * @arg @c kGTLRPartners_EventData_Key_Details Value "DETAILS" * @arg @c kGTLRPartners_EventData_Key_Distance Value "DISTANCE" * @arg @c kGTLRPartners_EventData_Key_DistanceType Value "DISTANCE_TYPE" * @arg @c kGTLRPartners_EventData_Key_ElementFocus Value "ELEMENT_FOCUS" * @arg @c kGTLRPartners_EventData_Key_EventDataTypeUnspecified Value * "EVENT_DATA_TYPE_UNSPECIFIED" * @arg @c kGTLRPartners_EventData_Key_Exam Value "EXAM" * @arg @c kGTLRPartners_EventData_Key_ExperimentId Value "EXPERIMENT_ID" * @arg @c kGTLRPartners_EventData_Key_GpsMotivation Value "GPS_MOTIVATION" * @arg @c kGTLRPartners_EventData_Key_HistoryToken Value "HISTORY_TOKEN" * @arg @c kGTLRPartners_EventData_Key_Identifier Value "IDENTIFIER" * @arg @c kGTLRPartners_EventData_Key_Industry Value "INDUSTRY" * @arg @c kGTLRPartners_EventData_Key_InsightTag Value "INSIGHT_TAG" * @arg @c kGTLRPartners_EventData_Key_Language Value "LANGUAGE" * @arg @c kGTLRPartners_EventData_Key_Location Value "LOCATION" * @arg @c kGTLRPartners_EventData_Key_MarketingOptIn Value * "MARKETING_OPT_IN" * @arg @c kGTLRPartners_EventData_Key_Progress Value "PROGRESS" * @arg @c kGTLRPartners_EventData_Key_Query Value "QUERY" * @arg @c kGTLRPartners_EventData_Key_SearchStartIndex Value * "SEARCH_START_INDEX" * @arg @c kGTLRPartners_EventData_Key_Service Value "SERVICE" * @arg @c kGTLRPartners_EventData_Key_ShowVow Value "SHOW_VOW" * @arg @c kGTLRPartners_EventData_Key_Solution Value "SOLUTION" * @arg @c kGTLRPartners_EventData_Key_TrafficSourceId Value * "TRAFFIC_SOURCE_ID" * @arg @c kGTLRPartners_EventData_Key_TrafficSubId Value "TRAFFIC_SUB_ID" * @arg @c kGTLRPartners_EventData_Key_Url Value "URL" * @arg @c kGTLRPartners_EventData_Key_ViewPort Value "VIEW_PORT" * @arg @c kGTLRPartners_EventData_Key_Website Value "WEBSITE" */ @property(copy, nullable) NSString *key; /** Data values. */ @property(strong, nullable) NSArray<NSString *> *values; @end /** * Response message for GetCompany. */ @interface GTLRPartners_GetCompanyResponse : GTLRObject /** The company. */ @property(strong, nullable) GTLRPartners_Company *company; /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; @end /** * An object representing a latitude/longitude pair. This is expressed as a * pair of doubles representing degrees latitude and degrees longitude. Unless * specified otherwise, this must conform to the WGS84 standard. Values must be * within normalized ranges. Example of normalization code in Python: def * NormalizeLongitude(longitude): """Wrapsdecimal degrees longitude to [-180.0, * 180.0].""" q, r = divmod(longitude, 360.0) if r > 180.0 or (r == 180.0 and q * <= -1.0): return r - 360.0 return r def NormalizeLatLng(latitude, * longitude): """Wraps decimal degrees latitude and longitude to [-180.0, * 180.0] and [-90.0, 90.0], respectively.""" r = latitude % 360.0 if r = * 270.0: return r - 360, NormalizeLongitude(longitude) else: return 180 - r, * NormalizeLongitude(longitude + 180.0) assert 180.0 == * NormalizeLongitude(180.0) assert -180.0 == NormalizeLongitude(-180.0) assert * -179.0 == NormalizeLongitude(181.0) assert (0.0, 0.0) == * NormalizeLatLng(360.0, 0.0) assert (0.0, 0.0) == NormalizeLatLng(-360.0, * 0.0) assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0) assert (-85.0, * -170.0) == NormalizeLatLng(-95.0, 10.0) assert (90.0, 10.0) == * NormalizeLatLng(90.0, 10.0) assert (-90.0, -10.0) == NormalizeLatLng(-90.0, * -10.0) assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0) assert (0.0, * -170.0) == NormalizeLatLng(180.0, 10.0) assert (-90.0, 10.0) == * NormalizeLatLng(270.0, 10.0) assert (90.0, 10.0) == NormalizeLatLng(-270.0, * 10.0) */ @interface GTLRPartners_LatLng : GTLRObject /** * The latitude in degrees. It must be in the range [-90.0, +90.0]. * * Uses NSNumber of doubleValue. */ @property(strong, nullable) NSNumber *latitude; /** * The longitude in degrees. It must be in the range [-180.0, +180.0]. * * Uses NSNumber of doubleValue. */ @property(strong, nullable) NSNumber *longitude; @end /** * A lead resource that represents an advertiser contact for a `Company`. These * are usually generated via Google Partner Search (the advertiser portal). */ @interface GTLRPartners_Lead : GTLRObject /** Comments lead source gave. */ @property(copy, nullable) NSString *comments; /** Email address of lead source. */ @property(copy, nullable) NSString *email; /** Last name of lead source. */ @property(copy, nullable) NSString *familyName; /** First name of lead source. */ @property(copy, nullable) NSString *givenName; /** List of reasons for using Google Partner Search and creating a lead. */ @property(strong, nullable) NSArray<NSString *> *gpsMotivations; /** * ID of the lead. * * identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). */ @property(copy, nullable) NSString *identifier; /** The minimum monthly budget lead source is willing to spend. */ @property(strong, nullable) GTLRPartners_Money *minMonthlyBudget; /** Phone number of lead source. */ @property(copy, nullable) NSString *phoneNumber; /** * Type of lead. * * Likely values: * @arg @c kGTLRPartners_Lead_Type_LeadTypeUnspecified Value * "LEAD_TYPE_UNSPECIFIED" * @arg @c kGTLRPartners_Lead_Type_LtGps Value "LT_GPS" */ @property(copy, nullable) NSString *type; /** Website URL of lead source. */ @property(copy, nullable) NSString *websiteUrl; @end /** * Response message for ListCompanies. * * @note This class supports NSFastEnumeration and indexed subscripting over * its "companies" property. If returned as the result of a query, it * should support automatic pagination (when @c shouldFetchNextPages is * enabled). */ @interface GTLRPartners_ListCompaniesResponse : GTLRCollectionObject /** * The list of companies. * * @note This property is used to support NSFastEnumeration and indexed * subscripting on this class. */ @property(strong, nullable) NSArray<GTLRPartners_Company *> *companies; /** * A token to retrieve next page of results. Pass this value in the * `ListCompaniesRequest.page_token` field in the subsequent call to * ListCompanies to retrieve the next page of results. */ @property(copy, nullable) NSString *nextPageToken; /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; @end /** * Response message for ListUserStates. */ @interface GTLRPartners_ListUserStatesResponse : GTLRObject /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; /** User's states. */ @property(strong, nullable) NSArray<NSString *> *userStates; @end /** * The localized company information. */ @interface GTLRPartners_LocalizedCompanyInfo : GTLRObject /** List of country codes for the localized company info. */ @property(strong, nullable) NSArray<NSString *> *countryCodes; /** Localized display name. */ @property(copy, nullable) NSString *displayName; /** * Language code of the localized company info, as defined by BCP 47 (IETF BCP * 47, "Tags for Identifying Languages"). */ @property(copy, nullable) NSString *languageCode; /** * Localized brief description that the company uses to advertise themselves. */ @property(copy, nullable) NSString *overview; @end /** * A location with address and geographic coordinates. */ @interface GTLRPartners_Location : GTLRObject /** The complete address of the location. */ @property(copy, nullable) NSString *address; /** The latitude and longitude of the location, in degrees. */ @property(strong, nullable) GTLRPartners_LatLng *latLng; @end /** * Request message for LogClientMessage. */ @interface GTLRPartners_LogMessageRequest : GTLRObject /** * Map of client info, such as URL, browser navigator, browser platform, etc. */ @property(strong, nullable) GTLRPartners_LogMessageRequestClientInfo *clientInfo; /** Details about the client message. */ @property(copy, nullable) NSString *details; /** * Message level of client message. * * Likely values: * @arg @c kGTLRPartners_LogMessageRequest_Level_MessageLevelUnspecified * Value "MESSAGE_LEVEL_UNSPECIFIED" * @arg @c kGTLRPartners_LogMessageRequest_Level_MlFine Value "ML_FINE" * @arg @c kGTLRPartners_LogMessageRequest_Level_MlInfo Value "ML_INFO" * @arg @c kGTLRPartners_LogMessageRequest_Level_MlSevere Value "ML_SEVERE" * @arg @c kGTLRPartners_LogMessageRequest_Level_MlWarning Value "ML_WARNING" */ @property(copy, nullable) NSString *level; /** Current request metadata. */ @property(strong, nullable) GTLRPartners_RequestMetadata *requestMetadata; @end /** * Map of client info, such as URL, browser navigator, browser platform, etc. * * @note This class is documented as having more properties of NSString. Use @c * -additionalJSONKeys and @c -additionalPropertyForName: to get the list * of properties and then fetch them; or @c -additionalProperties to * fetch them all at once. */ @interface GTLRPartners_LogMessageRequestClientInfo : GTLRObject @end /** * Response message for LogClientMessage. */ @interface GTLRPartners_LogMessageResponse : GTLRObject /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; @end /** * Request message for LogUserEvent. */ @interface GTLRPartners_LogUserEventRequest : GTLRObject /** * The action that occurred. * * Likely values: * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedCreateMccConnectWithCompanyNotFound * Value "AGECNY_CLICKED_CREATE_MCC_CONNECT_WITH_COMPANY_NOT_FOUND" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedGiveEditAccessConnectWithCompanyNotFound * Value "AGECNY_CLICKED_GIVE_EDIT_ACCESS_CONNECT_WITH_COMPANY_NOT_FOUND" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgecnyClickedLogOutConnectWithCompanyNotFound * Value "AGECNY_CLICKED_LOG_OUT_CONNECT_WITH_COMPANY_NOT_FOUND" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgecnyFoundCompanyToConnectWith * Value "AGECNY_FOUND_COMPANY_TO_CONNECT_WITH" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedAddressInMyProfilePortal * Value "AGENCY_ADDED_ADDRESS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedChannelsInMyProfilePortal * Value "AGENCY_ADDED_CHANNELS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedIndustriesInMyProfilePortal * Value "AGENCY_ADDED_INDUSTRIES_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedJobFunctionInMyProfilePortal * Value "AGENCY_ADDED_JOB_FUNCTION_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedMarketsInMyProfilePortal * Value "AGENCY_ADDED_MARKETS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedNewCompanyLocation * Value "AGENCY_ADDED_NEW_COMPANY_LOCATION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyAddedPhoneNumberInMyProfilePortal * Value "AGENCY_ADDED_PHONE_NUMBER_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedAddIndustriesDropDown * Value "AGENCY_CHANGED_ADD_INDUSTRIES_DROP_DOWN" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedAddMarketsDropDown * Value "AGENCY_CHANGED_ADD_MARKETS_DROP_DOWN" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedPrimaryAccountAssociation * Value "AGENCY_CHANGED_PRIMARY_ACCOUNT_ASSOCIATION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedPrimaryCountryAssociation * Value "AGENCY_CHANGED_PRIMARY_COUNTRY_ASSOCIATION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedRoles * Value "AGENCY_CHANGED_ROLES" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyChangedTosCountry * Value "AGENCY_CHANGED_TOS_COUNTRY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyCheckedRecieveMailPromotionsMyprofile * Value "AGENCY_CHECKED_RECIEVE_MAIL_PROMOTIONS_MYPROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyCheckedRecieveMailPromotionsSignup * Value "AGENCY_CHECKED_RECIEVE_MAIL_PROMOTIONS_SIGNUP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedAcceptTosButton * Value "AGENCY_CLICKED_ACCEPT_TOS_BUTTON" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedAffiliateButtonInMyProfileInPortal * Value "AGENCY_CLICKED_AFFILIATE_BUTTON_IN_MY_PROFILE_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedBackButtonOnConnectWithCompany * Value "AGENCY_CLICKED_BACK_BUTTON_ON_CONNECT_WITH_COMPANY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCancelAcceptTosButton * Value "AGENCY_CLICKED_CANCEL_ACCEPT_TOS_BUTTON" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCertificationsLeftNavInPortal * Value "AGENCY_CLICKED_CERTIFICATIONS_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCertificationsProductLeftNavInPortal * Value "AGENCY_CLICKED_CERTIFICATIONS_PRODUCT_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCommunityJoinNowLinkInPortalNotifications * Value "AGENCY_CLICKED_COMMUNITY_JOIN_NOW_LINK_IN_PORTAL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCommunityLeftNavInPortal * Value "AGENCY_CLICKED_COMMUNITY_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedConnectToCompanyLinkInPortalNotifications * Value "AGENCY_CLICKED_CONNECT_TO_COMPANY_LINK_IN_PORTAL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedContinueToOverviewOnConnectWithCompany * Value "AGENCY_CLICKED_CONTINUE_TO_OVERVIEW_ON_CONNECT_WITH_COMPANY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedCreateMccInMyProfilePortal * Value "AGENCY_CLICKED_CREATE_MCC_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedExamDetailsOnCertAdwordsPage * Value "AGENCY_CLICKED_EXAM_DETAILS_ON_CERT_ADWORDS_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGetCertifiedLinkInPortalNotifications * Value "AGENCY_CLICKED_GET_CERTIFIED_LINK_IN_PORTAL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGetVideoAdsCertifiedLinkInPortalNotifications * Value * "AGENCY_CLICKED_GET_VIDEO_ADS_CERTIFIED_LINK_IN_PORTAL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedGiveEditAccessInMyProfilePortal * Value "AGENCY_CLICKED_GIVE_EDIT_ACCESS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightContentInPortal * Value "AGENCY_CLICKED_INSIGHT_CONTENT_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsDownloadContent * Value "AGENCY_CLICKED_INSIGHTS_DOWNLOAD_CONTENT" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsLeftNavInPortal * Value "AGENCY_CLICKED_INSIGHTS_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsUploadContent * Value "AGENCY_CLICKED_INSIGHTS_UPLOAD_CONTENT" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsViewedDeprecated * Value "AGENCY_CLICKED_INSIGHTS_VIEWED_DEPRECATED" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedInsightsViewNowPitchDecksInPortal * Value "AGENCY_CLICKED_INSIGHTS_VIEW_NOW_PITCH_DECKS_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinCommunityButtonCommunityPortal * Value "AGENCY_CLICKED_JOIN_COMMUNITY_BUTTON_COMMUNITY_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinNowButtonBottom * Value "AGENCY_CLICKED_JOIN_NOW_BUTTON_BOTTOM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedJoinNowButtonTop * Value "AGENCY_CLICKED_JOIN_NOW_BUTTON_TOP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLeftNavStories * Value "AGENCY_CLICKED_LEFT_NAV_STORIES" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLinkToMccLinkInPortalNotifications * Value "AGENCY_CLICKED_LINK_TO_MCC_LINK_IN_PORTAL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedLogOutInMyProfilePortal * Value "AGENCY_CLICKED_LOG_OUT_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedMyProfileLeftNavInPortal * Value "AGENCY_CLICKED_MY_PROFILE_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedOffersLeftNavInPortal * Value "AGENCY_CLICKED_OFFERS_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedPartnerStatusLeftNavInPortal * Value "AGENCY_CLICKED_PARTNER_STATUS_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedPartnerStatusProductLeftNavInPortal * Value "AGENCY_CLICKED_PARTNER_STATUS_PRODUCT_LEFT_NAV_IN_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSaveAndContinueAtBotOfCompleteProfile * Value "AGENCY_CLICKED_SAVE_AND_CONTINUE_AT_BOT_OF_COMPLETE_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSaveAndContinueAtBotOfIncompleteProfile * Value "AGENCY_CLICKED_SAVE_AND_CONTINUE_AT_BOT_OF_INCOMPLETE_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSeeExamsCertificationMainPage * Value "AGENCY_CLICKED_SEE_EXAMS_CERTIFICATION_MAIN_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSendButtonOnOffersPage * Value "AGENCY_CLICKED_SEND_BUTTON_ON_OFFERS_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSignInButtonTop * Value "AGENCY_CLICKED_SIGN_IN_BUTTON_TOP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedSkipForNowOnConnectWithCompanyPage * Value "AGENCY_CLICKED_SKIP_FOR_NOW_ON_CONNECT_WITH_COMPANY_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedTakeExamOnCertExamPage * Value "AGENCY_CLICKED_TAKE_EXAM_ON_CERT_EXAM_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClickedUnaffiliateInMyProfilePortal * Value "AGENCY_CLICKED_UNAFFILIATE_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyClosedConnectedToCompanyXButtonWrongCompany * Value "AGENCY_CLOSED_CONNECTED_TO_COMPANY_X_BUTTON_WRONG_COMPANY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyCompletedFieldConnectWithCompany * Value "AGENCY_COMPLETED_FIELD_CONNECT_WITH_COMPANY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyDidntHaveAnMccAssociatedOnCompleteProfile * Value "AGENCY_DIDNT_HAVE_AN_MCC_ASSOCIATED_ON_COMPLETE_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyDismissedAffiliationWidget * Value "AGENCY_DISMISSED_AFFILIATION_WIDGET" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyFailedCompanyVerification * Value "AGENCY_FAILED_COMPANY_VERIFICATION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyFilledOutCompAffiliationInMyProfilePortal * Value "AGENCY_FILLED_OUT_COMP_AFFILIATION_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyHadAnMccAssociatedOnCompleteProfile * Value "AGENCY_HAD_AN_MCC_ASSOCIATED_ON_COMPLETE_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyIgnoredSuggestedAgenciesAndSearched * Value "AGENCY_IGNORED_SUGGESTED_AGENCIES_AND_SEARCHED" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyLinkedIndividualMcc * Value "AGENCY_LINKED_INDIVIDUAL_MCC" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyLookedAtAddChannelDropDown * Value "AGENCY_LOOKED_AT_ADD_CHANNEL_DROP_DOWN" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyLookedAtJobFunctionDropDown * Value "AGENCY_LOOKED_AT_JOB_FUNCTION_DROP_DOWN" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyOpenedDialogWithNoUsers * Value "AGENCY_OPENED_DIALOG_WITH_NO_USERS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyOpenedLastAdminDialog * Value "AGENCY_OPENED_LAST_ADMIN_DIALOG" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyPickedSearchedAgency * Value "AGENCY_PICKED_SEARCHED_AGENCY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyPickedSuggestedAgency * Value "AGENCY_PICKED_SUGGESTED_AGENCY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyProgressInsightsViewContent * Value "AGENCY_PROGRESS_INSIGHTS_VIEW_CONTENT" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyPromotedUserToAdmin * Value "AGENCY_PROMOTED_USER_TO_ADMIN" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySearchedForAgencies * Value "AGENCY_SEARCHED_FOR_AGENCIES" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAccountManagerAsJobFunction * Value "AGENCY_SELECTED_ACCOUNT_MANAGER_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAccountPlannerAsJobFunction * Value "AGENCY_SELECTED_ACCOUNT_PLANNER_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedAnalyticsAsJobFunction * Value "AGENCY_SELECTED_ANALYTICS_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedCreativeAsJobFunction * Value "AGENCY_SELECTED_CREATIVE_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedCrossChannelFromAddChannel * Value "AGENCY_SELECTED_CROSS_CHANNEL_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedDisplayFromAddChannel * Value "AGENCY_SELECTED_DISPLAY_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMediaBuyerAsJobFunction * Value "AGENCY_SELECTED_MEDIA_BUYER_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMediaPlannerAsJobFunction * Value "AGENCY_SELECTED_MEDIA_PLANNER_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedMobileFromAddChannel * Value "AGENCY_SELECTED_MOBILE_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInBetaTestsAndMktResearch * Value "AGENCY_SELECTED_OPT_IN_BETA_TESTS_AND_MKT_RESEARCH" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInBetaTestsInMyProfilePortal * Value "AGENCY_SELECTED_OPT_IN_BETA_TESTS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInNewsInMyProfilePortal * Value "AGENCY_SELECTED_OPT_IN_NEWS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInNewsInvitationsAndPromos * Value "AGENCY_SELECTED_OPT_IN_NEWS_INVITATIONS_AND_PROMOS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInPerformanceSuggestions * Value "AGENCY_SELECTED_OPT_IN_PERFORMANCE_SUGGESTIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInPerformanceSugInMyProfilePortal * Value "AGENCY_SELECTED_OPT_IN_PERFORMANCE_SUG_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptInSelectAllEmailNotifications * Value "AGENCY_SELECTED_OPT_IN_SELECT_ALL_EMAIL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOptOutUnselectAllEmailNotifications * Value "AGENCY_SELECTED_OPT_OUT_UNSELECT_ALL_EMAIL_NOTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedOtherAsJobFunction * Value "AGENCY_SELECTED_OTHER_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedProductionAsJobFunction * Value "AGENCY_SELECTED_PRODUCTION_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSalesRepAsJobFunction * Value "AGENCY_SELECTED_SALES_REP_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSearchFromAddChannel * Value "AGENCY_SELECTED_SEARCH_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSearchSpecialistAsJobFunction * Value "AGENCY_SELECTED_SEARCH_SPECIALIST_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSelectAllOptInsInMyProfilePortal * Value "AGENCY_SELECTED_SELECT_ALL_OPT_INS_IN_MY_PROFILE_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSeoAsJobFunction * Value "AGENCY_SELECTED_SEO_AS_JOB_FUNCTION" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedSocialFromAddChannel * Value "AGENCY_SELECTED_SOCIAL_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedToolsFromAddChannel * Value "AGENCY_SELECTED_TOOLS_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySelectedYoutubeFromAddChannel * Value "AGENCY_SELECTED_YOUTUBE_FROM_ADD_CHANNEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySuccessfullyConnectedWithCompanyInMyProfile * Value "AGENCY_SUCCESSFULLY_CONNECTED_WITH_COMPANY_IN_MY_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySuccessfullyCreatedCompany * Value "AGENCY_SUCCESSFULLY_CREATED_COMPANY" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencySuggestedToUser * Value "AGENCY_SUGGESTED_TO_USER" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnaffiliated * Value "AGENCY_UNAFFILIATED" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInBetaTestsAndMktResearch * Value "AGENCY_UNSELECTED_OPT_IN_BETA_TESTS_AND_MKT_RESEARCH" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInNewsInvitationsAndPromos * Value "AGENCY_UNSELECTED_OPT_IN_NEWS_INVITATIONS_AND_PROMOS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_AgencyUnselectedOptInPerformanceSuggestions * Value "AGENCY_UNSELECTED_OPT_IN_PERFORMANCE_SUGGESTIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_CancelledCompanySignUp * Value "CANCELLED_COMPANY_SIGN_UP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_CancelledIndividualSignUp * Value "CANCELLED_INDIVIDUAL_SIGN_UP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_Clicked Value * "CLICKED" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_ClickedHelpAtBottom * Value "CLICKED_HELP_AT_BOTTOM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_ClickedHelpAtTop * Value "CLICKED_HELP_AT_TOP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_ClientError Value * "CLIENT_ERROR" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_EventActionUnspecified * Value "EVENT_ACTION_UNSPECIFIED" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_PartnerViewedBySmb * Value "PARTNER_VIEWED_BY_SMB" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactForm * Value "SMB_CANCELED_PARTNER_CONTACT_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactFormOnGps * Value "SMB_CANCELED_PARTNER_CONTACT_FORM_ON_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCanceledPartnerContactFormOnProfilePage * Value "SMB_CANCELED_PARTNER_CONTACT_FORM_ON_PROFILE_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbChangedASearchParameterTop * Value "SMB_CHANGED_A_SEARCH_PARAMETER_TOP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedAdwordsCertificateHelpIcon * Value "SMB_CLICKED_ADWORDS_CERTIFICATE_HELP_ICON" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedCompanyNameLinkToProfile * Value "SMB_CLICKED_COMPANY_NAME_LINK_TO_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartner * Value "SMB_CLICKED_CONTACT_A_PARTNER" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartnerOnGps * Value "SMB_CLICKED_CONTACT_A_PARTNER_ON_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedContactAPartnerOnProfilePage * Value "SMB_CLICKED_CONTACT_A_PARTNER_ON_PROFILE_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedFindAPartnerButtonBottom * Value "SMB_CLICKED_FIND_A_PARTNER_BUTTON_BOTTOM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedFindAPartnerButtonTop * Value "SMB_CLICKED_FIND_A_PARTNER_BUTTON_TOP" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedPartnerWebsite * Value "SMB_CLICKED_PARTNER_WEBSITE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedShowMorePartnersButtonBottom * Value "SMB_CLICKED_SHOW_MORE_PARTNERS_BUTTON_BOTTOM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbClickedVideoAdsCertificateHelpIcon * Value "SMB_CLICKED_VIDEO_ADS_CERTIFICATE_HELP_ICON" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactForm * Value "SMB_COMPLETED_PARTNER_CONTACT_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactFormOnGps * Value "SMB_COMPLETED_PARTNER_CONTACT_FORM_ON_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbCompletedPartnerContactFormOnProfilePage * Value "SMB_COMPLETED_PARTNER_CONTACT_FORM_ON_PROFILE_PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredEmailInContactPartnerForm * Value "SMB_ENTERED_EMAIL_IN_CONTACT_PARTNER_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredNameInContactPartnerForm * Value "SMB_ENTERED_NAME_IN_CONTACT_PARTNER_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredPhoneInContactPartnerForm * Value "SMB_ENTERED_PHONE_IN_CONTACT_PARTNER_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbEnteredWebsiteInContactPartnerForm * Value "SMB_ENTERED_WEBSITE_IN_CONTACT_PARTNER_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbFailedRecaptchaInContactPartnerForm * Value "SMB_FAILED_RECAPTCHA_IN_CONTACT_PARTNER_FORM" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbNoPartnersAvailableWithSearchCriteria * Value "SMB_NO_PARTNERS_AVAILABLE_WITH_SEARCH_CRITERIA" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbPerformedSearchOnGps * Value "SMB_PERFORMED_SEARCH_ON_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAdwordsCertificate * Value "SMB_VIEWED_ADWORDS_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAnalyticsCertificate * Value "SMB_VIEWED_ANALYTICS_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAPartnerOnGps * Value "SMB_VIEWED_A_PARTNER_ON_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedAPartnerProfile * Value "SMB_VIEWED_A_PARTNER_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedDoubleclickCertificate * Value "SMB_VIEWED_DOUBLECLICK_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedMobileCertificate * Value "SMB_VIEWED_MOBILE_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedShoppingCertificate * Value "SMB_VIEWED_SHOPPING_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_SmbViewedVideoAdsCertificate * Value "SMB_VIEWED_VIDEO_ADS_CERTIFICATE" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_VisitedAgencyPortal * Value "VISITED_AGENCY_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_VisitedGps Value * "VISITED_GPS" * @arg @c kGTLRPartners_LogUserEventRequest_EventAction_VisitedLanding Value * "VISITED_LANDING" */ @property(copy, nullable) NSString *eventAction; /** * The category the action belongs to. * * Likely values: * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_EventCategoryUnspecified * Value "EVENT_CATEGORY_UNSPECIFIED" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_ExternalLinks * Value "EXTERNAL_LINKS" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerClient * Value "GOOGLE_PARTNER_CLIENT" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerLanding * Value "GOOGLE_PARTNER_LANDING" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPanel * Value "GOOGLE_PARTNER_PANEL" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortal * Value "GOOGLE_PARTNER_PORTAL" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCertifications * Value "GOOGLE_PARTNER_PORTAL_CERTIFICATIONS" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalClients * Value "GOOGLE_PARTNER_PORTAL_CLIENTS" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCommunity * Value "GOOGLE_PARTNER_PORTAL_COMMUNITY" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalCompanyProfile * Value "GOOGLE_PARTNER_PORTAL_COMPANY_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalInsights * Value "GOOGLE_PARTNER_PORTAL_INSIGHTS" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalLastAdminDialog * Value "GOOGLE_PARTNER_PORTAL_LAST_ADMIN_DIALOG" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPortalMyProfile * Value "GOOGLE_PARTNER_PORTAL_MY_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerPublicUserProfile * Value "GOOGLE_PARTNER_PUBLIC_USER_PROFILE" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerSearch * Value "GOOGLE_PARTNER_SEARCH" * @arg @c kGTLRPartners_LogUserEventRequest_EventCategory_GooglePartnerSignupFlow * Value "GOOGLE_PARTNER_SIGNUP_FLOW" */ @property(copy, nullable) NSString *eventCategory; /** List of event data for the event. */ @property(strong, nullable) NSArray<GTLRPartners_EventData *> *eventDatas; /** * The scope of the event. * * Likely values: * @arg @c kGTLRPartners_LogUserEventRequest_EventScope_EventScopeUnspecified * Value "EVENT_SCOPE_UNSPECIFIED" * @arg @c kGTLRPartners_LogUserEventRequest_EventScope_Page Value "PAGE" * @arg @c kGTLRPartners_LogUserEventRequest_EventScope_Session Value * "SESSION" * @arg @c kGTLRPartners_LogUserEventRequest_EventScope_Visitor Value * "VISITOR" */ @property(copy, nullable) NSString *eventScope; /** Advertiser lead information. */ @property(strong, nullable) GTLRPartners_Lead *lead; /** Current request metadata. */ @property(strong, nullable) GTLRPartners_RequestMetadata *requestMetadata; /** The URL where the event occurred. */ @property(copy, nullable) NSString *url; @end /** * Response message for LogUserEvent. */ @interface GTLRPartners_LogUserEventResponse : GTLRObject /** Current response metadata. */ @property(strong, nullable) GTLRPartners_ResponseMetadata *responseMetadata; @end /** * Represents an amount of money with its currency type. */ @interface GTLRPartners_Money : GTLRObject /** The 3-letter currency code defined in ISO 4217. */ @property(copy, nullable) NSString *currencyCode; /** * Number of nano (10^-9) units of the amount. The value must be between * -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` * must be positive or zero. If `units` is zero, `nanos` can be positive, zero, * or negative. If `units` is negative, `nanos` must be negative or zero. For * example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. * * Uses NSNumber of intValue. */ @property(strong, nullable) NSNumber *nanos; /** * The whole units of the amount. For example if `currencyCode` is `"USD"`, * then 1 unit is one US dollar. * * Uses NSNumber of longLongValue. */ @property(strong, nullable) NSNumber *units; @end /** * Basic information from a public profile. */ @interface GTLRPartners_PublicProfile : GTLRObject /** The URL to the main display image of the public profile. */ @property(copy, nullable) NSString *displayImageUrl; /** The display name of the public profile. */ @property(copy, nullable) NSString *displayName; /** * The ID which can be used to retrieve more details about the public profile. * * identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). */ @property(copy, nullable) NSString *identifier; /** The URL of the public profile. */ @property(copy, nullable) NSString *url; @end /** * Information related to ranking of results. */ @interface GTLRPartners_Rank : GTLRObject /** * The type of rank. * * Likely values: * @arg @c kGTLRPartners_Rank_Type_RankTypeUnspecified Value * "RANK_TYPE_UNSPECIFIED" * @arg @c kGTLRPartners_Rank_Type_RtFinalScore Value "RT_FINAL_SCORE" */ @property(copy, nullable) NSString *type; /** * The numerical value of the rank. * * Uses NSNumber of doubleValue. */ @property(strong, nullable) NSNumber *value; @end /** * reCaptcha challenge info. */ @interface GTLRPartners_RecaptchaChallenge : GTLRObject /** * The ID of the reCaptcha challenge. * * identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). */ @property(copy, nullable) NSString *identifier; /** The response to the reCaptcha challenge. */ @property(copy, nullable) NSString *response; @end /** * Common data that is in each API request. */ @interface GTLRPartners_RequestMetadata : GTLRObject /** Experiment IDs the current request belongs to. */ @property(strong, nullable) NSArray<NSString *> *experimentIds; /** Locale to use for the current request. */ @property(copy, nullable) NSString *locale; /** Google Partners session ID. */ @property(copy, nullable) NSString *partnersSessionId; /** Source of traffic for the current request. */ @property(strong, nullable) GTLRPartners_TrafficSource *trafficSource; /** * Values to use instead of the user's respective defaults for the current * request. These are only honored by whitelisted products. */ @property(strong, nullable) GTLRPartners_UserOverrides *userOverrides; @end /** * Common data that is in each API response. */ @interface GTLRPartners_ResponseMetadata : GTLRObject /** Debug information about this request. */ @property(strong, nullable) GTLRPartners_DebugInfo *debugInfo; @end /** * Source of traffic for the current request. */ @interface GTLRPartners_TrafficSource : GTLRObject /** * Identifier to indicate where the traffic comes from. An identifier has * multiple letters created by a team which redirected the traffic to us. */ @property(copy, nullable) NSString *trafficSourceId; /** * Second level identifier to indicate where the traffic comes from. An * identifier has multiple letters created by a team which redirected the * traffic to us. */ @property(copy, nullable) NSString *trafficSubId; @end /** * Values to use instead of the user's respective defaults. These are only * honored by whitelisted products. */ @interface GTLRPartners_UserOverrides : GTLRObject /** IP address to use instead of the user's geo-located IP address. */ @property(copy, nullable) NSString *ipAddress; /** Logged-in user ID to impersonate instead of the user's ID. */ @property(copy, nullable) NSString *userId; @end NS_ASSUME_NONNULL_END
53.08553
134
0.814395
[ "object" ]
e0d39ef3e19ba2e09a20195cbcde9fc5c389ad10
1,364
h
C
Engine/Source/Platform/Vulkan/VkShader.h
Claudio-Marchini/Lumen
41183d71f0fe6dfe9964617b127b40b26339c822
[ "MIT" ]
null
null
null
Engine/Source/Platform/Vulkan/VkShader.h
Claudio-Marchini/Lumen
41183d71f0fe6dfe9964617b127b40b26339c822
[ "MIT" ]
null
null
null
Engine/Source/Platform/Vulkan/VkShader.h
Claudio-Marchini/Lumen
41183d71f0fe6dfe9964617b127b40b26339c822
[ "MIT" ]
null
null
null
#pragma once #include <filesystem> #include <map> #include <unordered_map> #include <vulkan/vulkan.h> #include "VkDescriptorSet.h" #include "Graphics/Rhi/Shader.h" namespace Lumen::Graphics::Vulkan { class VkUniformBuffer; class VkPipeline; class VkShader final : public Shader { public: VkShader() = default; explicit VkShader(const std::unordered_map<std::string, ShaderStage>& sources); ~VkShader() override { VkShader::Release(); } [[nodiscard]] const std::vector<VkPipelineShaderStageCreateInfo>& PipelineStages() const { return mPipelineInfos; } [[nodiscard]] const VkDescriptorSet& DescriptorSet(u32 setIndex) const { return mDescriptorSets.at(setIndex); } [[nodiscard]] std::vector<VkDescriptorSetLayout> DescriptorsLayout() const; [[nodiscard]] const std::vector<VkPushConstantRange>& PushConstants() const { return mPushConstants; } void Init() override; void Release() override; static void SetInterface(); private: void CreateModule(const std::vector<u32>& blob, VkShaderStageFlagBits stage); void Reflect(const std::vector<u32>& blob, VkShaderStageFlagBits stage); std::vector<VkShaderModule> mModules{}; std::vector<VkPipelineShaderStageCreateInfo> mPipelineInfos{}; std::map<setLocation, VkDescriptorSet> mDescriptorSets{}; std::vector<VkPushConstantRange> mPushConstants{}; }; }
31
118
0.744868
[ "vector" ]
e0d7b2f7ebefe171ff493c13a1e07212d0056bc2
2,238
h
C
src/core/include/core/Token.h
jonathanhaigh/sq
6ca366b86ff6436620c36eabb1f0103cab88722b
[ "MIT" ]
1
2020-11-12T16:21:41.000Z
2020-11-12T16:21:41.000Z
src/core/include/core/Token.h
jonathanhaigh/sq
6ca366b86ff6436620c36eabb1f0103cab88722b
[ "MIT" ]
44
2021-02-08T19:17:57.000Z
2021-04-05T18:51:38.000Z
src/core/include/core/Token.h
jonathanhaigh/sq
6ca366b86ff6436620c36eabb1f0103cab88722b
[ "MIT" ]
null
null
null
/* ----------------------------------------------------------------------------- * Copyright 2021 Jonathan Haigh * SPDX-License-Identifier: MIT * ---------------------------------------------------------------------------*/ #ifndef SQ_INCLUDE_GUARD_core_Token_h_ #define SQ_INCLUDE_GUARD_core_Token_h_ #include "Token.fwd.h" #include "core/typeutil.h" #include <gsl/gsl> #include <iosfwd> #include <regex> #include <string_view> #include <vector> namespace sq { enum class TokenKind : int { BoolFalse, BoolTrue, Colon, Comma, Dot, DQString, Eof, Equals, Float, GreaterThan, GreaterThanOrEqualTo, Identifier, Integer, LBrace, LBracket, LessThan, LessThanOrEqualTo, LParen, RBrace, RBracket, RParen }; class Token { public: /** * Create a Token object. * * @param query the full query string in which the token was found. * @param pos the character position within the query at which the token * was found. * @param len the length, in characters, of the token. * @param kind the kind of the token. */ Token(std::string_view query, gsl::index pos, gsl::index len, TokenKind kind) noexcept; /** * Get the full query string in which the token was found. */ SQ_ND std::string_view query() const noexcept; /** * Get the character position within the query at which the token was * found. */ SQ_ND gsl::index pos() const noexcept; /** * Get the length, in characters, of the token. */ SQ_ND gsl::index len() const noexcept; /** * Get a std::string_view pointing to the characters of the token. */ SQ_ND std::string_view view() const noexcept; /** * Get the kind of the token. */ SQ_ND TokenKind kind() const noexcept; private: std::string_view query_; gsl::index pos_; gsl::index len_; TokenKind kind_; }; std::ostream &operator<<(std::ostream &os, TokenKind kind); /** * Print information about a token. * * The text printed includes information about the position of the token in the * input query, not just the characters that make up the token. */ std::ostream &operator<<(std::ostream &os, const Token &token); } // namespace sq #endif // SQ_INCLUDE_GUARD_core_Token_h_
21.314286
80
0.632261
[ "object", "vector" ]
e0de215e026dd48cb669cc331392ded964bbaff0
5,517
h
C
Engine/foundation/messaging/asyncport.h
BikkyS/DreamEngine
47da4e22c65188c72f44591f6a96505d8ba5f5f3
[ "MIT" ]
26
2015-01-15T12:57:40.000Z
2022-02-16T10:07:12.000Z
Engine/foundation/messaging/asyncport.h
BikkyS/DreamEngine
47da4e22c65188c72f44591f6a96505d8ba5f5f3
[ "MIT" ]
null
null
null
Engine/foundation/messaging/asyncport.h
BikkyS/DreamEngine
47da4e22c65188c72f44591f6a96505d8ba5f5f3
[ "MIT" ]
17
2015-02-18T07:51:31.000Z
2020-06-01T01:10:12.000Z
#pragma once /**************************************************************************** Copyright (c) 2006, Radon Labs GmbH Copyright (c) 2011-2013,WebJet Business Division,CYOU http://www.genesis-3d.com.cn 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 "messaging/message.h" #include "messaging/handler.h" #include "messaging/handlerthreadbase.h" //------------------------------------------------------------------------------ namespace Messaging { class AsyncPort : public Core::RefCounted { __DeclareClass(AsyncPort); public: /// constructor AsyncPort(); /// destructor virtual ~AsyncPort(); /// set pointer to handler thread object (must be derived from HandlerThreadBase) void SetHandlerThread(const GPtr<HandlerThreadBase>& handlerThread); /// get pointer to handler thread object const GPtr<HandlerThreadBase>& GetHandlerThread() const; /// attach a handler to the port, may be called before or after Open() virtual void AttachHandler(const GPtr<Handler>& h); /// dynamically remove a handler from the port virtual void RemoveHandler(const GPtr<Handler>& h); /// open the async port virtual void Open(); /// close the async port virtual void Close(); /// return true if port is open bool IsOpen() const; /// send an asynchronous message to the port template<class MESSAGETYPE> void Send(const GPtr<MESSAGETYPE>& msg); /// send a message and wait for completion template<class MESSAGETYPE> void SendWait(const GPtr<MESSAGETYPE>& msg); /// wait for a message to be handled template<class MESSAGETYPE> void Wait(const GPtr<MESSAGETYPE>& msg); /// peek a message whether it has been handled template<class MESSAGETYPE> bool Peek(const GPtr<MESSAGETYPE>& msg); /// cancel a pending message template<class MESSAGETYPE> void Cancel(const GPtr<MESSAGETYPE>& msg); private: /// send an asynchronous message to the port void SendInternal(const GPtr<Message>& msg); /// send a message and wait for completion void SendWaitInternal(const GPtr<Message>& msg); /// wait for a message to be handled void WaitInternal(const GPtr<Message>& msg); /// peek a message whether it has been handled bool PeekInternal(const GPtr<Message>& msg); /// cancel a pending message void CancelInternal(const GPtr<Message>& msg); private: /// clear all attached message handlers void ClearHandlers(); GPtr<HandlerThreadBase> thread; bool isOpen; }; //------------------------------------------------------------------------------ /** */ inline void AsyncPort::SetHandlerThread(const GPtr<HandlerThreadBase>& handlerThread) { n_assert(!this->IsOpen()); this->thread = handlerThread; } //------------------------------------------------------------------------------ /** */ inline const GPtr<HandlerThreadBase>& AsyncPort::GetHandlerThread() const { return this->thread; } //------------------------------------------------------------------------------ /** */ inline bool AsyncPort::IsOpen() const { return this->isOpen; } //------------------------------------------------------------------------------ /** */ template<class MESSAGETYPE> inline void AsyncPort::Send(const GPtr<MESSAGETYPE>& msg) { this->SendInternal((const GPtr<Messaging::Message>&)msg); } //------------------------------------------------------------------------------ /** */ template<class MESSAGETYPE> inline void AsyncPort::SendWait(const GPtr<MESSAGETYPE>& msg) { this->SendWaitInternal((const GPtr<Messaging::Message>&)msg); } //------------------------------------------------------------------------------ /** */ template<class MESSAGETYPE> inline void AsyncPort::Wait(const GPtr<MESSAGETYPE>& msg) { this->WaitInternal((const GPtr<Messaging::Message>&)msg); } //------------------------------------------------------------------------------ /** */ template<class MESSAGETYPE> inline bool AsyncPort::Peek(const GPtr<MESSAGETYPE>& msg) { return this->PeekInternal((const GPtr<Messaging::Message>&)msg); } //------------------------------------------------------------------------------ /** */ template<class MESSAGETYPE> inline void AsyncPort::Cancel(const GPtr<MESSAGETYPE>& msg) { this->CancelInternal((const GPtr<Messaging::Message>&)msg); } } // namespace Messaging //------------------------------------------------------------------------------
33.23494
85
0.600145
[ "object", "3d" ]
e0e094c17d729041de7d6bcf8d7623b14b4ca2e5
9,882
c
C
examples/ps/client/generated/ps_process.c
Parrot-Developers/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
null
null
null
examples/ps/client/generated/ps_process.c
Parrot-Developers/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
1
2021-03-31T10:29:33.000Z
2021-03-31T10:29:33.000Z
examples/ps/client/generated/ps_process.c
isabella232/obus
d7104526659a12cccc1799e88f96192d9b1b5345
[ "BSD-3-Clause" ]
1
2016-11-03T10:42:14.000Z
2016-11-03T10:42:14.000Z
/** * @file ps_process.c * * @brief obus ps_process object client api * * @author obusgen 1.0.3 generated file, do not modify it. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <stdint.h> #include <string.h> #define OBUS_USE_PRIVATE #include "libobus.h" #include "libobus_private.h" #include "ps_process.h" int ps_process_state_is_valid(int32_t value) { return (value == PS_PROCESS_STATE_UNKNOWN || value == PS_PROCESS_STATE_RUNNING || value == PS_PROCESS_STATE_SLEEPING || value == PS_PROCESS_STATE_STOPPED || value == PS_PROCESS_STATE_ZOMBIE); } const char *ps_process_state_str(enum ps_process_state value) { const char *str; switch (value) { case PS_PROCESS_STATE_UNKNOWN: str = "UNKNOWN"; break; case PS_PROCESS_STATE_RUNNING: str = "RUNNING"; break; case PS_PROCESS_STATE_SLEEPING: str = "SLEEPING"; break; case PS_PROCESS_STATE_STOPPED: str = "STOPPED"; break; case PS_PROCESS_STATE_ZOMBIE: str = "ZOMBIE"; break; default: str = "???"; break; } return str; } static void ps_process_state_set_value(void *addr, int32_t value) { enum ps_process_state *v = addr; *v = (enum ps_process_state)value; } static int32_t ps_process_state_get_value(const void *addr) { const enum ps_process_state *v = addr; return (int32_t) (*v); } static void ps_process_state_format(const void *addr, char *buf, size_t size) { const enum ps_process_state *v = addr; if (ps_process_state_is_valid((int32_t) (*v))) snprintf(buf, size, "%s", ps_process_state_str(*v)); else snprintf(buf, size, "??? (%d)", (int32_t) (*v)); } static const struct obus_enum_driver ps_process_state_driver = { .name = "ps_process_state", .size = sizeof(enum ps_process_state), .default_value = PS_PROCESS_STATE_UNKNOWN, .is_valid = ps_process_state_is_valid, .set_value = ps_process_state_set_value, .get_value = ps_process_state_get_value, .format = ps_process_state_format }; enum ps_process_field_type { PS_PROCESS_FIELD_PID = 0, PS_PROCESS_FIELD_PPID, PS_PROCESS_FIELD_NAME, PS_PROCESS_FIELD_EXE, PS_PROCESS_FIELD_PCPU, PS_PROCESS_FIELD_STATE, }; static const struct obus_field_desc ps_process_info_fields[] = { [PS_PROCESS_FIELD_PID] = { .uid = 1, .name = "pid", .offset = obus_offsetof(struct ps_process_info, pid), .role = OBUS_PROPERTY, .type = OBUS_FIELD_U32, }, [PS_PROCESS_FIELD_PPID] = { .uid = 2, .name = "ppid", .offset = obus_offsetof(struct ps_process_info, ppid), .role = OBUS_PROPERTY, .type = OBUS_FIELD_U32, }, [PS_PROCESS_FIELD_NAME] = { .uid = 3, .name = "name", .offset = obus_offsetof(struct ps_process_info, name), .role = OBUS_PROPERTY, .type = OBUS_FIELD_STRING, }, [PS_PROCESS_FIELD_EXE] = { .uid = 4, .name = "exe", .offset = obus_offsetof(struct ps_process_info, exe), .role = OBUS_PROPERTY, .type = OBUS_FIELD_STRING, }, [PS_PROCESS_FIELD_PCPU] = { .uid = 5, .name = "pcpu", .offset = obus_offsetof(struct ps_process_info, pcpu), .role = OBUS_PROPERTY, .type = OBUS_FIELD_F32, }, [PS_PROCESS_FIELD_STATE] = { .uid = 6, .name = "state", .offset = obus_offsetof(struct ps_process_info, state), .role = OBUS_PROPERTY, .type = OBUS_FIELD_ENUM, .enum_drv = &ps_process_state_driver, }, }; static const struct obus_struct_desc ps_process_info_desc = { .size = sizeof(struct ps_process_info), .fields_offset = obus_offsetof(struct ps_process_info, fields), .n_fields = OBUS_SIZEOF_ARRAY(ps_process_info_fields), .fields = ps_process_info_fields, }; static const struct obus_event_update_desc event_updated_updates[] = { { .field = &ps_process_info_fields[PS_PROCESS_FIELD_PPID], .flags = 0, } , { .field = &ps_process_info_fields[PS_PROCESS_FIELD_NAME], .flags = 0, } , { .field = &ps_process_info_fields[PS_PROCESS_FIELD_EXE], .flags = 0, } , { .field = &ps_process_info_fields[PS_PROCESS_FIELD_PCPU], .flags = 0, } , { .field = &ps_process_info_fields[PS_PROCESS_FIELD_STATE], .flags = 0, } }; static const struct obus_event_desc ps_process_events_desc[] = { { .uid = 1, .name = "updated", .updates = event_updated_updates, .n_updates = OBUS_SIZEOF_ARRAY(event_updated_updates), } }; const char *ps_process_event_type_str(enum ps_process_event_type type) { if (type >= OBUS_SIZEOF_ARRAY(ps_process_events_desc)) return "???"; return ps_process_events_desc[type].name; } const struct obus_object_desc ps_process_desc = { .uid = PS_PROCESS_UID, .name = "process", .info_desc = &ps_process_info_desc, .n_events = OBUS_SIZEOF_ARRAY(ps_process_events_desc), .events = ps_process_events_desc, .n_methods = 0, .methods = NULL, }; static inline struct ps_process * ps_process_from_object(struct obus_object *object) { const struct obus_object_desc *desc; if (!object) return NULL; desc = obus_object_get_desc(object); if (desc != &ps_process_desc) return NULL; return (struct ps_process *)object; } static inline struct obus_object * ps_process_object(struct ps_process *object) { struct obus_object *obj; obj = (struct obus_object *)object; if (ps_process_from_object(obj) != object) return NULL; return (struct obus_object *)object; } static inline const struct obus_object * ps_process_const_object(const struct ps_process *object) { const struct obus_object *obj; obj = (const struct obus_object *)object; if (obus_object_get_desc(obj) != &ps_process_desc) return NULL; return obj; } const struct ps_process_info * ps_process_get_info(const struct ps_process *object) { return (const struct ps_process_info *) obus_object_get_info(ps_process_const_object(object)); } void ps_process_log(const struct ps_process *object, enum obus_log_level level) { obus_object_log(ps_process_const_object(object), level); } int ps_process_set_user_data(struct ps_process *object, void *user_data) { return obus_object_set_user_data(ps_process_object(object), user_data); } void *ps_process_get_user_data(const struct ps_process *object) { return obus_object_get_user_data(ps_process_const_object(object)); } obus_handle_t ps_process_get_handle(const struct ps_process *object) { return obus_object_get_handle(ps_process_const_object(object)); } struct ps_process * ps_process_from_handle(struct obus_client *client, obus_handle_t handle) { struct obus_object *obj; obj = obus_client_get_object(client, handle); return ps_process_from_object(obj); } struct ps_process * ps_process_next(struct obus_client *client, struct ps_process *previous) { struct obus_object *next, *prev; prev = (struct obus_object *)previous; next = obus_client_object_next(client, prev, ps_process_desc.uid); return ps_process_from_object(next); } static inline struct obus_event *ps_process_obus_event(struct ps_process_event *event) { return event && (obus_event_get_object_desc((struct obus_event *)event) == &ps_process_desc) ? (struct obus_event *)event : NULL; } static inline const struct obus_event *ps_process_const_obus_event(const struct ps_process_event *event) { return event && (obus_event_get_object_desc((const struct obus_event *)event) == &ps_process_desc) ? (const struct obus_event *)event : NULL; } enum ps_process_event_type ps_process_event_get_type(const struct ps_process_event *event) { const struct obus_event_desc *desc; desc = obus_event_get_desc(ps_process_const_obus_event(event)); return desc ? (enum ps_process_event_type)(desc - ps_process_events_desc) : PS_PROCESS_EVENT_COUNT; } void ps_process_event_log(const struct ps_process_event *event, enum obus_log_level level) { obus_event_log(ps_process_const_obus_event(event), level); } int ps_process_event_is_empty(const struct ps_process_event *event) { return obus_event_is_empty(ps_process_const_obus_event(event)); } int ps_process_event_commit(struct ps_process_event *event) { return obus_event_commit(ps_process_obus_event(event)); } const struct ps_process_info * ps_process_event_get_info(const struct ps_process_event *event) { return (const struct ps_process_info *) obus_event_get_info(ps_process_const_obus_event(event)); } /** * @brief subscribe to events concerning ps_process objects. * * @param[in] client bus client. * @param[in] provider callback set for reacting on ps_process events. * @param[in] user_data data passed to callbacks on events. * * @retval 0 success. **/ int ps_process_subscribe(struct obus_client *client, struct ps_process_provider *provider, void *user_data) { struct obus_provider *p; int ret; if (!client || !provider || !provider->add || !provider->remove || !provider->event) return -EINVAL; p = calloc(1, sizeof(*p)); if (!p) return -ENOMEM; p->add = (obus_provider_add_cb_t) provider->add; p->remove = (obus_provider_remove_cb_t) provider->remove; p->event = (obus_provider_event_cb_t) provider->event; p->desc = &ps_process_desc; p->user_data = user_data; ret = obus_client_register_provider(client, p); if (ret < 0) { free(p); return ret; } provider->priv = p; return 0; } /** * @brief unsubscribe to events concerning ps_process objects. * * @param[in] client bus client. * @param[in] provider passed to ps_process_subscribe. * * @retval 0 success. **/ int ps_process_unsubscribe(struct obus_client *client, struct ps_process_provider *provider) { int ret; if (!client || !provider) return -EINVAL; ret = obus_client_unregister_provider(client, provider->priv); if (ret < 0) return ret; free(provider->priv); provider->priv = NULL; return 0; }
23.361702
79
0.722627
[ "object" ]
e0e8b5133301e8f5ba1bd84efe52b4bb540f732b
3,574
h
C
image/jpeg_error.h
senarvi/senarvi-image
d13333b78c58a1265a92ab3ff34f637c0f31b7fa
[ "Apache-2.0" ]
null
null
null
image/jpeg_error.h
senarvi/senarvi-image
d13333b78c58a1265a92ab3ff34f637c0f31b7fa
[ "Apache-2.0" ]
null
null
null
image/jpeg_error.h
senarvi/senarvi-image
d13333b78c58a1265a92ab3ff34f637c0f31b7fa
[ "Apache-2.0" ]
null
null
null
// -*- mode: C++; tab-width: 4; c-basic-offset: 4 -*- #ifndef IMAGE_JPEG_ERROR_H #define IMAGE_JPEG_ERROR_H #include <string> #include <sstream> #include <exception> #include <stdexcept> // runtime_error #include <boost/filesystem/path.hpp> // stdio.h has to be included before jpeglib.h can be included. #include <stdio.h> #include <jpeglib.h> namespace image { /// \brief An exception class for libjpeg errors. /// class jpeg_error : public std::exception { public: /// \brief Construct an exception object from a compression error. /// /// The error message is read from a jpeg_compress_struct structure that /// has to be given as a parameter to the constructor. /// explicit jpeg_error( const std::string & function_name, jpeg_compress_struct & compress_info) throw () : function_name_(function_name), error_code_(compress_info.err->msg_code) { (*compress_info.err->format_message)( reinterpret_cast<j_common_ptr>(&compress_info), message_); } /// \brief Construct an exception object from a decompression error. /// /// The error message is read from a jpeg_decompress_struct structure that /// has to be given as a parameter to the constructor. /// explicit jpeg_error( const std::string & function_name, jpeg_decompress_struct & decompress_info) throw () : function_name_(function_name), error_code_(decompress_info.err->msg_code) { (*decompress_info.err->format_message)( reinterpret_cast<j_common_ptr>(&decompress_info), message_); } /// \brief Destruct the exception object. /// virtual ~jpeg_error() throw () {} /// \brief Return a pointer to the error message C string. /// /// The pointer is only valid until the exception object is destructed. /// const char * what() const throw () { return message_; } /// \brief Return a string containing the error message. /// const std::string message() const { std::ostringstream oss; oss << "In function `" << function_name_ << "':" << std::endl << "Libjpeg error " << error_code_ << ": " << what(); return oss.str(); } private: const std::string function_name_; const int error_code_; char message_[JMSG_LENGTH_MAX]; }; /// \brief An exception that is thrown if a jpeg_writer is created with /// the name of a file that exists already, but overwriting is not /// requested. /// class file_exists : public std::runtime_error { public: explicit file_exists(const boost::filesystem::path & file_path) : std::runtime_error("File exists already."), file_path_(file_path) {} /// \brief Destruct the exception object. /// ~file_exists() throw () {} const boost::filesystem::path & file_path() const { return file_path_; } private: boost::filesystem::path file_path_; }; } #endif
30.288136
83
0.543089
[ "object" ]
e0ef7aafd7bafb704c34dace5de7ccec839b7404
693
h
C
race/source/Sky.h
Roodranshu/opengl
194d84c98b2c10dd32b39e051d901b1e18a4e886
[ "MIT" ]
78
2015-05-04T18:30:51.000Z
2022-01-27T17:53:43.000Z
race/source/Sky.h
Roodranshu/opengl
194d84c98b2c10dd32b39e051d901b1e18a4e886
[ "MIT" ]
null
null
null
race/source/Sky.h
Roodranshu/opengl
194d84c98b2c10dd32b39e051d901b1e18a4e886
[ "MIT" ]
57
2015-04-10T12:42:18.000Z
2021-11-01T02:21:34.000Z
/************************************************************ Project: R.A.C.E. License: GPL ************************************************************/ #ifndef SKY_H #define SKY_H #include "includes.h" #include "race_math.h" #include "Texture_Manager.h" class Sky { private: Texture_Manager *tm; // texture manager Vector *vertex; // vertex array TexCoord *texcoord; // coord array int num_vert; // vertex num float radius; // plane radius public: Sky (Texture_Manager *); ~Sky(); // function void render (int); // render sky void init (float, float, float, float, float); // init data }; #endif
19.8
62
0.489177
[ "render", "vector" ]
e0f518feda779915c8babda7a6a217b8ca5fa609
8,463
h
C
Include/KAI/Core/Object/Class.h
cschladetsch/KAI
b7078bc73817f0f76805c9330dbaf45584d86a22
[ "MIT" ]
13
2015-07-23T08:45:31.000Z
2019-10-10T23:56:00.000Z
Include/KAI/Core/Object/Class.h
cschladetsch/KAI
b7078bc73817f0f76805c9330dbaf45584d86a22
[ "MIT" ]
16
2016-02-06T12:54:45.000Z
2020-10-30T14:23:35.000Z
Include/KAI/Core/Object/Class.h
cschladetsch/KAI
b7078bc73817f0f76805c9330dbaf45584d86a22
[ "MIT" ]
4
2017-02-27T22:24:19.000Z
2018-12-09T17:54:07.000Z
#pragma once #include <KAI/Core/Type/Traits.h> #include "KAI/Core/Object/Object.h" #include "KAI/Core/Object/ClassBase.h" #include "KAI/Core/Object/Label.h" #include "KAI/Core/Object/ObjectConstructParams.h" #include "KAI/Core/Object/GetStorageBase.h" #include "KAI/Core/TriColor.h" #include "KAI/Core/Value.h" #include <KAI/Core/Type/Deref.h> #include <KAI/Core/Registry.h> #undef RegisterClass KAI_BEGIN #pragma warning(push) // warning C4702: unreachable code #pragma warning(disable:4702) void MarkGrey(Object const &); template <class T> class Class : public ClassBase { public: typedef typename Type::Traits<T> Traits; enum { Props = Traits::Props }; Class(Label const &name) : ClassBase(name, Type::Traits<T>::Number) { } int GetTraitsProperties() const { return Props; } bool HasTraitsProperty(int N) const { return (Props & N) != 0; } // Lifetime management StorageBase *NewStorage(Registry *registry, Handle handle) const { auto born = registry->GetMemorySystem(). Allocate<Storage<T> >( ObjectConstructParams(registry, this, handle)); born->SetClean(); return born; } void Create(StorageBase &storage) const { CreateProperties(storage); Traits::LifetimeManager::Create(TypedStorage(storage)); } bool Destroy(StorageBase &storage) const { return Traits::LifetimeManager::Destroy(TypedStorage(storage)); } void Delete(StorageBase &storage) const { if (!_properties.empty()) { for (auto X : _properties) { PropertyBase const &prop = *X.second; if (!prop.IsSystemType()) continue; Object K = prop.GetObject(storage); if (K.Exists()) { K.RemovedFromContainer(storage); } } } Traits::LifetimeManager::Delete(TypedStorage(storage)); } Storage<T> *TypedStorage(StorageBase &storage) const { return reinterpret_cast<Storage<T> *>(&storage); } void CreateProperties(StorageBase &object) const { for (auto property : _properties) { PropertyBase const &prop = *property.second; if (!prop.IsSystemType()) continue; if (!prop.CreateDefaultValue()) continue; Object value = object.GetRegistry()->NewFromTypeNumber(prop.GetFieldTypeNumber()); prop.SetObject(object, value); } } void Assign(StorageBase &A, StorageBase const &B) const { Traits::Assign::Perform(Deref<T>(A), ConstDeref<T>(B)); } Object Duplicate(StorageBase const &parent) const { Storage<T> *result = parent.GetRegistry()->NewStorage<T>(); Traits::Assign::Perform(result->GetReference(), ConstDeref<T>(parent)); //foreach (Properties::value_type const &property, _properties) for (auto property : _properties) { PropertyBase const &prop = *property.second; // if it is a system-type property, clone it, else just store the value if (prop.IsSystemType()) { auto ch = prop.GetObject(parent); if (ch.Exists()) prop.SetObject(*result, ch.Clone()); else prop.SetObject(*result, Object()); } else prop.SetValue(*result, prop.GetValue(parent)); } return *result; } void GetContainedObjects(StorageBase &object, ObjectList &contained) const { Traits::ContainerOps::ForEachContained(CleanDeref<T>(object), AddContainedFun<T, ObjectList>(contained)); } void SetReferencedObjectsColor(StorageBase &Q, ObjectColor::Color C, HandleSet &H) const { ClassBase::SetReferencedObjectsColor(Q, C, H); Traits::ContainerOps::ForEachContained(CleanDeref<T>(Q), SetObjectColorRecursive<T>(C, H)); } void SetSwitch(StorageBase &Q, int S, bool M) const { Traits::ContainerOps::SetSwitch(CleanDeref<T>(Q), S, M); } void DetachFromContainer(StorageBase &Q, Object const &K) const { Traits::ContainerOps::Erase(Deref<T>(Q), K); } void SetMarked2(StorageBase &Q, bool M) const { Traits::ContainerOps::SetMarked(CleanDeref<T>(Q), M); } void MakeReachableGrey(StorageBase &base) const { ClassBase::MakeReachableGrey(base); Traits::ContainerOps::ForEachContained( CleanDeref<T>(base), MakeReachableGreyFun<T>()); } Object UpCast(StorageBase &Q) const { // This is almost always a bad idea. I see no reason to allow it in KAI as well. KAI_NOT_IMPLEMENTED(); } Object CrossCast(StorageBase &, Type::Number) const { KAI_NOT_IMPLEMENTED(); } Object DownCast(StorageBase &, Type::Number) const { KAI_NOT_IMPLEMENTED(); } HashValue GetHashValue(const StorageBase &Q) const { return Traits::HashFunction::Calc(ConstDeref<T>(Q)); } Object Absolute(const StorageBase &object) const { Object result = object.Clone(); Traits::Absolute::Perform(Deref<T>(object)); return result; } bool Boolean(const StorageBase &A) const { return Traits::Boolean::Perform(ConstDeref<T>(A)); } bool Less(const StorageBase &A, const StorageBase &B) const { return Traits::Less::Perform(ConstDeref<T>(A), ConstDeref<T>(B)); } bool Equiv(const StorageBase &A, const StorageBase &B) const { if (!HasTraitsProperty(Type::Properties::Equiv) && HasTraitsProperty(Type::Properties::Less)) return !Less(A,B) && !Less(B,A); return Traits::Equiv::Perform(ConstDeref<T>(A),ConstDeref<T>(B)); } bool Greater(const StorageBase &A, const StorageBase &B) const { return Traits::Greater::Perform(ConstDeref<T>(A), ConstDeref<T>(B)); } StorageBase *Plus(StorageBase const &A, StorageBase const &B) const { Storage<T> *R = A.GetRegistry()->NewStorage<T>(); Traits::Assign::Perform(R->GetReference(), Traits::Plus::Perform(ConstDeref<T>(A), ConstDeref<T>(B))); return R; } StorageBase *Minus(StorageBase const &A, StorageBase const &B) const { Storage<T> *R = A.GetRegistry()->NewStorage<T>(); Traits::Assign::Perform(R->GetReference(), Traits::Minus::Perform(ConstDeref<T>(A), ConstDeref<T>(B))); return R; } StorageBase *Multiply(StorageBase const &A, StorageBase const &B) const { Storage<T> *R = A.GetRegistry()->NewStorage<T>(); Traits::Assign::Perform(R->GetReference(), Traits::Multiply::Perform(ConstDeref<T>(A), ConstDeref<T>(B))); return R; } StorageBase *Divide(StorageBase const &A, StorageBase const &B) const { Storage<T> *R = A.GetRegistry()->NewStorage<T>(); Traits::Assign::Perform(R->GetReference(), Traits::Divide::Perform(ConstDeref<T>(A), ConstDeref<T>(B))); return R; } void Insert(StringStream &S, const StorageBase &Q) const { Traits::StringStreamInsert::Insert(S, ConstDeref<T>(Q)); } StorageBase *Extract(Registry &R, StringStream &S) const { Storage<T> *Q = R.NewStorage<T>(); Traits::StringStreamExtract::Extract(S, Q->GetReference()); return Q; } void ExtractValue(Object &object, StringStream &strstream) const { Traits::StringStreamExtract::Extract(strstream, Deref<T>(object)); } void Insert(BinaryStream &S, const StorageBase &Q) const { Traits::BinaryStreamInsert::Insert(S, ConstDeref<T>(Q)); } StorageBase *Extract(Registry &R, BinaryStream &S) const { Value<T> Q = R.New<T>(); Traits::BinaryPacketExtract::Extract(S, *Q); return &Q.GetObject().GetStorageBase(); } }; template <class T> Pointer<ClassBase const *> NewClass(Registry &R, const Label &name) { auto klass = new Class<T>(name); return R.AddClass(Type::Traits<T>::Number, klass); } template <class T> Storage<T> *Clone(StorageBase const &Q) { auto dup = Q.GetRegistry()->NewStorage<T>(); dup->GetClass()->Clone(*dup, Q); return dup; } #pragma warning(pop) KAI_END
28.785714
114
0.607704
[ "object" ]
e0f72ff162633903395093e061fef852ef98e80d
3,833
h
C
src/raffo.h
t-crest/drone
d3d2c9b43acf815cbd2a438f6546c9f644d12c50
[ "BSD-2-Clause" ]
null
null
null
src/raffo.h
t-crest/drone
d3d2c9b43acf815cbd2a438f6546c9f644d12c50
[ "BSD-2-Clause" ]
null
null
null
src/raffo.h
t-crest/drone
d3d2c9b43acf815cbd2a438f6546c9f644d12c50
[ "BSD-2-Clause" ]
3
2020-07-20T14:15:16.000Z
2021-04-17T21:21:02.000Z
/* * Copyright (c) 2020, Michael Platzer (TU Wien) * 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. * * 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. * * SPDX-License-Identifier: BSD-2-Clause */ /** * Fixed-point implementation of a quadcopter controller. * * The drone controller uses the method proposed by Raffo et. al. [1], * implemented with fixed-point computation. More details on the algorithm can * be found in the dissertation of the author [2]. * * This is a combined attitude and position controller, but it can also be used * for attitude control only by setting the position and velocity errors to 0. * Although the control algorithm technically requires the rotors to be tilted * * [1] G. V. Raffo, M. G. Ortega and F. R. Rubio, "Nonlinear H-infinity * controller for the quad-rotor helicopter with input coupling", 18th * IFAC World Congress, vol. 44, no. 1, pp. 13834-13839, 2011. * * [2] G. V. Raffo, "Robust control strategies for a quadrotor helicopter", * Doctoral Thesis, Universidad de Sevilla, Escuela Tecnica Superior de * Ingenieria, 2011. */ #ifndef RAFFO_H #define RAFFO_H #include <stdint.h> /** * @param[in] R_W rotation matrix from body to world frame * @param[in] omega angular rate vector (in body frame coordinates) * @param[in] xi_err position error vector (in world frame coordinates) * @param[in] d_xi_err velocity error vector ( -"- ) * @param[in] dd_xi_des desired acceleration vector ( -"- ) * @param[in] yaw_des desired yaw angle ( -"- ) * @param[in] d_yaw_des desired derivative of yaw angle ( -"- ) * @param[out] dd_xi_ctrl target acceleration of controller ( -"- ) * @param[out] f_prop propeller thrusts (force normal to each propeller) */ void raffo_update(const int32_t R_W[3][3], const int32_t omega[3], const int32_t xi_err[3], const int32_t d_xi_err[3], const int32_t dd_xi_des[3], int32_t yaw_des, int32_t d_yaw_des, //int32_t dd_xi_ctrl[3], int32_t f_prop[4]); #define R_W_SCALE 30 // all values within [-1, 1] #define OMEGA_SCALE 25 // gyroscope measurements may be in range [-40, 40] #define XI_SCALE 25 // range limited to [-63, 63] #define D_XI_SCALE 25 // range limited to [-63, 63] #define DD_XI_SCALE 23 // accelerometer range up to 16 g, i.e. [-157, 157] #define YAW_SCALE 28 // all values within [-pi, pi] #define F_PROP_SCALE 24 // range limited to [-127,127] #endif // RAFFO_H
45.630952
79
0.695017
[ "vector" ]
460afdb0743e58078cd8443430998d4117b7fc09
627
h
C
chrome/browser/sharing/sharing_dialog.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
chrome/browser/sharing/sharing_dialog.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
chrome/browser/sharing/sharing_dialog.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_SHARING_SHARING_DIALOG_H_ #define CHROME_BROWSER_SHARING_SHARING_DIALOG_H_ // The cross-platform UI interface which displays the sharing dialog. // This object is responsible for its own lifetime. class SharingDialog { public: virtual ~SharingDialog() = default; // Called to close the dialog and prevent future callbacks into the // controller. virtual void Hide() = 0; }; #endif // CHROME_BROWSER_SHARING_SHARING_DIALOG_H_
31.35
73
0.779904
[ "object" ]
461987770c9b45cbb981a3e0e565e381c083b1c1
3,673
h
C
Mistiq/src/ECS/Systems/Systems.h
SGAoo7/Mistiq
05feb006366bc2ad15b1752f38bbe45f6967cc8c
[ "Apache-2.0" ]
1
2020-10-05T15:36:31.000Z
2020-10-05T15:36:31.000Z
Mistiq/src/ECS/Systems/Systems.h
SGAoo7/Mistiq
05feb006366bc2ad15b1752f38bbe45f6967cc8c
[ "Apache-2.0" ]
null
null
null
Mistiq/src/ECS/Systems/Systems.h
SGAoo7/Mistiq
05feb006366bc2ad15b1752f38bbe45f6967cc8c
[ "Apache-2.0" ]
1
2020-10-05T15:36:15.000Z
2020-10-05T15:36:15.000Z
#pragma once #include "Mstqpch.h" #include "ECS/System.h" #include "ECS/Components/Components.h" #include "Mistiq/Application.h" #include "ECS/ECSManager.h" namespace Mistiq { class MeshRenderer : public System { public: MeshRenderer() { std::set<unsigned int> requiredComponents; requiredComponents.insert(Mistiq::Mesh::s_Type); requiredComponents.insert(Mistiq::Location::s_Type); m_RequiredComponents = requiredComponents; } void AddEntity(Entity& entity) override { MSTQ_OPTICK_EVENT("MeshRendererSystemAddEntity"); System::AddEntity(entity); std::shared_ptr<Mesh> mesh = Application::instance().m_ECSManager->GetComponent<Mesh>(entity); std::shared_ptr<Location> location = Application::instance().m_ECSManager->GetComponent<Location>(entity); mesh->enabled = true; glGenVertexArrays(1, &mesh->VAO); glGenBuffers(1, &mesh->VBO); glGenBuffers(1, &mesh->EBO); glBindVertexArray(mesh->VAO); glBindBuffer(GL_ARRAY_BUFFER, mesh->VBO); glBufferData(GL_ARRAY_BUFFER, mesh->model->primitives[0]->vertices.size() * sizeof(Mistiq::Vertex), &mesh->model->primitives[0]->vertices[0], GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, mesh->model->primitives[0]->indices.size() * sizeof(unsigned int), &mesh->model->primitives[0]->indices[0], GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Mistiq::Vertex), (void*)0); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Mistiq::Vertex), (void*)offsetof(Mistiq::Vertex, normal)); glEnableVertexAttribArray(2); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Mistiq::Vertex), (void*)offsetof(Mistiq::Vertex, tex)); mesh->program = std::make_shared<Mistiq::ShaderProgram>(); std::shared_ptr<Mistiq::Shader> vertShader = std::make_shared<Mistiq::Shader>("assets/shaders/basic_lighting.vert", Mistiq::Shader::ESHADER_TYPE::SHADER_TYPE_VERTEX); std::shared_ptr<Mistiq::Shader> fragShader = std::make_shared<Mistiq::Shader>("assets/shaders/basic_lighting.frag", Mistiq::Shader::ESHADER_TYPE::SHADER_TYPE_FRAGMENT); mesh->program->AddShader(vertShader); mesh->program->AddShader(fragShader); mesh->program->Link(); mesh->program->Use(); mesh->texture1 = std::make_shared<Mistiq::Texture>("assets/models/Environment/Blockout/BlockoutTemp.png"); mesh->texture1->Load(); mesh->program->Use(); mesh->program->SetInt("texture1", 0); mesh->Model = glm::mat4(1.0f); mesh->Model = glm::translate(mesh->Model, glm::vec3(location->m_Translation.x, location->m_Translation.y, location->m_Translation.z)); mesh->Model = glm::rotate(mesh->Model, glm::radians(location->m_Rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); mesh->Model = glm::rotate(mesh->Model, glm::radians(location->m_Rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); mesh->Model = glm::rotate(mesh->Model, glm::radians(location->m_Rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); mesh->Model = glm::scale(mesh->Model, glm::vec3(location->m_Scale.x, location->m_Scale.y, location->m_Scale.z)); } void Update() override { MSTQ_OPTICK_EVENT("MeshRendererSystemUpdate"); for (auto entity : m_MatchingEntities) { } } }; class Transform : public System { public: Transform() { std::set<unsigned int> requiredComponents; requiredComponents.insert(Mistiq::Location::s_Type); m_RequiredComponents = requiredComponents; } void Update() override { MSTQ_OPTICK_EVENT("TransformSystemUpdate"); for (auto entity : m_MatchingEntities) { } } }; }
36.366337
171
0.716036
[ "mesh", "model", "transform" ]
461f59a40dde031085ec38357004eb941eaf0b33
369
h
C
docrank/ranker_nonswig.h
larsjuhljensen/mamba
a95286d74736547a4baa0b391fa223f6cad701b0
[ "BSD-2-Clause" ]
1
2020-07-08T07:06:06.000Z
2020-07-08T07:06:06.000Z
docrank/ranker_nonswig.h
larsjuhljensen/mamba
a95286d74736547a4baa0b391fa223f6cad701b0
[ "BSD-2-Clause" ]
null
null
null
docrank/ranker_nonswig.h
larsjuhljensen/mamba
a95286d74736547a4baa0b391fa223f6cad701b0
[ "BSD-2-Clause" ]
1
2020-09-16T08:13:30.000Z
2020-09-16T08:13:30.000Z
#ifndef __RANKER_NONSWIG_HEADER__ #define __RANKER_NONSWIG_HEADER__ #include <vector> #include <tr1/unordered_map> using namespace std; using namespace tr1; typedef vector<int> INT_VECTOR; typedef unordered_map<int, INT_VECTOR> INT_INT_VECTOR_MAP; typedef unordered_map<int, float> INT_DOUBLE_MAP; typedef unordered_map<int, int> INT_INT_MAP; #endif
23.0625
59
0.794038
[ "vector" ]
463ad31d6b5c5ec504d8481fbcfa3115bab53cbd
4,256
h
C
src/print.h
nptcl/npt
608c1bf38380aaa9e20748458b7f091da898d535
[ "Unlicense" ]
37
2019-02-24T00:07:11.000Z
2022-03-03T09:41:43.000Z
src/print.h
nptcl/npt
608c1bf38380aaa9e20748458b7f091da898d535
[ "Unlicense" ]
9
2019-07-01T04:08:36.000Z
2021-06-13T03:51:43.000Z
src/print.h
nptcl/npt
608c1bf38380aaa9e20748458b7f091da898d535
[ "Unlicense" ]
2
2019-04-11T04:01:02.000Z
2019-07-15T08:21:00.000Z
#ifndef __PRINT_HEADER__ #define __PRINT_HEADER__ #include <stdarg.h> #include "typedef.h" #define array_print_ _n(array_print_) #define base_print_ _n(base_print_) #define radix_print_ _n(radix_print_) #define case_print_ _n(case_print_) #define circle_print_ _n(circle_print_) #define escape_print_ _n(escape_print_) #define gensym_print_ _n(gensym_print_) #define readably_print_ _n(readably_print_) #define pretty_print_ _n(pretty_print_) #define level_print_ _n(level_print_) #define length_print_ _n(length_print_) #define lines_print_ _n(lines_print_) #define miser_width_print_ _n(miser_width_print_) #define right_margin_print_ _n(right_margin_print_) #define pprint_dispatch_print_ _n(pprint_dispatch_print_) #define push_array_print _n(push_array_print) #define push_base_print _n(push_base_print) #define push_radix_print _n(push_radix_print) #define push_case_print_ _n(push_case_print_) #define push_circle_print _n(push_circle_print) #define push_escape_print _n(push_escape_print) #define push_gensym_print _n(push_gensym_print) #define push_readably_print _n(push_readably_print) #define push_pretty_print _n(push_pretty_print) #define push_level_print_ _n(push_level_print_) #define push_level_nil_print _n(push_level_nil_print) #define push_length_print_ _n(push_length_print_) #define push_length_nil_print _n(push_length_nil_print) #define push_lines_print_ _n(push_lines_print_) #define push_lines_nil_print _n(push_lines_nil_print) #define push_miser_width_print_ _n(push_miser_width_print_) #define push_miser_width_nil_print _n(push_miser_width_nil_print) #define push_right_margin_print_ _n(push_right_margin_print_) #define push_right_margin_nil_print _n(push_right_margin_nil_print) #define push_pprint_dispatch _n(push_pprint_dispatch) #define print_unreadable_object_ _n(print_unreadable_object_) #define print_unreadable_common_ _n(print_unreadable_common_) #define build_print _n(build_print) #define init_print _n(init_print) #define PRINT_DEFAULT_WIDTH 72 enum PrintCase { PrintCase_unread = 0, PrintCase_upcase, PrintCase_downcase, PrintCase_capitalize, PrintCase_preserve, PrintCase_invert, PrintCase_escape, PrintCase_size }; typedef int (*calltype_print)(Execute ptr, addr stream, addr object); int array_print_(Execute ptr, int *ret); int base_print_(Execute ptr, unsigned *ret); int radix_print_(Execute ptr, int *ret); int case_print_(Execute ptr, enum PrintCase *ret); int circle_print_(Execute ptr, int *ret); int escape_print_(Execute ptr, int *ret); int gensym_print_(Execute ptr, int *ret); int readably_print_(Execute ptr, int *ret); int pretty_print_(Execute ptr, int *ret); int level_print_(Execute ptr, size_t *value, int *ret); int length_print_(Execute ptr, size_t *value, int *ret); int lines_print_(Execute ptr, size_t *value, int *ret); int miser_width_print_(Execute ptr, size_t *value, int *ret); int right_margin_print_(Execute ptr, addr stream, size_t *ret); int pprint_dispatch_print_(Execute ptr, addr *ret); void push_array_print(Execute ptr, int value); void push_base_print(Execute ptr, unsigned base); void push_radix_print(Execute ptr, int value); int push_case_print_(Execute ptr, enum PrintCase pcase); void push_circle_print(Execute ptr, int value); void push_escape_print(Execute ptr, int value); void push_gensym_print(Execute ptr, int value); void push_readably_print(Execute ptr, int value); void push_pretty_print(Execute ptr, int value); int push_level_print_(Execute ptr, size_t value); void push_level_nil_print(Execute ptr); int push_length_print_(Execute ptr, size_t value); void push_length_nil_print(Execute ptr); int push_lines_print_(Execute ptr, size_t value); void push_lines_nil_print(Execute ptr); int push_miser_width_print_(Execute ptr, size_t value); void push_miser_width_nil_print(Execute ptr); int push_right_margin_print_(Execute ptr, size_t value); void push_right_margin_nil_print(Execute ptr); void push_pprint_dispatch(Execute ptr, addr value); int print_unreadable_object_(Execute ptr, addr stream, addr pos, int type, int identity, calltype_print call); int print_unreadable_common_(Execute ptr, addr stream, addr pos, int type, int identity, addr body); /* initialize */ void build_print(Execute ptr); void init_print(void); #endif
39.045872
69
0.831297
[ "object" ]
463b3f19c26877ec434ec7289ef762c8be69afa0
533
h
C
UnsplashAPIDemo/UnsplashAPIDemo/UnsplashAPI/UnsplashModels/UnsplashPhotoExif.h
fengzhichu/UnsplashAPI
06480751bc046d73355102320fa0d46d3e1b5f32
[ "Unlicense" ]
1
2017-08-20T07:43:05.000Z
2017-08-20T07:43:05.000Z
UnsplashAPIDemo/UnsplashAPIDemo/UnsplashAPI/UnsplashModels/UnsplashPhotoExif.h
fengzhichu/UnsplashAPI
06480751bc046d73355102320fa0d46d3e1b5f32
[ "Unlicense" ]
null
null
null
UnsplashAPIDemo/UnsplashAPIDemo/UnsplashAPI/UnsplashModels/UnsplashPhotoExif.h
fengzhichu/UnsplashAPI
06480751bc046d73355102320fa0d46d3e1b5f32
[ "Unlicense" ]
null
null
null
// // UnsplashPhotoExif.h // Picaso // // Created by Hummer on 16/8/18. // Copyright © 2016年 Amazation. All rights reserved. // #import <Foundation/Foundation.h> @interface UnsplashPhotoExif : NSObject @property (nonatomic, copy) NSString *exposureTime; //exposure_time; @property (nonatomic, assign) NSUInteger iso; @property (nonatomic, copy) NSString *model; @property (nonatomic, copy) NSString *aperture; @property (nonatomic, copy) NSString *focalLenght; // focal_length; @property (nonatomic, copy) NSString *make; @end
28.052632
68
0.742964
[ "model" ]
463c1354af93c26eaa5c6fa18543bf0f5d943cc4
1,412
h
C
EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSettingPowerBatteryPercentage.h
SmartSoftAsia/iOS-Fleet-Management-SDK
5dfc845366c44be6de1414aca17e9e05ba0ef3fc
[ "MIT" ]
null
null
null
EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSettingPowerBatteryPercentage.h
SmartSoftAsia/iOS-Fleet-Management-SDK
5dfc845366c44be6de1414aca17e9e05ba0ef3fc
[ "MIT" ]
null
null
null
EstimoteFleetManagementSDK/EstimoteFleetManagementSDK.framework/Versions/A/Headers/ESTSettingPowerBatteryPercentage.h
SmartSoftAsia/iOS-Fleet-Management-SDK
5dfc845366c44be6de1414aca17e9e05ba0ef3fc
[ "MIT" ]
null
null
null
// Estimote Fleet Management SDK // Copyright (c) 2015 Estimote. All rights reserved. #import <Foundation/Foundation.h> #import "ESTSettingReadOnly.h" @class ESTSettingPowerBatteryPercentage; NS_ASSUME_NONNULL_BEGIN /** * Block used as a result of read setting BatteryPercentage operation for Power packet. * * @param batteryPercentageSetting BatteryPercentage setting carrying value. * @param error Operation error. No error means success. */ typedef void(^ESTSettingPowerBatteryPercentageCompletionBlock)(ESTSettingPowerBatteryPercentage * _Nullable batteryPercentageSetting, NSError * _Nullable error); /** * ESTSettingPowerBatteryPercentage represents Power BatteryPercentage value. */ @interface ESTSettingPowerBatteryPercentage : ESTSettingReadOnly <NSCopying> /** * Designated initializer. * * @param batteryPercentage Power BatteryPercentage value. * * @return Initialized object. */ - (instancetype)initWithValue:(uint8_t)batteryPercentage; /** * Returns current value of Power BatteryPercentage setting. * * @return Power BatteryPercentage value. */ - (uint8_t)getValue; /** * Method allows to read value of initialized Power BatteryPercentage setting object. * * @param completion Block to be invoked when the operation is complete. */ - (void)readValueWithCompletion:(ESTSettingPowerBatteryPercentageCompletionBlock)completion; @end NS_ASSUME_NONNULL_END
27.686275
161
0.788952
[ "object" ]
df8c80c315db3a9214aebb87f7cf5abab8051e9b
1,061
h
C
src/sources/pinkycore/camera.h
Pentan/RaytracingCamp2019
5ac05b09413f26b529d1416882819158a8722c77
[ "MIT" ]
null
null
null
src/sources/pinkycore/camera.h
Pentan/RaytracingCamp2019
5ac05b09413f26b529d1416882819158a8722c77
[ "MIT" ]
null
null
null
src/sources/pinkycore/camera.h
Pentan/RaytracingCamp2019
5ac05b09413f26b529d1416882819158a8722c77
[ "MIT" ]
null
null
null
#ifndef PINKYPI_CAMERA_H #define PINKYPI_CAMERA_H #include <string> #include <vector> #include <memory> #include "pptypes.h" #include "ray.h" namespace PinkyPi { class Camera { public: enum CameraType { kPerspectiveCamera, kOrthographicsCamera }; public: Camera(); ~Camera(); void initWithType(CameraType t); // tx and ty range is (-1,1) Ray getRay(PPFloat tx, PPFloat ty); // std::string name; CameraType type; union { struct { PPFloat aspect; PPFloat yfov; PPFloat zfar; PPFloat znear; } perspective; struct { PPFloat xmag; PPFloat ymag; PPFloat zfar; PPFloat znear; } orthographics; }; PPFloat focalLength; PPFloat fNumber; PPFloat focusDistance; }; } #endif
19.290909
43
0.470311
[ "vector" ]
df948b2a853eeef7e37397eee87e53cff2933812
2,814
h
C
DependencyWalker/dependency.h
cgfandia/DependencyWalker
962f92a1b2a9edf58c3180a6ccc6e424cba02ff1
[ "MIT" ]
3
2021-11-21T08:43:50.000Z
2022-03-06T05:16:33.000Z
DependencyWalker/dependency.h
cgfandia/DependencyWalker
962f92a1b2a9edf58c3180a6ccc6e424cba02ff1
[ "MIT" ]
null
null
null
DependencyWalker/dependency.h
cgfandia/DependencyWalker
962f92a1b2a9edf58c3180a6ccc6e424cba02ff1
[ "MIT" ]
1
2022-03-06T05:16:46.000Z
2022-03-06T05:16:46.000Z
#pragma once #include "context.h" #include <string> #include <vector> #include <unordered_set> namespace dw { template<typename T> struct Merge { void operator()(std::shared_ptr<T> l, std::shared_ptr<T> r) {} }; template<typename T> struct Hash { size_t operator()(const T& ctx) const { return std::hash<T>()(ctx); } }; template<typename T, typename Hasher = Hash<T>, typename Merger = Merge<T>> class Dependency { struct HashShared { std::size_t operator()(const std::shared_ptr<Dependency<T>>& dep) const { if (dep) { return Hasher()(*dep->GetContext()); } return 0; } }; struct CompareShared { bool operator()(const std::shared_ptr<Dependency<T>>& l, const std::shared_ptr<Dependency<T>>& r) const { if (l && r) { return *l == *r; } return l == r; } }; public: using Context = T; using ParentsCollection = std::vector<std::weak_ptr<Dependency>>; using ChildrenCollection = std::unordered_set<std::shared_ptr<Dependency>, Dependency::HashShared, Dependency::CompareShared>; protected: ParentsCollection parents_; ChildrenCollection children_; std::shared_ptr<T> context_; public: const ParentsCollection& Parents() const { return parents_; }; const ChildrenCollection& Children() const { return children_; }; void AppendChild(std::shared_ptr<Dependency> child) { if (child) { auto old_child_it = children_.find(child); if (old_child_it != children_.end()) { if ((*old_child_it)->GetContext() && child->GetContext()) { Merger()((*old_child_it)->GetContext(), child->GetContext()); } } else { children_.emplace(child); } } } void AppendParent(std::shared_ptr<Dependency> parent) { if (parent) { parents_.push_back(parent); } } void SetContext(std::shared_ptr<T> context) { context_ = context; } std::shared_ptr<Dependency> Clone() const { auto clone = std::make_shared<Dependency>(*this); auto context = GetContext(); if (context) { clone.SetContext(std::make_shared<T>(*context)); } return clone; } std::shared_ptr<T> GetContext() const { return context_; } bool IsLeaf() const { return Children().empty(); } bool operator<(const Dependency<T>& other) const { if (GetContext() && other.GetContext()) { return *GetContext() < *other.GetContext(); } return GetContext() < other.GetContext(); } bool operator==(const Dependency<T>& other) const { if (GetContext() && other.GetContext()) { return *GetContext() == *other.GetContext(); } return GetContext() == other.GetContext(); } }; template<typename T> class DependencyFactory { virtual std::shared_ptr<Dependency<T>> Create() = 0; }; } // dw namespace
26.055556
128
0.636816
[ "vector" ]
df96aa6464d7bfd5ad9f27840e812fb676e39fba
1,220
h
C
include/caffeine/Interpreter/FailureLogger.h
mishazharov/caffeine
a1a8ad5bd2d69b5378d71d15ddec4658ea34f057
[ "MIT" ]
17
2021-03-04T01:10:22.000Z
2022-03-30T18:33:14.000Z
include/caffeine/Interpreter/FailureLogger.h
mishazharov/caffeine
a1a8ad5bd2d69b5378d71d15ddec4658ea34f057
[ "MIT" ]
320
2020-11-16T02:42:50.000Z
2022-03-31T16:43:26.000Z
include/caffeine/Interpreter/FailureLogger.h
mishazharov/caffeine
a1a8ad5bd2d69b5378d71d15ddec4658ea34f057
[ "MIT" ]
6
2020-11-10T02:37:10.000Z
2021-12-25T06:58:44.000Z
#ifndef CAFFEINE_INTERPRETER_FAILURELOGGER_H #define CAFFEINE_INTERPRETER_FAILURELOGGER_H #include "caffeine/Interpreter/Context.h" #include "caffeine/Solver/Solver.h" #include <iosfwd> #include <mutex> namespace caffeine { struct Failure { Assertion check; std::string_view message; explicit Failure(const Assertion& check) : check(check), message("") {} Failure(const Assertion& check, std::string_view msg) : check(check), message(msg) {} }; class FailureLogger { public: FailureLogger() = default; virtual ~FailureLogger() = default; virtual void log_failure(const Model* model, const Context& context, const Failure& failure) = 0; protected: FailureLogger(const FailureLogger&) = default; FailureLogger(FailureLogger&&) = default; FailureLogger& operator=(const FailureLogger&) = default; FailureLogger& operator=(FailureLogger&&) = default; }; class PrintingFailureLogger : public FailureLogger { private: std::ostream* os; std::mutex mtx; public: PrintingFailureLogger(std::ostream& os); void log_failure(const Model* model, const Context& context, const Failure& failure) override; }; } // namespace caffeine #endif
23.461538
73
0.718033
[ "model" ]
dfc4b7806e5301a3f2a1ee96bc865b10453a35b5
3,292
h
C
voxblox_bridge/include/voxblox_bridge/block_plus.h
ricfrr/Complexity-Aware
e9a0ae5dc8381695398d3d74e57d52866f85631b
[ "MIT" ]
null
null
null
voxblox_bridge/include/voxblox_bridge/block_plus.h
ricfrr/Complexity-Aware
e9a0ae5dc8381695398d3d74e57d52866f85631b
[ "MIT" ]
null
null
null
voxblox_bridge/include/voxblox_bridge/block_plus.h
ricfrr/Complexity-Aware
e9a0ae5dc8381695398d3d74e57d52866f85631b
[ "MIT" ]
null
null
null
#ifndef VOXPLUS_BLOCK_H_ #define VOXPLUS_BLOCK_H_ #include "voxblox/core/block.h" //#include "voxblox/core/block_inl.h" //#include "voxblox/Block.pb.h" #include <algorithm> #include <atomic> #include <bitset> #include <memory> #include <vector> #include "iostream" // #include "voxblox/core/common.h" namespace voxblox_bridge { namespace Update { /// Status of which derived things still need to be updated. enum Status { kMap, kMesh, kEsdf, kCount }; } // namespace Update /** An n x n x n container holding VoxelType. It is aware of its 3D position and * contains functions for accessing voxels by position and index */ template <typename VoxelType> class BlockPlus : public voxblox::Block<VoxelType> { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr<BlockPlus<VoxelType>> Ptr; typedef std::shared_ptr<const BlockPlus<VoxelType>> ConstPtr; BlockPlus(size_t voxels_per_side, voxblox::FloatingPoint voxel_size, const voxblox::Point &origin) : has_data_(false), voxels_per_side_(voxels_per_side), voxel_size_(voxel_size), origin_(origin), updated_(false) { num_voxels_ = voxels_per_side_ * voxels_per_side_ * voxels_per_side_; voxel_size_inv_ = 1.0 / voxel_size_; block_size_ = voxels_per_side_ * voxel_size_; block_size_inv_ = 1.0 / block_size_; voxels_.reset(new VoxelType[num_voxels_]); } explicit BlockPlus(const voxblox::BlockProto &proto); ~BlockPlus() {} inline void setBlockIntensity() { std::vector<VoxelType> vec; for (size_t voxel_idx = 0u; voxel_idx < num_voxels_; ++voxel_idx) { const VoxelType &voxel = voxels_[voxel_idx]; block_intensity_ += voxel.distance; } block_intensity_ /= num_voxels_; // define the voxel complexity as a combination of the distance and the complexity of the surrounding area for (size_t voxel_idx = 0u; voxel_idx < num_voxels_; ++voxel_idx) { voxels_[voxel_idx].complexity = block_intensity_ + voxels_[voxel_idx].distance; } } inline const std::vector<VoxelType> getVoxelList() const { std::vector<VoxelType> vec; for (size_t voxel_idx = 0u; voxel_idx < num_voxels_; ++voxel_idx) { const VoxelType &voxel = voxels_[voxel_idx]; vec.push_back(voxel); } return vec; } float getBlockIntensity() { return block_intensity_; } protected: std::unique_ptr<VoxelType[]> voxels_; // Derived, cached parameters. size_t num_voxels_; /// Is set to true if any one of the voxels in this block received an update. bool has_data_; private: void deserializeProto(const voxblox::BlockProto &proto); void serializeProto(voxblox::BlockProto *proto) const; // Base parameters. const size_t voxels_per_side_; const voxblox::FloatingPoint voxel_size_; voxblox::Point origin_; // Derived, cached parameters. voxblox::FloatingPoint voxel_size_inv_; voxblox::FloatingPoint block_size_; voxblox::FloatingPoint block_size_inv_; float block_intensity_; /// Is set to true when data is updated. std::bitset<Update::kCount> updated_; }; } #endif
26.336
112
0.680134
[ "vector", "3d" ]
dfc6ceccacbefd5ac9cab93edbc4cc50a4bab3d4
982
h
C
projects/C_to_Promela/StateVecVarAttrib.h
maurizioabba/rose
7597292cf14da292bdb9a4ef573001b6c5b9b6c0
[ "BSD-3-Clause" ]
14
2017-03-07T00:14:33.000Z
2022-02-09T00:59:22.000Z
projects/C_to_Promela/StateVecVarAttrib.h
sujankh/rose-matlab
7435d4fa1941826c784ba97296c0ec55fa7d7c7e
[ "BSD-3-Clause" ]
11
2016-11-22T13:14:55.000Z
2021-12-14T00:56:51.000Z
projects/C_to_Promela/StateVecVarAttrib.h
sujankh/rose-matlab
7435d4fa1941826c784ba97296c0ec55fa7d7c7e
[ "BSD-3-Clause" ]
6
2016-11-07T13:38:45.000Z
2021-04-04T12:13:31.000Z
#include "iostream" #include "vector" // StateVecVarAttrib #define STATEVECVARASTATTRIBSTR "STATE_VEC_VAR_ATTRIB" class StateVecVarASTAttrib: public AstAttribute { protected: bool varIsLocal; bool varIsInStateVector; public: StateVecVarASTAttrib(bool local):varIsLocal(local){ varIsInStateVector=true; } void setInState(bool val){varIsInStateVector=val;}; void setGlobal(bool val){varIsLocal=!val;}; void markAsGlobal(){varIsLocal=false;}; void setNotInState() { varIsInStateVector=false; } bool isInState() { return varIsInStateVector; } bool isLocalState() { return varIsInStateVector && varIsLocal; } bool isGlobalState() { return varIsInStateVector && !varIsLocal; } bool isLocalVar() { return varIsLocal; } bool isGlobalVar() { return !varIsLocal; } }; bool nodeHasStateVecVarAttrib(SgNode* node); StateVecVarASTAttrib * getStateVecVarAttrib(SgNode* node); void setStateVecVarAttrib(SgNode*node,StateVecVarASTAttrib* attr);
18.884615
66
0.758656
[ "vector" ]
dfcbc3db627e2657723111de97fe18d570fd5dbb
2,492
h
C
Raven.CppClient/MultiGetCommand.h
maximburyak/ravendb-cpp-client
ab284d00bc659e8438c829f1b4a39aa78c31fa88
[ "MIT" ]
null
null
null
Raven.CppClient/MultiGetCommand.h
maximburyak/ravendb-cpp-client
ab284d00bc659e8438c829f1b4a39aa78c31fa88
[ "MIT" ]
null
null
null
Raven.CppClient/MultiGetCommand.h
maximburyak/ravendb-cpp-client
ab284d00bc659e8438c829f1b4a39aa78c31fa88
[ "MIT" ]
null
null
null
#pragma once #include "RavenCommand.h" #include "GetResponse.h" #include "HttpCache.h" #include "GetRequest.h" namespace ravendb::client::documents::commands::multi_get { class MultiGetCommand : public http::RavenCommand<std::vector<GetResponse>> { private: const std::reference_wrapper <http::HttpCache> _cache; const std::reference_wrapper<const std::vector<GetRequest>> _commands; std::string _base_url{}; public: MultiGetCommand(http::HttpCache& cache, const std::vector<GetRequest>& commands) : _cache(cache) , _commands(commands) { _response_type = http::RavenCommandResponseType::RAW; } void create_request(CURL* curl, const ServerNode& node, std::string& url) override { std::ostringstream url_builder; url_builder << node.url << "/databases/" << node.database; _base_url = url_builder.str(); curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1); //TODO use the cache nlohmann::json object = nlohmann::json::object(); nlohmann::json array = nlohmann::json::array(); using impl::utils::json_utils::set_val_to_json; for(const auto& command : _commands.get()) { nlohmann::json temp_object = nlohmann::json::object(); std::ostringstream temp_url{}; temp_url << "/databases/" << node.database + command.url; set_val_to_json(temp_object, "Url", temp_url.str()); set_val_to_json(temp_object, "Query", command.query); set_val_to_json(temp_object, "Method", command.method); set_val_to_json(temp_object, "Headers", command.headers); nlohmann::json content = nullptr; if(command.content) { command.content->write_content(content); } set_val_to_json(temp_object, "Content", content); array.push_back(std::move(temp_object)); } set_val_to_json(object, "Requests", std::move(array)); curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, object.dump().c_str()); _headers_list.append("Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, _headers_list.get()); url_builder << "/multi_get"; url = url_builder.str(); } bool is_read_request() const noexcept override { return false; } void set_response(CURL* curl, const nlohmann::json& response, bool from_cache) override { auto it = response.find("Results"); if(it == response.end() || !it->is_array()) { throw std::invalid_argument("wrong response"); } for(const auto& result : *it) { _result.push_back(result.get<GetResponse>()); } } }; }
27.688889
89
0.69703
[ "object", "vector" ]
dfd55a46589f9e6f9823402e9675eda369d9f246
11,163
h
C
src/BasicTools/Graph/UndirectedGraph.h
CRLab/ObjRecRANSAC
32e6a422465d710f54e6fac3d96fd80bc862f679
[ "Unlicense" ]
30
2015-05-31T06:27:25.000Z
2021-06-03T11:42:43.000Z
src/BasicTools/Graph/UndirectedGraph.h
CRLab/ObjRecRANSAC
32e6a422465d710f54e6fac3d96fd80bc862f679
[ "Unlicense" ]
3
2016-02-17T04:22:29.000Z
2019-04-03T13:33:56.000Z
src/BasicTools/Graph/UndirectedGraph.h
CRLab/ObjRecRANSAC
32e6a422465d710f54e6fac3d96fd80bc862f679
[ "Unlicense" ]
26
2015-03-12T05:33:32.000Z
2021-12-07T02:50:35.000Z
/* * Graph.h * * Created on: Jan 22, 2010 * Author: papazov */ #ifndef _TUM_UNDIRECTED_GRAPH_H_ #define _TUM_UNDIRECTED_GRAPH_H_ #include "GraphNode.h" #include "GraphNodeData.h" #include <cstdio> #include <string> #include <list> #include <map> using namespace std; namespace tum { /** This is an implementation of an undirected graph. */ template <class _Key_, class _Compare_> class UndirectedGraph { public: UndirectedGraph(); virtual ~UndirectedGraph(); /** Adds 'node_pair' and its 'neighbours' to this graph. The method checks whether the nodes specified by the keys * given in 'node_pair' and 'neighbours' already exist in the graph or not and creates new nodes only for the new keys. * At the end the node given by 'node_pair' will be neighbour with the nodes in 'neighbours'. If 'neighbours' is NULL * the method will just insert the node given by 'node_pair' in the graph (if the key of 'node_pair' is not already * in use). If 'deleteNotInsertedData' is 'true' then the method will delete each 'GraphNodeData' object (provided by * the user in 'node' and 'neighbours') which is not inserted in to the graph because the corresponding key is already * in use. */ void addNodes(pair<_Key_, GraphNodeData*> node, list<pair<_Key_, GraphNodeData*> > *neighbours, bool deleteNotInsertedData); int getNumberOfNodes(){ return mAllNodes.size();} map<_Key_, GraphNode<_Key_,_Compare_>*, _Compare_>& getNodes(){ return mAllNodes;} /** The method constructs a string which can be visualized with the graphviz library. */ inline void getGraphVizString(string& graphVizStr); /** The method constructs a string in the DOT format and saves it in 'graphVizStr' which can be visualized with the * graphviz library. Each edge is contained only once in the string, i.e., if A is connected with B 'graphViz' will * contain either A--B or B--A, but NOT both! */ inline void getGraphVizStringSingleEdges(string& graphVizStr); inline void print(FILE* stream, const char* label = NULL); inline void printShort(FILE* stream, const char* label = NULL); /** Deletes all nodes. */ inline void clear(); protected: /** This list contains one node per independent component of this graph. The nodes can be used * as entry points for the independent components of the graph. */ // list<GraphNode*> mComponents; /** This is a map of all nodes in this graph. It is useful when some operation needs to be done * with all nodes of the graph. */ map<_Key_, GraphNode<_Key_,_Compare_>*, _Compare_> mAllNodes; int mGraphNodeLabel; }; }//namespace tum //=== inline methods =========================================================================================================== template<class _Key_, class _Compare_> tum::UndirectedGraph<_Key_, _Compare_>::UndirectedGraph() { mGraphNodeLabel = 1; } //============================================================================================================================== template<class _Key_, class _Compare_> tum::UndirectedGraph<_Key_, _Compare_>::~UndirectedGraph() { this->clear(); } //============================================================================================================================== template<class _Key_, class _Compare_> inline void tum::UndirectedGraph<_Key_, _Compare_>::clear() { typename map<_Key_, GraphNode<_Key_,_Compare_>*, _Compare_>::iterator it; for ( it = mAllNodes.begin() ; it != mAllNodes.end() ; ++it ) delete it->second; mAllNodes.clear(); mGraphNodeLabel = 1; } //============================================================================================================================== template<class _Key_, class _Compare_> inline void tum::UndirectedGraph<_Key_, _Compare_>::printShort(FILE* stream, const char* label) { typename map<_Key_, GraphNode<_Key_,_Compare_>*, _Compare_>::iterator node; if ( label ) fprintf(stream, "%s\n{\n", label); else fprintf(stream, "undirected graph\n{\n"); for ( node = mAllNodes.begin() ; node != mAllNodes.end() ; ++node ) { if ( !node->second->getData() ) { fprintf(stream, "ERROR: there is a node without data!\n"); return; } fprintf(stream, " '%s' has %i neighbour(s)\n", node->second->getData()->getLabel(), node->second->getNumberOfNeighbours()); } fprintf(stream, "}\n"); fflush(stream); } //============================================================================================================================== template<class _Key_, class _Compare_> inline void tum::UndirectedGraph<_Key_, _Compare_>::print(FILE* stream, const char* label) { typename map<_Key_, GraphNode<_Key_,_Compare_>*, _Compare_>::iterator node; if ( label ) fprintf(stream, "%s\n{\n", label); else fprintf(stream, "undirected graph\n{\n"); for ( node = mAllNodes.begin() ; node != mAllNodes.end() ; ++node ) { map<_Key_,GraphNode<_Key_,_Compare_>*,_Compare_>& neighbours = node->second->getNeighbours(); typename map<_Key_,GraphNode<_Key_,_Compare_>*,_Compare_>::iterator neigh; if ( !node->second->getData() ) { fprintf(stream, "ERROR: there is a node without data!\n"); return; } fprintf(stream, " %s: ", node->second->getData()->getLabel()); for ( neigh = neighbours.begin() ; neigh != neighbours.end() ; ++neigh ) { if ( !neigh->second->getData() ) { fprintf(stream, "ERROR: there is a node without data!\n"); return; } fprintf(stream, " %s ", neigh->second->getData()->getLabel()); } fprintf(stream, "\n"); } fprintf(stream, "}\n"); fflush(stream); } //============================================================================================================================== template<class _Key_, class _Compare_> void tum::UndirectedGraph<_Key_, _Compare_>::addNodes(pair<_Key_, GraphNodeData*> node_pair, list<pair<_Key_, GraphNodeData*> > *neighbours, bool deleteNotInsertedData) { // Some variables GraphNode<_Key_,_Compare_>* node = new GraphNode<_Key_,_Compare_>(node_pair.first); pair<typename map<_Key_, GraphNode<_Key_,_Compare_>*>::iterator, bool> insertResult; // Try to insert the new node insertResult = mAllNodes.insert(pair<_Key_,GraphNode<_Key_,_Compare_>*>(node->getKey(), node)); // If 'true' then 'node' was inserted otherwise (i.e., 'false') its key already exists if ( insertResult.second ) node->setData(node_pair.second); else { // There is already a graph node with this key -> delete 'node' delete node; if ( deleteNotInsertedData ) delete node_pair.second; // Get the existing graph node node = insertResult.first->second; } // Check if we should add some neighbours if ( neighbours ) { for ( typename list<pair<_Key_,GraphNodeData*> >::iterator it = neighbours->begin() ; it != neighbours->end() ; ++it ) { // Create a new neighbour candidate GraphNode<_Key_,_Compare_>* neigh_node = new GraphNode<_Key_,_Compare_>(it->first); // Try to add 'neigh_node' to the graph insertResult = mAllNodes.insert(pair<_Key_,GraphNode<_Key_,_Compare_>*>(neigh_node->getKey(), neigh_node)); if ( insertResult.second ) // The node was really inserted to the graph neigh_node->setData(it->second); else { // There already exists a node with key 'it->first' delete neigh_node; if ( deleteNotInsertedData ) delete it->second; // Get the existing node neigh_node = insertResult.first->second; } // Add 'neigh_node' as neighbour of 'node' node->addNeighbour(neigh_node); // Add 'node' as neighbour of 'neigh_node' neigh_node->addNeighbour(node); } } } //============================================================================================================================== template<class _Key_, class _Compare_> inline void tum::UndirectedGraph<_Key_, _Compare_>::getGraphVizString(string& graphVizStr) { graphVizStr += "graph undirected \n{\n"; GraphNodeData* data; char node_str[GND_MAX_LABEL_SIZE], neigh_str[GND_MAX_LABEL_SIZE]; for ( typename map<_Key_,GraphNode<_Key_,_Compare_>*>::iterator it = mAllNodes.begin() ; it != mAllNodes.end() ; ++it ) { data = it->second->getData(); if ( data ) { if ( data->getLabel()[0] == '\0' ) sprintf(data->getLabel(), "%i", mGraphNodeLabel++); sprintf(node_str, "%s", data->getLabel()); } else sprintf(node_str, "%i", mGraphNodeLabel++); map<_Key_,GraphNode<_Key_,_Compare_>*>& neighs = it->second->getNeighbours(); if ( neighs.size() ) { typename map<_Key_,GraphNode<_Key_,_Compare_>*>::iterator neigh_it; graphVizStr += '\t'; for ( neigh_it = neighs.begin() ; neigh_it != neighs.end() ; ++neigh_it ) { data = neigh_it->second->getData(); if ( data ) { if ( data->getLabel()[0] == '\0' ) sprintf(data->getLabel(), "%i", mGraphNodeLabel++); sprintf(neigh_str, "%s", data->getLabel()); } else sprintf(neigh_str, "%i", mGraphNodeLabel++); graphVizStr += node_str; graphVizStr += "--"; graphVizStr += neigh_str; graphVizStr += "; "; } graphVizStr += '\n'; } else { graphVizStr += '\t'; graphVizStr += node_str; graphVizStr += ";\n"; } } graphVizStr += "}\n"; } //============================================================================================================================== template<class _Key_, class _Compare_> inline void tum::UndirectedGraph<_Key_, _Compare_>::getGraphVizStringSingleEdges(string& graphVizStr) { typename map<_Key_,GraphNode<_Key_,_Compare_>*>::iterator it; GraphNodeData* data; char node_str[GND_MAX_LABEL_SIZE], neigh_str[GND_MAX_LABEL_SIZE]; int i; graphVizStr += "graph undirected \n{\n"; // Just set the node ids for ( i = 0, it = mAllNodes.begin() ; it != mAllNodes.end() ; ++it, ++i ) it->second->setTmpId(i); for ( i = 0, it = mAllNodes.begin() ; it != mAllNodes.end() ; ++it, ++i ) { data = it->second->getData(); if ( data ) { if ( data->getLabel()[0] == '\0' ) sprintf(data->getLabel(), "%i", it->second->getTmpId()); sprintf(node_str, "%s", data->getLabel()); } else sprintf(node_str, "%i", it->second->getTmpId()); map<_Key_,GraphNode<_Key_,_Compare_>*>& neighs = it->second->getNeighbours(); if ( neighs.size() ) { typename map<_Key_,GraphNode<_Key_,_Compare_>*>::iterator neigh_it; graphVizStr += '\t'; for ( neigh_it = neighs.begin() ; neigh_it != neighs.end() ; ++neigh_it ) { if ( neigh_it->second->getTmpId() < i ) continue; data = neigh_it->second->getData(); if ( data ) { if ( data->getLabel()[0] == '\0' ) sprintf(data->getLabel(), "%i", neigh_it->second->getTmpId()); sprintf(neigh_str, "%s", data->getLabel()); } else sprintf(neigh_str, "%i", neigh_it->second->getTmpId()); graphVizStr += node_str; graphVizStr += "--"; graphVizStr += neigh_str; graphVizStr += "; "; } graphVizStr += '\n'; } else { graphVizStr += '\t'; graphVizStr += node_str; graphVizStr += ";\n"; } } graphVizStr += "}\n"; } //============================================================================================================================== #endif /* _TUM_UNDIRECTED_GRAPH_H_ */
32.73607
140
0.605751
[ "object" ]
dfd98806c15b3dc5567ce576ee3aec4fea946bb6
730
h
C
src/OptiBluetooth.h
KarolStola/Opti
4364ad585a278dfc7a80fd48866f9be4541f04a4
[ "MIT" ]
null
null
null
src/OptiBluetooth.h
KarolStola/Opti
4364ad585a278dfc7a80fd48866f9be4541f04a4
[ "MIT" ]
null
null
null
src/OptiBluetooth.h
KarolStola/Opti
4364ad585a278dfc7a80fd48866f9be4541f04a4
[ "MIT" ]
null
null
null
#ifndef OPTI_BLUETOOTH_H #define OPTI_BLUETOOTH_H #include <Arduino.h> #include <BluetoothSerial.h> class OptiBluetooth { public: OptiBluetooth(const std::string & deviceName); void Initialize(); void Update(); void AddMessageHandler(class BluetoothMessageHandler * handler); void SendMessage(const String & message); void SetMessageDelimiter(char ending); virtual ~OptiBluetooth(); private: void HandleMessage(const String & message); static constexpr char invalidDelimiter = 127; char messageDelimiter = invalidDelimiter; std::string deviceName; BluetoothSerial bluetoothSerial; std::vector<class BluetoothMessageHandler *> messageHandlers; void Cleanup(); }; #endif
24.333333
68
0.742466
[ "vector" ]
dfe8cff7fba882f3e2673bc7790368425bcda285
9,256
h
C
level03/smartshoe/insole_pressure_detector/wifilib.h
bmcage/skills4smartex
44ed5b074c441974cd66025ef83b0eb7ca12546c
[ "BSD-3-Clause" ]
null
null
null
level03/smartshoe/insole_pressure_detector/wifilib.h
bmcage/skills4smartex
44ed5b074c441974cd66025ef83b0eb7ca12546c
[ "BSD-3-Clause" ]
null
null
null
level03/smartshoe/insole_pressure_detector/wifilib.h
bmcage/skills4smartex
44ed5b074c441974cd66025ef83b0eb7ca12546c
[ "BSD-3-Clause" ]
null
null
null
#include <ESP8266WiFi.h> //WPA2 Enterprise support extern "C" { #include "user_interface.h" #include "wpa2_enterprise.h" } #include <WiFiUdp.h> #include "myNTPClient.h" #include <Time.h> #include <TimeLib.h> #include <Timezone.h> //MQTT library #include <PubSubClient.h> bool personinbed = true; unsigned long NTPUpdateInterval = 60000 ; unsigned long NTPstartTijd; unsigned long NTPlastUpdate; time_t utc, localtimenow=0; unsigned long currentTime; unsigned long wifireconnectTime = 0; unsigned long mqttreconnectTime = 0; bool correcttimeset = false, firstcorrecttime = false; IPAddress ip; //IPAddress mqtt_ip(mqtt_server_IP[0], mqtt_server_IP[1], mqtt_server_IP[2], mqtt_server_IP[3]); bool obtainedwifi = false; // Define NTP properties #define NTP_OFFSET 60 * 60 // Summer Time ? //#define NTP_OFFSET 60 * 0 // Winter Time ? #define NTP_INTERVAL 60 * 1000 // In miliseconds bool UK_DATE = false; // Set up the NTP UDP client WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL); //NTPClient timeClient2(ntpUDP, NTP_ADDRESS2, NTP_OFFSET, NTP_INTERVAL); // Set up the MQTT client WiFiClient espClient; PubSubClient MQTTclient(espClient); String date; String t; //const char * days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} ; //const char * months[] = {"Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"} ; //const char * ampm[] = {"AM", "PM"} ; const char * days[] = {"Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za"} ; const char * months[] = {"Jan", "Feb", "Maa", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} ; const char * ampm[] = {"VM", "NM"} ; // set up the wifi connection. If wait, we wait for the wifi to come up // indefenitely void setupWiFi(bool wait) { int nrpoints; // Connect to WiFi network if (SERIALTESTOUTPUT) { Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); } //we only try to set up wifi once every 2 minutes ! if (wait || (millis() - wifireconnectTime > 2*60000L)) { //clean up any old config that are still present WiFi.softAPdisconnect(); WiFi.disconnect(); if (WPA2_ENTERPRISE_CONNECTION) { // WPA2 Connection starts here // Setting ESP into STATION mode only (no AP mode or dual mode) wifi_set_opmode(STATION_MODE); struct station_config wifi_config; memset(&wifi_config, 0, sizeof(wifi_config)); strcpy((char*)wifi_config.ssid, ssid); wifi_station_set_config(&wifi_config); wifi_station_clear_cert_key(); wifi_station_clear_enterprise_ca_cert(); wifi_station_set_wpa2_enterprise_auth(1); wifi_station_set_enterprise_identity((uint8*)username, strlen(username)); wifi_station_set_enterprise_username((uint8*)username, strlen(username)); wifi_station_set_enterprise_password((uint8*)password, strlen(password)); wifi_station_connect(); // WPA2 Connection ends here } else if (use_static_IP) { // we force a static IP for this station and set IPAddress stationIP(static_IP[0], static_IP[1], static_IP[2], static_IP[3]); IPAddress gateway(static_gateway_IP[0], static_gateway_IP[1], static_gateway_IP[2], static_gateway_IP[3]); // set gateway to match your network IPAddress subnet(255, 255, 255, 0); // set subnet mask to match yourelse WiFi.mode(WIFI_STA); delay(100); //set a static IP address WiFi.config(stationIP, gateway, subnet); WiFi.begin(ssid, password); } else { WiFi.mode(WIFI_AP); WiFi.begin(ssid, password); } wifireconnectTime = millis(); } if (wait) { unsigned long startwait = millis(); while (WiFi.status() != WL_CONNECTED) { nrpoints += 1; delay(500); if (SERIALTESTOUTPUT) { Serial.print("."); } if (nrpoints > 50) { nrpoints = 0; if (SERIALTESTOUTPUT) Serial.println(" "); } if (millis() - startwait > 20000L ) { Serial.println(""); Serial.println("Could not connect WiFi"); return; } } if (SERIALTESTOUTPUT) { Serial.println(""); Serial.println("WiFi connected"); } } } void MQTTsubscribe2topics() { //write here all MQTT topics we subscribe to. Act on it in the callback! //MQTTclient.subscribe("xxxxx"); } void MQTTpublish_reconnected() { //publish a message that we connected to MQTTclient.publish("RoomEnv_T_RH-Status", "Sensor T-RH reconnected to MQTTserver"); } boolean MQTTpublish(const char* topic, const char* payload) { // API to publish to the server. // this is used to notify of sensor data MQTTclient.publish(topic, payload); } void MQTTreconnect() { // We connect to the MQTT broker //we only try to set up mqtt connection once every 1 minutes ! if (!MQTTclient.connected() && (millis() < 60000L || millis() - mqttreconnectTime > 1*60000L)) { if (SERIALTESTOUTPUT) { Serial.print("Attempting MQTT connection..."); } // Create a random client ID String clientId = "RoomEnv_T_RH-"; clientId += String(random(0xffff), HEX); // Attempt to connect if (MQTTclient.connect(clientId.c_str())) { if (SERIALTESTOUTPUT) { Serial.println("connected now"); } // Once connected, publish an announcement ? MQTTpublish_reconnected(); // ... and resubscribe to all topics MQTTsubscribe2topics(); } else { if (SERIALTESTOUTPUT) { Serial.print("failed, rc="); Serial.print(MQTTclient.state()); Serial.println(" try again in 60 seconds"); } } mqttreconnectTime = millis(); } } void MQTT_msg_callback(char* topic, byte* payload, unsigned int length) { // if a topic subscribed to in reconnect occurs, this callback is called if (SERIALTESTOUTPUT) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); } } void setupMQTTClient() { // to call in the setup of the arduino MQTTclient.setServer(mqtt_server, 1883); MQTTclient.setCallback(MQTT_msg_callback); } void handleMQTTClient() { // to call in the loop of the arduino if (!MQTTclient.connected()) { MQTTreconnect(); } MQTTclient.loop(); } void obtainDateTime() { if (WiFi.status() == WL_CONNECTED) //Check WiFi connection status { ip = WiFi.localIP(); obtainedwifi = true; date = ""; // clear the variables t = ""; // update the NTP client and get the UNIX UTC timestamp unsigned long epochTime; //if (random(0,2) == 0) { timeClient.update(); NTPlastUpdate = millis(); epochTime = timeClient.getEpochTime(); //} else {timeClient2.update(); // NTPlastUpdate = millis(); // epochTime = timeClient2.getEpochTime(); //} // convert received time stamp to time_t object time_t local; utc = epochTime; setTime(utc); // Then convert the UTC UNIX timestamp to local time // normal time from zon 2 march to sun 2 nov TimeChangeRule euBRU = {"BRU", Second, Sun, Mar, 2, +60}; //normal time UTC + 1 hours - change this as needed TimeChangeRule euUCT = {"UCT", First, Sun, Nov, 2, 0}; //daylight saving time summer: UTC - change this as needed Timezone euBrussel(euBRU, euUCT); local = euBrussel.toLocal(utc); // now format the Time variables into strings with proper names for month, day etc date += days[weekday(local)-1]; date += ", "; date += day(local); date += " "; date += months[month(local)-1]; date += ", "; int yearnow = year(local); date += yearnow; if (firstcorrecttime) firstcorrecttime = false; if (!correcttimeset && yearnow > 2000) { firstcorrecttime = true; correcttimeset = true; } if (UK_DATE) { // format the time to 12-hour format with AM/PM and no seconds t += hourFormat12(local); } else { // normal format hour t += hour(local); } t += ":"; if(minute(local) < 10) // add a zero if minute is under 10 t += "0"; t += minute(local); t += " "; if (UK_DATE) { t += ampm[isPM(local)]; t += " "; } if (SERIALTESTOUTPUT) { // Display the date and time Serial.println(""); Serial.print("Local date: "); Serial.print(date); Serial.println(""); Serial.print("Local time: "); Serial.println(t); } } else { //reconnect obtainedwifi = false; } } /* SET variable localtimenow to the correct current time */ void determine_localtimenow() { time_t timenow = now(); // Then convert the UTC UNIX timestamp to local time // Then convert the UTC UNIX timestamp to local time // normal time from zon 2 march to sun 2 nov TimeChangeRule euBRU = {"BRU", Second, Sun, Mar, 2, +60}; //normal time UTC + 1 hours - change this as needed TimeChangeRule euUCT = {"UCT", First, Sun, Nov, 2, 0}; //daylight saving time summer: UTC - change this as needed Timezone euBrussel(euBRU, euUCT); localtimenow = euBrussel.toLocal(timenow); }
30.547855
149
0.64099
[ "object" ]
dff469beb635895cbd93149faf2a920606a30f6b
5,927
h
C
chrome/browser/tab_contents/tab_contents_view_gtk.h
SlimKatLegacy/android_external_chromium
bc611cda58cc18d0dbaa8a7aee05eb3c0742e573
[ "BSD-3-Clause" ]
2
2017-02-20T14:25:04.000Z
2019-12-13T13:58:28.000Z
chrome/browser/tab_contents/tab_contents_view_gtk.h
SlimKatLegacy/android_external_chromium
bc611cda58cc18d0dbaa8a7aee05eb3c0742e573
[ "BSD-3-Clause" ]
2
2017-07-25T09:37:22.000Z
2017-08-04T07:18:56.000Z
chrome/browser/tab_contents/tab_contents_view_gtk.h
SlimKatLegacy/android_external_chromium
bc611cda58cc18d0dbaa8a7aee05eb3c0742e573
[ "BSD-3-Clause" ]
2
2020-01-12T00:55:53.000Z
2020-11-04T06:36:41.000Z
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ #pragma once #include <gtk/gtk.h> #include <vector> #include "base/memory/scoped_ptr.h" #include "chrome/browser/ui/gtk/focus_store_gtk.h" #include "chrome/browser/ui/gtk/owned_widget_gtk.h" #include "content/browser/tab_contents/tab_contents_view.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "ui/base/gtk/gtk_signal.h" class ConstrainedWindowGtk; class RenderViewContextMenuGtk; class SadTabGtk; class TabContentsDragSource; class WebDragDestGtk; class TabContentsViewGtk : public TabContentsView, public NotificationObserver { public: // The corresponding TabContents is passed in the constructor, and manages our // lifetime. This doesn't need to be the case, but is this way currently // because that's what was easiest when they were split. explicit TabContentsViewGtk(TabContents* tab_contents); virtual ~TabContentsViewGtk(); // Unlike Windows, ConstrainedWindows need to collaborate with the // TabContentsViewGtk to position the dialogs. void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window); void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); // Override the stored focus widget. This call only makes sense when the // tab contents is not focused. void SetFocusedWidget(GtkWidget* widget); // TabContentsView implementation -------------------------------------------- virtual void CreateView(const gfx::Size& initial_size); virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host); virtual gfx::NativeView GetNativeView() const; virtual gfx::NativeView GetContentNativeView() const; virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); virtual void OnTabCrashed(base::TerminationStatus status, int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); virtual void GetViewBounds(gfx::Rect* out) const; // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); virtual void ShowPopupMenu(const gfx::Rect& bounds, int item_height, double item_font_size, int selected_item, const std::vector<WebMenuItem>& items, bool right_aligned); virtual void StartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask allowed_ops, const SkBitmap& image, const gfx::Point& image_offset); virtual void UpdateDragCursor(WebKit::WebDragOperation operation); virtual void GotFocus(); virtual void TakeFocus(bool reverse); // NotificationObserver implementation --------------------------------------- virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); private: // Insert the given widget into the content area. Should only be used for // web pages and the like (including interstitials and sad tab). Note that // this will be perfectly happy to insert overlapping render views, so care // should be taken that the correct one is hidden/shown. void InsertIntoContentArea(GtkWidget* widget); void CancelDragIfAny(); // Handle focus traversal on the render widget native view. CHROMEGTK_CALLBACK_1(TabContentsViewGtk, gboolean, OnFocus, GtkDirectionType); // Used to adjust the size of its children when the size of |expanded_| is // changed. CHROMEGTK_CALLBACK_2(TabContentsViewGtk, void, OnChildSizeRequest, GtkWidget*, GtkRequisition*); // Used to propagate the size change of |expanded_| to our RWHV to resize the // renderer content. CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSizeAllocate, GtkAllocation*); CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSetFloatingPosition, GtkAllocation*); // Contains |expanded_| as its GtkBin member. OwnedWidgetGtk floating_; // This container holds the tab's web page views. It is a GtkExpandedContainer // so that we can control the size of the web pages. GtkWidget* expanded_; // The context menu is reset every time we show it, but we keep a pointer to // between uses so that it won't go out of scope before we're done with it. scoped_ptr<RenderViewContextMenuGtk> context_menu_; // Used to get notifications about renderers coming and going. NotificationRegistrar registrar_; scoped_ptr<SadTabGtk> sad_tab_; FocusStoreGtk focus_store_; // The UI for the constrained dialog currently displayed. This is owned by // TabContents, not the view. ConstrainedWindowGtk* constrained_window_; // The helper object that handles drag destination related interactions with // GTK. scoped_ptr<WebDragDestGtk> drag_dest_; // Object responsible for handling drags from the page for us. scoped_ptr<TabContentsDragSource> drag_source_; // The size we want the tab contents view to be. We keep this in a separate // variable because resizing in GTK+ is async. gfx::Size requested_size_; DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk); }; #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
39.778523
80
0.722625
[ "render", "object", "vector" ]
dff6d93c4395d5f83c5216c1d47e284d64e25791
11,920
h
C
starter/ios/Runner/dcmtk/dcmtk/dcmfg/fgctreconstruction.h
happymanx/Weather_FFI
a7f9bf8f1bda2b50c9d9a875c08fccf58379ad9f
[ "MIT" ]
null
null
null
starter/ios/Runner/dcmtk/dcmtk/dcmfg/fgctreconstruction.h
happymanx/Weather_FFI
a7f9bf8f1bda2b50c9d9a875c08fccf58379ad9f
[ "MIT" ]
null
null
null
starter/ios/Runner/dcmtk/dcmtk/dcmfg/fgctreconstruction.h
happymanx/Weather_FFI
a7f9bf8f1bda2b50c9d9a875c08fccf58379ad9f
[ "MIT" ]
null
null
null
/* * * Copyright (C) 2019, Open Connections GmbH * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation are maintained by * * OFFIS e.V. * R&D Division Health * Escherweg 2 * D-26121 Oldenburg, Germany * * * Module: dcmfg * * Author: Michael Onken * * Purpose: Class for managing the CT Reconstruction Functional Group * */ #ifndef FGCTRECONSTRUCTION_H #define FGCTRECONSTRUCTION_H #include "dcmtk/config/osconfig.h" #include "dcmtk/dcmdata/dctk.h" #include "dcmtk/dcmfg/fgbase.h" #include "dcmtk/ofstd/ofstring.h" #include "dcmtk/ofstd/ofvector.h" /** Class representing the "CT Reconstruction" Functional Group Macro. */ class DCMTK_DCMFG_EXPORT FGCTReconstruction : public FGBase { public: /** Constructor, creates empty functional group */ FGCTReconstruction(); /** Virtual destructor */ virtual ~FGCTReconstruction(); /** Returns a deep copy of this object * @return Deep copy of this object */ virtual FGBase* clone() const; /** Returns shared functional group type * @return The functional group type (DcmFGTypes::EFGS_BOTH) */ virtual DcmFGTypes::E_FGSharedType getSharedType() const { return DcmFGTypes::EFGS_BOTH; } /** Clear all data */ virtual void clearData(); /** Check whether the current content of this group is consistent and complete * @return EC_Normal, if no errors are found, error otherwise */ virtual OFCondition check() const; /** Read CT Reconstruction Sequence from given item * @param item The item to read from * @return EC_Normal if reading was successful, error otherwise */ virtual OFCondition read(DcmItem& item); /** Writes the content of this class into CT Reconstruction Sequence * (newly created) into given item * @param item The item to write to * @return EC_Normal if writing was successful, error otherwise */ virtual OFCondition write(DcmItem& item); /** Comparison operator that compares the normalized value of this object * with a given object of the same type, i.e.\ the elements within both * functional groups (this and rhs parameter) are compared by value! * Both objects (this and rhs) need to have the same type (i.e.\ both * FGUnknown) to be comparable. This function is used in order * to decide whether a functional group already exists, or is new. This * is used in particular to find out whether a given functional group * can be shared (i.e.\ the same information already exists as shared * functional group) or is different from the same shared group. In that * case the shared functional group must be distributed into per-frame * functional groups, instead. The exact implementation for implementing * the comparison is not relevant. However, it must be a comparison * by value. * @param rhs the right hand side of the comparison * @return 0 if the object values are equal. * -1 if either the value of the first component that does not match * is lower in the this object, or all compared components match * but this component is shorter. Also returned if this type and * rhs type (DcmFGTypes::E_FGType) do not match. * 1 if either the value of the first component that does not match * is greater in this object, or all compared components match * but this component is longer. */ virtual int compare(const FGBase& rhs) const; // --- get() functionality --- /** Get Reconstruction Algorithm * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionAlgorithm(OFString& value, const signed long pos = 0); /** Get Convolution Kernel * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getConvolutionKernel(OFString& value, const signed long pos = 0); /** Get Convolution Kernel Group * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getConvolutionKernelGroup(OFString& value, const signed long pos = 0); /** Get Reconstruction Diameter * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionDiameter(OFString& value, const signed long pos = 0); /** Get Reconstruction Diameter * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1) * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionDiameter(Float64& value, const unsigned long pos = 0); /** Get Reconstruction Field of View * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionFieldOfView(OFString& value, const signed long pos = 0); /** Get Reconstruction Field of View * @param values Reference to variable that should hold the result * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionFieldOfView(OFVector<Float64>& values); /** Get Reconstruction Pixel Spacing * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionPixelSpacing(OFString& value, const signed long pos = 0); /** Get Reconstruction Pixel Spacing * @param values Reference to variable that should hold the result * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionPixelSpacing(OFVector<Float64>& values); /** Get Reconstruction Angle * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionAngle(OFString& value, const signed long pos = 0); /** Get Reconstruction Angle * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1) * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getReconstructionAngle(Float64& value, const unsigned long pos = 0); /** Get Image Filter * @param value Reference to variable that should hold the result * @param pos Index of the value to get (0..vm-1), -1 for all components * @return EC_Normal, if value could be returned, error otherwise */ virtual OFCondition getImageFilter(OFString& value, const signed long pos = 0); // --- set() functionality --- /** Set Reconstruction Algorithm * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setReconstructionAlgorithm(const OFString& value, const OFBool checkValue = OFTrue); /** Set Convolution Kernel * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setConvolutionKernel(const OFString& value, const OFBool checkValue = OFTrue); /** Set Convolution Kernel Group * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setConvolutionKernelGroup(const OFString& value, const OFBool checkValue = OFTrue); /** Set Reconstruction Diameter * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setReconstructionDiameter(const Float64 value, const OFBool checkValue = OFTrue); /** Set Reconstruction Field of View * @param value1 First value that should be set * @param value2 Second value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setReconstructionFieldOfView(const Float64 value1, const Float64 value2, const OFBool checkValue = OFTrue); /** Set Reconstruction Pixel Spacing * @param value1 First value that should be set * @param value2 Second value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setReconstructionPixelSpacing(const Float64 value1, const Float64 value2, const OFBool checkValue = OFTrue); /** Set Reconstruction Angle * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setReconstructionAngle(const Float64 value, const OFBool checkValue = OFTrue); /** Set Image Filter * @param value Value that should be set * @param checkValue If OFTrue, basic checks are performed whether the value is * valid for this attribute * @return EC_Normal, if value was set, error otherwise */ virtual OFCondition setImageFilter(const OFString& value, const OFBool checkValue = OFTrue); private: /* Content of CT Reconstruction Macro */ /// Reconstruction Algorithm (CS, VM 1, Required type 1C) DcmCodeString m_ReconstructionAlgorithm; /// Convolution Kernel (SH, 1-n, 1C) DcmShortString m_ConvolutionKernel; /// Convolution Kernel Group (CS, 1, 1C) DcmCodeString m_ConvolutionKernelGroup; /// Reconstruction Diameter (DS, 1, 1C) DcmDecimalString m_ReconstructionDiameter; /// Reconstruction Field of View (FD, 2, 1C) DcmFloatingPointDouble m_ReconstructionFieldOfView; /// Reconstruction Pixel Spacing (FD, 2, 1C) DcmFloatingPointDouble m_ReconstructionPixelSpacing; /// Reconstruction Angle (FD, 1, 1C) DcmFloatingPointDouble m_ReconstructionAngle; /// Image Filter (SH, 1, 1C) DcmShortString m_ImageFilter; }; #endif // FGCTRECONSTRUCTION_H
41.533101
112
0.68943
[ "object" ]
5f00411ecaa2ec6307e39b35d0e451e51313ff39
6,263
h
C
src/library/voxelization.h
DavidWilliams81/cubiquity
dc2e6f0a558c517cfc7b0bfcb40b9f1a48b0c2ed
[ "CC0-1.0" ]
151
2020-07-23T23:29:35.000Z
2022-03-28T08:37:58.000Z
src/library/voxelization.h
DavidWilliams81/cubiquity
dc2e6f0a558c517cfc7b0bfcb40b9f1a48b0c2ed
[ "CC0-1.0" ]
null
null
null
src/library/voxelization.h
DavidWilliams81/cubiquity
dc2e6f0a558c517cfc7b0bfcb40b9f1a48b0c2ed
[ "CC0-1.0" ]
8
2020-08-03T13:24:49.000Z
2022-01-18T04:50:16.000Z
/*************************************************************************************************** * Cubiquity - A micro-voxel engine for games and other interactive applications * * * * Written in 2019 by David Williams * * * * To the extent possible under law, the author(s) have dedicated all copyright and related and * * neighboring rights to this software to the public domain worldwide. This software is distributed * * without any warranty. * * * * You should have received a copy of the CC0 Public Domain Dedication along with this software. * * If not, see http://creativecommons.org/publicdomain/zero/1.0/. * ***************************************************************************************************/ #ifndef CUBIQUITY_VOXELIZATION_H #define CUBIQUITY_VOXELIZATION_H #include "utility.h" #include "geometry.h" #include "storage.h" #include <functional> #include <limits> #include <map> #include <memory> #include <random> #include <unordered_set> namespace Cubiquity { //! Respresents a set of triangles in a way which is optimised for winding number calculation. //! This class provides and implementation of the hierarchical approach to computing generalized winging numbers, as described in [REF] class ClosedTriangleTree : private Internals::NonCopyable // Avoid deep vs. shallow copy ambiguity { public: //! Constructs a ClosedTriangleTree from a TriangleList. explicit ClosedTriangleTree(const TriangleList &triangles, bool tidyInput = true); private: Box3f mBounds; TriangleList mTriangles; TriangleList mClosingTriangles; std::unique_ptr<ClosedTriangleTree> mChildren[2]; // Making this function a friend lets us keep this class opaque to the user. friend float computeWindingNumber(const Vector3f& queryPoint, const ClosedTriangleTree& meshNode); }; //! Calculates the winding number for a query point and a list of triangles //! This overload uses a simple brute-force approch and is privided mostly for reference. float computeWindingNumber(const Vector3f& queryPoint, const TriangleList& triangles); //! Calculates the winding number for a query point and a hierarchical triangle structure. //! This overload is much faster than using a triangle list and the theorectical result is //! exactly the same. In practice there are some small deviations for at least two reasons: //! * Diffeent triangles are processed and in a different order, hence there is //! potential for floating-point incacuracies to creep in. //! * The triangles in the hierarchical struture are (usually) quantized slightly to //! improve floating-point comparisons (see ClosedTriangleTree). float computeWindingNumber(const Vector3f& queryPoint, const ClosedTriangleTree& meshNode); enum class Thickness { Separate6, Separate26, Custom }; void scanConvert3D(const Triangle& triangle, MaterialId matId, Volume& volume, Thickness thickness, float multiplier, uint pass); void scanConvert3DRecursive(const Triangle& triangle, MaterialId matId, Volume& volume, Thickness thickness, float multiplier, uint pass); typedef std::vector<MaterialId> MaterialList; class Surface { public: Surface(); void addTriangle(const Triangle& tri, MaterialId matId); void build(); std::string name; TriangleList triangles; MaterialList materials; Box3f bounds; float meanWindingNumber; MaterialId mainMaterial; std::unique_ptr<ClosedTriangleTree> closedTriangleTree; }; float findThreshold(const Surface& surface); MaterialId findMainMaterial(const Surface& surface); //! Perform a solid voxelisation of the given geometry into the volume. //! //! The provided geometry is assumed to be in 'volume space', i.e. it is correctly transformed //! to be in the desired location in the the volume. The algorithm works by firstly drawing the //! 'shell' of the geometry into the volume using a 3D version of scan conversion, and then //! classifying each part of the volume (either per-voxel or per-octree-node) as inside or //! outside. It is generally this second part which dominates the runtime. //! //! The voxelisation process works best under the following conditions: //! //! * All polygons in the scene have consistant winding. There should not be a mix of //! clockwise and counter-clockwise wound polygons. It can cause significant problems if //! this rule is violated. //! * The scene should consist of closed objects ideally with a single material. Single- //! sided objects represent windows or a ground plane can cause significant problem. //! These should be given some thickness if possible. //! * There should be no hierarchy amounst the objects, as they will be treated as a flat //! list. //! //! \param preserveSurfaceMaterials Ensures that materials which get written to the volume //! during the scan conversion do not get overwritten during the classification. This can //! be useful when one object contains multiple different materials, as otherwise the //! material which gets chosen to fill the object might overwrite the surface. It is also //! useful in conjunction wth 'internalMaterialOveride' to create objects with a different //! material on the surface compared to the inside, or to represent hollow objects. //! \param internalMaterialOveride Causes all objects to be filled with the specified material //! instead of their own. If 'preserveSurfaceMaterials' is disabled then this results in a //! binary voxelisation. void voxelize(Volume& volume, Surface& surface, bool useSurfaceMaterials = true, MaterialId* internalMaterialOverride = nullptr, MaterialId* externalMaterialOverride = nullptr); } #endif //CUBIQUITY_VOXELIZATION_H
52.191667
139
0.673479
[ "geometry", "object", "vector", "3d", "solid" ]
5f024a8531e63506702ae4ac605024634ab780f9
24,345
c
C
server.c
aakashp2000/Chess-using-tcp
37547c4694fb048511feef4721de5b3ab087a4bf
[ "Apache-2.0" ]
null
null
null
server.c
aakashp2000/Chess-using-tcp
37547c4694fb048511feef4721de5b3ab087a4bf
[ "Apache-2.0" ]
null
null
null
server.c
aakashp2000/Chess-using-tcp
37547c4694fb048511feef4721de5b3ab087a4bf
[ "Apache-2.0" ]
null
null
null
#include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> #include <unistd.h> #include <errno.h> #include <stdio.h> #include <arpa/inet.h> #include <string.h> #include <sys/wait.h> #include <iostream> #include <fstream> #include <algorithm> #define PORT 2728 using namespace std; extern int errno; char A[9][9]; int vizA[4] = {0}; int vizB[4] = {0}; void CreateTable(char A[9][9]) { int i, j; for(i = 1; i <= 8; i++) for(j = 1; j <= 8; j++) A[i][j] = '-'; // umplu matricea cu - for(i = 1; i <= 8; i++) A[i][0] = '1' + i - 1; //bordare pe linie for(i = 1; i <= 8; i++) A[9][i] = 'a' + i - 1; // bordare pe coloana A[9][0] = '*'; for(j = 1; j <= 8; j++) A[2][j] = 'P'; for(j = 1; j <= 8; j++) A[7][j] = 'p'; //turele A[1][1] = A[1][8] = 'T'; A[8][1] = A[8][8] = 't'; //cai A[1][2] = A[1][7] = 'C'; A[8][2] = A[8][7] = 'c'; //nebuni A[1][3] = A[1][6] = 'N'; A[8][3] = A[8][6] = 'n'; //Regina A[1][4] = 'Q'; A[8][4] = 'q'; //Rege A[1][5] = 'K'; A[8][5] = 'k'; } struct Player { int round; int fd; }; string Convert(char A[9][9]) { int i, j; string s = ""; for (i = 1; i <= 8; i++) { for (j = 1; j <= 8; j++) { s += A[i][j]; } } return s; } int LC(int sr, int sc, int fr, int fc) { //parcurgerea pieselor pe linii si coloane (N S E V) int i, j; if(fr > sr && fc == sc) { i = sr + 1, j = sc; while(A[i][j] == '-' && i < fr) i++; if(i == fr && j == fc) return 1; else return 0; } else if(fr < sr && fc == sc) { i = sr - 1, j = sc; while(A[i][j] == '-' && i > fr) i--; if(i == fr && j == fc) return 1; else return 0; } else if(fc > sc && fr == sr) { i = sr, j = sc + 1; while(A[i][j] == '-' && j < fc) j++; if(i == fr && j == fc) return 1; else return 0; } else if(fc < sc && fr == sr) { i = sr, j = sc - 1; while(A[i][j] == '-' && j > fc) j--; if(i == fr && j == fc) return 1; else return 0; } else return 0; } int DIAG(int sr, int sc, int fr, int fc) { // parcurgere diagonale NE NV SE SV int i, j; if(fr > sr && fc > sc) { i = sr + 1, j = sc + 1; while(A[i][j] == '-' && i < fr && j < fc) i++, j++; if(i == fr && j == fc) return 1; else return 0; } else if(fr > sr && fc < sc) { i = sr + 1, j = sc - 1; while(A[i][j] == '-' && i < fr && j > fc) i++, j--; if(i == fr && j == fc) return 1; else return 0; } else if(fr < sr && fc > sc) { i = sr - 1, j = sc + 1; while(A[i][j] == '-' && i > fr && j < fc) i--, j++; if(i == fr && j == fc) return 1; else return 0; } else if(fr < sr && fc < sc) { i = sr - 1, j = sc - 1; while(A[i][j] == '-' && i > fr && j > fc) i--, j--; if(i == fr && j == fc) return 1; else return 0; } else return 0; } int bigLetter(char letter) { if(letter >= 'A' && letter <= 'Z') return 1; return 0; } int smallLetter(char letter) { if(letter >= 'a' && letter <= 'z') return 1; return 0; } int Pion(char type, int sr, int sc, int fr, int fc) { if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(fr <= sr) return 0; // nu are voie pionul sa fie dat inapoi else if(fr - sr == 2 && sr == 2 && fc == sc && A[fr][fc] == '-') { if(smallLetter(A[fr][fc])) return 0; else return 1; } else if(fr - sr == 1 && abs(fc - sc) == 1 && (smallLetter(A[fr][fc]))) return 1; else if(fr - sr == 1 && fc == sc && !smallLetter(A[fr][fc])) return 1; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(fr >= sr) return 0; // nu are voie pionul sa fie dat inapoi else if(sr - fr == 2 && sr == 7 && fc == sc && A[fr][fc] == '-') { if(bigLetter(A[fr][fc])) return 0; else return 1; } else if(sr - fr == 1 && abs(fc - sc) == 1 && (bigLetter(A[fr][fc]))) return 1; else if(sr - fr == 1 && fc == sc && !bigLetter(A[fr][fc])) return 1; } } int Rege(char type, int sr, int sc, int fr, int fc) { if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if((abs(fr - sr) == 1 || abs(fr - sr) == 0) && (abs(fc - sc) == 1 || abs(fc - sc) == 0)) return 1; else return 0; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if((abs(fr - sr) == 1 || abs(fr - sr) == 0) && (abs(fc - sc) == 1 || abs(fc - sc) == 0)) return 1; else return 0; } } int Cal(char type, int sr, int sc, int fr, int fc) { if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii if((abs(fr - sr) == 1 || abs(fr - sr) == 2) && (abs(fc - sc) == 1 || abs(fc - sc) == 2)) return 1; else return 0; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii if((abs(fr - sr) == 1 || abs(fr - sr) == 2) && (abs(fc - sc) == 1 || abs(fc - sc) == 2)) return 1; else return 0; } } int Tura(char type, int sr, int sc, int fr, int fc) { if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(LC(sr, sc, fr, fc)) return 1; else return 0; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(LC(sr, sc, fr, fc)) return 1; else return 0; } } int Nebun(char type, int sr, int sc, int fr, int fc) { if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; else if(DIAG(sr, sc, fr, fc)) return 1; else return 0; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; else if(DIAG(sr, sc, fr, fc)) return 1; else return 0; } } int Regina(char type, int sr, int sc, int fr, int fc) { int i, j; if(bigLetter(type)) { if(bigLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(DIAG(sr, sc, fr, fc) || LC(sr, sc, fr, fc)) return 1; else return 0; } else if(smallLetter(type)) { if(smallLetter(A[fr][fc])) return 0; else if(fr > 8 || fr < 1 || fc > 8 || fc < 1) return 0; //in afara matricii else if(DIAG(sr, sc, fr, fc) || LC(sr, sc, fr, fc)) return 1; else return 0; } } int validMove(char type, int sr, int sc, int fr, int fc) { switch(type) { case 'p': if(Pion(type, sr, sc, fr, fc)) return 1; else return 0; case 'P': if(Pion(type, sr, sc, fr, fc)) return 1; else return 0; case 'k': if(Rege(type, sr, sc, fr, fc)) return 1; else return 0; case 'K': if(Rege(type, sr, sc, fr, fc)) return 1; else return 0; case 'c': if(Cal(type, sr, sc, fr, fc)) return 1; else return 0; case 'C': if(Cal(type, sr, sc, fr, fc)) return 1; else return 0; case 't': if(Tura(type, sr, sc, fr, fc)) return 1; else return 0; case 'T': if(Tura(type, sr, sc, fr, fc)) return 1; else return 0; case 'n': if(Nebun(type, sr, sc, fr, fc)) return 1; else return 0; case 'N': if(Nebun(type, sr, sc, fr, fc)) return 1; else return 0; case 'q': if(Regina(type, sr, sc, fr, fc)) return 1; else return 0; case 'Q': if(Regina(type, sr, sc, fr, fc)) return 1; else return 0; } } void findMyKing(char type, int &fr, int &fc) { int i, j; for(i = 1; i <= 8; i++) for(j = 1; j <= 8; j++) if(A[i][j] == type) { fr = i; fc = j; break; } } int isAttacked(char type, int fr, int fc) { int i, j; if(fr < 1 || fr > 8 || fc < 1 || fc > 8) return 0; else if(bigLetter(type)) { for(i = 1; i <= 8; i++) for(j = 1; j <= 8; j++) if(smallLetter(A[i][j])) if(validMove(A[i][j], i, j, fr, fc)) return 1; return 0; } else if(smallLetter(type)) { for(i = 1; i <= 8; i++) for(j = 1; j <= 8; j++) if(bigLetter(A[i][j])) if(validMove(A[i][j], i, j, fr, fc)) return 1; return 0; } } int Sah(char type) { int fr, fc; findMyKing(type, fr, fc); if(isAttacked(type, fr, fc)) return 1; return 0; } void Copy(char B[9][9], char A[9][9]) { int i, j; for(i = 1; i <= 8; i++) for(j = 1; j <= 8; j++) B[i][j] = A[i][j]; } int SahMat(char type) { const int dir[8] = {0}; char B[9][9], C[9][9]; Copy(B, A); Copy(C, A); int i, j, fr, fc; findMyKing(type, fr, fc); if(smallLetter(type)) { if(C[fr - 1][fc] == '-') A[fr - 1][fc] = 'K'; if(C[fr + 1][fc] == '-') A[fr + 1][fc] = 'K'; if(C[fr - 1][fc - 1] == '-') A[fr - 1][fc - 1] = 'K'; if(C[fr - 1][fc + 1] == '-') A[fr - 1][fc + 1] = 'K'; if(C[fr + 1][fc + 1] == '-') A[fr + 1][fc + 1] = 'K'; if(C[fr + 1][fc - 1] == '-') A[fr + 1][fc - 1] = 'K'; if(C[fr][fc - 1] == '-') A[fr][fc - 1] = 'K'; if(C[fr][fc + 1] == '-') A[fr][fc + 1] = 'K'; } else if(bigLetter(type)) { if(C[fr - 1][fc] == '-') A[fr - 1][fc] = 'k'; if(C[fr + 1][fc] == '-') A[fr + 1][fc] = 'k'; if(C[fr - 1][fc - 1] == '-') A[fr - 1][fc - 1] = 'k'; if(C[fr - 1][fc + 1] == '-') A[fr - 1][fc + 1] = 'k'; if(C[fr + 1][fc + 1] == '-') A[fr + 1][fc + 1] = 'k'; if(C[fr + 1][fc - 1] == '-') A[fr + 1][fc - 1] = 'k'; if(C[fr][fc - 1] == '-') A[fr][fc - 1] = 'k'; if(C[fr][fc + 1] == '-') A[fr][fc + 1] = 'k'; } if(Sah(type)) { int nr = 1; if(isAttacked(type, fr - 1, fc) && B[fr - 1][fc] == '-') B[fr - 1][fc] = 'x', nr++; if(isAttacked(type, fr + 1, fc) && B[fr + 1][fc] == '-') B[fr + 1][fc] = 'x', nr++; if(isAttacked(type, fr - 1, fc - 1) && B[fr - 1][fc - 1] == '-') B[fr - 1][fc - 1] = 'x', nr++; if(isAttacked(type, fr - 1, fc + 1) && B[fr - 1][fc + 1] == '-') B[fr - 1][fc + 1] = 'x', nr++; if(isAttacked(type, fr + 1, fc + 1) && B[fr + 1][fc + 1] == '-') B[fr + 1][fc + 1] = 'x', nr++; if(isAttacked(type, fr + 1, fc - 1) && B[fr + 1][fc - 1] == '-') B[fr + 1][fc - 1] = 'x', nr++; if(isAttacked(type, fr, fc - 1) && B[fr][fc - 1] == '-') B[fr][fc - 1] = 'x', nr++; if(isAttacked(type, fr, fc + 1) && B[fr][fc + 1] == '-') B[fr][fc + 1] = 'x', nr++; Copy(A, C); if(B[fr][fc + 1] == '-' || B[fr][fc - 1] == '-' || B[fr + 1][fc - 1] == '-' || B[fr + 1][fc + 1] == '-' || B[fr - 1][fc + 1] == '-' || B[fr - 1][fc - 1] == '-' || B[fr + 1][fc] == '-' || B[fr - 1][fc] == '-') return 0; if(nr > 1) return 1; } return 0; } int Message(int fd, int &verify, char move) { string s; char buffer[100]; int bytes; char msg[100], save; char msgrasp[100]=" "; bytes = read (fd, msg, sizeof (buffer)); if (bytes < 0) { perror ("Eroare la read() de la client.\n"); return 0; } int sr, sc, fr, fc; char type, c1, c2, transform; strcpy(msgrasp, msg); int i, nr = 0; // Preluare coordonate. for(i = 0; msgrasp[i]; i++) { if(msgrasp[i] != ' ') { switch(nr) { case 0: { sc = (int)msgrasp[i] - 96; c1 = msgrasp[i]; } case 1: sr = (int)msgrasp[i] - 48; case 2: { fc = (int)msgrasp[i] - 96; c2 = msgrasp[i]; } case 3: fr = (int)msgrasp[i] - 48; case 4: transform = msgrasp[i]; } nr++; } } save = A[fr][fc]; type = A[sr][sc]; //Vizitari piese pentru a verifica daca se poate executa rocada sau nu. Daca piesele au fost mutate rocada nu mai poate avea loc. if(type == 'K' && transform != 'F') vizA[2] = 1; else if(type == 'T' && sc == 1 && transform != 'F') vizA[1] = 1; else if(type == 'T' && sc == 8 && transform != 'F') vizA[3] = 1; else if(type == 'k' && transform != 'F') vizB[2] = 1; else if(type == 't' && sc == 1 && transform != 'F') vizB[1] = 1; else if(type == 't' && sc == 8 && transform != 'F') vizB[3] = 1; cout << type << " " << sr << " " << sc << " " << fr << " " << fc << " " << transform << endl; if(strcmp(msg, "surrender\n") == 0) return -1; else if(move == 'a' && SahMat('K')) { strcpy(msg, "Castigatorul este jucatorul B"); write(fd, msg, strlen(msg)); return -1; } else if(move == 'b' && SahMat('k')) { strcpy(msg, "Castigatorul este jucatorul A"); write(fd, msg, strlen(msg)); return -1; } else if(move == 'a' && smallLetter(type)) { strcpy(msg, "Mutare invalida"); write(fd, msg, strlen(msg)); return -2; } else if(move == 'b' && bigLetter(type)) { strcpy(msg, "Mutare invalida"); write(fd, msg, strlen(msg)); return -2; } else if(A[sr][sc] == '-') { strcpy(msg, "Mutare invalida"); write(fd, msg, strlen(msg)); return -2; } else if(transform == 'F'){ //ROCADA int ok = 0; if(sr == 1 && fr == 1){ char t1, t2; t1 = A[sr][sc], t2 = A[fr][fc]; if(sc == 1 && fc == 5){ if(bigLetter(t1) && bigLetter(t2)){ if(!isAttacked(t1, fr, fc - 1) && !isAttacked(t2, fr, fc - 2)){ if(A[sr][sc + 1] == '-' && A[sr][sc + 2] == '-' && A[sr][sc + 3] == '-') if(!vizA[1] && !vizA[2]){ A[sr][sc] = '-'; A[fr][fc] = '-'; A[sr][sc + 2] = t2; A[sr][fc - 1] = t1; vizA[1] = 1; vizA[2] = 1; ok = 1; } } } } else if(sc == 5 && fc == 8){ if(bigLetter(t1) && bigLetter(t2)){ if(!isAttacked(t1, fr, sc + 1) && !isAttacked(t2, fr, sc + 2)){ if(A[sr][sc + 1] == '-' && A[sr][sc + 2] == '-') if(!vizA[2] && !vizA[3]){ A[sr][sc] = '-'; A[fr][fc] = '-'; A[sr][sc + 1] = t2; A[sr][fc - 1] = t1; vizA[2] = 1; vizA[3] = 1; ok = 1; } } } } } else if(sr == 8 && fr == 8){ char t1, t2; t1 = A[sr][sc], t2 = A[fr][fc]; if(sc == 1 && fc == 5){ if(smallLetter(t1) && smallLetter(t2)){ if(!isAttacked(t1, fr, fc - 1) && !isAttacked(t2, fr, fc - 2)){ if(A[sr][sc + 1] == '-' && A[sr][sc + 2] == '-' && A[sr][sc + 3] == '-') if(!vizB[1] && !vizB[2]){ A[sr][sc] = '-'; A[fr][fc] = '-'; A[sr][sc + 2] = t2; A[sr][fc - 1] = t1; vizB[1] = 1; vizB[2] = 1; ok = 1; } } } } else if(sc == 5 && fc == 8){ if(smallLetter(t1) && smallLetter(t2)){ if(!isAttacked(t1, fr, sc + 1) && !isAttacked(t2, fr, sc + 2)){ if(A[sr][sc + 1] == '-' && A[sr][sc + 2] == '-') if(!vizB[2] && !vizB[3]){ A[sr][sc] = '-'; A[fr][fc] = '-'; A[sr][sc + 1] = t2; A[sr][fc - 1] = t1; vizB[2] = 1; vizB[3] = 1; ok = 1; } } } } } if(!ok) { strcpy(msg, "Nu se poate efectua rocada!"); write(fd, msg, strlen(msg)); return -2; } else if(ok){ //PrintTable(A); s = Convert(A); write(fd, s.c_str(), s.size()); cout << "Rocarda efectuata!" << endl; verify = 1; return s.size(); } } else if(!validMove(type, sr, sc, fr, fc)) { strcpy(msg, "Mutare invalida"); write(fd, msg, strlen(msg)); return -2; } else if(validMove(type, sr, sc, fr, fc)) { A[sr][sc] = '-'; A[fr][fc] = type; if(move == 'a' && Sah('K')) { strcpy(msg, "Mutare invalida! Sah!"); write(fd, msg, strlen(msg)); A[sr][sc] = type; A[fr][fc] = save; return -2; } else if(move == 'b' && Sah('k')) { strcpy(msg, "Mutare invalida! Sah!"); write(fd, msg, strlen(msg)); A[sr][sc] = type; A[fr][fc] = save; return -2; } // transformare pion in alta piesa cand ajunge pe ultima linie a inamicului if(type == 'p' && fr == 1 && smallLetter(transform) && (transform == 'n' || transform == 'c' || transform == 'q' || transform == 't')) A[sr][sc] = '-', A[fr][fc] = transform; else if(type == 'P' && fr == 8 && bigLetter(transform) && (transform == 'N' || transform == 'C' || transform == 'Q' || transform == 'T')) A[sr][sc] = '-', A[fr][fc] = transform; else if((transform != 'n' || transform != 'c' || transform != 'q' || transform != 't' || transform != 'N' || transform != 'C' || transform != 'Q' || transform != 'T') && (type == 'p' || type == 'P')){ if(fr == 1 || fr == 8){ strcpy(msg, "Transformare invalida!"); write(fd, msg, strlen(msg)); return -2; } } if(move == 'a' && Sah('k')){ strcpy(msg, "Mutare efecuata! Regele inamicului este in sah!"); s = Convert(A); bytes = s.size(); } else if(move == 'b' && Sah('K')){ strcpy(msg, "Mutare efecuata! Regele inamicului este in sah!"); s = Convert(A); bytes = s.size(); } else{ strcpy(msg, "Mutare efecuata!"); s = Convert(A); bytes = s.size(); } //PrintTable(A); cout << type << " a fost mutat de pe pozitia " << c1 << " " << sr << " la pozitia " << c2 << " " << fr << endl; cout << "Se asteapta mutarea celuilalt jucator!" << endl; if(fd % 2 == 0){ if (bytes && write (fd + 1, s.c_str(), bytes) < 0) { perror ("[server] Eroare la write() catre client.\n"); return 0; } if (strlen(msg) && write(fd, msg, strlen(msg)) < 0){ perror ("[server] Eroare la write() catre client.\n"); return 0; } } else if(fd % 2 == 1){ if (bytes && write (fd - 1, s.c_str(), bytes) < 0) { perror ("[server] Eroare la write() catre client.\n"); return 0; } if (strlen(msg) && write(fd, msg, strlen(msg)) < 0){ perror ("[server] Eroare la write() catre client.\n"); return 0; } } verify = 1; return bytes; } } char * conv_addr (struct sockaddr_in address) { static char str[25]; char port[7]; strcpy (str, inet_ntoa (address.sin_addr)); bzero (port, 7); sprintf (port, ":%d", ntohs (address.sin_port)); strcat (str, port); return (str); } int main () { struct sockaddr_in server; struct sockaddr_in from; fd_set readfds; fd_set actfds; struct timeval tv; int sd, client; int optval=1; int fd; int nfds; pid_t childpid; unsigned int len; int v[250] = {0}; if ((sd = socket (AF_INET, SOCK_STREAM, 0)) == -1) { perror ("[server] Eroare la socket().\n"); return errno; } setsockopt(sd, SOL_SOCKET, SO_REUSEADDR,&optval,sizeof(optval)); bzero (&server, sizeof (server)); server.sin_family = AF_INET; server.sin_addr.s_addr = htonl (INADDR_ANY); server.sin_port = htons (PORT); if (bind (sd, (struct sockaddr *) &server, sizeof (struct sockaddr)) == -1) { perror ("[server] Eroare la bind().\n"); return errno; } if (listen (sd, 10) == -1) { perror ("[server] Eroare la listen().\n"); return errno; } FD_ZERO (&actfds); FD_SET (sd, &actfds); tv.tv_sec = 1; tv.tv_usec = 0; nfds = sd; printf ("[server] Asteptam la portul %d...\n", PORT); fflush (stdout); while (1) { bcopy ((char *) &actfds, (char *) &readfds, sizeof (readfds)); if (select (nfds+1, &readfds, NULL, NULL, &tv) < 0) { perror ("[server] Eroare la select().\n"); return errno; } if (FD_ISSET (sd, &readfds)) { len = sizeof (from); bzero (&from, sizeof (from)); client = accept (sd, (struct sockaddr *) &from, &len); if (client < 0) { perror ("[server] Eroare la accept().\n"); continue; } if (nfds < client) nfds = client; FD_SET (client, &actfds); printf("[server] S-a conectat clientul cu descriptorul %d, de la adresa %s.\n",client, conv_addr (from)); fflush (stdout); } if(nfds % 2 == 1 && nfds > 3 && !v[nfds - 1] && !v[nfds]) { //cout << a.fd << " " << b.fd << endl; v[nfds - 1] = 1; v[nfds] = 1; if((childpid = fork()) == 0) { CreateTable(A); //PrintTable(A); cout << "Jocul a inceput!" << endl; Player a; Player b; a.round = 1; a.fd = nfds - 1; b.round = 0; b.fd = nfds; close(sd); int ft = 0; while(1) { if(a.round == 1) { fd = a.fd; int verify = 0; if (fd != sd) { if(!ft){ string s; s = Convert(A); int bytes = s.size(); if (bytes && write (fd, s.c_str(), bytes) < 0) { perror ("[server] Eroare la write() catre client.\n"); return 0; } ft = 1; } if(Message(fd, verify, 'a') == -1) { close (fd); FD_CLR (fd, &actfds); close(fd + 1); FD_CLR(fd + 1, &actfds); v[a.fd] = 0; v[b.fd] = 0; exit(0); //cout << "Jocul a luat sfarsit! Jucatorul B a castigat!" << endl; } else if(verify == 1) { a.round = 0; b.round = 1; verify = 0; } } } if(b.round == 1) { fd = b.fd; int verify = 0; if (fd != sd) { if(Message(fd, verify, 'b') == -1) { close (fd); FD_CLR (fd, &actfds); close(fd - 1); FD_CLR(fd - 1, &actfds); v[a.fd] = 0; v[b.fd] = 0; exit(0); //cout << "Jocul a luat sfarsit! Jucatorul A a castigat!" << endl; } else if(verify == 1) { b.round = 0; a.round = 1; verify = 0; } } } } } } } }
30.317559
202
0.413473
[ "transform" ]
5f02cd2fd9321265b4472f2215ec4faddcbd35d3
11,308
h
C
code/evel_library/evel_throttle.h
nomadic1/evel-library
275460dd8ceb6889684055cbf7711c49e1fa09e4
[ "BSD-4-Clause" ]
null
null
null
code/evel_library/evel_throttle.h
nomadic1/evel-library
275460dd8ceb6889684055cbf7711c49e1fa09e4
[ "BSD-4-Clause" ]
null
null
null
code/evel_library/evel_throttle.h
nomadic1/evel-library
275460dd8ceb6889684055cbf7711c49e1fa09e4
[ "BSD-4-Clause" ]
null
null
null
#ifndef EVEL_THROTTLE_INCLUDED #define EVEL_THROTTLE_INCLUDED /**************************************************************************//** * @file * EVEL throttle definitions. * * These are internal definitions related to throttling specicications, which * are required within the library but are not intended for external * consumption. * * License * ------- * * Copyright(c) <2016>, AT&T Intellectual Property. All other 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: This product includes * software developed by the AT&T. * 4. Neither the name of AT&T 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 AT&T INTELLECTUAL PROPERTY ''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 AT&T INTELLECTUAL PROPERTY 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 "evel_internal.h" #include "jsmn.h" /*****************************************************************************/ /* Maximum depth of JSON response that we can handle. */ /*****************************************************************************/ #define EVEL_JSON_STACK_DEPTH 10 /**************************************************************************//** * Maximum number of tokens that we allow for in a JSON response. *****************************************************************************/ #define EVEL_MAX_RESPONSE_TOKENS 1024 /**************************************************************************//** * The nature of the next token that we are iterating through. Within an * object, we alternate between collecting keys and values. Within an array, * we only collect items. *****************************************************************************/ typedef enum { EVEL_JSON_KEY, EVEL_JSON_VALUE, EVEL_JSON_ITEM } EVEL_JSON_STATE; /**************************************************************************//** * States which we move through during JSON processing, tracking our way * through the supported JSON structure. *****************************************************************************/ typedef enum { /***************************************************************************/ /* Initial state. */ /***************************************************************************/ EVEL_JCS_START, /***************************************************************************/ /* {"commandList": [ */ /***************************************************************************/ EVEL_JCS_COMMAND_LIST, /***************************************************************************/ /* {"commandList": [{ */ /***************************************************************************/ EVEL_JCS_COMMAND_LIST_ENTRY, /***************************************************************************/ /* {"commandList": [{"command": { */ /***************************************************************************/ EVEL_JCS_COMMAND, /***************************************************************************/ /* ... "eventDomainThrottleSpecification": { */ /***************************************************************************/ EVEL_JCS_SPEC, /***************************************************************************/ /* ... "suppressedFieldNames": [ */ /***************************************************************************/ EVEL_JCS_FIELD_NAMES, /***************************************************************************/ /* ... "suppressedNvPairsList": [ */ /***************************************************************************/ EVEL_JCS_PAIRS_LIST, /***************************************************************************/ /* ... "suppressedNvPairsList": [{ */ /***************************************************************************/ EVEL_JCS_PAIRS_LIST_ENTRY, /***************************************************************************/ /* ... "suppressedNvPairNames": [ */ /***************************************************************************/ EVEL_JCS_NV_PAIR_NAMES, EVEL_JCS_MAX } EVEL_JSON_COMMAND_STATE; /**************************************************************************//** * An entry in the JSON stack. *****************************************************************************/ typedef struct evel_json_stack_entry { /***************************************************************************/ /* The number of elements required at this level. */ /***************************************************************************/ int num_required; /***************************************************************************/ /* The number of elements collected at this level. */ /***************************************************************************/ int json_count; /***************************************************************************/ /* The collection state at this level in the JSON stack. */ /***************************************************************************/ EVEL_JSON_STATE json_state; /***************************************************************************/ /* The key being collected (if json_state is EVEL_JSON_VALUE), or NULL. */ /***************************************************************************/ char * json_key; } EVEL_JSON_STACK_ENTRY; /**************************************************************************//** * The JSON stack. *****************************************************************************/ typedef struct evel_json_stack { /***************************************************************************/ /* The current position of the stack - starting at zero. */ /***************************************************************************/ int level; /***************************************************************************/ /* The stack itself. */ /***************************************************************************/ EVEL_JSON_STACK_ENTRY entry[EVEL_JSON_STACK_DEPTH]; /***************************************************************************/ /* The underlying memory chunk. */ /***************************************************************************/ const MEMORY_CHUNK * chunk; } EVEL_JSON_STACK; /**************************************************************************//** * Initialize event throttling to the default state. * * Called from ::evel_initialize. *****************************************************************************/ void evel_throttle_initialize(); /**************************************************************************//** * Clean up event throttling. * * Called from ::evel_terminate. *****************************************************************************/ void evel_throttle_terminate(); /**************************************************************************//** * Handle a JSON response from the listener, as a list of tokens from JSMN. * * @param chunk Memory chunk containing the JSON buffer. * @param json_tokens Array of tokens to handle. * @param num_tokens The number of tokens to handle. * @param post The memory chunk in which to place any resulting POST. * @return true if the command was handled, false otherwise. *****************************************************************************/ bool evel_handle_command_list(const MEMORY_CHUNK * const chunk, const jsmntok_t * const json_tokens, const int num_tokens, MEMORY_CHUNK * const post); /**************************************************************************//** * Return the ::EVEL_THROTTLE_SPEC for a given domain. * * @param domain The domain for which to return state. *****************************************************************************/ EVEL_THROTTLE_SPEC * evel_get_throttle_spec(EVEL_EVENT_DOMAINS domain); /**************************************************************************//** * Determine whether a field_name should be suppressed. * * @param throttle_spec Throttle specification for the domain being encoded. * @param field_name The field name to encoded or suppress. * @return true if the field_name should be suppressed, false otherwise. *****************************************************************************/ bool evel_throttle_suppress_field(EVEL_THROTTLE_SPEC * throttle_spec, const char * const field_name); /**************************************************************************//** * Determine whether a name-value pair should be allowed (not suppressed). * * @param throttle_spec Throttle specification for the domain being encoded. * @param field_name The field name holding the name-value pairs. * @param name The name of the name-value pair to encoded or suppress. * @return true if the name-value pair should be suppressed, false otherwise. *****************************************************************************/ bool evel_throttle_suppress_nv_pair(EVEL_THROTTLE_SPEC * throttle_spec, const char * const field_name, const char * const name); #endif
49.379913
79
0.386098
[ "object" ]
5f0e12cac91601a30525f71bdb77167f2b8c8906
775
h
C
src/phonglighting.h
Samulus/raytracer
2cfce84af0190117f16dc054df1667bc8868b438
[ "MIT" ]
null
null
null
src/phonglighting.h
Samulus/raytracer
2cfce84af0190117f16dc054df1667bc8868b438
[ "MIT" ]
1
2019-09-02T20:55:06.000Z
2019-09-02T20:55:06.000Z
src/phonglighting.h
Samulus/raytracer
2cfce84af0190117f16dc054df1667bc8868b438
[ "MIT" ]
null
null
null
// // phonglighting.h // Author: Samuel Vargas // Date: 09/25/2019 // #pragma once #include "lighttransport.h" class PhongLighting : LightTransport { private: std::vector<std::unique_ptr<Light>> lights; public: PhongLighting(); ~PhongLighting() override; std::optional<RayCollision> calculatePixelColor(GLubyte& r, GLubyte& g, GLubyte& b, const RayCollision& rayCollision, const World& world) const override; void addLight(std::unique_ptr<Light>& light); linalg::aliases::float3 calculateLightContribution(const Light* light, const linalg::vec<float,3>& intersectionPoint, const Geometry* hitObject) const; private: void calculateDiffuseColor(GLubyte& r, GLubyte& g, GLubyte& b, const RayCollision& rayCollision, const World& world) const; };
33.695652
157
0.741935
[ "geometry", "vector" ]
5f0f928019e4ccc6129fceef212d2fa7cce6fe9a
16,876
h
C
physx/source/simulationcontroller/src/ScBodySim.h
yangfengzzz/PhysX
aed9c3035955d4ad90e5741f7d1dcfb5c178d44f
[ "BSD-3-Clause" ]
null
null
null
physx/source/simulationcontroller/src/ScBodySim.h
yangfengzzz/PhysX
aed9c3035955d4ad90e5741f7d1dcfb5c178d44f
[ "BSD-3-Clause" ]
null
null
null
physx/source/simulationcontroller/src/ScBodySim.h
yangfengzzz/PhysX
aed9c3035955d4ad90e5741f7d1dcfb5c178d44f
[ "BSD-3-Clause" ]
null
null
null
// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * 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. // * Neither the name of NVIDIA CORPORATION 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 ''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 OWNER 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. // // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PHYSICS_SCP_BODYSIM #define PX_PHYSICS_SCP_BODYSIM #include "DyArticulation.h" #include "PsIntrinsics.h" #include "PsUtilities.h" #include "PxRigidDynamic.h" #include "PxsRigidBody.h" #include "PxsSimpleIslandManager.h" #include "PxvDynamics.h" #include "ScBodyCore.h" #include "ScConstraintGroupNode.h" #include "ScRigidSim.h" #include "ScSimStateData.h" namespace physx { namespace Bp { class BoundsArray; } class PxsTransformCache; class PxsSimulationController; namespace Sc { #define SC_NOT_IN_SCENE_INDEX 0xffffffff // the body is not in the scene yet #define SC_NOT_IN_ACTIVE_LIST_INDEX 0xfffffffe // the body is in the scene but not in the active list class Scene; class ArticulationSim; static const PxReal ScInternalWakeCounterResetValue = 20.0f * 0.02f; #if PX_VC #pragma warning(push) #pragma warning(disable : 4324) // Padding was added at the end of a structure because of a __declspec(align) value. #endif class BodySim : public RigidSim { public: enum InternalFlags { // BF_DISABLE_GRAVITY = 1 << 0, // Don't apply the scene's gravity BF_HAS_STATIC_TOUCH = 1 << 1, // Set when a body is part of an island with static contacts. Needed to be able to // recalculate adaptive force if this changes BF_KINEMATIC_MOVED = 1 << 2, // Set when the kinematic was moved BF_ON_DEATHROW = 1 << 3, // Set when the body is destroyed BF_IS_IN_SLEEP_LIST = 1 << 4, // Set when the body is added to the list of bodies which were put to sleep BF_IS_IN_WAKEUP_LIST = 1 << 5, // Set when the body is added to the list of bodies which were woken up BF_SLEEP_NOTIFY = 1 << 6, // A sleep notification should be sent for this body (and not a wakeup event, even if the // body is part of the woken list as well) BF_WAKEUP_NOTIFY = 1 << 7, // A wake up notification should be sent for this body (and not a sleep event, even if // the body is part of the sleep list as well) BF_HAS_CONSTRAINTS = 1 << 8, // Set if the body has one or more constraints BF_KINEMATIC_SETTLING = 1 << 9, // Set when the body was moved kinematically last frame BF_KINEMATIC_SETTLING_2 = 1 << 10, BF_KINEMATIC_MOVE_FLAGS = BF_KINEMATIC_MOVED | BF_KINEMATIC_SETTLING | BF_KINEMATIC_SETTLING_2, // Used to clear kinematic masks in 1 call BF_KINEMATIC_SURFACE_VELOCITY = 1 << 11, // Set when the application calls setKinematicVelocity. Actor remains awake // until application calls clearKinematicVelocity. BF_IS_COMPOUND_RIGID = 1 << 12 // Set when the body is a compound actor, we dont want to set the sq bounds // PT: WARNING: flags stored on 16-bits now. }; public: BodySim(Scene &, BodyCore &, bool); virtual ~BodySim(); void notifyAddSpatialAcceleration(); void notifyClearSpatialAcceleration(); void notifyAddSpatialVelocity(); void notifyClearSpatialVelocity(); void updateCached(Cm::BitMapPinned *shapeChangedMap); void updateCached(PxsTransformCache &transformCache, Bp::BoundsArray &boundsArray); void updateContactDistance(PxReal *contactDistance, const PxReal dt, Bp::BoundsArray &boundsArray); // hooks for actions in body core when it's attached to a sim object. Generally // we get called after the attribute changed. virtual void postActorFlagChange(PxU32 oldFlags, PxU32 newFlags); void postBody2WorldChange(); void postSetWakeCounter(PxReal t, bool forceWakeUp); void postSetKinematicTarget(); void postSwitchToKinematic(); void postSwitchToDynamic(); void postPosePreviewChange( const PxU32 posePreviewFlag); // called when PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW changes PX_FORCE_INLINE const PxTransform &getBody2World() const { return getBodyCore().getCore().body2World; } PX_FORCE_INLINE const PxTransform &getBody2Actor() const { return getBodyCore().getCore().getBody2Actor(); } PX_FORCE_INLINE const PxsRigidBody &getLowLevelBody() const { return mLLBody; } PX_FORCE_INLINE PxsRigidBody &getLowLevelBody() { return mLLBody; } void wakeUp(); // note: for user API call purposes only, i.e., use from BodyCore. For simulation internal purposes // there is internalWakeUp(). void putToSleep(); void disableCompound(); static PxU32 getRigidBodyOffset() { return PxU32(PX_OFFSET_OF_RT(BodySim, mLLBody)); } private: void activate(); void deactivate(); //--------------------------------------------------------------------------------- // Constraint projection //--------------------------------------------------------------------------------- public: PX_FORCE_INLINE ConstraintGroupNode *getConstraintGroup() { return mConstraintGroup; } PX_FORCE_INLINE void setConstraintGroup(ConstraintGroupNode *node) { mConstraintGroup = node; } //// A list of active projection trees in the scene might be better // PX_FORCE_INLINE void projectPose() { PX_ASSERT(mConstraintGroup); // ConstraintGroupNode::projectPose(*mConstraintGroup); } //--------------------------------------------------------------------------------- // Kinematics //--------------------------------------------------------------------------------- public: PX_FORCE_INLINE bool isKinematic() const { return getBodyCore().getFlags() & PxRigidBodyFlag::eKINEMATIC; } PX_FORCE_INLINE bool isArticulationLink() const { return getActorType() == PxActorType::eARTICULATION_LINK; } PX_FORCE_INLINE bool hasForcedKinematicNotif() const { return getBodyCore().getFlags() & (PxRigidBodyFlag::eFORCE_KINE_KINE_NOTIFICATIONS | PxRigidBodyFlag::eFORCE_STATIC_KINE_NOTIFICATIONS); } void calculateKinematicVelocity(PxReal oneOverDt); void updateKinematicPose(); bool deactivateKinematic(); private: PX_FORCE_INLINE void initKinematicStateBase(BodyCore &, bool asPartOfCreation); //--------------------------------------------------------------------------------- // Sleeping //--------------------------------------------------------------------------------- public: PX_FORCE_INLINE bool isActive() const { return (mActiveListIndex < SC_NOT_IN_ACTIVE_LIST_INDEX); } void setActive(bool active, PxU32 infoFlag = 0); // see ActivityChangeInfoFlag PX_FORCE_INLINE PxU32 getActiveListIndex() const { return mActiveListIndex; } // if the body is active, the index is smaller than SC_NOT_IN_ACTIVE_LIST_INDEX PX_FORCE_INLINE void setActiveListIndex(PxU32 index) { mActiveListIndex = index; } PX_FORCE_INLINE PxU32 getActiveCompoundListIndex() const { return mActiveCompoundListIndex; } // if the body is active and is compound, the index is smaller than SC_NOT_IN_ACTIVE_LIST_INDEX PX_FORCE_INLINE void setActiveCompoundListIndex(PxU32 index) { mActiveCompoundListIndex = index; } void internalWakeUp(PxReal wakeCounterValue = ScInternalWakeCounterResetValue); void internalWakeUpArticulationLink(PxReal wakeCounterValue); // called by ArticulationSim to wake up this link PxReal updateWakeCounter(PxReal dt, PxReal energyThreshold, const Cm::SpatialVector &motionVelocity); void resetSleepFilter(); void notifyReadyForSleeping(); // inform the sleep island generation system that the body is ready for sleeping void notifyNotReadyForSleeping(); // inform the sleep island generation system that the body is not ready for sleeping PX_FORCE_INLINE bool checkSleepReadinessBesidesWakeCounter(); // for API triggered changes to test sleep readiness PX_FORCE_INLINE void registerCountedInteraction() { mLLBody.getCore().numCountedInteractions++; PX_ASSERT(mLLBody.getCore().numCountedInteractions); } PX_FORCE_INLINE void unregisterCountedInteraction() { PX_ASSERT(mLLBody.getCore().numCountedInteractions); mLLBody.getCore().numCountedInteractions--; } PX_FORCE_INLINE PxU32 getNumCountedInteractions() const { return mLLBody.getCore().numCountedInteractions; } PX_FORCE_INLINE Ps::IntBool isFrozen() const { return Ps::IntBool(mLLBody.mInternalFlags & PxsRigidBody::eFROZEN); } private: PX_FORCE_INLINE void notifyWakeUp( bool wakeUpInIslandGen = false); // inform the sleep island generation system that the object got woken up PX_FORCE_INLINE void notifyPutToSleep(); // inform the sleep island generation system that the object was put to sleep PX_FORCE_INLINE void internalWakeUpBase(PxReal wakeCounterValue); //--------------------------------------------------------------------------------- // External velocity changes //--------------------------------------------------------------------------------- public: void updateForces(PxReal dt, PxsRigidBody **updatedBodySims, PxU32 *updatedBodyNodeIndices, PxU32 &index, Cm::SpatialVector *acceleration, const bool useAcceleration, bool simUsesAdaptiveForce); private: PX_FORCE_INLINE void raiseVelocityModFlag(VelocityModFlags f) { mVelModState |= f; } PX_FORCE_INLINE void clearVelocityModFlag(VelocityModFlags f) { mVelModState &= ~f; } PX_FORCE_INLINE bool readVelocityModFlag(VelocityModFlags f) { return (mVelModState & f) != 0; } PX_FORCE_INLINE void setForcesToDefaults(bool enableGravity); //--------------------------------------------------------------------------------- // Miscellaneous //--------------------------------------------------------------------------------- public: PX_FORCE_INLINE PxU16 getInternalFlag() const { return mInternalFlags; } PX_FORCE_INLINE PxU16 readInternalFlag(InternalFlags flag) const { return PxU16(mInternalFlags & flag); } PX_FORCE_INLINE void raiseInternalFlag(InternalFlags flag) { mInternalFlags |= flag; } PX_FORCE_INLINE void clearInternalFlag(InternalFlags flag) { mInternalFlags &= ~flag; } PX_FORCE_INLINE PxU32 getFlagsFast() const { return getBodyCore().getFlags(); } PX_FORCE_INLINE void incrementBodyConstraintCounter() { mLLBody.mCore->numBodyInteractions++; } PX_FORCE_INLINE void decrementBodyConstraintCounter() { PX_ASSERT(mLLBody.mCore->numBodyInteractions > 0); mLLBody.mCore->numBodyInteractions--; } PX_FORCE_INLINE BodyCore &getBodyCore() const { return static_cast<BodyCore &>(getRigidCore()); } PX_INLINE ArticulationSim *getArticulation() const { return mArticulation; } void setArticulation(ArticulationSim *a, PxReal wakeCounter, bool asleep, PxU32 bodyIndex); PX_FORCE_INLINE IG::NodeIndex getNodeIndex() const { return mNodeIndex; } PX_FORCE_INLINE void onConstraintAttach() { raiseInternalFlag(BF_HAS_CONSTRAINTS); registerCountedInteraction(); } void onConstraintDetach(); PX_FORCE_INLINE void onOriginShift(const PxVec3 &shift) { mLLBody.mLastTransform.p -= shift; } PX_FORCE_INLINE bool notInScene() const { return mActiveListIndex == SC_NOT_IN_SCENE_INDEX; } PX_FORCE_INLINE bool usingSqKinematicTarget() const { PxU32 ktFlags(PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES | PxRigidBodyFlag::eKINEMATIC); return (getFlagsFast() & ktFlags) == ktFlags; } PX_FORCE_INLINE PxU32 getNbShapes() const { return mElementCount; } void createSqBounds(); void destroySqBounds(); void freezeTransforms(Cm::BitMapPinned *shapeChangedMap); void invalidateSqBounds(); private: //--------------------------------------------------------------------------------- // Base body //--------------------------------------------------------------------------------- PxsRigidBody mLLBody; //--------------------------------------------------------------------------------- // Island manager //--------------------------------------------------------------------------------- IG::NodeIndex mNodeIndex; //--------------------------------------------------------------------------------- // External velocity changes //--------------------------------------------------------------------------------- // VelocityMod data allocated on the fly when the user applies velocity changes // which need to be accumulated. // VelMod dirty flags stored in BodySim so we can save ourselves the expense of looking at // the separate velmod data if no forces have been set. PxU16 mInternalFlags; PxU8 mVelModState; //--------------------------------------------------------------------------------- // Sleeping //--------------------------------------------------------------------------------- PxU32 mActiveListIndex; // Used by Scene to track active bodies PxU32 mActiveCompoundListIndex; // Used by Scene to track active compound bodies //--------------------------------------------------------------------------------- // Articulation //--------------------------------------------------------------------------------- ArticulationSim *mArticulation; // NULL if not in an articulation //--------------------------------------------------------------------------------- // Joints & joint groups //--------------------------------------------------------------------------------- // This is a tree data structure that gives us the projection order of joints in which this body is the tree root. // note: the link of the root body is not necces. the root link due to the re-rooting of the articulation! ConstraintGroupNode *mConstraintGroup; }; #if PX_VC #pragma warning(pop) #endif } // namespace Sc PX_FORCE_INLINE void Sc::BodySim::setForcesToDefaults(bool enableGravity) { if (!(mLLBody.mCore->mFlags & PxRigidBodyFlag::eRETAIN_ACCELERATIONS)) { SimStateData *simStateData = getBodyCore().getSimStateData(false); if (simStateData) { VelocityMod *velmod = simStateData->getVelocityModData(); velmod->clear(); } if (enableGravity) mVelModState = VMF_GRAVITY_DIRTY; // We want to keep the gravity flag to make sure the acceleration gets changed to // gravity-only in the next step (unless the application adds new forces of course) else mVelModState = 0; } else { SimStateData *simStateData = getBodyCore().getSimStateData(false); if (simStateData) { VelocityMod *velmod = simStateData->getVelocityModData(); velmod->clearPerStep(); } mVelModState &= (~(VMF_VEL_DIRTY)); } } PX_FORCE_INLINE bool Sc::BodySim::checkSleepReadinessBesidesWakeCounter() { const BodyCore &bodyCore = getBodyCore(); const SimStateData *simStateData = bodyCore.getSimStateData(false); const VelocityMod *velmod = simStateData ? simStateData->getVelocityModData() : NULL; bool readyForSleep = bodyCore.getLinearVelocity().isZero() && bodyCore.getAngularVelocity().isZero(); if (readVelocityModFlag(VMF_ACC_DIRTY)) { readyForSleep = readyForSleep && (!velmod || velmod->getLinearVelModPerSec().isZero()); readyForSleep = readyForSleep && (!velmod || velmod->getAngularVelModPerSec().isZero()); } if (readVelocityModFlag(VMF_VEL_DIRTY)) { readyForSleep = readyForSleep && (!velmod || velmod->getLinearVelModPerStep().isZero()); readyForSleep = readyForSleep && (!velmod || velmod->getAngularVelModPerStep().isZero()); } return readyForSleep; } } // namespace physx #endif
47.008357
120
0.666449
[ "object" ]
5f2282561f43b14f2dcc3c35f9cfff14c51a04c2
1,133
h
C
examples/ThirdPartyLibs/Gwen/Controls/Text.h
felipeek/bullet3
6a59241074720e9df119f2f86bc01765917feb1e
[ "Zlib" ]
9,136
2015-01-02T00:41:45.000Z
2022-03-31T15:30:02.000Z
examples/ThirdPartyLibs/Gwen/Controls/Text.h
felipeek/bullet3
6a59241074720e9df119f2f86bc01765917feb1e
[ "Zlib" ]
2,424
2015-01-05T08:55:58.000Z
2022-03-30T19:34:55.000Z
examples/ThirdPartyLibs/Gwen/Controls/Text.h
felipeek/bullet3
6a59241074720e9df119f2f86bc01765917feb1e
[ "Zlib" ]
2,921
2015-01-02T10:19:30.000Z
2022-03-31T02:48:42.000Z
/* GWEN Copyright (c) 2010 Facepunch Studios See license in Gwen.h */ #pragma once #ifndef GWEN_CONTROLS_TEXT_H #define GWEN_CONTROLS_TEXT_H #include "Gwen/BaseRender.h" #include "Gwen/Controls/Base.h" namespace Gwen { namespace ControlsInternal { class GWEN_EXPORT Text : public Controls::Base { public: GWEN_CONTROL(Text, Controls::Base); virtual ~Text(); Gwen::Font* GetFont(); void SetString(const UnicodeString& str); void SetString(const String& str); void Render(Skin::Base* skin); void Layout(Skin::Base* skin); void RefreshSize(); void SetFont(Gwen::Font* pFont) { m_Font = pFont; } const UnicodeString& GetText() const { return m_String; } Gwen::Point GetCharacterPosition(int iChar); int GetClosestCharacter(Gwen::Point p); int Length() const { return (int)m_String.size(); } virtual void SetTextColor(const Gwen::Color& col) { m_Color = col; } virtual void OnScaleChanged(); inline const Gwen::Color& TextColor() const { return m_Color; } private: Gwen::UnicodeString m_String; Gwen::Font* m_Font; Gwen::Color m_Color; }; } // namespace ControlsInternal } // namespace Gwen #endif
19.534483
69
0.728155
[ "render" ]
700e8b5f7a2f438042ee2aef7df00e5ed57ba166
2,693
h
C
DerydocaEngine/src/Rendering/Mesh.h
Derydoca/derydocaengine
a9cdb71082fbb879d9448dc0c1a95581681d61f1
[ "BSD-3-Clause" ]
37
2018-05-21T15:21:26.000Z
2020-11-16T17:50:44.000Z
DerydocaEngine/src/Rendering/Mesh.h
Derydoca/derydocaengine
a9cdb71082fbb879d9448dc0c1a95581681d61f1
[ "BSD-3-Clause" ]
38
2018-03-09T23:57:07.000Z
2020-07-10T20:52:42.000Z
DerydocaEngine/src/Rendering/Mesh.h
Derydoca/derydocaengine
a9cdb71082fbb879d9448dc0c1a95581681d61f1
[ "BSD-3-Clause" ]
5
2018-08-28T11:12:18.000Z
2019-09-05T09:30:41.000Z
#pragma once #include <glm/vec2.hpp> #include <glm/vec3.hpp> #include <string> #include "Color.h" #include "MeshFlags.h" namespace DerydocaEngine::Rendering { enum MeshComponents { None = 0x0, Positions = 0x1, Tangents = 0x2, Bitangents = 0x4, TexCoords = 0x8, Normals = 0x16, Indices = 0x32, Colors = 0x64, All = Positions | Tangents | Bitangents | TexCoords | Normals | Indices | Colors }; class Mesh { public: Mesh( const std::vector<glm::vec3>& positions = std::vector<glm::vec3>(), const std::vector<unsigned int>& indices = std::vector<unsigned int>(), const std::vector<glm::vec3>& normals = std::vector<glm::vec3>(), const std::vector<glm::vec2>& texCoords = std::vector<glm::vec2>(), const std::vector<glm::vec3>& tangents = std::vector<glm::vec3>(), const std::vector<glm::vec3>& bitangents = std::vector<glm::vec3>(), const std::vector<Color>& colors = std::vector<Color>()); ~Mesh(); void loadMeshComponentData( const MeshComponents& meshComponentFlags, const std::vector<glm::vec3>& positions = std::vector<glm::vec3>(), const std::vector<unsigned int>& indices = std::vector<unsigned int>(), const std::vector<glm::vec3>& normals = std::vector<glm::vec3>(), const std::vector<glm::vec2>& texCoords = std::vector<glm::vec2>(), const std::vector<glm::vec3>& tangents = std::vector<glm::vec3>(), const std::vector<glm::vec3>& bitangents = std::vector<glm::vec3>(), const std::vector<Color>& colors = std::vector<Color>()); void draw(); void setFlags(const MeshFlags& flags) { m_flags = flags; } unsigned int getVao() const { return m_vertexArrayObject; } size_t getNumVertices() const { return m_positions.size(); } size_t getNumIndices() const { return m_indices.size(); } private: enum { POSITION_VB, TANGENT_VB, BITANGENT_VB, TEXCOORD_VB, NORMAL_VB, INDEX_VB, COLOR_VB, NUM_BUFFERS }; Mesh(Mesh const& other) {} void operator=(Mesh const& other) {} void uploadToGpu(MeshComponents const& meshComponentFlags); void uploadPositions(); void uploadTexCoords(); void uploadNormals(); void uploadTangents(); void uploadBitangents(); void uploadIndices(); void uploadColors(); void bind(); void unbind(); void generateVao(); void generateBuffers(); unsigned int m_vertexArrayObject; std::array<unsigned int, NUM_BUFFERS> m_vertexArrayBuffers; std::vector<glm::vec3> m_positions; std::vector<unsigned int> m_indices; std::vector<glm::vec3> m_normals; std::vector<glm::vec2> m_texCoords; std::vector<glm::vec3> m_tangents; std::vector<glm::vec3> m_bitangents; std::vector<Color> m_colors; MeshFlags m_flags{}; }; }
28.648936
82
0.68251
[ "mesh", "vector" ]
7016d87194f5bd94d59204cf18750b988254840b
1,604
h
C
Thrax/src/include/thrax/rule-node.h
tirpidz/thrax
f9d8a7df1cad9943d45b12eb80dad8ba0c1c8070
[ "Apache-2.0" ]
1
2021-10-21T07:52:04.000Z
2021-10-21T07:52:04.000Z
src/include/thrax/rule-node.h
grammatek/thrax
7a50df8bdb673926264b8bd81d95eaad2e00804d
[ "Apache-2.0" ]
null
null
null
src/include/thrax/rule-node.h
grammatek/thrax
7a50df8bdb673926264b8bd81d95eaad2e00804d
[ "Apache-2.0" ]
null
null
null
// Copyright 2005-2020 Google LLC // // 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. // // A rule node is an assignment of an FST or other object to a variable. The // rule node contains the left and right hand sides of the assignment. #ifndef THRAX_RULE_NODE_H_ #define THRAX_RULE_NODE_H_ #include <memory> #include <fst/compat.h> #include <thrax/compat/compat.h> #include <thrax/node.h> namespace thrax { class AstWalker; class IdentifierNode; class RuleNode : public Node { public: enum ExportStatus { EXPORT, DO_NOT_EXPORT, }; // TODO(wolfsonkin): Make this interface use std::unique_ptr. RuleNode(IdentifierNode* name, Node* rhs, ExportStatus exp); ~RuleNode() override = default; IdentifierNode* GetName() const; Node* Get() const; bool ShouldExport() const; void Accept(AstWalker* walker) override; private: std::unique_ptr<IdentifierNode> name_; std::unique_ptr<Node> rhs_; ExportStatus export_; RuleNode(const RuleNode&) = delete; RuleNode& operator=(const RuleNode&) = delete; }; } // namespace thrax #endif // THRAX_RULE_NODE_H_
25.0625
76
0.731297
[ "object" ]
701c0f3ad50f1fc65de2af10c136a629ef1d141b
882
h
C
WeChatScraperIOS/WeChatScraperIOS/Classes/JSONKit/DDJSONKit.h
TongCui/wechat-scraper
274edec09f1b5bb7a8720cb2f631ff0543184ab4
[ "MIT" ]
null
null
null
WeChatScraperIOS/WeChatScraperIOS/Classes/JSONKit/DDJSONKit.h
TongCui/wechat-scraper
274edec09f1b5bb7a8720cb2f631ff0543184ab4
[ "MIT" ]
null
null
null
WeChatScraperIOS/WeChatScraperIOS/Classes/JSONKit/DDJSONKit.h
TongCui/wechat-scraper
274edec09f1b5bb7a8720cb2f631ff0543184ab4
[ "MIT" ]
null
null
null
// // DDJSONKit.h // PAPA // // Created by g.zhao on 13-4-2. // Copyright (c) 2013年 diandian. All rights reserved. // #import <Foundation/Foundation.h> @interface DDJSONKit : NSObject + (id)objectFromJSONString:(NSString *)responseString; + (id)objectFromJSONData:(NSData *)responseDate; + (id)objectFromJSONData:(NSData *)responseDate withError:(NSError **)error; + (NSData*)JSONDataFromObject:(id)object; @end @interface NSString (JSONKitSerializing) - (NSString *)JSONString; - (NSData *)JSONData; @end @interface NSArray (JSONKitSerializing) - (NSString *)JSONString; - (NSString *)JSONStringWithTrim:(BOOL)trim; - (NSData *)JSONData; @end @interface NSDictionary (JSONKitSerializing) - (NSString *)JSONString; - (NSString *)JSONStringWithTrim:(BOOL)trim; - (NSData *)JSONData; @end @interface NSData (JSONKitDeserializing) - (id)objectFromJSONData; @end
17.294118
76
0.727891
[ "object" ]