hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
108
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
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 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9a602f9f5123a3670e8b693e3b9852c589b22c54
| 30
|
cpp
|
C++
|
src/expression.cpp
|
koraxkorakos/mv
|
b5f589bd089fd05fde7a0837f39746e2e343499e
|
[
"BSD-2-Clause"
] | null | null | null |
src/expression.cpp
|
koraxkorakos/mv
|
b5f589bd089fd05fde7a0837f39746e2e343499e
|
[
"BSD-2-Clause"
] | null | null | null |
src/expression.cpp
|
koraxkorakos/mv
|
b5f589bd089fd05fde7a0837f39746e2e343499e
|
[
"BSD-2-Clause"
] | null | null | null |
//#include <mv/expression.hpp>
| 30
| 30
| 0.733333
|
koraxkorakos
|
9a6070ae0d84e05add8020fe843e371cff24d5a0
| 16,062
|
cpp
|
C++
|
src/cpm_BaseParaManager_MPI.cpp
|
jorji/CPMlib
|
7ba683d1abc60f11bafcc5732da831278b002afa
|
[
"BSD-2-Clause"
] | 4
|
2015-03-17T17:30:10.000Z
|
2019-01-31T15:13:59.000Z
|
src/cpm_BaseParaManager_MPI.cpp
|
jorji/CPMlib
|
7ba683d1abc60f11bafcc5732da831278b002afa
|
[
"BSD-2-Clause"
] | null | null | null |
src/cpm_BaseParaManager_MPI.cpp
|
jorji/CPMlib
|
7ba683d1abc60f11bafcc5732da831278b002afa
|
[
"BSD-2-Clause"
] | 4
|
2015-12-09T02:42:29.000Z
|
2022-03-18T09:03:28.000Z
|
/*
###################################################################################
#
# CPMlib - Computational space Partitioning Management library
#
# Copyright (c) 2012-2014 Institute of Industrial Science (IIS), The University of Tokyo.
# All rights reserved.
#
# Copyright (c) 2014-2016 Advanced Institute for Computational Science (AICS), RIKEN.
# All rights reserved.
#
# Copyright (c) 2016-2017 Research Institute for Information Technology (RIIT), Kyushu University.
# All rights reserved.
#
###################################################################################
*/
/**
* @file cpm_BaseParaManager_MPI.cpp
* パラレルマネージャクラスのMPIインターフェイス関数ソースファイル
* @date 2012/05/31
*/
#include "stdlib.h"
#include "cpm_BaseParaManager.h"
#if !defined(_WIN32) && !defined(WIN32)
#include <unistd.h> // for gethostname() of FX10/K
#endif
////////////////////////////////////////////////////////////////////////////////
// MPI_Datatypeを取得
MPI_Datatype
cpm_BaseParaManager::GetMPI_Datatype(int datatype)
{
if( datatype == CPM_REAL )
{
if( RealIsDouble() ) return MPI_DOUBLE;
return MPI_FLOAT;
}
else if( datatype == CPM_CHAR ) return MPI_CHAR;
else if( datatype == CPM_SHORT ) return MPI_SHORT;
else if( datatype == CPM_INT ) return MPI_INT;
else if( datatype == CPM_LONG ) return MPI_LONG;
else if( datatype == CPM_FLOAT ) return MPI_FLOAT;
else if( datatype == CPM_DOUBLE ) return MPI_DOUBLE;
else if( datatype == CPM_LONG_DOUBLE ) return MPI_LONG_DOUBLE;
else if( datatype == CPM_UNSIGNED_CHAR ) return MPI_UNSIGNED_CHAR;
else if( datatype == CPM_UNSIGNED_SHORT ) return MPI_UNSIGNED_SHORT;
else if( datatype == CPM_UNSIGNED ) return MPI_UNSIGNED;
else if( datatype == CPM_UNSIGNED_LONG ) return MPI_UNSIGNED_LONG;
#ifdef MPI_LONG_LONG_INT
else if( datatype == CPM_LONG_LONG_INT ) return MPI_LONG_LONG_INT;
#endif
#ifdef MPI_LONG_LONG
else if( datatype == CPM_LONG_LONG ) return MPI_LONG_LONG;
#endif
#ifdef MPI_UNSIGNED_LONG_LONG
else if( datatype == CPM_UNSIGNED_LONG_LONG ) return MPI_UNSIGNED_LONG_LONG;
#endif
return MPI_DATATYPE_NULL;
}
////////////////////////////////////////////////////////////////////////////////
// MPI_Opを取得
MPI_Op
cpm_BaseParaManager::GetMPI_Op(int op)
{
if ( op == CPM_MAX ) return MPI_MAX;
else if( op == CPM_MIN ) return MPI_MIN;
else if( op == CPM_SUM ) return MPI_SUM;
else if( op == CPM_PROD ) return MPI_PROD;
else if( op == CPM_LAND ) return MPI_LAND;
else if( op == CPM_BAND ) return MPI_BAND;
else if( op == CPM_LOR ) return MPI_LOR;
else if( op == CPM_BOR ) return MPI_BOR;
else if( op == CPM_LXOR ) return MPI_LXOR;
else if( op == CPM_BXOR ) return MPI_BXOR;
// else if( op == CPM_MINLOC ) return CPM_MINLOC; // not support
// else if( op == CPM_MAXLOC ) return CPM_MAXLOC; // not support
return MPI_OP_NULL;
}
////////////////////////////////////////////////////////////////////////////////
// ランク番号の取得
int
cpm_BaseParaManager::GetMyRankID( int procGrpNo )
{
// 不正なプロセスグループ番号
if( procGrpNo < 0 || procGrpNo >= int(m_procGrpList.size()) )
{
// プロセスグループが存在しない
return getRankNull();
}
// コミュニケータをチェック
MPI_Comm comm = m_procGrpList[procGrpNo];
if( IsCommNull(comm) )
{
// プロセスグループに自ランクが含まれない
return getRankNull();
}
// ランク番号を取得
int rankNo;
MPI_Comm_rank( comm, &rankNo );
// ランク番号
return rankNo;
}
////////////////////////////////////////////////////////////////////////////////
// ランク数の取得
int
cpm_BaseParaManager::GetNumRank( int procGrpNo )
{
// 不正なプロセスグループ番号
if( procGrpNo < 0 || procGrpNo >= int(m_procGrpList.size()) )
{
// プロセスグループが存在しない
return -1;
}
// コミュニケータをチェック
MPI_Comm comm = m_procGrpList[procGrpNo];
if( IsCommNull(comm) )
{
// プロセスグループに自ランクが含まれない
return -1;
}
// ランク数を取得
int nrank;
MPI_Comm_size( comm, &nrank );
// ランク数
return nrank;
}
////////////////////////////////////////////////////////////////////////////////
// ホスト名の取得
std::string
cpm_BaseParaManager::GetHostName()
{
char name[512];
memset(name, 0x00, sizeof(char)*512);
if( gethostname(name, 512) != 0 ) return std::string("");
return std::string(name);
}
////////////////////////////////////////////////////////////////////////////////
// コミュニケータの取得
MPI_Comm
cpm_BaseParaManager::GetMPI_Comm( int procGrpNo )
{
// 不正なプロセスグループ番号
if( procGrpNo < 0 || procGrpNo >= int(m_procGrpList.size()) )
{
// プロセスグループが存在しない
return getCommNull();
}
return m_procGrpList[procGrpNo];
}
////////////////////////////////////////////////////////////////////////////////
// Abort
void
cpm_BaseParaManager::Abort( int errorcode )
{
// MPI_Abort
MPI_Abort(MPI_COMM_WORLD, errorcode);
exit(errorcode);
}
////////////////////////////////////////////////////////////////////////////////
// Barrier
cpm_ErrorCode
cpm_BaseParaManager::Barrier( int procGrpNo )
{
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm( procGrpNo );
if( IsCommNull( comm ) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Barrier
if( MPI_Barrier(comm) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_BARRIER;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Wait
cpm_ErrorCode
cpm_BaseParaManager::Wait( MPI_Request *request )
{
if( !request )
{
return CPM_ERROR_INVALID_PTR;
}
if( *request == MPI_REQUEST_NULL )
{
return CPM_ERROR_MPI_INVALID_REQUEST;
}
// MPI_Wait
MPI_Status status;
if( MPI_Wait( request, &status ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_WAIT;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Waitall
cpm_ErrorCode
cpm_BaseParaManager::Waitall( int count, MPI_Request requests[] )
{
// status
int cnt = 0;
MPI_Status *stat = new MPI_Status[count];
MPI_Request *req = new MPI_Request[count];
for( int i=0;i<count;i++ )
{
if( requests[i] != MPI_REQUEST_NULL ) req[cnt++] = requests[i];
}
if( cnt == 0 )
{
delete [] stat;
delete [] req;
return CPM_SUCCESS;
}
// MPI_Waitall
if( MPI_Waitall( cnt, req, stat ) != MPI_SUCCESS )
{
delete [] stat;
delete [] req;
return CPM_ERROR_MPI_WAITALL;
}
delete [] stat;
delete [] req;
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Bcast(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Bcast( MPI_Datatype dtype, void *buf, int count, int root, int procGrpNo )
{
if( !buf )
{
return CPM_ERROR_INVALID_PTR;
}
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Bcast
if( MPI_Bcast( buf, count, dtype, root, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_BCAST;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Send(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Send( MPI_Datatype dtype, void *buf, int count, int dest, int procGrpNo )
{
if( !buf )
{
return CPM_ERROR_INVALID_PTR;
}
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Send
int tag = 1;
if( MPI_Send( buf, count, dtype, dest, tag, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_SEND;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Recv(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Recv( MPI_Datatype dtype, void *buf, int count, int source, int procGrpNo )
{
if( !buf )
{
return CPM_ERROR_INVALID_PTR;
}
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Send
int tag = 1;
MPI_Status status;
if( MPI_Recv( buf, count, dtype, source, tag, comm, &status ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_SEND;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Isend(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Isend( MPI_Datatype dtype, void *buf, int count, int dest, MPI_Request *request, int procGrpNo )
{
if( !buf || !request )
{
return CPM_ERROR_INVALID_PTR;
}
*request = MPI_REQUEST_NULL;
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Isend
int tag = 1;
if( MPI_Isend( buf, count, dtype, dest, tag, comm, request ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_ISEND;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Irecv(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Irecv( MPI_Datatype dtype, void *buf, int count, int source, MPI_Request *request, int procGrpNo )
{
if( !buf || !request )
{
return CPM_ERROR_INVALID_PTR;
}
*request = MPI_REQUEST_NULL;
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Irecv
int tag = 1;
if( MPI_Irecv( buf, count, dtype, source, tag, comm, request ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_IRECV;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Allreduce(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Allreduce( MPI_Datatype dtype, void *sendbuf, void *recvbuf, int count, MPI_Op op, int procGrpNo )
{
if( !sendbuf || !recvbuf )
{
return CPM_ERROR_INVALID_PTR;
}
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Allreduce
if( MPI_Allreduce( sendbuf, recvbuf, count, dtype, op, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_ALLREDUCE;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Gather(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Gather( MPI_Datatype stype, void *sendbuf, int sendcnt
, MPI_Datatype rtype, void *recvbuf, int recvcnt
, int root, int procGrpNo )
{
if( !sendbuf || !recvbuf )
{
return CPM_ERROR_INVALID_PTR;
}
//コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Gather
if( MPI_Gather( sendbuf, sendcnt, stype, recvbuf, recvcnt, rtype, root, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_GATHER;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Allgather(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Allgather( MPI_Datatype stype, void *sendbuf, int sendcnt
, MPI_Datatype rtype, void *recvbuf, int recvcnt
, int procGrpNo )
{
if( !sendbuf || !recvbuf )
{
return CPM_ERROR_INVALID_PTR;
}
//コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Allaather
if( MPI_Allgather( sendbuf, sendcnt, stype, recvbuf, recvcnt, rtype, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_ALLGATHER;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Gatherv(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Gatherv( MPI_Datatype stype, void *sendbuf, int sendcnt
, MPI_Datatype rtype, void *recvbuf, int *recvcnts
, int *displs, int root, int procGrpNo )
{
if( !sendbuf || !recvbuf || !recvcnts || !displs )
{
return CPM_ERROR_INVALID_PTR;
}
//コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Gather
if( MPI_Gatherv( sendbuf, sendcnt, stype, recvbuf, recvcnts, displs
, rtype, root, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_GATHERV;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// Allgatherv(MPI_Datatype指定)
cpm_ErrorCode
cpm_BaseParaManager::Allgatherv( MPI_Datatype stype, void *sendbuf, int sendcnt
, MPI_Datatype rtype, void *recvbuf, int *recvcnts
, int *displs, int procGrpNo )
{
if( !sendbuf || !recvbuf || !recvcnts || !displs )
{
return CPM_ERROR_INVALID_PTR;
}
// コミュニケータを取得
MPI_Comm comm = GetMPI_Comm(procGrpNo);
if( IsCommNull(comm) )
{
// プロセスグループが存在しない
return CPM_ERROR_NOT_IN_PROCGROUP;
}
// MPI_Allaather
if( MPI_Allgatherv( sendbuf, sendcnt, stype, recvbuf, recvcnts, displs, rtype, comm ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_ALLGATHERV;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// cpm_Wait
cpm_ErrorCode
cpm_BaseParaManager::cpm_Wait( int reqNo )
{
// MPI_Request
MPI_Request *req = m_reqList.Get(reqNo);
if( !req )
{
return CPM_ERROR_INVALID_OBJKEY;
}
// MPI_Wait
MPI_Status status;
if( MPI_Wait( req, &status ) != MPI_SUCCESS )
{
return CPM_ERROR_MPI_WAIT;
}
// 削除
return m_reqList.Delete(reqNo);
}
////////////////////////////////////////////////////////////////////////////////
// cpm_Waitall
cpm_ErrorCode
cpm_BaseParaManager::cpm_Waitall( int count, int reqNoList[] )
{
// MPI_Request
MPI_Status* stat = new MPI_Status [count];
MPI_Request* req = new MPI_Request[count];
int cnt = 0;
for( int i=0;i<count;i++ )
{
MPI_Request *r = m_reqList.Get( reqNoList[i] );
if( r )
{
r[cnt++] = *req;
}
}
if( cnt == 0 )
{
delete [] stat;
delete [] req;
return CPM_ERROR_INVALID_OBJKEY;
}
// MPI_Waitall
if( MPI_Waitall( cnt, req, stat ) != MPI_SUCCESS )
{
delete [] stat;
delete [] req;
return CPM_ERROR_MPI_WAITALL;
}
// 削除
for( int i=0;i<count;i++ )
{
m_reqList.Delete( reqNoList[i] );
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// cpm_Isend
cpm_ErrorCode
cpm_BaseParaManager::cpm_Isend( void *buf, int count, int datatype, int dest, int *reqNo, int procGrpNo )
{
// MPI_Datatype
MPI_Datatype dtype = cpm_BaseParaManager::GetMPI_Datatype( datatype );
if( dtype == MPI_DATATYPE_NULL )
{
return CPM_ERROR_MPI_INVALID_DATATYPE;
}
// MPI_Request
MPI_Request *req = m_reqList.Create();
if( !req )
{
return CPM_ERROR_INVALID_PTR;
}
// Isend
cpm_ErrorCode ret = Isend( dtype, buf, count, dest, req, procGrpNo );
if( ret != MPI_SUCCESS )
{
delete req;
return ret;
}
// MPI_Requestを登録
if( (*reqNo = m_reqList.Add(req) ) < 0 )
{
delete req;
return CPM_ERROR_REGIST_OBJKEY;
}
return CPM_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// cpm_Irecv
cpm_ErrorCode
cpm_BaseParaManager::cpm_Irecv( void *buf, int count, int datatype, int source, int *reqNo, int procGrpNo )
{
// MPI_Datatype
MPI_Datatype dtype = cpm_BaseParaManager::GetMPI_Datatype( datatype );
if( dtype == MPI_DATATYPE_NULL )
{
return CPM_ERROR_MPI_INVALID_DATATYPE;
}
// Irecv
MPI_Request req;
cpm_ErrorCode ret = Irecv( dtype, buf, count, source, &req, procGrpNo );
if( ret != MPI_SUCCESS )
{
return ret;
}
// MPI_Requestを登録
MPI_Request *r = m_reqList.Create();
*r = req;
if( (*reqNo = m_reqList.Add(r) ) < 0 )
{
delete r;
return CPM_ERROR_REGIST_OBJKEY;
}
return CPM_SUCCESS;
}
| 23.86627
| 119
| 0.577886
|
jorji
|
9a666e5b485039da1cb223c3e70bf30f808f2da4
| 28
|
cpp
|
C++
|
DataStructures/Src/Precompiled.cpp
|
ikarusx/ModernCpp
|
8c0111dec2d0a2a183250e2f9594573b99687ec5
|
[
"MIT"
] | null | null | null |
DataStructures/Src/Precompiled.cpp
|
ikarusx/ModernCpp
|
8c0111dec2d0a2a183250e2f9594573b99687ec5
|
[
"MIT"
] | null | null | null |
DataStructures/Src/Precompiled.cpp
|
ikarusx/ModernCpp
|
8c0111dec2d0a2a183250e2f9594573b99687ec5
|
[
"MIT"
] | null | null | null |
#include "Precompiled.hpp"
| 9.333333
| 26
| 0.75
|
ikarusx
|
9a6726017803c35221f177ec07786cb6a428563f
| 10,074
|
cpp
|
C++
|
coh2_rgt_extractor/Rainman_src/CRgdHashTable.cpp
|
tranek/coh2_rgt_extractor
|
dba2db9a06d3f31fb815ca865181d8f631306522
|
[
"MIT"
] | 1
|
2016-09-24T14:57:56.000Z
|
2016-09-24T14:57:56.000Z
|
coh2_rgt_extractor/Rainman_src/CRgdHashTable.cpp
|
tranek/coh2_rgt_extractor
|
dba2db9a06d3f31fb815ca865181d8f631306522
|
[
"MIT"
] | null | null | null |
coh2_rgt_extractor/Rainman_src/CRgdHashTable.cpp
|
tranek/coh2_rgt_extractor
|
dba2db9a06d3f31fb815ca865181d8f631306522
|
[
"MIT"
] | null | null | null |
/*
Rainman Library
Copyright (C) 2006 Corsix <corsix@gmail.com>
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; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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
*/
#include "CRgdHashTable.h"
#include "memdebug.h"
#include "Exception.h"
extern "C" {
typedef unsigned long int ub4; /* unsigned 4-byte quantities */
typedef unsigned char ub1;
ub4 hash(ub1 * k,ub4 length,ub4 initval);
ub4 hash3(ub1 * k,ub4 length,ub4 initval);
}
static char* mystrdup(const char* sStr)
{
char* s = new char[strlen(sStr) + 1];
if(s == 0) return 0;
strcpy(s, sStr);
return s;
}
CRgdHashTable::CRgdHashTable(void)
{
for(int i = 1; i < 10000; ++i)
{
char sBuf[24];
_Value Val;
Val.bCustom = false;
Val.sString = CHECK_MEM(mystrdup(itoa(i,sBuf,10)));
m_mHashTable[hash((ub1*)sBuf, (ub4) strlen(sBuf), 0)] = Val;
}
}
CRgdHashTable::~CRgdHashTable(void)
{
_Clean();
}
void CRgdHashTable::New()
{
_Clean();
}
void CRgdHashTable::FillUnknownList(std::vector<unsigned long>& oList)
{
for(std::map<unsigned long, CRgdHashTable::_Value>::iterator itr = m_mHashTable.begin(); itr != m_mHashTable.end(); ++itr)
{
if(itr->second.sString == 0) oList.push_back(itr->first);
}
}
static char* fgetline(FILE *f, unsigned int iInitSize = 32)
{
unsigned int iTotalLen;
if(f == 0) throw new CRainmanException(__FILE__, __LINE__, "No file");
if(iInitSize < 4) iInitSize = 4;
iTotalLen = iInitSize;
char *sBuffer = new char[iInitSize];
char *sReadTo = sBuffer;
if(sBuffer == 0) throw new CRainmanException(0, __FILE__, __LINE__, "Failed to allocate %u", iInitSize);
do
{
if(fgets(sReadTo, iInitSize, f) == 0)
{
if(feof(f))
{
if(sReadTo[strlen(sReadTo) - 1] == '\n') sReadTo[strlen(sReadTo) - 1] = 0;
return sBuffer;
}
delete[] sBuffer;
throw new CRainmanException(__FILE__, __LINE__, "Failed to read string");
}
if(sReadTo[strlen(sReadTo) - 1] == '\n')
{
size_t n = strlen(sReadTo) - 1;
sReadTo[n] = 0;
while(n > 0)
{
--n;
if(sReadTo[n] == '\n' || sReadTo[n] == '\r') sReadTo[n] = 0;
else break;
}
return sBuffer;
}
iTotalLen += iInitSize;
char *sTmp = new char[iTotalLen];
if(sTmp == 0)
{
delete[] sBuffer;
throw new CRainmanException(0, __FILE__, __LINE__, "Failed to allocate %u", iTotalLen);
}
strcpy(sTmp, sBuffer);
delete[] sBuffer;
sBuffer = sTmp;
sReadTo = sBuffer + strlen(sBuffer);
}while(1);
}
void CRgdHashTable::ExtendWithDictionary(const char* sFile, bool bCustom)
{
FILE *fFile = fopen(sFile, "rb");
if(fFile == 0) throw new CRainmanException(0, __FILE__, __LINE__, "Failed to open file \'%s\'", sFile);
while(!feof(fFile))
{
char* sLine;
try
{
sLine = fgetline(fFile);
}
catch(CRainmanException* pE)
{
fclose(fFile);
throw new CRainmanException(__FILE__, __LINE__, "Failed to read line", pE);
}
char *sBaseLine = sLine;
bool bUnk = false;
if( (strncmp(sLine, "# 0x", 4) == 0) && (strncmp(sLine + 12, " is an unknown value!!", 22) == 0))
{
bUnk = true;
sLine[0] = ' ';
sLine[12] = '=';
}
if(sLine[0] != '#')
{
unsigned long iKey = 0;
int iBitsRead = -8;
// Read in key
while((*sLine != '=') && *sLine)
{
if(iBitsRead == -8)
{
if(*sLine == '0') iBitsRead = -4;
}
else if(iBitsRead == -4)
{
if(*sLine == 'x' || *sLine == 'X') iBitsRead = 0;
}
else if(iBitsRead < 32)
{
if(*sLine >= '0' && *sLine <= '9')
{
iKey <<= 4;
iKey |= (*sLine - '0');
iBitsRead += 4;
}
else if(*sLine >= 'a' && *sLine <= 'f')
{
iKey <<= 4;
iKey |= (*sLine - 'a' + 10);
iBitsRead += 4;
}
else if(*sLine >= 'A' && *sLine <= 'F')
{
iKey <<= 4;
iKey |= (*sLine - 'A' + 10);
iBitsRead += 4;
}
}
++sLine;
}
if(*sLine && *sLine == '=')
{
++sLine;
// Read in value
char *sValue = 0;
if(!bUnk)
{
sValue = new char[strlen(sLine) + 1];
if(sValue == 0)
{
delete[] sBaseLine;
fclose(fFile);
throw new CRainmanException(__FILE__, __LINE__, "Failed to allocate memory");
}
char *sTmp = sValue;
memset(sValue, 0, strlen(sLine) + 1);
while(*sLine)
{
if( (*sLine != ' ') && (*sLine != '\t') && (*sLine != '\r') && (*sLine != '\n') )
{
*sTmp = *sLine;
++sTmp;
}
++sLine;
}
}
_Value Val;
Val = m_mHashTable[iKey];
if(Val.sString)
{
Val.bCustom = Val.bCustom && bCustom;
delete[] sValue;
}
else
{
Val.sString = sValue;
Val.bCustom = bCustom;
}
m_mHashTable[iKey] = Val;
}
delete[] sBaseLine;
}
else
{
delete[] sLine;
}
}
fclose(fFile);
}
void CRgdHashTable::XRefWithStringList(const char* sFile)
{
FILE *fFile = fopen(sFile, "rb");
if(fFile == 0) throw new CRainmanException(0, __FILE__, __LINE__, "Failed to open file \'%s\'", sFile);
while(!feof(fFile))
{
char* sLine;
try
{
sLine = fgetline(fFile);
}
catch(CRainmanException* pE)
{
fclose(fFile);
throw new CRainmanException(__FILE__, __LINE__, "Failed to read line", pE);
}
unsigned long iKey = hash((ub1*)sLine, (ub4) strlen(sLine), 0);
if(m_mHashTable.find(iKey) != m_mHashTable.end() && m_mHashTable[iKey].sString == 0)
{
_Value Val;
Val.bCustom = true;
Val.sString = CHECK_MEM(mystrdup(sLine));
m_mHashTable[iKey] = Val;
}
delete[] sLine;
}
}
void CRgdHashTable::SaveCustomKeys(const char* sFile)
{
FILE *fFile = fopen(sFile, "wb");
if(fFile == 0) throw new CRainmanException(0, __FILE__, __LINE__, "Failed to open file \'%s\'", sFile);
fputs("#RGD_DIC\n# This dictionary is generated from any keys that are \'discovered\'\n", fFile);
for(std::map<unsigned long, _Value>::iterator itr = m_mHashTable.begin(); itr != m_mHashTable.end(); ++itr)
{
if(itr->second.bCustom)
{
if(itr->second.sString == 0) fputs("# ", fFile);
// Output key
fputs("0x", fFile);
unsigned long iMask = 0xF0000000;
for(int i = 7; i >= 0; --i)
{
fputc("0123456789ABCDEF"[(itr->first & iMask) >> (i << 2)], fFile);
iMask >>= 4;
}
// Output value
if(itr->second.sString == 0)
{
fputs(" is an unknown value!!\n", fFile);
}
else
{
fputc('=', fFile);
fputs(itr->second.sString, fFile);
fputc('\n', fFile);
}
}
}
fclose(fFile);
}
const char* CRgdHashTable::HashToValue(unsigned long iHash)
{
const char* s = m_mHashTable[iHash].sString;
if(s == 0)
{
m_mHashTable[iHash].bCustom = true;
return 0;
}
return s;
}
unsigned long CRgdHashTable::ValueToHash(const char* sValue)
{
if(sValue[0] == '0' && sValue[1] == 'x')
{
for(int i = 2; i < 10; ++i)
{
if(!(
(sValue[i] >= '0' && sValue[i] <= '9') ||
(sValue[i] >= 'a' && sValue[i] <= 'f') ||
(sValue[i] >= 'A' && sValue[i] <= 'F')
))
goto nothex;
}
if(sValue[10] == 0)
{
unsigned long iKey = 0;
for(int i = 2; i < 10; ++i)
{
iKey <<= 4;
if(sValue[i] >= '0' && sValue[i] <= '9') iKey |= (sValue[i] - '0');
if(sValue[i] >= 'a' && sValue[i] <= 'f') iKey |= (sValue[i] - 'a' + 10);
if(sValue[i] >= 'A' && sValue[i] <= 'F') iKey |= (sValue[i] - 'A' + 10);
}
return iKey;
}
}
nothex:
unsigned long iKey = hash((ub1*)sValue, (ub4) strlen(sValue), 0);
if(m_mHashTable[iKey].sString == 0)
{
_Value Val;
Val.bCustom = false;
const char* sTmp = sValue;
do
{
if( ((*sTmp) < '0') || ((*sTmp) > '9') )
{
Val.bCustom = true;
break;
}
++sTmp;
}while(*sTmp);
Val.sString = CHECK_MEM(mystrdup(sValue));
m_mHashTable[iKey] = Val;
}
return iKey;
}
unsigned long CRgdHashTable::ValueToHashStatic(const char* sValue, size_t iValueLen)
{
if(sValue[0] == '0' && sValue[1] == 'x' && iValueLen == 10)
{
for(int i = 2; i < 10; ++i)
{
if(!(
(sValue[i] >= '0' && sValue[i] <= '9') ||
(sValue[i] >= 'a' && sValue[i] <= 'f') ||
(sValue[i] >= 'A' && sValue[i] <= 'F')
))
goto nothex;
}
unsigned long iKey = 0;
for(int i = 2; i < 10; ++i)
{
iKey <<= 4;
if(sValue[i] >= '0' && sValue[i] <= '9') iKey |= (sValue[i] - '0');
if(sValue[i] >= 'a' && sValue[i] <= 'f') iKey |= (sValue[i] - 'a' + 10);
if(sValue[i] >= 'A' && sValue[i] <= 'F') iKey |= (sValue[i] - 'A' + 10);
}
return iKey;
}
nothex:
unsigned long iKey = hash((ub1*)sValue, (ub4) iValueLen, 0);
return iKey;
}
unsigned long CRgdHashTable::ValueToHashStatic(const char* sValue)
{
if(sValue[0] == '0' && sValue[1] == 'x')
{
for(int i = 2; i < 10; ++i)
{
if(!(
(sValue[i] >= '0' && sValue[i] <= '9') ||
(sValue[i] >= 'a' && sValue[i] <= 'f') ||
(sValue[i] >= 'A' && sValue[i] <= 'F')
))
goto nothex;
}
if(sValue[10] == 0)
{
unsigned long iKey = 0;
for(int i = 2; i < 10; ++i)
{
iKey <<= 4;
if(sValue[i] >= '0' && sValue[i] <= '9') iKey |= (sValue[i] - '0');
if(sValue[i] >= 'a' && sValue[i] <= 'f') iKey |= (sValue[i] - 'a' + 10);
if(sValue[i] >= 'A' && sValue[i] <= 'F') iKey |= (sValue[i] - 'A' + 10);
}
return iKey;
}
}
nothex:
unsigned long iKey = hash((ub1*)sValue, (ub4) strlen(sValue), 0);
return iKey;
}
CRgdHashTable::_Value::_Value()
{
sString = 0;
bCustom = false;
}
void CRgdHashTable::_Clean()
{
for(std::map<unsigned long, _Value>::iterator itr = m_mHashTable.begin(); itr != m_mHashTable.end(); ++itr)
{
if(itr->second.sString) delete[] itr->second.sString;
}
}
| 23.105505
| 123
| 0.571074
|
tranek
|
9a6b74f17a9d9e386a1fb0d561ea3f9cb5dada08
| 1,518
|
hpp
|
C++
|
include/pichi/common/endpoint.hpp
|
imuzi/pichi
|
5ad1372bff4c3bffd201ccfb41df6c839c83c506
|
[
"BSD-3-Clause"
] | 164
|
2018-09-28T09:41:05.000Z
|
2021-11-13T09:17:07.000Z
|
include/pichi/common/endpoint.hpp
|
imuzi/pichi
|
5ad1372bff4c3bffd201ccfb41df6c839c83c506
|
[
"BSD-3-Clause"
] | 5
|
2018-12-21T13:40:02.000Z
|
2021-07-24T04:23:44.000Z
|
include/pichi/common/endpoint.hpp
|
imuzi/pichi
|
5ad1372bff4c3bffd201ccfb41df6c839c83c506
|
[
"BSD-3-Clause"
] | 14
|
2018-12-18T09:35:42.000Z
|
2021-07-06T12:16:34.000Z
|
#ifndef PICHI_COMMON_ENDPOINT_HPP
#define PICHI_COMMON_ENDPOINT_HPP
#include <algorithm>
#include <functional>
#include <iterator>
#include <pichi/common/buffer.hpp>
#include <pichi/common/enumerations.hpp>
#include <string>
#include <string_view>
#include <type_traits>
namespace std {
inline string to_string(string_view sv) { return {cbegin(sv), cend(sv)}; }
} // namespace std
namespace pichi {
struct Endpoint {
EndpointType type_;
std::string host_;
uint16_t port_;
};
template <typename Int> void hton(Int src, MutableBuffer<uint8_t> dst)
{
static_assert(std::is_integral_v<Int>, "input type must be integral.");
assert(sizeof(Int) <= dst.size());
auto p = reinterpret_cast<uint8_t*>(&src);
std::reverse_copy(p, p + sizeof(Int), std::begin(dst));
}
template <typename Int> Int ntoh(ConstBuffer<uint8_t> src)
{
static_assert(std::is_integral_v<Int>, "output type must be integral.");
assert(src.size() >= sizeof(Int));
Int dst;
std::reverse_copy(std::cbegin(src), std::cend(src), reinterpret_cast<uint8_t*>(&dst));
return dst;
}
extern size_t serializeEndpoint(Endpoint const&, MutableBuffer<uint8_t>);
extern Endpoint parseEndpoint(std::function<void(MutableBuffer<uint8_t>)>);
extern EndpointType detectHostType(std::string_view);
extern Endpoint makeEndpoint(std::string_view, uint16_t);
extern Endpoint makeEndpoint(std::string_view, std::string_view);
extern bool operator==(Endpoint const&, Endpoint const&);
} // namespace pichi
#endif // PICHI_COMMON_ENDPOINT_HPP
| 27.107143
| 88
| 0.746377
|
imuzi
|
9a6c9753edc8507678f6e6f21f471beed68494d1
| 3,668
|
cpp
|
C++
|
oneEngine/oneGame/source/renderer/camera/RrRTCamera.cpp
|
jonting/1Engine
|
f22ba31f08fa96fe6405ebecec4f374138283803
|
[
"BSD-3-Clause"
] | 8
|
2017-12-08T02:59:31.000Z
|
2022-02-02T04:30:03.000Z
|
oneEngine/oneGame/source/renderer/camera/RrRTCamera.cpp
|
jonting/1Engine
|
f22ba31f08fa96fe6405ebecec4f374138283803
|
[
"BSD-3-Clause"
] | 2
|
2021-04-16T03:44:42.000Z
|
2021-08-30T06:48:44.000Z
|
oneEngine/oneGame/source/renderer/camera/RrRTCamera.cpp
|
jonting/1Engine
|
f22ba31f08fa96fe6405ebecec4f374138283803
|
[
"BSD-3-Clause"
] | 1
|
2021-04-16T02:09:54.000Z
|
2021-04-16T02:09:54.000Z
|
#include "core/time/time.h"
#include "renderer/state/Settings.h"
#include "renderer/types/ObjectSettings.h"
#include "renderer/texture/RrRenderTexture.h"
#include "renderer/state/RrHybridBufferChain.h"
#include "RrRTCamera.h"
RrRTCamera::RrRTCamera (
renderer::rrInternalSettings* const targetSettings,
Vector2i const& targetSize,
Real renderFramerate,
bool autoRender
) : RrCamera (),
m_renderCounter(0),
m_renderStepTime(1.0F / renderFramerate),
m_autoRender(autoRender)
{
layerVisibility[renderer::kRenderLayerSecondary] = false;
layerVisibility[renderer::kRenderLayerV2D] = false;
// Set render texture immediately
//m_renderTexture = targetTexture;
// Create the buffer chain immediately.
SetTargetInfo(targetSettings, targetSize);
}
RrRTCamera::~RrRTCamera ( void )
{
;
}
// SetTargetInfo(settings, size) : Sets up render target for the camera.
// Will free previously created buffers.
// Returns true on successful creation.
bool RrRTCamera::SetTargetInfo ( renderer::rrInternalSettings* const settings, Vector2i const& size )
{
m_usedTargetSettings = *settings;
m_targetSize = size;
gpu::ErrorCode status = m_chain.CreateTargetBufferChain(&m_usedTargetSettings, size);
return status == gpu::kError_SUCCESS;
}
// FreeTarget() : Frees up the render target.
bool RrRTCamera::FreeTarget ( void )
{
bool status = m_chain.FreeTargetBufferChain();
return status;
}
// Update
void RrRTCamera::LateUpdate ( void )
{
// If autorender, then tell scene to update at given framerate
if ( m_autoRender )
{
if ( m_needsNewPasses ) {
m_needsNewPasses = false;
}
m_renderCounter += Time::deltaTime;
if ( m_renderCounter > m_renderStepTime )
{
m_renderCounter = 0.0F; // TODO: why not a subtract+limit
m_needsNewPasses = true;
}
}
// However, if there's not a valid render target, turn rendering off
//if ( m_renderTexture == NULL )
if ( !active )
{
m_needsNewPasses = false;
}
// Perform late update, which will update the viewport size to an incorrect value:
RrCamera::LateUpdate();
// So we set the proper viewport now:
viewport.pos.x = viewportPercent.pos.x * m_targetSize.x;
viewport.pos.y = viewportPercent.pos.y * m_targetSize.y;
viewport.size.x = viewportPercent.size.x * m_targetSize.x;
viewport.size.y = viewportPercent.size.y * m_targetSize.y;
}
// Update Camera Matrix
void RrRTCamera::UpdateMatrix ( void )
{
// Update the projection matrix normally.
RrCamera::UpdateMatrix();
// Update the texture matrix after the camera matrix is updated
UpdateTextureMatrix();
}
// Update Texture Matrix
void RrRTCamera::UpdateTextureMatrix ( void )
{
const Real bias[16] = {
0.5F, 0.0F, 0.0F, 0.0F,
0.0F, 0.5F, 0.0F, 0.0F,
0.0F, 0.0F, 0.5F, 0.0F,
0.5F, 0.5F, 0.5F, 1.0F
};
const Matrix4x4 biasMatrix ( bias );
//textureMatrix = viewTransform * projTransform * biasMatrix;
textureMatrix = viewprojMatrix * biasMatrix;
}
// PassCount() : Returns number of passes this camera will render
// Must be 1 or greater in order to render.
int RrRTCamera::PassCount ( void )
{
return 1;
}
// PassRetrieve(array, array_size) : Writes pass information into the array given in
// Will write either PassCount() or maxPasses passes, whatever is smaller.
void RrRTCamera::PassRetrieve ( const rrCameraPassInput* input, rrCameraPass* passList )
{
RrCamera::PassRetrieve(input, passList); // TODO: Proper buffer chain!
if (input->m_maxPasses > 0)
{
passList[0].m_bufferChain = &m_chain;
}
}
void RrRTCamera::RenderBegin ( void )
{
// Call the parent one
RrCamera::RenderBegin();
// bind to m_renderTexture ???
// todo
}
void RrRTCamera::RenderEnd ( void )
{
RrCamera::RenderEnd();
}
| 26.014184
| 101
| 0.730098
|
jonting
|
9a7253aa706747c7104c81bf942ca292d57d6aa9
| 1,303
|
cpp
|
C++
|
src/trace/GLLib/Texture/TextureTarget.cpp
|
attila-sim/attila-sim
|
a64b57240b4e10dc4df7f21eff0232b28df09532
|
[
"BSD-3-Clause"
] | 23
|
2016-01-14T04:47:13.000Z
|
2022-01-13T14:02:08.000Z
|
src/trace/GLLib/Texture/TextureTarget.cpp
|
attila-sim/attila-sim
|
a64b57240b4e10dc4df7f21eff0232b28df09532
|
[
"BSD-3-Clause"
] | 2
|
2018-03-25T14:39:20.000Z
|
2022-03-18T05:11:21.000Z
|
src/trace/GLLib/Texture/TextureTarget.cpp
|
attila-sim/attila-sim
|
a64b57240b4e10dc4df7f21eff0232b28df09532
|
[
"BSD-3-Clause"
] | 17
|
2016-02-13T05:35:35.000Z
|
2022-03-24T16:05:40.000Z
|
/**************************************************************************
*
* Copyright (c) 2002 - 2011 by Computer Architecture Department,
* Universitat Politecnica de Catalunya.
* All rights reserved.
*
* The contents of this file may not be disclosed to third parties,
* copied or duplicated in any form, in whole or in part, without the
* prior permission of the authors, Computer Architecture Department
* and Universitat Politecnica de Catalunya.
*
*/
#include "TextureTarget.h"
using namespace libgl;
TextureTarget::TextureTarget(GLuint target) : BaseTarget(target)
{
if ( target != GL_TEXTURE_1D && target != GL_TEXTURE_2D && target != GL_TEXTURE_3D &&
target != GL_TEXTURE_CUBE_MAP )
panic("TextureTarget", "TextureTarget", "Unexpected texture target");
TextureObject* defTex = new TextureObject(0, target); // create a default object
defTex->setTarget(*this);
setCurrent(*defTex);
setDefault(defTex);
/*****************************************
* CONFIGURE DEFAULT TEXTURE OBJECT HERE *
*****************************************/
}
TextureObject* TextureTarget::createObject(GLuint name)
{
TextureObject* to = new TextureObject(name, getName());
to->setTarget(*this);
return to;
}
| 30.302326
| 90
| 0.604758
|
attila-sim
|
9a77b287a6fd0647a604244033677071702b2567
| 187,010
|
cpp
|
C++
|
libs/graph_parallel/test/performance_test.cpp
|
thejkane/AGM
|
4d5cfe9522461d207ceaef7d90c1cd10ce9b469c
|
[
"BSL-1.0"
] | 1
|
2021-09-03T10:22:04.000Z
|
2021-09-03T10:22:04.000Z
|
libs/graph_parallel/test/performance_test.cpp
|
thejkane/AGM
|
4d5cfe9522461d207ceaef7d90c1cd10ce9b469c
|
[
"BSL-1.0"
] | null | null | null |
libs/graph_parallel/test/performance_test.cpp
|
thejkane/AGM
|
4d5cfe9522461d207ceaef7d90c1cd10ce9b469c
|
[
"BSL-1.0"
] | null | null | null |
// Copyright (C) 2014 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Nicholas Edmonds
// Andrew Lumsdaine
// Marcin Zalewski
// Thejaka Kanewala
#define LIB_CDS 1
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <stdint.h>
#include <inttypes.h>
#include <cstdlib>
#include <math.h>
//#define DISABLE_SELF_SEND_CHECK
//#define AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
//#define PBGL2_PRINT_WORK_STATS
// #define PRINT_STATS
// #define PRINT_DEBUG
#define AMPLUSPLUS_PRINT_HIT_RATES
#define BFS_SV_CC_HACK
// #define DS_SHARED_REDUCTIONS
// #define BFS_VECTOR
#define DISABLE_BFS_BITMAP
#ifdef __bgp__
#define BGP_REPORT_MEMORY 1 // if >1 all ranks will report memory usage
#endif
//#define NUMBER_COMPONENTS
// #define PBGL_TIMING // turn on local component counting, sequential timing, and such in CC
// #define PRINT_ET
#define BARRIER_TRANS
// #define CLONE
#define CALCULATE_GTEPS 1
#include <am++/am++.hpp>
#include <am++/mpi_transport.hpp>
#include <am++/counter_coalesced_message_type.hpp>
#include <boost/graph/distributed/time_calc.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/graph/use_mpi.hpp>
#include <boost/property_map/parallel/distributed_property_map.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/distributed/compressed_sparse_row_graph.hpp>
#include <boost/graph/recursive_rmat_generator.hpp>
#include <boost/graph/erdos_renyi_generator.hpp>
#include <boost/graph/graph500_generator.hpp>
#include <boost/graph/permute_graph.hpp>
#include <boost/graph/parallel/algorithm.hpp> // for all_reduce
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/distributed/delta_stepping_shortest_paths.hpp>
#include <boost/graph/distributed/delta_stepping_shortest_paths_node.hpp>
#include <boost/graph/distributed/delta_stepping_shortest_paths_thread.hpp>
#include <boost/graph/distributed/delta_stepping_shortest_paths_numa.hpp>
#include <boost/graph/distributed/mis.hpp>
#include <boost/graph/distributed/mis_delta.hpp>
#include <boost/graph/distributed/luby_mis.hpp>
#include <boost/graph/distributed/kla_sssp_buffer.hpp>
#include <boost/graph/distributed/kla_sssp_numa.hpp>
#include <boost/graph/distributed/kla_sssp_node.hpp>
#include <boost/graph/distributed/kla_sssp_thread.hpp>
#include <boost/graph/distributed/distributed_control.hpp>
#include <boost/graph/distributed/distributed_control_node.hpp>
#include <boost/graph/distributed/distributed_control_pheet.hpp>
#include <boost/graph/distributed/priority_q_defs.hpp>
#include <boost/graph/distributed/distributed_control_chaotic.hpp>
#include <boost/graph/distributed/cc_dc.hpp>
#include <boost/graph/distributed/cc_chaotic.hpp>
#include <boost/graph/distributed/delta_stepping_cc.hpp>
#include <boost/graph/distributed/cc_diff_dc.hpp>
#include <boost/graph/distributed/level_sync_cc.hpp>
#include <boost/graph/distributed/connected_components.hpp>
#include <boost/graph/distributed/sv_cc.hpp>
#include <boost/graph/distributed/page_rank.hpp>
#include <boost/graph/distributed/graph_reader.hpp>
#include <boost/graph/relax.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_map/parallel/global_index_map.hpp>
#include <boost/parallel/append_buffer.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <parallel/algorithm>
#include <algorithm> // for std::min, std::max
#include <functional>
#include <cds/init.h> // for cds::Initialize and cds::Terminate
#include <cds/gc/hp.h> // for cds::HP (Hazard Pointer) SMR
//#include "statistics.h"
#define HAS_NOT_BEEN_SEEN
#ifdef DISABLE_SELF_SEND_CHECK
#warning "==================^^^^^Self send check is disabled !^^^^^======================="
#endif
int _RANK;
using namespace boost;
using boost::parallel::all_reduce;
using boost::parallel::maximum;
using std::max;
#include <time.h>
#include <sys/time.h>
/*typedef double time_type;
inline time_type get_time()
{
return MPI_Wtime();
#if 0
timeval tp;
gettimeofday(&tp, 0);
return tp.tv_sec + tp.tv_usec / 1000000.0;
#endif
}*/
std::string print_time(time_type t)
{
std::ostringstream out;
out << std::setiosflags(std::ios::fixed) << std::setprecision(2) << t;
return out.str();
}
struct flip_pair {
template <typename T>
T operator()(const T& x) const {
// flipping edges by keeping same weight
return std::make_pair(x.second.first, std::make_pair(x.first, x.second.second));
}
};
#define PRINT_GRAPH500_STATS(lbl, israte) \
do { \
printf ("Min(%s): %20.17e\n", lbl, stats[0]); \
printf ("First Quartile(%s): %20.17e\n", lbl, stats[1]); \
printf ("Median(%s): %20.17e\n", lbl, stats[2]); \
printf ("Third Quartile(%s): %20.17e\n", lbl, stats[3]); \
printf ("Max(%s): %20.17e\n", lbl, stats[4]); \
if (!israte) { \
printf ("Mean(%s): %20.17e\n", lbl, stats[5]); \
printf ("Stddev(%s): %20.17e\n", lbl, stats[6]); \
} else { \
printf ("Harmonic Mean(%s): %20.17e\n", lbl, stats[7]); \
printf ("Harmonic Stddev(%s): %20.17e\n", lbl, stats[8]); \
} \
} while (0)
extern void statistics (double *out, double *data, size_t n);
static int
dcmp (const void *a, const void *b)
{
const double da = *(const double*)a;
const double db = *(const double*)b;
if (da > db) return 1;
if (db > da) return -1;
if (da == db) return 0;
fprintf (stderr, "No NaNs permitted in output.\n");
abort ();
return 0;
}
void statistics (double *out, double *data, size_t n)
{
long double s, mean;
double t;
int k;
/* Quartiles */
qsort (data, n, sizeof (*data), dcmp);
out[0] = data[0];
t = (n+1) / 4.0;
k = (int) t;
if (t == k)
out[1] = data[k];
else
out[1] = 3*(data[k]/4.0) + data[k+1]/4.0;
t = (n+1) / 2.0;
k = (int) t;
if (t == k)
out[2] = data[k];
else
out[2] = data[k]/2.0 + data[k+1]/2.0;
t = 3*((n+1) / 4.0);
k = (int) t;
if (t == k)
out[3] = data[k];
else
out[3] = data[k]/4.0 + 3*(data[k+1]/4.0);
out[4] = data[n-1];
s = data[n-1];
for (k = n-1; k > 0; --k)
s += data[k-1];
mean = s/n;
out[5] = mean;
s = data[n-1] - mean;
s *= s;
for (k = n-1; k > 0; --k) {
long double tmp = data[k-1] - mean;
s += tmp * tmp;
}
out[6] = sqrt (s/(n-1));
s = (data[0]? 1.0L/data[0] : 0);
for (k = 1; k < n; ++k)
s += (data[k]? 1.0L/data[k] : 0);
out[7] = n/s;
mean = s/n;
/*
Nilan Norris, The Standard Errors of the Geometric and Harmonic
Means and Their Application to Index Numbers, 1940.
http://www.jstor.org/stable/2235723
*/
s = (data[0]? 1.0L/data[0] : 0) - mean;
s *= s;
for (k = 1; k < n; ++k) {
long double tmp = (data[k]? 1.0L/data[k] : 0) - mean;
s += tmp * tmp;
}
s = (sqrt (s)/(n-1)) * out[7] * out[7];
out[8] = s;
}
//
// Performance counters
//
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
std::vector<time_type> epoch_times;
// These should really be atomic
typedef unsigned long long flush_type;
typedef amplusplus::detail::atomic<flush_type> atomic_flush_type;
#define FLUSH_MPI_TYPE MPI_UNSIGNED_LONG
std::unique_ptr<atomic_flush_type[]> flushes;
flush_type flushes_size;
std::vector<flush_type> all_flushes, cumulative_flushes;
atomic_flush_type full{}, messages_received{};
flush_type all_full{}, cumulative_full{}, all_messages{}, cumulative_messages{};
void print_and_clear_epoch_times()
{
if(_RANK == 0) {
std::cout << "There were " << epoch_times.size() << " epochs." << std::endl;
std::cout << "Epoch times ";
BOOST_FOREACH(time_type t, epoch_times) {
std::cout << print_time(t) << " ";
}
std::cout << "\n";
}
epoch_times.clear();
}
void clear_buffer_stats() {
for(unsigned int i = 0; i < flushes_size; ++i)
flushes[i] = 0;
full = 0;
messages_received = 0;
}
void clear_cumulative_buffer_stats() {
for(unsigned int i = 0; i < flushes_size; ++i)
cumulative_flushes[i] = 0;
cumulative_full = 0;
cumulative_messages = 0;
}
void print_buffer_stats() {
unsigned long long sum = 0;
unsigned long long number_of_buffers = 0;
flush_type tmp_flushes[flushes_size];
for(int i = 0; i < flushes_size; ++i)
tmp_flushes[i] = flushes[i].load();
flush_type tmp_full = full.load();
flush_type tmp_messages = messages_received.load();
MPI_Allreduce(&tmp_flushes, &all_flushes.front(), flushes_size, FLUSH_MPI_TYPE, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&tmp_full, &all_full, 1, FLUSH_MPI_TYPE, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&tmp_messages, &all_messages, 1, FLUSH_MPI_TYPE, MPI_SUM, MPI_COMM_WORLD);
if(_RANK == 0) std::cout << "Flushes: ";
for(unsigned int i = 0; i < all_flushes.size(); ++i) {
if(all_flushes[i] != 0) {
if(_RANK == 0) std::cout << i+1 << "->" << all_flushes[i] << " ";
sum += (i + 1) * all_flushes[i];
number_of_buffers += all_flushes[i];
cumulative_flushes[i] += all_flushes[i];
}
}
cumulative_full += all_full;
cumulative_messages += all_messages;
if(_RANK == 0) {
std::cout << std::endl;
std::cout << "There were " << number_of_buffers << " incomplete flushes with the average size of a flush of " << (number_of_buffers != 0 ? sum/number_of_buffers : 0) << std::endl;
std::cout << "Full buffers: " << all_full << std::endl;
std::cout << "Messages: " << all_messages << std::endl;
}
}
namespace amplusplus {
namespace performance_counters {
void hook_flushed_message_size(amplusplus::rank_type dest, size_t count, size_t elt_size)
{
if(count <= flushes_size)
flushes[count-1]++;
#ifdef PRINT_STATS
time_type t = get_time();
fprintf(stderr, "Flush: %d bytes to %d at %f\n", (count * elt_size), dest, t);
#endif
}
void hook_full_buffer_send(amplusplus::rank_type dest, size_t count, size_t elt_size)
{
full++;
#ifdef PRINT_STATS
time_type t = get_time();
fprintf(stderr, "Full buffer: %d bytes to %d at %f\n", (count * elt_size), dest, t);
#endif
}
void hook_message_received(amplusplus::rank_type src, size_t count, size_t elt_size)
{
messages_received += count;
#ifdef PRINT_STATS
time_type t = get_time();
fprintf(stderr, "%d: Message received: %d bytes from %d at %f\n", _RANK, (count * elt_size), src, t);
#endif
}
void hook_begin_epoch(amplusplus::transport& trans)
{
epoch_times.push_back(get_time());
}
void hook_epoch_finished(amplusplus::transport& trans)
{
epoch_times.back() = get_time() - epoch_times.back();
}
}
}
#endif // AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
// Hit rates
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
unsigned long long cumulative_hits, cumulative_tests;
void print_and_accumulate_cache_stats(std::pair<unsigned long long, unsigned long long> stats) {
unsigned long long hits, tests;
MPI_Allreduce(&stats.first, &hits, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&stats.second, &tests, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
cumulative_hits += hits;
cumulative_tests += tests;
if(_RANK == 0) {
std::cout << "Cache hit rates: " << hits << " hits, " << tests << " tests. Success ratio: " << (double)hits / (double)tests << "." << std::endl;
}
}
#endif // AMPLUSPLUS_PRINT_HIT_RATES
#ifdef PBGL2_PRINT_WORK_STATS
typedef std::tuple<unsigned long long, unsigned long long, unsigned long long, unsigned long long> work_stats_t;
typedef std::tuple<unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long> all_work_stats_t;
// Distributed control work stats
all_work_stats_t dc_stats, ds_stats;
void clear_cumulative_work_stats() {
dc_stats = all_work_stats_t{ 0ul, 0ul, 0ul, 0ul, 0ul, 0ul };
ds_stats = all_work_stats_t{ 0ul, 0ul, 0ul, 0ul, 0ul, 0ul };
}
void print_q_stats(unsigned long long max_q_sz,
unsigned long long avg_max_q_size = 0) {
unsigned long long max, min;
MPI_Allreduce(&max_q_sz, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD);
MPI_Allreduce(&max_q_sz, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, MPI_COMM_WORLD);
if (_RANK == 0)
std::cout << "Maximum max q size : " <<
max << " minimum max q size : " << min << std::endl;
if (avg_max_q_size != 0) {
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
unsigned long long avg_max_sum;
MPI_Allreduce(&avg_max_q_size, &avg_max_sum, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
if (_RANK == 0)
std::cout << "Average maximum queue size : " << (avg_max_sum / world_size) << std::endl;
}
}
void print_and_accumulate_work_stats(work_stats_t stats, all_work_stats_t &cummulative_stats, size_t edges_traverse) {
work_stats_t temp_stats;
MPI_Allreduce(&std::get<0>(stats), &std::get<0>(temp_stats), 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&std::get<1>(stats), &std::get<1>(temp_stats), 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&std::get<2>(stats), &std::get<2>(temp_stats), 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Allreduce(&std::get<3>(stats), &std::get<3>(temp_stats), 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD);
if(_RANK == 0) std::cout << "Useful work: " << std::get<0>(temp_stats) << ", invalidated work: " << std::get<1>(temp_stats) << ", useless work: " << std::get<2>(temp_stats) << ", rejected work: " << std::get<3>(temp_stats) << ", number of edges traversed : " << edges_traverse << ", level of ordering: " << (std::get<0>(temp_stats) + std::get<2>(temp_stats) - (2*edges_traverse)-1) << ", extra edge relaxes: " << (std::get<1>(temp_stats)-std::get<3>(temp_stats)) << std::endl;
std::get<0>(cummulative_stats) += std::get<0>(temp_stats);
std::get<1>(cummulative_stats) += std::get<1>(temp_stats);
std::get<2>(cummulative_stats) += std::get<2>(temp_stats);
std::get<3>(cummulative_stats) += std::get<3>(temp_stats);
std::get<4>(cummulative_stats) += (std::get<0>(temp_stats) + std::get<2>(temp_stats) - (2*edges_traverse) - 1); // ordering
std::get<5>(cummulative_stats) += (std::get<1>(temp_stats)-std::get<3>(temp_stats)); // extra relaxes
}
// TODO: Unify these two macros? We probably don't need macros at all. This is just a leftover from the previous test harness.
#define PBGL2_DC_PRINT \
<< "\nUseful work: " << (std::get<0>(dc_stats) / num_sources) << " (per source), invalidated work: " << (std::get<1>(dc_stats) / num_sources) << " (per source), useless work: " << (std::get<2>(dc_stats)/num_sources) << " (per source), rejected work: " << (std::get<3>(dc_stats)/num_sources) << " (per source). Rejected/useful ratio: " << ((double)std::get<3>(dc_stats) / (double)std::get<0>(dc_stats)) << ". Invalidated/useful ratio: " << ((double)std::get<1>(dc_stats) / (double)std::get<0>(dc_stats)) << ", level of ordering: " << std::get<4>(dc_stats) << ", extra edge relaxes: " << std::get<5>(dc_stats)
#define PBGL2_DS_PRINT \
<< "\nUseful work: " << (std::get<0>(ds_stats) / num_sources) << " (per source), invalidated work: " << (std::get<1>(ds_stats) / num_sources) << " (per source), useless work: " << (std::get<2>(ds_stats)/num_sources) << " (per source), rejected work: " << (std::get<3>(ds_stats)/num_sources) << " (per source). Rejected/useful ratio: " << ((double)std::get<3>(ds_stats) / (double)std::get<0>(ds_stats)) << ". Invalidated/useful ratio: " << ((double)std::get<1>(ds_stats) / (double)std::get<0>(ds_stats)) << ", level of ordering: " << (std::get<4>(ds_stats)/num_sources) << ", extra edge relaxes: " << (std::get<5>(ds_stats)/num_sources)
#endif // PBGL2_PRINT_WORK_STATS
//
// Edge properties
//
typedef int32_t weight_type; // Needed so atomics are available on MacOS
struct WeightedEdge {
WeightedEdge(weight_type weight = 0) : weight(weight) { }
weight_type weight;
};
namespace amplusplus {
template<>
struct make_mpi_datatype<WeightedEdge> : make_mpi_datatype_base {
make_mpi_datatype<weight_type> dt1;
scoped_mpi_datatype dt;
make_mpi_datatype(): dt1() {
int blocklengths[1] = {1};
MPI_Aint displacements[1];
WeightedEdge test_object;
MPI_Aint test_object_ptr;
MPI_Get_address(&test_object, &test_object_ptr);
MPI_Get_address(&test_object.weight, &displacements[0]);
displacements[0] -= test_object_ptr;
MPI_Datatype types[1] = {dt1.get()};
MPI_Type_create_struct(1, blocklengths, displacements, types, dt.get_ptr());
MPI_Type_commit(dt.get_ptr());
}
MPI_Datatype get() const {return dt;}
};
}
//
// Edge weight generator iterator
//
template<typename F, typename RandomGenerator>
class generator_iterator
{
public:
typedef std::input_iterator_tag iterator_category;
typedef typename F::result_type value_type;
typedef const value_type& reference;
typedef const value_type* pointer;
typedef void difference_type;
explicit
generator_iterator(RandomGenerator& gen, const F& f = F())
: f(f), gen(&gen)
{
value = this->f(gen);
}
reference operator*() const { return value; }
pointer operator->() const { return &value; }
generator_iterator& operator++()
{
value = f(*gen);
return *this;
}
generator_iterator operator++(int)
{
generator_iterator temp(*this);
++(*this);
return temp;
}
bool operator==(const generator_iterator& other) const
{ return f == other.f; }
bool operator!=(const generator_iterator& other) const
{ return !(*this == other); }
private:
F f;
RandomGenerator* gen;
value_type value;
};
template<typename F, typename RandomGenerator>
inline generator_iterator<F, RandomGenerator>
make_generator_iterator( RandomGenerator& gen, const F& f)
{ return generator_iterator<F, RandomGenerator>(gen, f); }
template <typename Graph, typename DistanceMap, typename WeightMap>
size_t get_gteps(amplusplus::transport& trans, Graph& g, DistanceMap& distance, const WeightMap& weight) {
distance.set_consistency_model(boost::parallel::cm_forward);
distance.set_max_ghost_cells(0);
size_t gteps = 0;
{
amplusplus::scoped_epoch epoch(g.transport());
size_t dist = std::numeric_limits<size_t>::max();
BGL_FORALL_VERTICES_T(v, g, Graph) {
dist = get(distance, v);
if(dist < std::numeric_limits<size_t>::max()) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
gteps+=1;
//get(distance, target(e, g));
}
}
}
}
gteps = gteps / 2; // we are considering an undirected graph
return gteps;
}
template <typename Graph, typename DistanceMap, typename WeightMap, typename Vertex>
size_t count_edges(amplusplus::transport& trans, Graph& g, DistanceMap& distance, const WeightMap& weight, const Vertex source) {
distance.set_consistency_model(boost::parallel::cm_forward);
distance.set_max_ghost_cells(0);
size_t gteps = 0;
{
amplusplus::scoped_epoch epoch(g.transport());
size_t dist = std::numeric_limits<size_t>::max();
BGL_FORALL_VERTICES_T(v, g, Graph) {
dist = get(distance, v);
if(dist < std::numeric_limits<size_t>::max()) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
// check whether this is a self loop; if self loop dont count it
if (target(e,g) == v)
continue;
gteps+=1;
//get(distance, target(e, g));
}
}
}
}
return gteps;
}
template<typename MessageType>
class threaded_distributor {
public:
threaded_distributor(MessageType& mtype) : msg_type(mtype) {}
void operator()() {
}
template <typename InIter, typename Flip>
void operator()(int tid, InIter begin, InIter end, const Flip& flip,
amplusplus::transport& trans) {
AMPLUSPLUS_WITH_THREAD_ID(tid) {
concurrent_distribute(begin, end, flip, trans, msg_type);
}
}
private:
MessageType& msg_type;
};
template <typename Edges>
class threaded_merger {
public:
threaded_merger(Edges& all) : all_edges(all) {}
void operator()() {
}
template <typename EdgesIter>
void operator()(EdgesIter pos, EdgesIter begin, EdgesIter end) {
std::copy(begin, end, pos);
}
private:
Edges& all_edges;
};
template <typename Graph, typename ComponentMap, typename vertices_sz_t>
void calculate_cc_stats(Graph& g, ComponentMap& components, vertices_sz_t n, bool allstats) {
typedef unsigned int component_t;
typedef std::map<component_t, component_t> component_stats_t;
component_stats_t component_stats;
#ifdef PRINT_DEBUG
std::cout << "Calculating local components ..." << std::endl;
#endif
BGL_FORALL_VERTICES_T(v, g, Graph) {
component_t vcomp = (component_t)get(components, v);
component_stats_t::iterator
ite = component_stats.find(vcomp);
if (ite == component_stats.end()) {
component_stats.insert(std::make_pair(vcomp, 1));
} else {
++((*ite).second);
}
}
// end calculating local components.
// exchange all components
component_t localcomps = component_stats.size();
#ifdef PRINT_DEBUG
std::cout << "Rank : " << _RANK << ", found local components : " << localcomps << std::endl;
#endif
// allstats false
if (!allstats) {
// sort by number of vertices
std::vector<std::pair<int, int>> pairs;
for (auto itr = component_stats.begin(); itr != component_stats.end(); ++itr)
pairs.push_back(*itr);
component_stats.clear();
std::sort(pairs.begin(), pairs.end(), [=](std::pair<int, int>& a, std::pair<int, int>& b) {
return a.second > b.second;
});
if (_RANK == 0) {
std::cout << "Printing component statistics ..." << std::endl;
std::cout << "Printing only five largest components. To print all use --allstats" << std::endl;
std::cout << "Total number of components in root : " << pairs.size() << std::endl;
}
int i = 0;
vertices_sz_t rn = 0;
for (; i < 5; ++i) {
int compid = pairs[i].first;
int vtcs = pairs[i].second;
//check whether component id is same across all nodes
int retcomp;
MPI_Barrier(MPI_COMM_WORLD);
std::cout << "r : " << _RANK << ", c=" << compid << ", i=" << i << std::endl;
MPI_Allreduce(&compid, &retcomp, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (retcomp == compid) {
// run a all reduce on all the vertices
int allvs;
MPI_Barrier(MPI_COMM_WORLD);
MPI_Allreduce(&vtcs, &allvs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (_RANK == 0) {
std::cout << "component : " << compid << " vertices : " << allvs
<< " percentage : " << ((((double)allvs)/(double)n) * 100)
<< std::endl;
}
} else {
std::cout << "[ComponentStats] A mismatch found" << std::endl;
}
}
} else { // allstats true
component_t allcomps;
// calculate sum of localcomps
MPI_Allreduce(&localcomps, &allcomps, 1, MPI_UNSIGNED, MPI_SUM, MPI_COMM_WORLD);
component_t expectedcomps = allcomps - localcomps;
if (_RANK == 0)
std::cout << "All the components : " << allcomps << ", expecting receive components : "
<< expectedcomps << std::endl;
typedef struct component_vertices {
component_t c;
component_t vs;
component_vertices():
c(0), vs(0) {}
component_vertices(int pc, int pvs):
c(pc), vs(pvs) {}
component_vertices(const component_vertices &cvob):
c(cvob.c), vs(cvob.vs) {}
} cvs;
const int nitems=2;
int blocklengths[2] = {1,1};
MPI_Datatype types[2] = {MPI_UNSIGNED, MPI_UNSIGNED};
MPI_Datatype mpi_cv_type;
MPI_Aint offsets[2];
offsets[0] = offsetof(cvs, c);
offsets[1] = offsetof(cvs, vs);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_cv_type);
MPI_Type_commit(&mpi_cv_type);
std::vector<cvs> sendcomps;
std::vector<cvs> recvcomps;
if (_RANK != 0) {
// go through local component stat maps and collect them to an array
sendcomps.resize(localcomps);
int j = 0;
component_stats_t::iterator itesend = component_stats.begin();
for (; itesend != component_stats.end(); ++itesend) {
sendcomps[j].c = (*itesend).first;
sendcomps[j].vs = (*itesend).second;
#ifdef PRINT_DEBUG
std::cout << "Rank : " << _RANK << ", c=" << sendcomps[j].c << ", vs=" << sendcomps[j].vs << std::endl;
#endif
++j;
}
#ifdef PRINT_DEBUG
std::cout << "Rank : " << _RANK << ", sending components : " << localcomps << std::endl;
#endif
if (MPI_Send(&sendcomps[0], localcomps, mpi_cv_type, 0/*rank = 0*/, 13 /*tag*/,
MPI_COMM_WORLD) != 0) {
std::cout << "MPI_Send : " << "Error exchanging components" << std::endl;
}
}
MPI_Barrier(MPI_COMM_WORLD);
if (_RANK == 0) {
recvcomps.resize(expectedcomps);
if (expectedcomps != 0) {
#ifdef PRINT_DEBUG
std::cout << "Rank : " << _RANK << ", expected components : " << expectedcomps << std::endl;
#endif
int recvcount = 0;
component_t rcvexpectedcomps = expectedcomps;
while (recvcount != expectedcomps) {
MPI_Status status;
if (MPI_Recv(&recvcomps[recvcount], rcvexpectedcomps, mpi_cv_type, MPI_ANY_SOURCE, 13,
MPI_COMM_WORLD, &status) != 0)
std::cout << "MPI_Recv : " << "Error receiving messages" << std::endl;
int instcount = 0;
if (MPI_Get_count(&status, mpi_cv_type, &instcount) != MPI_SUCCESS)
std::cout << "MPI_Get_count :" << "Error getting received count" << std::endl;
recvcount += instcount;
rcvexpectedcomps -= instcount;
}
}
}
sendcomps.clear();
#ifdef PRINT_DEBUG
std::cout << "Rank : " << _RANK
<< ", Merging received components to component stats. Received components : "
<< recvcomps.size() << std::endl;
#endif
// update compnent stats
typename std::vector<cvs>::iterator veciter = recvcomps.begin();
for(; veciter != recvcomps.end(); ++veciter) {
component_stats_t::iterator
ite = component_stats.find((*veciter).c);
if (ite == component_stats.end()) {
#ifdef PRINT_DEBUG
std::cout << "inserting c=" << (*veciter).c << ", vs=" << (*veciter).vs << std::endl;
#endif
component_stats.insert(std::make_pair((*veciter).c, (*veciter).vs));
} else {
#ifdef PRINT_DEBUG
std::cout << "adding c=" << (*veciter).c << ", vs=" << (*veciter).vs << std::endl;
#endif
(*ite).second += (*veciter).vs;
}
}
recvcomps.clear();
if (_RANK == 0) {
// sort by number of vertices
std::vector<std::pair<int, int>> pairs;
for (auto itr = component_stats.begin(); itr != component_stats.end(); ++itr)
pairs.push_back(*itr);
component_stats.clear();
#ifdef PRINT_DEBUG
std::cout << "Sorting components by the number of vertices in their" << std::endl;
#endif
std::sort(pairs.begin(), pairs.end(), [=](std::pair<int, int>& a, std::pair<int, int>& b) {
return a.second > b.second;
});
std::cout << "Printing component statistics ..." << std::endl;
std::cout << "Total number of components : " << pairs.size() << std::endl;
int i = 0;
vertices_sz_t rn = 0;
std::vector<std::pair<int, int>>::iterator piter = pairs.begin();
for (; piter != pairs.end(); ++piter) {
std::cout << "component : " << (*piter).first << " vertices : " << (*piter).second
<< " percentage : " << ((((double)((*piter).second))/(double)n) * 100)
<< std::endl;
rn += (vertices_sz_t)(*piter).second;
}
std::cout << "rn = " << rn << ", n = " << n << std::endl;
assert(rn == n);
std::cout << "Done with CC stats." << std::endl;
}
}
}
template <typename Graph>
bool run_grah_stats(Graph& g) {
typedef typename boost::property_map<Graph, vertex_owner_t>::const_type OwnerMap;
OwnerMap owner = get(vertex_owner, g);
int remote_edges = 0;
int local_edges = 0;
BGL_FORALL_EDGES_T(e, g, Graph) {
if (get(owner, source(e, g)) != _RANK)
std::cout << "sv : " << source(e, g) << " svown : "
<< get(owner, source(e, g))
<< " tv : " << target(e, g)
<< " tvown : " << get(owner, target(e, g))
<< " rank : " << _RANK << std::endl;
// assert(get(owner, source(e, g)) == _RANK);
if (get(owner, target(e, g)) != _RANK)
++remote_edges;
else
++local_edges;
}
int alllocale = num_edges(g);
std::cout << "Rank : " << _RANK << " remote e : " << remote_edges
<< " local e : " << local_edges
<< " remote per : "
<< ((double)remote_edges / (double)alllocale) * 100
<< "%" << std::endl;
}
template <typename Graph, typename ComponentMap>
bool verify_cc(Graph& g, ComponentMap& components) {
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
components.set_consistency_model(boost::parallel::cm_forward);
components.set_max_ghost_cells(0);
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(components, source(e, g));
get(components, target(e, g));
}
}
}
{
amplusplus::scoped_epoch epoch(g.transport()); // at the moment get() sends a message
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_ADJ_T(v, u, g, Graph) {
// std::cout << "verifying vertex v : " << v << std::endl;
//#ifdef PRINT_DEBUG
if (get(components, v) != get(components, u))
std::cout << "Component of " << v << " : " << get(components, v)
<< " component of " << u << " : " << get(components, u)
<< std::endl;
assert(get(components, v) == get(components, u));
}
}
}
components.clear(); // Clear memory used by ghost cells
}
template <typename Graph, typename DistanceMap, typename WeightMap>
bool verify_sssp(amplusplus::transport& trans, Graph& g, DistanceMap& distance, const WeightMap& weight) {
distance.set_consistency_model(boost::parallel::cm_forward);
distance.set_max_ghost_cells(0);
if (trans.rank() == 0) std::cout<<"Verifying results......";
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(distance, target(e, g));
}
}
}
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
#ifdef PRINT_DEBUG
if (get(distance, target(e, g)) > boost::closed_plus<weight_type>()(get(distance, source(e, g)), get(weight, e)))
std::cout << get(get(vertex_local, g), source(e, g)) << "@" << get(get(vertex_owner, g), source(e, g)) << "->"
<< get(get(vertex_local, g), target(e, g)) << "@" << get(get(vertex_owner, g), target(e, g)) << " weight = "
<< get(weight, e)
<< " distance(" << get(get(vertex_local, g), source(e, g)) << "@" << get(get(vertex_owner, g), source(e, g))
<< ") = " << get(distance, source(e, g)) << " distance(" << get(get(vertex_local, g), target(e, g)) << "@"
<< get(get(vertex_owner, g), target(e, g)) << ") = " << get(distance, target(e, g)) << std::endl;
#else
if(get(distance, target(e, g)) > boost::closed_plus<weight_type>()(get(distance, v), get(weight, e))) std::abort();
#endif
}
}
if (trans.rank() == 0) std::cout << "Verified." << std::endl;
distance.clear(); // Clear memory used by ghost cells
return true;
}
template <typename Graph, typename MISMap>
bool verify_mis(amplusplus::transport& trans, Graph& g, MISMap& mis) {
typedef typename boost::property_map<Graph, vertex_owner_t>::const_type OwnerMap;
OwnerMap owner(get(vertex_owner, g));
mis.set_consistency_model(boost::parallel::cm_forward || boost::parallel::cm_backward);
mis.set_max_ghost_cells(0);
if (trans.rank() == 0) std::cout<<"Verifying MIS results......";
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(mis, target(e, g));
}
}
}
bool result = true;
int found_mis = 0;
#ifdef PRINT_DEBUG
std::cout << "MIS = {";
#endif
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(mis, v) == MIS_FIX1) {// v in mis, none of the neigbours should be in mis
#ifdef PRINT_DEBUG
if (v == 35) {
std::cout << "Printing all neighbors of " << v
<< " -- [";
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
std::cout << target(e, g) << ", ";
}
std::cout << "]" << std::endl;
}
std::cout << v << "-[";
#endif
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
#ifdef PRINT_DEBUG
std::cout << target(e, g) << ", ";
#endif
if (v == target(e, g))
continue;
if (get(mis, target(e, g)) == MIS_FIX1) {
std::cout << "[FAIL] Vertex : " << v << " and its neigbour " << target(e, g)
<< " are both in MIS."
<< " Vertex value : " << get(mis, v)
<< " neighbor value : " << get(mis, target(e, g))
<< std::endl;
std::cout << "Neighbors of " << v << "- {";
BGL_FORALL_ADJ_T(v, u1, g, Graph) {
std::cout << "(" << u1 << ", " << get(mis, u1) << ")";
}
std::cout << "}" << std::endl;
auto k = target(e, g);
if (get(owner, k) == g.transport().rank()) {
std::cout << "Neighbors of " << k << "- {";
BGL_FORALL_ADJ_T(k, u2, g, Graph) {
std::cout << "(" << u2 << ", " << get(mis, u2) << ")";
}
std::cout << "}" << std::endl;
}
result = false;
} else {
#ifdef PRINT_DEBUG
if (get(mis, target(e, g)) != MIS_FIX0) {
std::cout << "vertex : "
<< target(e, g)
<< ", is in "
<< get(mis, target(e, g))
<< std::endl;
}
#endif
// cannot be MIS_UNFIX
assert(get(mis, target(e, g)) == MIS_FIX0);
found_mis = 1;
}
}
#ifdef PRINT_DEBUG
std::cout << "], ";
#endif
} else {
// if v is not in mis, at least one of its neighbors must
// be in mis
if (get(mis, v) != MIS_FIX0) {
std::cout << "[ERROR] Vertex - " << v << " is in " << get(mis, v)
<< std::endl;
}
if (get(mis, v) != MIS_FIX0) {
std::cout << "Error : " << v << " is not in MIS_FIX0. But in " << get(mis, v)
<< std::endl;
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
auto k = target(e, g);
std::cout << "neigbor : " << k << " mis : " << get(mis, k)
<< std::endl;
}
}
assert(get(mis, v) == MIS_FIX0);
bool inmis = false;
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
if (v == target(e, g))
continue;
if (get(mis, target(e, g)) == MIS_FIX1) {
inmis = true;
break;
}
}
if (!inmis) {
std::cout << "Vertex : " << v << " and none of its neighbors is in MIS" << std::endl;
assert(false);
}
}
}
#ifdef PRINT_DEBUG
std::cout << "}" << std::endl;
#endif
// Run a reduction on found mis.
// We cannot expect every rank will have found_mis true.
// E.g:- rank0 - {0,1}, rank1 - {281474976710656, 281474976710657}
// If every vertex is connect to each other, a vertex (Lets say 0) will
// be in one rank. In the second rank all vertices are out of mis.
int or_found_mis = 0;
MPI_Allreduce(&found_mis, &or_found_mis, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (or_found_mis == 0) {
std::cout << "Did not find any MIS" <<std::endl;
result = false;
}
return result;
}
//=================================================//
// vertex id distributions
enum id_distribution_t {
vertical,
horizontal
};
//=================================================//
template <typename PriorityQueueGenerator = boost::graph::distributed::thread_priority_queue_gen,
typename Graph, typename MISMap,
typename MessageGenerator>
time_type
run_fix_mis(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
MISMap& mis,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
if (trans.rank() == 0)
std::cout << "Initializing mis map ..." << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(mis, v, MIS_UNFIX); }
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Creating algorithm instance ..." << std::endl;
boost::graph::distributed::maximal_independent_set<Graph, MISMap,
PriorityQueueGenerator, MessageGenerator>
D(g, mis, trans, flushFreq, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Invoking algorithm ..." << std::endl;
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
if (trans.rank() == 0)
std::cout << "Algorithm done ..." << std::endl;
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
//#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
//#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
if (trans.rank()==0)
std::cout << "Verifying mis ..." << std::endl;
if (!verify_mis(trans, g, mis)) {
std::cout << "MIS Verification Failed" << std::endl;
assert(false);
return 0;
}
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(mis, v) != MIS_UNFIX)
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< std::endl;
//if (total < 100) return -1.;
return end - start;
}
template <typename Graph, typename MISMap,
typename MessageGenerator>
time_type
run_fix_mis_bucket(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
MISMap& mis,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
if (trans.rank() == 0)
std::cout << "Initializing mis-delta map ..." << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(mis, v, MIS_UNFIX); }
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Creating algorithm instance ..." << std::endl;
boost::graph::distributed::maximal_independent_set_delta<Graph, MISMap,
append_buffer<Vertex, 10u>, MessageGenerator>
D(g, mis, trans, flushFreq, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Invoking algorithm ..." << std::endl;
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
if (trans.rank() == 0)
std::cout << "Algorithm done ..." << std::endl;
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
//#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
//#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
if (trans.rank()==0)
std::cout << "Verifying delta mis ..." << std::endl;
if (!verify_mis(trans, g, mis)) {
std::cout << "Delta-MIS Verification Failed" << std::endl;
assert(false);
return 0;
}
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(mis, v) != MIS_UNFIX)
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< std::endl;
//if (total < 100) return -1.;
return end - start;
}
template <typename SelectGenerator, typename Graph, typename MISMap, typename MessageGenerator>
time_type
run_luby_maximal_is(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
MISMap& mis,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<random_t>::iterator, VertexIndexMap> RandomMap;
// create a property map
std::vector<random_t> pivec(num_vertices(g), 0);
RandomMap rmap(pivec.begin(), get(vertex_index, g)); // TODO remove copying
if (trans.rank() == 0)
std::cout << "Initializing mis map ..." << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(mis, v, MIS_UNFIX); }
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Creating algorithm instance ..." << std::endl;
boost::graph::distributed::luby_mis<Graph, MISMap, RandomMap,
// boost::graph::distributed::select_a_functor_gen,
SelectGenerator,
MessageGenerator>
D(g, mis, rmap, n, trans, flushFreq, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
if (trans.rank() == 0)
std::cout << "Invoking algorithm ..." << std::endl;
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
if (trans.rank() == 0)
std::cout << "Algorithm done ..." << std::endl;
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
//#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
//#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
if (trans.rank()==0)
std::cout << "Verifying mis ..." << std::endl;
if (!verify_mis(trans, g, mis)) {
std::cout << "MIS Verification Failed" << std::endl;
assert(false);
return 0;
}
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(mis, v) != MIS_UNFIX)
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< std::endl;
//if (total < 100) return -1.;
return end - start;
}
template <typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_kla_sssp(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify, bool level_sync,
MessageGenerator msg_gen, size_t k_level) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename property_traits<WeightMap>::value_type Dist;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::kla_shortest_paths_buffer<Graph, DistanceMap, WeightMap,
append_buffer<std::pair<Vertex, std::pair<Dist, size_t> >, 10u>, MessageGenerator>
D(g, distance, weight, trans, k_level, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) {
verify_sssp(trans, g, distance, weight);
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::numa_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_kla_sssp_numa(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify, bool level_sync,
MessageGenerator msg_gen, size_t k_level,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename property_traits<WeightMap>::value_type Dist;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
#ifdef LIB_CDS
// LIBCDS Stuff goes here
if (trans.rank() == 0)
std::cout << "Initializing LIBCDS .... " << std::endl;
cds::Initialize();
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC;
// Attach for the main thread
cds::threading::Manager::attachThread();
#endif
boost::graph::distributed::kla_shortest_paths_numa<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, k_level, flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef LIB_CDS
if (trans.rank() == 0)
std::cout << "Termminating LIBCDS .... " << std::endl;
cds::Terminate();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) {
verify_sssp(trans, g, distance, weight);
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::numa_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_kla_sssp_thread(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify, bool level_sync,
MessageGenerator msg_gen, size_t k_level,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename property_traits<WeightMap>::value_type Dist;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::kla_shortest_paths_thread<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, k_level,flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) {
verify_sssp(trans, g, distance, weight);
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::numa_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_kla_sssp_node(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify, bool level_sync,
MessageGenerator msg_gen, size_t k_level,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename property_traits<WeightMap>::value_type Dist;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
#ifdef LIB_CDS
// LIBCDS Stuff goes here
if (trans.rank() == 0)
std::cout << "Initializing LIBCDS .... " << std::endl;
cds::Initialize();
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC;
// Attach for the main thread
cds::threading::Manager::attachThread();
#endif
boost::graph::distributed::kla_shortest_paths_node<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, k_level, flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef LIB_CDS
if (trans.rank() == 0)
std::cout << "Termminating LIBCDS .... " << std::endl;
cds::Terminate();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) {
verify_sssp(trans, g, distance, weight);
}
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_delta_stepping(amplusplus::transport& trans, amplusplus::transport& barrier_trans, Graph& g, const WeightMap& weight, DistanceMap& distance, typename graph_traits<Graph>::vertex_descriptor current_source, weight_type delta, int num_threads, typename graph_traits<Graph>::vertices_size_type n, bool verify, bool level_sync, MessageGenerator msg_gen) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::delta_stepping_shortest_paths<Graph, DistanceMap, WeightMap,
append_buffer<Vertex, 10u>, MessageGenerator>
D(g, distance, weight, trans, delta, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::default_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_delta_stepping_node(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
weight_type delta, int num_threads, typename graph_traits<Graph>::
vertices_size_type n, bool verify, bool level_sync, MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
#ifdef LIB_CDS
// LIBCDS Stuff goes here
if (trans.rank() == 0)
std::cout << "Initializing LIBCDS .... " << std::endl;
cds::Initialize();
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC;
// Attach for the main thread
cds::threading::Manager::attachThread();
#endif
boost::graph::distributed::delta_stepping_shortest_paths_node<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, delta, flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef LIB_CDS
if (trans.rank() == 0)
std::cout << "Termminating LIBCDS .... " << std::endl;
cds::Terminate();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::default_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_delta_stepping_numa(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
weight_type delta, int num_threads, typename graph_traits<Graph>::
vertices_size_type n, bool verify, bool level_sync, MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
#ifdef LIB_CDS
// LIBCDS Stuff goes here
if (trans.rank() == 0)
std::cout << "Initializing LIBCDS .... " << std::endl;
cds::Initialize();
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC;
// Attach for the main thread
cds::threading::Manager::attachThread();
#endif
boost::graph::distributed::delta_stepping_shortest_paths_numa<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, delta, flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef LIB_CDS
if (trans.rank() == 0)
std::cout << "Termminating LIBCDS .... " << std::endl;
cds::Terminate();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::default_priority_queue_gen,
typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_delta_stepping_thread(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
weight_type delta, int num_threads, typename graph_traits<Graph>::
vertices_size_type n, bool verify, bool level_sync, MessageGenerator msg_gen,
int flushFreq) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::delta_stepping_shortest_paths_thread<Graph, DistanceMap, WeightMap,
PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, delta, flushFreq, msg_gen);
trans.set_nthreads(1);
D.set_source(current_source);
if (level_sync)
D.set_level_sync();
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, ds_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
unsigned long long num_levels = D.get_num_levels();
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start)
<< ", " << num_levels << " levels required." << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::pheet_priority_queue_gen_128, typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_distributed_control_pheet(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads, typename graph_traits<Graph>::vertices_size_type n,
bool verify, MessageGenerator msg_gen,
MessageGenerator priority_msg_gen,
unsigned int flushFreq,
unsigned int eager_limit) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
// Initialize with infinite (max) distance
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::distributed_control_pheet<Graph, DistanceMap, WeightMap, PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, msg_gen, priority_msg_gen, flushFreq, eager_limit);
trans.set_nthreads(1);
//trans.set_recvdepth(recvDepth);
D.set_source(current_source);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
// calculate the number of edges
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, dc_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
#ifdef PBGL2_PRINT_WORK_STATS
//get the queue size
size_t local_q_size = D.get_max_q_size();
print_q_stats(local_q_size);
#endif
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start) << "\n" << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename PriorityQueueGenerator = boost::graph::distributed::default_priority_queue_gen, typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_distributed_control_node(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g, const WeightMap& weight,
DistanceMap& distance,
typename graph_traits<Graph>::vertex_descriptor current_source,
int num_threads, typename graph_traits<Graph>::vertices_size_type n,
bool verify, MessageGenerator msg_gen,
MessageGenerator priority_msg_gen,
unsigned int flushFreq,
unsigned int eager_limit,
bool numa=false) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
// Initialize with infinite (max) distance
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
#ifdef LIB_CDS
// LIBCDS Stuff goes here
if (trans.rank() == 0)
std::cout << "Initializing LIBCDS .... " << std::endl;
cds::Initialize();
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC;
// Attach for the main thread
cds::threading::Manager::attachThread();
#endif
boost::graph::distributed::distributed_control_node<Graph, DistanceMap, WeightMap, PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, msg_gen, priority_msg_gen, flushFreq, eager_limit, numa);
trans.set_nthreads(1);
//trans.set_recvdepth(recvDepth);
D.set_source(current_source);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef LIB_CDS
if (trans.rank() == 0)
std::cout << "Termminating LIBCDS .... " << std::endl;
cds::Terminate();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, dc_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
#ifdef PBGL2_PRINT_WORK_STATS
//get the queue size
size_t local_q_size = D.get_max_q_size();
print_q_stats(local_q_size);
#endif
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start) << "\n" << std::endl;
if (total < 100) return -1.;
return end - start;
}
// Duplicating code; pretty bad ....
// TODO find the metaprogramming way to add cds initialization code
template <typename PriorityQueueGenerator = boost::graph::distributed::default_priority_queue_gen, typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_distributed_control(amplusplus::transport& trans, amplusplus::transport& barrier_trans, Graph& g, const WeightMap& weight, DistanceMap& distance, typename graph_traits<Graph>::vertex_descriptor current_source, int num_threads, typename graph_traits<Graph>::vertices_size_type n, bool verify, MessageGenerator msg_gen, MessageGenerator priority_msg_gen, unsigned int flushFreq, unsigned int eager_limit) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
// Initialize with infinite (max) distance
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::distributed_control<Graph, DistanceMap, WeightMap, PriorityQueueGenerator, MessageGenerator>
D(g, distance, weight, trans, msg_gen, priority_msg_gen, flushFreq, eager_limit);
trans.set_nthreads(1);
//trans.set_recvdepth(recvDepth);
D.set_source(current_source);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
work_stats_t work_stats = D.get_work_stats();
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
print_and_accumulate_work_stats(work_stats, dc_stats, edges_in_comp);
// print q stats
print_q_stats(D.get_max_q_size(), D.get_avg_max_q_size());
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start) << "\n" << std::endl;
if (total < 100) return -1.;
return end - start;
}
// Duplicating code; pretty bad ....
// TODO find the metaprogramming way to add cds initialization code
template <typename Graph, typename WeightMap, typename DistanceMap, typename MessageGenerator>
time_type
run_distributed_control_chaotic(amplusplus::transport& trans, amplusplus::transport& barrier_trans, Graph& g, const WeightMap& weight, DistanceMap& distance, typename graph_traits<Graph>::vertex_descriptor current_source, int num_threads, typename graph_traits<Graph>::vertices_size_type n, bool verify, MessageGenerator msg_gen, unsigned int flushFreq, unsigned int eager_limit) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
// Initialize with infinite (max) distance
BGL_FORALL_VERTICES_T(v, g, Graph)
{ put(distance, v, std::numeric_limits<weight_type>::max()); }
trans.set_nthreads(num_threads);
boost::graph::distributed::distributed_control_chaotic<Graph, DistanceMap, WeightMap, MessageGenerator>
D(g, distance, weight, trans, msg_gen, flushFreq, eager_limit);
trans.set_nthreads(1);
//trans.set_recvdepth(recvDepth);
D.set_source(current_source);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
size_t edges_in_comp = count_edges(trans, g, distance, weight, current_source);
work_stats_t work_stats = D.get_work_stats();
print_and_accumulate_work_stats(work_stats, dc_stats, edges_in_comp);
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) verify_sssp(trans, g, distance, weight);
vertices_size_type visited = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(distance, v) < std::numeric_limits<weight_type>::max())
++visited;
}
boost::parallel::all_reduce<vertices_size_type, std::plus<vertices_size_type> >
r(trans, std::plus<vertices_size_type>());
vertices_size_type total = r(visited);
if (verify)
if (trans.rank() == 0)
std::cout << "Visited " << total << " vertices of " << n << " in " << print_time(end - start) << "\n" << std::endl;
if (total < 100) return -1.;
return end - start;
}
template <typename Graph, typename MessageGenerator>
time_type
run_ps_sv_cc(amplusplus::transport& trans,
Graph& g,
int num_threads,
bool verify,
bool level_sync,
MessageGenerator msg_gen,
size_t vertices_per_lock) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0) std::cout << "Initializing PS-SV-CC algorithm ... " << std::endl;
// Instantiate algorithms used later here so we don't time their constructions
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
// Parent, component, and lock maps for SV CC
std::vector<Vertex> parentS(num_vertices(g), graph_traits<Graph>::null_vertex());
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ParentMap;
ParentMap parent(parentS.begin(), get(vertex_index, g));
std::vector<int> sv_componentS(num_vertices(g), std::numeric_limits<int>::max());
typedef iterator_property_map<std::vector<int>::iterator, VertexIndexMap> ComponentMap;
ComponentMap component(sv_componentS.begin(), get(vertex_index, g));
typedef boost::parallel::lock_map<VertexIndexMap> LockMap;
LockMap locks(get(vertex_index, g), num_vertices(g) / vertices_per_lock);
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(parent, v, v);
}
using boost::parallel::all_reduce;
using boost::parallel::maximum;
all_reduce<vertices_size_type, maximum<vertices_size_type> >
reduce_max(trans, maximum<vertices_size_type>());
// TODO: If level_sync we should make the PS below a BFS
boost::graph::distributed::parallel_search<Graph, ParentMap, MessageGenerator>
PS(g, parent, graph_traits<Graph>::null_vertex(), msg_gen);
trans.set_nthreads(num_threads);
boost::graph::distributed::connected_components<Graph, ParentMap, MessageGenerator>
CC(trans, g, parent, locks, msg_gen);
trans.set_nthreads(1);
if (level_sync)
CC.set_level_sync();
// Less than on vertices w/ special casing for null_vertex() so we start parallel
// search from the same vertex below
typedef typename property_map<Graph, vertex_owner_t>::const_type OwnerMap;
typedef typename property_map<Graph, vertex_local_t>::const_type LocalMap;
typedef graph::distributed::cc_vertex_compare<OwnerMap, LocalMap> VertexLessThan;
VertexLessThan vertex_lt(get(vertex_owner, g), get(vertex_local, g));
//
// Start timing loop
//
{ amplusplus::scoped_epoch epoch(trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Starting PS-SV-CC algorithm ... " << std::endl;
time_type start = get_time();
//
// Find max-degree vertex (gotta time this part too)
//
Vertex max_v = graph_traits<Graph>::null_vertex(); // Avoid uninitialized warning
{
vertices_size_type degree = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (out_degree(v, g) > degree) {
degree = out_degree(v, g);
max_v = v;
}
}
using boost::parallel::all_reduce;
using boost::parallel::maximum;
vertices_size_type max = reduce_max(degree);
// If the max-degree vertex is somewhere else then clear local max v
// Note: This fails to handle two vertices with the same degree... in
// that case the parallel search may start from more than one
// vertex, which is perfectly acceptable provided they're in the
// same component... a reasonable but not fool-proof assumption
if (max != degree)
max_v = graph_traits<Graph>::null_vertex();
}
// Find global minimum vertex w/ max degree as source so all procs start
// at the same place
all_reduce<Vertex, VertexLessThan> min_vertex(trans, vertex_lt);
max_v = min_vertex(max_v);
//
// Run parallel search from max_v, this will mark all reachable vertices with
// null_vertex() in parent map
//
PS.run(max_v);
#ifdef PRINT_STATS
all_reduce<vertices_size_type, std::plus<vertices_size_type> >
reduce_plus(trans, std::plus<vertices_size_type>());
vertices_size_type giant_component_count = 0;
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (get(parent, v) == graph_traits<Graph>::null_vertex())
++giant_component_count;
}
vertices_size_type total = reduce_plus(giant_component_count);
if (verify)
if (trans.rank() == 0)
std::cout << total << " vertices in giant component\n";
#endif
//
// Run SV CC on filtered graph
//
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(CC), i + 1);
threads[i].swap(thr);
}
CC(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Done with PS-SV-CC algorithm in : " << (end-start) << std::endl;
// Back to one thread
trans.set_nthreads(1);
#ifdef NUMBER_COMPONENTS
#error "Should be disabled for performance testing"
int num_components = CC.template number_components<ComponentMap>(component);
if (trans.rank() == 0)
std::cout << num_components << " components found\n";
#endif
if (verify) {
if (trans.rank() == 0) std::cout << "Verifying PS-SV-CC algorithm ... " << std::endl;
parent.set_consistency_model(boost::parallel::cm_forward);
parent.set_max_ghost_cells(0);
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(parent, source(e, g));
get(parent, target(e, g));
}
}
}
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_ADJ_T(v, u, g, Graph) {
#ifdef PRINT_DEBUG
if (get(parent, v) != get(parent, u))
std::cout << trans.rank() << ": parent(" << get(get(vertex_local, g), v) << "@"
<< get(get(vertex_owner, g), v) << ") = " << get(get(vertex_local, g), get(parent, v))
<< "@" << get(get(vertex_owner, g), get(parent, v)) << " parent("
<< get(get(vertex_local, g), u) << "@" << get(get(vertex_owner, g), u)
<< ") = " << get(get(vertex_local, g), get(parent, u))
<< "@" << get(get(vertex_owner, g), get(parent, u)) << std::endl;
#else
assert(get(parent, v) == get(parent, u));
#endif
}
}
parent.clear(); // Clear memory used by ghost cells
}
return time_type(end - start);
}
template <typename Graph, typename MessageGenerator>
time_type
run_sv_c_c(amplusplus::transport& trans, Graph& g,
int num_threads,
bool verify,
bool level_sync,
MessageGenerator msg_gen,
size_t vertices_per_lock) {
#ifdef CLONE
amplusplus::transport trans = trans_passed.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0) std::cout << "Initializing SV-CC algorithm ... " << std::endl;
// Instantiate algorithms used later here so we don't time their constructions
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
// Parent, component, and lock maps for SV CC
std::vector<Vertex> parentS(num_vertices(g), graph_traits<Graph>::null_vertex());
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ParentMap;
ParentMap parent(parentS.begin(), get(vertex_index, g));
std::vector<int> sv_componentS(num_vertices(g), std::numeric_limits<int>::max());
typedef iterator_property_map<std::vector<int>::iterator, VertexIndexMap> ComponentMap;
ComponentMap component(sv_componentS.begin(), get(vertex_index, g));
typedef boost::parallel::lock_map<VertexIndexMap> LockMap;
LockMap locks(get(vertex_index, g), num_vertices(g) / vertices_per_lock);
if (trans.rank() == 0) std::cout << "Number of vertices : " << num_vertices(g) << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(parent, v, v);
}
trans.set_nthreads(num_threads);
boost::graph::distributed::sv_cc<Graph, ParentMap, MessageGenerator>
CC(trans, g, parent, locks, msg_gen);
trans.set_nthreads(1);
if (level_sync)
CC.set_level_sync();
{ amplusplus::scoped_epoch epoch(trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Starting SV-CC algorithm ... " << std::endl;
time_type start = get_time();
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(CC), i + 1);
threads[i].swap(thr);
}
CC(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
// Back to one thread
trans.set_nthreads(1);
if (trans.rank() == 0) std::cout << "Done with SV-CC algorithm in : " << (end-start) << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef NUMBER_COMPONENTS
int num_components = CC.template number_components<ComponentMap>(component);
if (trans.rank() == 0)
std::cout << num_components << " components found\n";
#endif
CC.print_stats();
if (verify) {
if (trans.rank() == 0) std::cout << "Verifying SV-CC algorithm ... " << std::endl;
parent.set_consistency_model(boost::parallel::cm_forward);
parent.set_max_ghost_cells(0);
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(parent, source(e, g));
get(parent, target(e, g));
}
}
}
{
amplusplus::scoped_epoch epoch(trans); // at the moment get() sends a message
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (out_degree(v, g) == 0) {
assert(get(parent, v) == v);
}
BGL_FORALL_ADJ_T(v, u, g, Graph) {
#ifdef PRINT_DEBUG
if (get(parent, v) != get(parent, u))
std::cout << trans.rank() << ": parent(" << get(get(vertex_local, g), v) << "@"
<< get(get(vertex_owner, g), v) << ") = " << get(get(vertex_local, g), get(parent, v))
<< "@" << get(get(vertex_owner, g), get(parent, v)) << " parent("
<< get(get(vertex_local, g), u) << "@" << get(get(vertex_owner, g), u)
<< ") = " << get(get(vertex_local, g), get(parent, u))
<< "@" << get(get(vertex_owner, g), get(parent, u)) << std::endl;
#else
assert(get(parent, v) == get(parent, u));
#endif
}
}
}
parent.clear(); // Clear memory used by ghost cells
}
return time_type(end - start);
}
template <typename Graph, typename MessageGenerator>
time_type
run_sv_cc_optimized(amplusplus::transport& trans, Graph& g,
int num_threads,
bool verify,
bool level_sync,
MessageGenerator msg_gen,
size_t vertices_per_lock) {
#ifdef CLONE
amplusplus::transport trans = trans_passed.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0) std::cout << "Initializing SV-CC algorithm ... " << std::endl;
// Instantiate algorithms used later here so we don't time their constructions
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
// Parent, component, and lock maps for SV CC
std::vector<Vertex> parentS(num_vertices(g), graph_traits<Graph>::null_vertex());
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ParentMap;
ParentMap parent(parentS.begin(), get(vertex_index, g));
std::vector<int> sv_componentS(num_vertices(g), std::numeric_limits<int>::max());
typedef iterator_property_map<std::vector<int>::iterator, VertexIndexMap> ComponentMap;
ComponentMap component(sv_componentS.begin(), get(vertex_index, g));
typedef boost::parallel::lock_map<VertexIndexMap> LockMap;
LockMap locks(get(vertex_index, g), num_vertices(g) / vertices_per_lock);
if (trans.rank() == 0) std::cout << "Number of vertices : " << num_vertices(g) << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(parent, v, v);
}
trans.set_nthreads(num_threads);
boost::graph::distributed::connected_components<Graph, ParentMap, MessageGenerator>
CC(trans, g, parent, locks, msg_gen);
trans.set_nthreads(1);
if (level_sync)
CC.set_level_sync();
{ amplusplus::scoped_epoch epoch(trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Starting SV-CC-Opt algorithm ... " << std::endl;
time_type start = get_time();
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(CC), i + 1);
threads[i].swap(thr);
}
CC(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
// Back to one thread
trans.set_nthreads(1);
if (trans.rank() == 0) std::cout << "Done with SV-CC algorithm in : " << (end-start) << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef NUMBER_COMPONENTS
int num_components = CC.template number_components<ComponentMap>(component);
if (trans.rank() == 0)
std::cout << num_components << " components found\n";
#endif
if (verify) {
if (trans.rank() == 0) std::cout << "Verifying SV-CC algorithm ... " << std::endl;
parent.set_consistency_model(boost::parallel::cm_forward);
parent.set_max_ghost_cells(0);
{
amplusplus::scoped_epoch epoch(g.transport());
BGL_FORALL_VERTICES_T(v, g, Graph) {
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
get(parent, source(e, g));
get(parent, target(e, g));
}
}
}
{
amplusplus::scoped_epoch epoch(trans); // at the moment get() sends a message
BGL_FORALL_VERTICES_T(v, g, Graph) {
if (out_degree(v, g) == 0) {
assert(get(parent, v) == v);
}
BGL_FORALL_ADJ_T(v, u, g, Graph) {
#ifdef PRINT_DEBUG
if (get(parent, v) != get(parent, u))
std::cout << trans.rank() << ": parent(" << get(get(vertex_local, g), v) << "@"
<< get(get(vertex_owner, g), v) << ") = " << get(get(vertex_local, g), get(parent, v))
<< "@" << get(get(vertex_owner, g), get(parent, v)) << " parent("
<< get(get(vertex_local, g), u) << "@" << get(get(vertex_owner, g), u)
<< ") = " << get(get(vertex_local, g), get(parent, u))
<< "@" << get(get(vertex_owner, g), get(parent, u)) << std::endl;
#else
assert(get(parent, v) == get(parent, u));
#endif
}
}
}
parent.clear(); // Clear memory used by ghost cells
}
return time_type(end - start);
}
template <typename PriorityQueueGenerator = boost::graph::distributed::cc_default_priority_queue_gen,
typename Graph,
typename MessageGenerator>
time_type
run_data_driven_cc(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
bool print_stats,
bool allstats,
MessageGenerator msg_gen,
MessageGenerator priority_msg_gen,
unsigned int flushFreq,
unsigned int eager_limit) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0) std::cout << "Initializing data driven connected components ..." << std::endl;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
std::vector<Vertex> componentS(num_vertices(g), std::numeric_limits<Vertex>::max());
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ComponentsMap;
ComponentsMap components(componentS.begin(), get(vertex_index, g));
//#ifndef CC_PRIORITY
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(components, v, v);
}
//#endif
std::cout << "Rank: " << trans.rank() << ", Number of vertices : " << num_vertices(g)
<< "Number of edges : " << num_edges(g) << " total vertices : " << n << std::endl;
trans.set_nthreads(num_threads);
boost::graph::distributed::data_driven_cc<Graph, ComponentsMap, PriorityQueueGenerator, MessageGenerator>
D(g, components, trans, msg_gen, priority_msg_gen, flushFreq, eager_limit);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Invoking DD-CC algorithm ......" << std::endl;
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type start = D.get_start_time();
time_type end = D.get_end_time();
if (trans.rank() == 0) std::cout << "Done with DD-CC algorithm in : " << (end-start) << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
#endif
#ifdef PBGL2_PRINT_WORK_STATS
//work_stats_t work_stats = D.get_work_stats();
//print_and_accumulate_work_stats(work_stats, dc_stats);
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
verify_cc(g, components);
}
if (print_stats)
calculate_cc_stats(g, components, n, allstats);
if (trans.rank() == 0) std::cout << "End invoking algorithm ..." << std::endl;
return end - start;
}
// Run chaotic CC
template <typename Graph, typename MessageGenerator>
time_type
run_chaotic_cc(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
bool print_stats,
bool allstats,
MessageGenerator msg_gen) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0) std::cout << "Initializing data driven connected components ..." << std::endl;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
std::vector<Vertex> componentS(num_vertices(g), std::numeric_limits<Vertex>::max());
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ComponentsMap;
ComponentsMap components(componentS.begin(), get(vertex_index, g));
if (trans.rank() == 0) std::cout << "Number of vertices : " << num_vertices(g) << " total : " << n << std::endl;
trans.set_nthreads(num_threads);
boost::graph::distributed::chaotic_cc<Graph, ComponentsMap, MessageGenerator>
D(g, components, trans, n, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Invoking DD-CC algorithm ......" << std::endl;
time_type start = get_time();
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
if (trans.rank() == 0) std::cout << "Done with Chaotic-CC algorithm in : " << (end-start) << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
verify_cc(g, components);
} // end verify
if (print_stats)
calculate_cc_stats(g, components, n, allstats);
if (trans.rank() == 0) std::cout << "End invoking algorithm ..." << std::endl;
return end - start;
}
/**
* One-to-one mapping of vertices. In this case
* vertex is mapped to running id. Id is increase column wise.
* 1 4
* 2 5
* 3 6
*/
template<typename Graph>
struct block_id_distribution {
typedef typename graph_traits<Graph>::vertices_size_type VerticesSzType;
public:
block_id_distribution(Graph& _pg, VerticesSzType& pn):g(_pg), n(pn) {
if (_RANK == 0)
std::cout << "[INFO] Using vertical id distribution" << std::endl;
}
template<typename SizeType>
SizeType operator()(SizeType k) {
SizeType blocksz = g.distribution().block_size(0, n);
return (get(get(vertex_owner, g), k))*blocksz + g.distribution().local(k);
}
private:
Graph& g;
VerticesSzType n;
};
/**
* One-to-one mapping of vertices. In this case
* vertex is mapped to running id. Id is increase row wise.
* 1 2
* 3 4
* 5 6
*/
template<typename Graph>
struct row_id_distribution {
public:
row_id_distribution(Graph& _pg, int ranks):g(_pg), totalranks(ranks) {
if (_RANK == 0)
std::cout << "[INFO] Using horizontal id distribution" << std::endl;
}
template<typename SizeType>
SizeType operator()(SizeType k) {
auto offset = g.distribution().local(k) * totalranks;
return offset + get(get(vertex_owner, g), k);
}
private:
Graph& g;
int totalranks;
};
// Run delta-stepping CC
template <typename Graph, typename MessageGenerator, typename IdDistribution>
time_type
run_delta_cc(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
size_t nbuckets,
IdDistribution idd,
bool verify,
bool print_stats,
bool allstats,
MessageGenerator msg_gen) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0)
std::cout << "Initializing delta connected components with buckets = "
<< nbuckets << "..." << std::endl;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
#ifdef PRINT_DEBUG
block_id_distribution<Graph> logical_block_id(g, n);
row_id_distribution<Graph> logical_row_block_id(g, trans.size());
if (trans.rank()==0) {
std::cout << "Printing vertex information in rank " << trans.rank() << std::endl;
std::cout << "==========================================================" << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
std::cout << "vid: " << v << ", local id : " << g.distribution().local(v)
<< ", logical block id: " << logical_block_id(v)
<< ", logical row block id : " << logical_row_block_id(v)
<< std::endl;
/* BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
Vertex u = target(e, g);
std::cout << "neighbor vid: " << u << ", local id : " << g.distribution().local(u)
<< ", logical block id: " << logical_block_id(u, g, n)
<< ", logical row block id : " << logical_row_block_id(u, g, trans.size())
<< std::endl;
}*/
}
}
MPI_Barrier(MPI_COMM_WORLD);
if (trans.rank()==1) {
std::cout << "Printing vertex information in rank " << trans.rank() << std::endl;
std::cout << "==========================================================" << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
std::cout << "vid: " << v << ", local id : " << g.distribution().local(v)
<< ", logical block id: " << logical_block_id(v)
<< ", logical row block id : " << logical_row_block_id(v)
<< std::endl;
}
}
MPI_Barrier(MPI_COMM_WORLD);
if (trans.rank()==2) {
std::cout << "Printing vertex information in rank " << trans.rank() << std::endl;
std::cout << "==========================================================" << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
std::cout << "vid: " << v << ", local id : " << g.distribution().local(v)
<< ", logical block id: " << logical_block_id(v, g, n)
<< ", logical row block id : " << logical_row_block_id(v, g, trans.size())
<< std::endl;
BGL_FORALL_OUTEDGES_T(v, e, g, Graph) {
Vertex u = target(e, g);
std::cout << "neighbor vid: " << u << ", local id : " << g.distribution().local(u)
<< ", logical block id: " << logical_block_id(u, g, n)
<< ", logical row block id : " << logical_row_block_id(u, g, trans.size())
<< std::endl;
}
}
}
MPI_Barrier(MPI_COMM_WORLD);
if (trans.rank()==3) {
std::cout << "Printing vertex information in rank " << trans.rank() << std::endl;
std::cout << "==========================================================" << std::endl;
BGL_FORALL_VERTICES_T(v, g, Graph) {
std::cout << "vid: " << v << ", local id" << g.distribution().local(v)
<< ", logical block id: " << logical_block_id(v, g, n)
<< ", logical row block id : " << logical_row_block_id(v, g, trans.size())
<< std::endl;
}
}
MPI_Barrier(MPI_COMM_WORLD);
#endif
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
std::vector<Vertex> componentS(num_vertices(g), std::numeric_limits<Vertex>::max());
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ComponentsMap;
ComponentsMap components(componentS.begin(), get(vertex_index, g));
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(components, v, v);
}
if (trans.rank() == 0) std::cout << "Number of vertices : " << num_vertices(g) << " total : " << n << std::endl;
trans.set_nthreads(num_threads);
boost::graph::distributed::delta_stepping_cc<Graph,
ComponentsMap,
IdDistribution,
MessageGenerator>
D(g, components, trans, nbuckets, idd, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Invoking Delta-CC algorithm ......" << std::endl;
time_type start = get_time();
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
// TODO: Add exception handling. Excptions should be caught in every thread and checked in the main thread.
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
if (trans.rank() == 0) std::cout << "Done with Delta-CC algorithm in : " << (end-start) << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
verify_cc(g, components);
}
if (print_stats)
calculate_cc_stats(g, components, n, allstats);
if (trans.rank() == 0) std::cout << "End invoking algorithm ..." << std::endl;
return end - start;
}
// Run level CC
template <typename Graph, typename MessageGenerator>
time_type
run_level_sync_cc(amplusplus::transport& trans,
amplusplus::transport& barrier_trans,
Graph& g,
int num_threads,
typename graph_traits<Graph>::vertices_size_type n,
bool verify,
bool print_stats,
bool allstats,
MessageGenerator msg_gen) {
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for this run
#endif
if (trans.rank() == 0)
std::cout << "Initializing level sync connected components... "
<< std::endl;
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename graph_traits<Graph>::vertices_size_type vertices_size_type;
std::vector<Vertex> componentS(num_vertices(g), std::numeric_limits<Vertex>::max());
typedef typename property_map<Graph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<Vertex>::iterator, VertexIndexMap> ComponentsMap;
ComponentsMap components(componentS.begin(), get(vertex_index, g));
BGL_FORALL_VERTICES_T(v, g, Graph) {
put(components, v, v);
}
if (trans.rank() == 0) std::cout << "Number of vertices : " << num_vertices(g) << " total : " << n << std::endl;
trans.set_nthreads(num_threads);
boost::graph::distributed::level_sync_cc<Graph,
ComponentsMap,
MessageGenerator>
D(g, components, trans, n, msg_gen);
trans.set_nthreads(1);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
epoch_times.clear();
clear_buffer_stats();
#endif
if (trans.rank() == 0) std::cout << "Invoking level-sync-CC algorithm ......" << std::endl;
// Many threads now
trans.set_nthreads(num_threads);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
boost::thread thr(boost::ref(D), i + 1);
threads[i].swap(thr);
}
D(0);
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
time_type end = get_time();
time_type start = D.get_start_time();
if (trans.rank() == 0)
std::cout << "Done with level-sync-CC algorithm in : " << (end-start)
<< ", buckets(levels) processed : "
<< D.get_num_levels() << std::endl;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
print_and_clear_epoch_times();
print_buffer_stats();
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
//const std::pair<unsigned long long, unsigned long long> stats = D.get_cache_stats();
//print_and_accumulate_cache_stats(stats);
#endif
// Back to one thread
trans.set_nthreads(1);
if (verify) {
verify_cc(g, components);
}
if (print_stats)
calculate_cc_stats(g, components, n, allstats);
if (trans.rank() == 0) std::cout << "End invoking algorithm ..." << std::endl;
return end - start;
}
enum mode_type {mode_none, mode_self, mode_async_bfs, mode_ds_async_bfs, mode_level_synchronized_bfs, mode_delta_stepping, mode_dc, mode_connected_components, mode_page_rank};
enum routing_type {rt_none, rt_hypercube, rt_rook};
// functions to separate edge weight and edge
// separating edge
template<typename t1, typename t2>
struct select_edge : std::unary_function< std::pair<t1, std::pair<t1, t2> >, std::pair<t1, t1> > {
public:
select_edge() {}
std::pair<t1, t1> operator()(std::pair<t1, std::pair<t1, t2> >& ew) const {
return std::make_pair(ew.first, ew.second.first);
}
};
// separating edge weight
template<typename t1, typename t2>
struct select_edge_weight : std::unary_function< std::pair<t1, std::pair<t1, t2> >, t2 > {
public:
select_edge_weight() {}
t2 operator()(std::pair<t1, std::pair<t1, t2> >& ew) const {
return ew.second.second;
}
};
template<typename T>
void time_statistics(std::vector<T>& data,
T& m,
T& minimum,
T& q1,
T& median,
T& q3,
T& maximum,
T& stddev) {
using namespace boost::accumulators;
accumulator_set<T, stats<tag::variance> > acc;
for_each(data.begin(), data.end(), bind<void>(ref(acc), _1));
m = mean(acc);
stddev = sqrt(variance(acc));
auto const min = 0;
auto const Q1 = data.size() / 4;
auto const Q2 = data.size() / 2;
auto const Q3 = Q1 + Q2;
auto const max = data.size() - 1;
std::nth_element(data.begin(), data.begin() + min, data.end());
minimum = data[min];
std::nth_element(data.begin(), data.begin() + Q1, data.end());
q1 = data[Q1];
std::nth_element(data.begin() + Q1 + 1, data.begin() + Q2, data.end());
median = data[Q2];
std::nth_element(data.begin() + Q2 + 1, data.begin() + Q3, data.end());
q3 = data[Q3];
std::nth_element(data.begin() + Q3 + 1, data.begin() + max, data.end());
maximum = data[max];
}
class dc_test {
private:
std::vector<int> thread_num_vals;
size_t scale = 20, num_sources = 64, iterations = 20;
double edgefactor = 16;
unsigned long long n = static_cast<unsigned long long>(floor(pow(2, scale)));
bool verify = false, level_sync = false, stats = true;
uint64_t seed64 = 12345;
weight_type C = 100;
weight_type delta_min = 1, delta_max = 1, delta_step = 1;
unsigned int levels_min = 1, levels_max = 1, levels_step = 1;
mode_type mode = mode_none;
std::vector<routing_type> routing;
double edge_list_reserve_factor = 1.15;
bool no_reductions = false, per_thread_reductions = true;
std::vector<size_t> coalescing_size;
size_t distribution_coalescing_size = 1 << 17;
std::vector<size_t> reduction_cache_size;
std::vector<unsigned int> number_poll_task;
std::vector<std::string> dc_data_structures;
std::vector<unsigned int> flushFreq;
std::vector<unsigned int> eager_limit;
std::vector<unsigned int> recvDepth;
std::vector<unsigned int> delta;
std::vector<unsigned int> k_levels = {1};
std::vector<unsigned int> priority_coalescing_size_v = {40000};
bool run_dc = false, run_chaotic = false, run_ds = false, run_kla = false;
// distributions
enum distribution_t {
block,
cyclic
};
size_t block_size = 10;
// default block distribution
distribution_t distribution_type = block;
id_distribution_t id_distribution;
// mis
bool run_ss_mis = false;
bool run_bucket_mis = false;
bool run_luby_mis = false;
std::vector<std::string> luby_algorithms;
// connected components
bool run_cc = false;
std::vector<std::string> cc_algorithms;
// Available CC algorithms
// 1. run_sv_cc
// 2. run_sv_cc_level_sync
// 3. run_sv_cc_opt
// 4. run_sv_cc_opt_level_sync
// 5. run_sv_ps_cc // optimized version
// 6. run_sv_ps_cc_level_sync // optmized version
// 7. run_dd_cc
// 8. run_cc_chaotic
// 9. run_cc_ds // delta stepping cc
// 10. run_level_sync_cc // level sync agm
// data driven connected components
size_t vertices_per_lock = 64;
std::vector<size_t> nbuckets;
size_t cutoff_degree = 0;
// CC stats
// print CC stats
bool print_cc_stats = false;
// print all CC stats (otherwise limited to 5)
bool allstats = false;
// read graph from file
std::string graph_file;
bool read_graph = false;
bool gen_graph = false;
bool with_weight = false;
public:
dc_test(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if(arg == "--receive-depth") {
recvDepth = extract_params<unsigned int>( argv[i+1] );
//std::cerr<<"receiveDepth from main"<<recvDepth<<std::endl;
}
if (arg == "--threads") {
thread_num_vals = extract_params<int>(argv[i+1]);
}
if (arg == "--graph-file") {
graph_file = argv[i+1];
read_graph = true;
}
if (arg == "--with-weight") {
// read the graph file with weight
with_weight = true;
}
if (arg == "--seed") {
seed64 = boost::lexical_cast<uint64_t>( argv[i+1] );
}
if (arg == "--scale") {
scale = boost::lexical_cast<size_t>( argv[i+1] );
n = (unsigned long long)(1) << scale;
gen_graph = true;
}
if (arg == "--degree")
edgefactor = boost::lexical_cast<double>( argv[i+1] );
if (arg == "--num-sources")
num_sources = boost::lexical_cast<size_t>( argv[i+1] );
if (arg == "--iterations")
iterations = boost::lexical_cast<size_t>( argv[i+1] );
if (arg == "--verify")
verify = true;
if (arg == "--stats")
stats = true;
if (arg == "--coalescing-size") {
coalescing_size = extract_params<size_t>( argv[i+1] );
}
if (arg == "--reduction-cache-size")
reduction_cache_size = extract_params<size_t>( argv[i+1] );
if (arg == "--distribution-coalescing-size")
distribution_coalescing_size = boost::lexical_cast<size_t>( argv[i+1] );
if (arg == "--distribution") {
if (strcmp(argv[i+1],"block") == 0)
distribution_type = block;
else if (strcmp(argv[i+1],"cyclic") == 0)
distribution_type = cyclic;
else {
std::cout << "Invalid distribution type. Available types are block and cyclic" << std::endl;
// abort = true;
}
}
if (arg == "--block-size") {
block_size = boost::lexical_cast<size_t>( argv[i+1] );
}
if (arg == "--id-distribution") {
if (strcmp(argv[i+1],"vertical") == 0)
id_distribution = vertical;
else if (strcmp(argv[i+1],"horizontal") == 0)
id_distribution = horizontal;
else {
std::cout << "Invalid id distribution type. Available types are vertical and horizontal"
<< std::endl;
// abort = true;
}
}
if (arg == "--max-weight")
C = boost::lexical_cast<weight_type>( argv[i+1] );
if(arg == "--poll-task"){
number_poll_task = extract_params<unsigned int>( argv[i+1] );
//std::cerr<<"poll task number:" <<number_poll_task<<"\n";
}
if (arg == "--flush") {
flushFreq = extract_params<unsigned int> ( argv[i+1] );
}
if (arg == "--eager-limit") {
eager_limit = extract_params<unsigned int> ( argv[i+1] );
}
if (arg == "--priority_coalescing_size") {
priority_coalescing_size_v = extract_params<unsigned int> ( argv[i+1] );
}
if(arg == "--ds"){
dc_data_structures = extract_params<std::string> ( argv[i+1] );
}
if (arg == "--rook")
routing.push_back(rt_rook);
if (arg == "--rt_none")
routing.push_back(rt_none);
if (arg == "--with-no-reductions")
no_reductions = true;
if (arg == "--without-no-reductions")
no_reductions = false;
if (arg == "--with-per-thread-reductions")
per_thread_reductions = true;
if (arg == "--without-per-thread-reductions")
per_thread_reductions = false;
if (arg == "--run_dc")
run_dc = true;
if (arg == "--run_chaotic")
run_chaotic = true;
// CC
if (arg == "--run_cc")
run_cc = true;
if (arg == "--cc_algorithms") {
cc_algorithms = extract_params<std::string> ( argv[i+1] );
}
if (arg == "--vertices-per-lock") {
if (!run_cc) {
std::cerr << "Vertices per lock is only allowed for Shiloach-Vishky connected components."
<< std::endl;
}
vertices_per_lock = boost::lexical_cast<size_t>( argv[i+1] );
}
if (arg == "--level-sync") {
if (!run_cc) {
std::cerr << "Level synch is only allowed for Shiloach-Vishky connected components."
<< std::endl;
return;
}
level_sync = true;
}
if (arg == "--buckets") {
nbuckets = extract_params<size_t> ( argv[i+1] );
}
if (arg == "--print_cc_stats")
print_cc_stats = true;
if (arg == "--allstats")
allstats = true;
if (arg == "--cutoff_degree") {
cutoff_degree = boost::lexical_cast<size_t>( argv[i+1] );
}
// MIS
if (arg == "--run_ss_mis")
run_ss_mis = true;
if (arg == "--run_bucket_mis")
run_bucket_mis = true;
if (arg == "--run_luby_mis") {
run_luby_mis = true;
}
if (arg == "--luby_algorithms") {
luby_algorithms = extract_params<std::string> ( argv[i+1] );
}
if (arg == "--run_ds")
run_ds = true;
if (arg == "--run_kla")
run_kla = true;
if (arg == "--klevel")
k_levels = extract_params<unsigned int> ( argv[i+1] );
if (arg == "--delta") {
delta = extract_params<unsigned int> ( argv[i+1] );
}
}
if (thread_num_vals.empty()) thread_num_vals.push_back(1);
if (routing.empty()) routing.push_back(rt_none);
// Check for necessary parameters
bool abort = false;
if (read_graph && gen_graph) {
std::cout << "Both generate graph and read graph from file options are specified. Aborting !"
<< std::endl;
abort = true;
}
if(coalescing_size.empty()) {
std::cerr << "Provide a list of coalescing sizes: --coalescing-size x,y,..." << std::endl;
abort = true;
}
if(recvDepth.empty()) {
std::cerr << "Provide a list of receive depths: --receive-depth x,y,..." << std::endl;
abort = true;
}
if(number_poll_task.empty()) {
std::cerr << "Provide a list of poll tasks: --poll-task x,y,..." << std::endl;
abort = true;
}
if(flushFreq.empty()) {
std::cerr << "Provide a list of flush frequencies: --flush x,y,..." << std::endl;
abort = true;
}
if(!(run_dc || run_ds || run_kla || run_cc || run_chaotic ||
run_ss_mis || run_luby_mis || run_bucket_mis)) {
std::cerr << "Select at least one algorithm (--run_dc or --run_ds or"
<< " --run_kla or --run_cc or --run_chaotic or"
<< " --run_ss_mis or --run_luby_mis or --run_bucket_mis)." << std::endl;
abort = true;
} else if (run_cc) {
if (cc_algorithms.empty()) {
std::cerr << "Must specify atleast one connected component algorithms to run. Options : "
<< "run_sv_cc, run_sv_ps_cc, run_sv_cc_level_sync, run_sv_ps_cc_level_sync, run_dd_cc, run_cc_chaotic, run_cc_ds, run_level_sync_cc"
<< ", run_sv_cc_opt, run_sv_cc_opt_level_sync"
<< std::endl;
abort = true;
}
}
if (run_luby_mis && luby_algorithms.empty()) {
std::cerr << "Select at least one Luby algorithm using --luby_algorithms. "
<< "Available algorithms are A, AV1,AV2, B"
<< std::endl;
abort = true;
}
if(abort) std::abort();
}
typedef unsigned long long block_node_t;
void test_main(int argc, char* argv[]) {
amplusplus::environment env = amplusplus::mpi_environment(argc, argv, true);
amplusplus::transport trans = env.create_transport();
amplusplus::transport barrier_trans = trans.clone();
_RANK = trans.rank(); // For performance counter output
if (_RANK == 0) {
#ifdef NEW_GRAPH500_SPEC
std::cout << "Synthetic graph generator used -- RMAT-2" << std::endl;
#else
std::cout << "Synthetic graph generator used -- RMAT-1" << std::endl;
#endif
}
typedef amplusplus::transport::rank_type rank_type;
typedef compressed_sparse_row_graph<directedS, no_property, WeightedEdge, no_property, distributedS<unsigned long long> > Digraph;
typedef graph_traits<Digraph>::vertex_descriptor Vertex;
typedef graph_traits<Digraph>::edges_size_type edges_size_type;
typedef graph_traits<Digraph>::vertices_size_type vertices_size_type;
typedef property_map<Digraph, vertex_index_t>::type VertexIndexMap;
typedef property_map<Digraph, vertex_owner_t>::const_type OwnerMap;
// Output of permutation
// edge is expressed as source_vertex, target_vertex
// But in the distribution we need source vertex as first element in the pair
// Therefore we are putting source vertex first and then another pair with target and weight
// So it will be pair<source, pair<target, weight> >.
typedef std::vector<std::pair<edges_size_type, std::pair<edges_size_type, weight_type> > > edge_with_weight_t;
edge_with_weight_t edges;
parallel::variant_distribution<vertices_size_type> distrib;
time_type gen_start;
// Seed general-purpose RNG
rand48 gen, synch_gen;
gen.seed(seed64);
synch_gen.seed(seed64);
typedef generator_iterator<uniform_int<weight_type>, rand48> weight_iterator_t;
weight_iterator_t gi
= make_generator_iterator(gen, uniform_int<weight_type>(1, C));
if (read_graph) {
gen_start = get_time();
std::cout << "Reading graph from file : " << graph_file << std::endl;
graph_reader<block_node_t> gr(graph_file.c_str());
gr.read_header();
n = gr.get_num_vertices();
edges_size_type m = gr.get_num_edges();
// reserve space for edges
std::cout << "Reserving space for edges : " << m << std::endl;
edges.reserve(m);
std::cout << "Reserved space for edges." << std::endl;
auto bdist = parallel::block<vertices_size_type>(trans, n);
// starting position for current rank
block_node_t start_index = bdist.start(trans.rank());
// locally stored ids in current rank
block_node_t local_count = bdist.block_size(n);
distrib = bdist;
if (with_weight) {
if (_RANK == 0)
std::cout << "Reading edges with weights ..." << std::endl;
if (!gr.read_edges_with_weight<edges_size_type, weight_type,
edge_with_weight_t>(start_index, local_count, edges))
return;
} else {
if (_RANK == 0)
std::cout << "Reading edges with generated weights ..." << std::endl;
if (!gr.read_edges_wo_weight<edges_size_type,edge_with_weight_t,
weight_iterator_t>(start_index,
local_count,
edges,
gi))
return;
}
std::cout << "Total number of edges read : " << edges.size()
<< std::endl;
} else {
assert(gen_graph);
edges_size_type m = static_cast<edges_size_type>(floor(n * edgefactor));
gen_start = get_time();
edges.reserve(static_cast<edges_size_type>(floor(edge_list_reserve_factor * 2 * m / trans.size())));
if (distribution_type == cyclic) {
distrib = parallel::oned_block_cyclic<vertices_size_type>(trans, block_size);
std::cout << "Distribution is cyclic. block size : " << block_size << std::endl;
} else //(distribution_type == block)
distrib = parallel::block<vertices_size_type>(trans, n);
{
boost::uniform_int<uint64_t> rand_64(0, std::numeric_limits<uint64_t>::max());
#ifdef CLONE
amplusplus::transport trans = trans.clone(); // Clone transport for distribution
#endif
edges_size_type e_start = trans.rank() * (m + trans.size() - 1) / trans.size();
edges_size_type e_count = (std::min)((m + trans.size() - 1) / trans.size(), m - e_start);
// Permute and redistribute copy constructs the input iterator
uint64_t a = rand_64(gen);
uint64_t b = rand_64(gen);
// Build a graph to test with
typedef graph500_iterator<Digraph, generator_iterator<uniform_int<weight_type>, rand48>, weight_type > Graph500Iter;
// Select the highest thread val
int num_threads = 1;
for(unsigned int thread_choice : thread_num_vals) {
if (num_threads < thread_choice)
num_threads = thread_choice;
}
// As for now, we assume that only the first routing from the list is used to generate the graph. It seems that it does not really matter which routing we use here since generation of the graph is not a part of the performance test.
if (routing[0] == rt_none) {
do_distribute<Graph500Iter, amplusplus::no_routing>(distrib, trans, e_start, e_count, a, b, edges, gi, num_threads);
} else if (routing[0] == rt_hypercube) {
do_distribute<Graph500Iter, amplusplus::hypercube_routing>(distrib, trans, e_start, e_count, a, b, edges, gi, num_threads);
} else if (routing[0] == rt_rook) {
do_distribute<Graph500Iter, amplusplus::rook_routing>(distrib, trans, e_start, e_count, a, b, edges, gi, num_threads);
}
}
}
typedef select_edge<edges_size_type, weight_type> EdgeSelectFunction;
typedef transform_iterator<EdgeSelectFunction, edge_with_weight_t::iterator> edge_only_iterator;
typedef select_edge_weight<edges_size_type, weight_type> WeightSelectFunction;
typedef transform_iterator<WeightSelectFunction, edge_with_weight_t::iterator> weight_only_iterator;
edge_only_iterator edge_begin(edges.begin(), EdgeSelectFunction()),
edge_end(edges.end(), EdgeSelectFunction());
weight_only_iterator weight_begin(edges.begin(), WeightSelectFunction());
std::cout << "rank -- " << trans.rank() << ", total edges received=" << edges.size() << std::endl;
time_type gt1 = get_time();
Digraph g(edges_are_unsorted_multi_pass, edge_begin, edge_end,
weight_begin, n, trans, distrib);
//Digraph g(edges_are_sorted, edge_begin, edge_end,
// weight_begin, n, trans, distrib);
time_type gt2 = get_time();
std::cout << "Local graph creation time : " << (gt2-gt1)
<< std::endl;
// Clear edge array above
edges.clear();
//============= run some stats ===================//
run_grah_stats(g);
//Generate sources
boost::uniform_int<uint64_t> rand_vertex(0, n-1);
{ amplusplus::scoped_epoch epoch(trans); }
time_type gen_end = get_time();
if (trans.rank() == 0) {
std::cout << "Graph generation took " << print_time(gen_end - gen_start) << "s\n";
#ifdef PRINT_DEBUG
// Printing graph edges and edge weights
// Property maps
typedef property_map<Digraph, weight_type WeightedEdge::*>::type WeightMap;
WeightMap weight = get(&WeightedEdge::weight, g);
typename graph_traits < Digraph >::edge_iterator ei, ei_end;
for (boost::tie(ei, ei_end) = boost::edges(g); ei != ei_end; ++ei) {
weight_type we = get(weight, *ei);
Vertex v = source(*ei, g);
std::cout << " Weight - " << we << " edge source : " << boost::source(*ei, g)
<< " edge target : " << boost::target(*ei, g) << std::endl;
}
#endif
}
// Max degree computation and printout
/*{
typedef typename graph_traits<Digraph>::degree_size_type Degree;
// Compute the maximum edge degree
Degree max_degree = 0;
BGL_FORALL_VERTICES_T(u, g, Digraph) {
max_degree = max BOOST_PREVENT_MACRO_SUBSTITUTION (max_degree, out_degree(u, g));
}
// max_degree = all_reduce(process_group(g), max_degree, maximum<Degree>());
all_reduce<Degree, maximum<Degree> > r(trans, maximum<Degree>());
max_degree = r(max_degree);
if(trans.rank() == 0)
std::cout << "Maximum Degree is " << max_degree << std::endl;
}*/
// Property maps
typedef property_map<Digraph, weight_type WeightedEdge::*>::type WeightMap;
WeightMap weight = get(&WeightedEdge::weight, g);
// Distance map
std::vector<weight_type> distanceS(num_vertices(g), std::numeric_limits<weight_type>::max());
typedef iterator_property_map<std::vector<weight_type>::iterator, VertexIndexMap> DistanceMap;
DistanceMap distance(distanceS.begin(), get(vertex_index, g));
std::string empty_ds = "";
for(unsigned int thread_choice : thread_num_vals) {
for(unsigned int coalescing_choice : coalescing_size) {
for(unsigned int depth_choice : recvDepth) {
for(unsigned int poll_choice : number_poll_task) {
for(routing_type routing_choice : routing) {
// First print the configuration
if(run_dc) {
for(unsigned int flush_choice : flushFreq) {
for(unsigned int eager_choice : eager_limit) {
for(unsigned int priority_coalescing_size : priority_coalescing_size_v) {
for (std::string dc_ds : dc_data_structures) {
if (trans.rank() == 0) std::cout << "[DC]"
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice;
select_alg(env,
thread_choice,
coalescing_choice,
priority_coalescing_size,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
eager_choice,
0,
dc_ds,
synch_gen,
rand_vertex,
false, //kla
true, //dc
false, //ds
false, //cc
false, //chaotic
false, //ss-mis
false, // bucket mis
false, //luby-mis
(size_t)1);
}
}
}
}
}
if (run_ss_mis || run_luby_mis || run_bucket_mis) {
for(unsigned int flush_choice : flushFreq) {
for (std::string dc_ds : dc_data_structures) {
if (run_ss_mis) {
if (trans.rank() == 0) std::cout << "[MIS-SS]"
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice
<< " Flush: " << flush_choice;
select_alg(env,
thread_choice,
coalescing_choice,
10000,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
0,
0,
dc_ds,
synch_gen,
rand_vertex,
false, //kla
false, // dc
false, // ds
false, // cc
false, // chaotic
true, // ss-mis
false, // bucket-mis
false, // luby-mis
1);
}
if (run_bucket_mis) {
if (trans.rank() == 0) std::cout << "[MIS-BUCKET]"
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice
<< " Flush: " << flush_choice;
select_alg(env,
thread_choice,
coalescing_choice,
10000,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
0,
0,
dc_ds,
synch_gen,
rand_vertex,
false, //kla
false, // dc
false, // ds
false, // cc
false, // chaotic
false, // ss-mis
true, //bucket-mis
false, // luby-mis
1);
}
if (run_luby_mis) {
for (std::string luby_algo : luby_algorithms) {
if (trans.rank() == 0) std::cout << "[MIS-LUBY]"
<< " Luby Algorithm :" << luby_algo
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice
<< " Flush: " << flush_choice;
select_alg(env,
thread_choice,
coalescing_choice,
10000,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
0,
0,
dc_ds,
synch_gen,
rand_vertex,
false, //kla
false, // dc
false, // ds
false, // cc
false, // chaotic
false, // ss-mis
false, //bucket mis
true, // luby-mis
1,
luby_algo);
}
}
}
}
}
if(run_chaotic) {
for(unsigned int flush_choice : flushFreq) {
for(unsigned int eager_choice : eager_limit) {
if (trans.rank() == 0) std::cout << "[Chaotic]"
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice;
select_alg(env,
thread_choice,
coalescing_choice,
coalescing_choice,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
eager_choice,
0,
empty_ds,
synch_gen,
rand_vertex,
false, //kla
false, // dc
false, // ds
false, // cc
true, // chaotic
false, //ss-mis
false, // bucket mis
false, //luby-mis
1);
}
}
}
if(run_ds) { // run_ds
for(unsigned int delta_choice : delta) {
for (std::string dc_ds : dc_data_structures) {
for(unsigned int flush_choice : flushFreq) {
if (trans.rank() == 0) std::cout << "[Delta]"
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Flush : " << flush_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice;
select_alg(env,
thread_choice,
coalescing_choice,
0,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
0,
delta_choice,
dc_ds,
synch_gen,
rand_vertex,
false, //kla
false, //dc
true, // ds
false, // cc
false, // chaotic
false, //ss-mis
false, // bucket mis
false, //ss-luby
1);
}
}
}
}
if(run_kla) {
unsigned int delta_choice = 1;
for(unsigned int k_level : k_levels) {
for (std::string dc_ds : dc_data_structures) {
for(unsigned int flush_choice : flushFreq) {
if (trans.rank() == 0) std::cout << "[KLA]"
<< " Data Structure :" << dc_ds
<< " Threads: " << thread_choice
<< " Flush : " << flush_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice
<< "k_level: " << k_level;
select_alg(env,
thread_choice,
coalescing_choice,
0,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
flush_choice,
0,
delta_choice,
dc_ds,
synch_gen,
rand_vertex,
true, //kla
false, //dc
false, //ds
false, //cc
false, //chaotic
false, //ss-mis
false, // bucket mis
false, //luby
k_level);
}
}
}
}
if (run_cc) {
for (std::string algorithm : cc_algorithms) {
if (algorithm == "run_dd_cc") {
for(unsigned int flush_choice : flushFreq) {
if (trans.rank() == 0) std::cout << "[CC]"
<< " Algorithm : " << algorithm
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice
<< " Flush: " << flush_choice;
unsigned int delta_choice = 1;
select_alg(env,
thread_choice,
coalescing_choice,
1,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
0,
0,
delta_choice,
empty_ds,
synch_gen,
rand_vertex,
false, //kla
false, //dc
false, //ds
true, //cc
false, //chaotic
false, //ss-mis
false, //bucket mis
false, //luby
0, // k-level
"", // luby algo
algorithm);
}
} else {
if (trans.rank() == 0) std::cout << "[CC]"
<< " Algorithm : " << algorithm
<< " Threads: " << thread_choice
<< " Coalescing: " << coalescing_choice
<< " Poll: " << poll_choice
<< " Routing: " << routing_choice
<< " Depth: " << depth_choice;
if ("run_cc_ds" == algorithm) {
unsigned int delta_choice = 1; // ignore
for(size_t bucketsz : nbuckets) {
select_alg(env,
thread_choice,
coalescing_choice,
1,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
0,
0,
delta_choice,
empty_ds,
synch_gen,
rand_vertex,
false, //kla
false, //dc
false, //ds
true, //cc
false, //chaotic
false, //ss-mis
false, // bucket mis
false, //luby
0, // k-level
"", // luby algo
algorithm,
bucketsz);
}
} else {
// delta is ignored
unsigned int delta_choice = 1;
select_alg(env,
thread_choice,
coalescing_choice,
1,
depth_choice,
poll_choice,
routing_choice,
g,
distance,
weight,
thread_choice,
0,
0,
delta_choice,
empty_ds,
synch_gen,
rand_vertex,
false, //kla
false, //dc
false, //ds
true, //cc
false, //chaotic
false, //ss-mis
false, // bucket mis
false, //luby
0, // k-level
"", // luby algo
algorithm);
}
}
}
}
}
}
}
}
}
}
private:
template<typename Result>
std::vector<Result> extract_params(const std::string args) {
size_t d = 0, d2;
std::vector<Result> r;
while ((d2 = args.find(',', d)) != std::string::npos) {
r.push_back(boost::lexical_cast<Result>(args.substr(d, d2 - d)));
d = d2 + 1;
}
r.push_back(boost::lexical_cast<Result>(args.substr(d, args.length())));
return r;
}
template<typename Digraph, typename DistanceMap, typename WeightMap, typename RNG, typename RandVertex>
void select_alg(amplusplus::environment& env,
unsigned int thread_choice,
unsigned int coalescing_choice,
unsigned int priority_coalescing_size,
unsigned int depth_choice,
unsigned int poll_choice,
routing_type routing_choice,
Digraph &g,
DistanceMap &distance,
WeightMap &weight,
unsigned int num_threads,
unsigned int flush_choice,
unsigned int eager_choice,
unsigned int delta_choice,
std::string& dc_ds_choice,
RNG synch_gen,
RandVertex rand_vertex,
bool run_kla,
bool run_dc,
bool run_ds,
bool run_cc,
bool run_chaotic,
bool run_ss_mis,
bool run_bucket_mis,
bool run_luby_mis,
size_t k_level,
std::string luby_algo="",
std::string cc_algo="",
size_t bucket_choice=0) {
//run_ds = !run_dc;
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
flushes.reset(new atomic_flush_type[coalescing_choice]);
flushes_size = coalescing_choice;
all_flushes.resize(coalescing_choice);
cumulative_flushes.resize(coalescing_choice);
#endif
// We will not run two algorithms at once since they have disjoint sets of parameters
if(run_dc && run_ds && run_kla) abort();
amplusplus::transport trans = env.create_transport();
amplusplus::transport barrier_trans = trans.clone();
if(run_dc && trans.rank() == 0) {
std::cout << " Priority: " << priority_coalescing_size << " Flush: " << flush_choice << " Eager: " << eager_choice;
}
if(run_ds && trans.rank() == 0) {
std::cout << " Delta: " << delta_choice;
}
if(run_kla && trans.rank() == 0) {
std::cout << " k_level: " << k_level<<std::endl;
}
// Create transport for the algorithm
env.template downcast_to_impl<amplusplus::detail::mpi_environment_obj>()->set_poll_tasks(poll_choice);
env.template downcast_to_impl<amplusplus::detail::mpi_environment_obj>()->set_recv_depth(depth_choice);
if (trans.rank() == 0)
std::cout << "per_thread_reductions - " << per_thread_reductions << " no_reductions : " << no_reductions << std::endl;
if(per_thread_reductions) {
for(unsigned int reduction_choice : reduction_cache_size) {
if (trans.rank() == 0) std::cout << " Reduction: " << reduction_choice << std::endl;
if (routing_choice == rt_none) {
typedef amplusplus::per_thread_cache_generator<amplusplus::counter_coalesced_message_type_gen, amplusplus::no_routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(coalescing_choice), reduction_choice, amplusplus::no_routing(trans.rank(), trans.size()));
MessageGenerator priority_msg_gen(amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1), reduction_choice, amplusplus::no_routing(trans.rank(), trans.size()));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
if(routing_choice == rt_hypercube) {
typedef amplusplus::per_thread_cache_generator<amplusplus::counter_coalesced_message_type_gen, amplusplus::hypercube_routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(coalescing_choice), reduction_choice, amplusplus::hypercube_routing(trans.rank(), trans.size()));
MessageGenerator priority_msg_gen(amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1), reduction_choice, amplusplus::hypercube_routing(trans.rank(), trans.size()));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
if(routing_choice == rt_rook) {
typedef amplusplus::per_thread_cache_generator<amplusplus::counter_coalesced_message_type_gen, amplusplus::rook_routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(coalescing_choice), reduction_choice, amplusplus::rook_routing(trans.rank(), trans.size()));
MessageGenerator priority_msg_gen(amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1), reduction_choice, amplusplus::rook_routing(trans.rank(), trans.size()));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
}
}
if(no_reductions) {
if (trans.rank() == 0) std::cout << " Reduction: 0 " << "coalescing " << coalescing_choice << " pri coalescing "
<< priority_coalescing_size
<< " routing " << routing_choice
<< " run_cc " << run_cc
<< std::endl;
if(routing_choice == rt_none) {
typedef amplusplus::simple_generator<amplusplus::counter_coalesced_message_type_gen> MessageGenerator;
MessageGenerator msg_gen((amplusplus::counter_coalesced_message_type_gen(coalescing_choice)));
MessageGenerator priority_msg_gen((amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1)));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
if(routing_choice == rt_hypercube) {
typedef amplusplus::routing_generator<amplusplus::counter_coalesced_message_type_gen, amplusplus::hypercube_routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(coalescing_choice), amplusplus::hypercube_routing(trans.rank(), trans.size()));
MessageGenerator priority_msg_gen(amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1), amplusplus::hypercube_routing(trans.rank(), trans.size()));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
if(routing_choice == rt_rook) {
typedef amplusplus::routing_generator<amplusplus::counter_coalesced_message_type_gen, amplusplus::rook_routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(coalescing_choice), amplusplus::rook_routing(trans.rank(), trans.size()));
MessageGenerator priority_msg_gen(amplusplus::counter_coalesced_message_type_gen(priority_coalescing_size, 1), amplusplus::rook_routing(trans.rank(), trans.size()));
select_msg_gen(msg_gen, priority_msg_gen, trans, barrier_trans, g, distance, weight, thread_choice, flush_choice, eager_choice, delta_choice, dc_ds_choice, synch_gen,
rand_vertex,
run_kla,
run_dc,
run_ds,
run_cc,
run_chaotic,
run_ss_mis,
run_bucket_mis,
run_luby_mis,
k_level,
luby_algo,
cc_algo,
bucket_choice);
}
}
}
template<typename MessageGenerator, typename Digraph, typename DistanceMap, typename WeightMap, typename RNG, typename RandVertex>
void select_msg_gen(MessageGenerator &msg_gen,
MessageGenerator &priority_msg_gen,
amplusplus::transport &trans,
amplusplus::transport &barrier_trans,
Digraph &g,
DistanceMap &distance,
WeightMap &weight,
unsigned int num_threads,
unsigned int flushFreq,
unsigned int eager_limit,
unsigned int delta,
std::string& dc_ds,
RNG synch_gen,
RandVertex rand_vertex,
bool run_kla,
bool run_dc,
bool run_ds,
bool run_cc,
bool run_chaotic,
bool run_ss_mis,
bool run_bucket_mis,
bool run_luby_mis,
size_t k_level,
std::string luby_algo,
std::string cc_algo,
size_t bucket_choice) {
//run_ds = !run_dc;
typedef typename graph_traits<Digraph>::vertex_descriptor Vertex;
time_type total_time = 0;
std::vector<time_type> all_times(num_sources);
std::vector<state_t> misvec(num_vertices(g), MIS_UNFIX);
typedef typename property_map<Digraph, vertex_index_t>::type VertexIndexMap;
typedef iterator_property_map<typename std::vector<state_t>::iterator, VertexIndexMap> MISMap;
MISMap mis(misvec.begin(), get(vertex_index, g));
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
clear_cumulative_buffer_stats();
#endif
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
cumulative_hits = 0; cumulative_tests = 0;
#endif
#ifdef PBGL2_PRINT_WORK_STATS
clear_cumulative_work_stats();
#endif
// For GTEPS
double total_elapsed_time = 0.0;
size_t *edge_traversed =(size_t *) calloc(num_sources, sizeof(size_t));
double *elapsed_time = (double *) calloc(num_sources, sizeof(double));
for (unsigned int source_i = 0; source_i < num_sources; ++source_i) {
#ifdef PRINT_ET
if (trans.rank() == 0)
std::cout << print_time(get_time() - job_start) << "s elapsed since job start\n";
#endif
Vertex current_source = vertex(rand_vertex(synch_gen), g);
time_type time;
if(run_dc) {
if(dc_ds == "vector") {
// Note : We need to modify vector data srtucture to accomadate new interface
std::cout << " This (vector data structure) option is not supported."
<< " We need to change vector implementation to satisfy new interface"
<< std::endl;
exit(1);
/*
time = run_distributed_control<boost::graph::distributed::vector_of_vector_gen>
(trans, barrier_trans, g, weight, distance, current_source, num_threads, n, verify, msg_gen, priority_msg_gen, flushFreq, eager_limit);
*/
} else if (dc_ds == "nodeq") { // priority queue per node
time = run_distributed_control_node<boost::graph::distributed::node_priority_queue_gen>
(trans, barrier_trans, g, weight, distance, current_source, num_threads, n, verify, msg_gen, priority_msg_gen, flushFreq, eager_limit);
} else if (dc_ds == "ms_nodeq"){ // priority queue per node
time = run_distributed_control_node<boost::graph::distributed::ms_node_priority_queue_gen>
(trans, barrier_trans, g, weight, distance, current_source, num_threads, n, verify, msg_gen, priority_msg_gen, flushFreq, eager_limit);
} else if (dc_ds == "numaq") { // priority queue per numa node
time = run_distributed_control_node<boost::graph::distributed::numa_priority_queue_gen>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit,
true); // numa true
} else if (dc_ds == "ms_numaq") { // priority queue per numa node
time = run_distributed_control_node<boost::graph::distributed::ms_numa_priority_queue_gen>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit,
true); // numa true
} else if (dc_ds == "pheet64q"){
time = run_distributed_control_pheet<boost::graph::distributed::pheet_priority_queue_gen_64>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit);
} else if (dc_ds == "pheet128q"){
time = run_distributed_control_pheet<boost::graph::distributed::pheet_priority_queue_gen_128>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit);
} else if (dc_ds == "pheet256q"){
time = run_distributed_control_pheet<boost::graph::distributed::pheet_priority_queue_gen_256>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit);
} else if (dc_ds == "pheet512q"){
time = run_distributed_control_pheet<boost::graph::distributed::pheet_priority_queue_gen_512>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit);
} else if (dc_ds == "pheet1024q"){
time = run_distributed_control_pheet<boost::graph::distributed::pheet_priority_queue_gen_1024>
(trans, barrier_trans, g, weight, distance,
current_source, num_threads, n,
verify, msg_gen, priority_msg_gen,
flushFreq, eager_limit);
} else if (dc_ds == "threadq"){
time = run_distributed_control(trans, barrier_trans, g, weight, distance, current_source, num_threads, n, verify, msg_gen, priority_msg_gen, flushFreq, eager_limit);
} else if (dc_ds == "buffer") {
std::cout << "Ignoring buffer data structure for Distirbuted Cotrol ..." << std::endl;
} else {
std::cout << "Data structure not specified ! " << std::endl;
assert(false);
}
} else if (run_cc) {
if (cc_algo == "run_dd_cc") {
time = run_data_driven_cc(trans,
barrier_trans,
g,
num_threads, n,
verify,
print_cc_stats,
allstats,
msg_gen,
priority_msg_gen, flushFreq, eager_limit);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_cc") {
time = run_sv_c_c(trans,
g,
num_threads,
verify,
false, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_cc_level_sync") {
time = run_sv_c_c(trans,
g,
num_threads,
verify,
true, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_cc_opt") {
time = run_sv_cc_optimized(trans,
g,
num_threads,
verify,
false, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_cc_opt_level_sync") {
time = run_sv_cc_optimized(trans,
g,
num_threads,
verify,
true, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_ps_cc") {
time = run_ps_sv_cc(trans,
g,
num_threads,
verify,
false, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_sv_ps_cc_level_sync") {
time = run_ps_sv_cc(trans,
g,
num_threads,
verify,
true, // level_sync
msg_gen,
vertices_per_lock);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_cc_chaotic") {
time = run_chaotic_cc(trans,
barrier_trans,
g,
num_threads,
n,
verify,
print_cc_stats,
allstats,
msg_gen);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_cc_ds") {
if (id_distribution == vertical)
time = run_delta_cc(trans,
barrier_trans,
g,
num_threads,
n,
bucket_choice,
block_id_distribution<Digraph>(g, n),
verify,
print_cc_stats,
allstats,
msg_gen);
else
time = run_delta_cc(trans,
barrier_trans,
g,
num_threads,
n,
bucket_choice,
row_id_distribution<Digraph>(g, trans.size()),
verify,
print_cc_stats,
allstats,
msg_gen);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
if (cc_algo == "run_level_sync_cc") {
time = run_level_sync_cc(trans,
barrier_trans,
g,
num_threads,
n,
verify,
print_cc_stats,
allstats,
msg_gen);
{ amplusplus::scoped_epoch epoch(barrier_trans); }
}
} else if(run_ds) { // run_ds
// For now we don't have the parameter for level_sync. It can be added later on.
if (dc_ds == "buffer") {
time = run_delta_stepping(trans,
barrier_trans,
g,
weight,
distance,
current_source,
delta,
num_threads, n, verify, false, msg_gen);
} else if (dc_ds == "nodeq") {
time = run_delta_stepping_node<boost::graph::distributed::node_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else if (dc_ds == "ms_nodeq") {
time = run_delta_stepping_node<boost::graph::distributed::ms_node_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else if (dc_ds == "threadq") {
time = run_delta_stepping_thread<boost::graph::distributed::thread_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else if (dc_ds == "mtthreadq") {
time = run_delta_stepping_thread<boost::graph::distributed::multi_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else if (dc_ds == "numaq") {
time = run_delta_stepping_numa<boost::graph::distributed::numa_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else if (dc_ds == "ms_numaq") {
time = run_delta_stepping_numa<boost::graph::distributed::ms_numa_priority_queue_gen>(trans,
barrier_trans, g,
weight, distance,
current_source, delta,
num_threads, n, verify, false, msg_gen,
flushFreq);
} else {
std::cout << "Data structure not specified ! " << std::endl;
assert(false);
}
} else if(run_chaotic) {
// chaotic SSSP
time = run_distributed_control_chaotic(trans, barrier_trans, g, weight, distance, current_source, num_threads, n, verify, msg_gen, flushFreq, eager_limit);
} else if(run_kla) {
if (dc_ds == "buffer") {
time = run_kla_sssp(trans, barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level);
} else if (dc_ds == "numaq") {
time = run_kla_sssp_numa<boost::graph::distributed::numa_priority_queue_gen>(trans,
barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level, flushFreq);
} else if (dc_ds == "ms_numaq") {
time = run_kla_sssp_numa<boost::graph::distributed::ms_numa_priority_queue_gen>(trans,
barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level,
flushFreq);
} else if (dc_ds == "nodeq") {
time = run_kla_sssp_node<boost::graph::distributed::node_priority_queue_gen>(trans,
barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level, flushFreq);
} else if (dc_ds == "ms_nodeq") {
time = run_kla_sssp_node<boost::graph::distributed::ms_node_priority_queue_gen>(trans,
barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level, flushFreq);
} else if (dc_ds == "threadq"){
time = run_kla_sssp_thread<boost::graph::distributed::thread_priority_queue_gen>(trans,
barrier_trans,
g, weight, distance,
current_source,
num_threads, n, verify,
false, msg_gen, k_level,
flushFreq);
} else {
assert(false);
}
} else if(run_ss_mis) {
time = run_fix_mis<boost::graph::distributed::thread_priority_queue_gen>(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else if(run_bucket_mis) {
time = run_fix_mis_bucket(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else if(run_luby_mis) {
if (luby_algo == "A") {
time = run_luby_maximal_is<boost::graph::distributed::select_a_functor_gen>(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else if (luby_algo == "AV1") {
time = run_luby_maximal_is<boost::graph::distributed::select_a_vertex_functor_gen>(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else if (luby_algo == "AV2"){
time = run_luby_maximal_is<boost::graph::distributed::select_a_v2_functor_gen>(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else if (luby_algo == "B") {
time = run_luby_maximal_is<boost::graph::distributed::select_b_functor_gen>(trans,
barrier_trans,
g,
mis,
num_threads,
n,
verify,
msg_gen,
flushFreq);
} else {
std::cerr << "Invalid algorithm type for Luby MIS."
<< " Available algorithms are A, AV1, AV2 and B"
<< std::endl;
assert(false);
}
} else {
assert(false);
}
#ifdef CALCULATE_GTEPS
if (!run_cc) {
elapsed_time[source_i] = time;
edge_traversed[source_i] = get_gteps(trans, g, distance, weight);
}
#endif
if (time == -1.) { // Not enough vertices visited
--source_i; continue;
}
total_time += time;
all_times[source_i] = time;
}
if (trans.rank() == 0) {
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
unsigned long long buffers{}, messages{};
for(unsigned int i = 0; i < cumulative_flushes.size(); ++i) {
buffers += cumulative_flushes[i];
messages += cumulative_flushes[i] * i;
}
float msg_per_buf = -1;
if (buffers != 0) {
msg_per_buf = messages/buffers;
}
#endif
if(run_dc) {
std::cout << "Total Distributed Control (DC)-(" << dc_ds
<< ") time for " << num_sources << " sources = "
<< print_time(total_time) << " ("
<< print_time(total_time / num_sources) << " per source), "
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
<< "messages = " << cumulative_messages << " (" << (cumulative_messages / num_sources) << " per source), "
<< " full buffers = " << cumulative_full << " (" << (cumulative_full / num_sources) << " per source)"
<< " partial flushes = " << buffers << " (" << (buffers / num_sources) << " per source) with "
<< msg_per_buf << " messages per buffer on average (-1 means buffer size is 0)."
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
<< "\nTests = " << (cumulative_tests / num_sources) << " (per source), hits = " << (cumulative_hits / num_sources)
<< " (per source), hit rate = " << (double(cumulative_hits) / double(cumulative_tests) * 100.) << "%"
#endif
#ifdef PBGL2_PRINT_WORK_STATS
PBGL2_DC_PRINT // The print macro for work stats
#endif
<< std::endl;
} else if(run_chaotic) {
std::cout << "Total Chaotic SSSP "
<< "time for " << num_sources << " sources = "
<< print_time(total_time) << " ("
<< print_time(total_time / num_sources) << " per source), "
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
<< "messages = " << cumulative_messages << " (" << (cumulative_messages / num_sources) << " per source), "
<< " full buffers = " << cumulative_full << " (" << (cumulative_full / num_sources) << " per source)"
<< " partial flushes = " << buffers << " (" << (buffers / num_sources) << " per source) with "
<< msg_per_buf << " messages per buffer on average (-1 means buffer size is 0)."
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
<< "\nTests = " << (cumulative_tests / num_sources) << " (per source), hits = " << (cumulative_hits / num_sources)
<< " (per source), hit rate = " << (double(cumulative_hits) / double(cumulative_tests) * 100.) << "%"
#endif
#ifdef PBGL2_PRINT_WORK_STATS
PBGL2_DC_PRINT // The print macro for work stats
#endif
<< std::endl;
} else if(run_ds) { // run_ds
std::cout << "Total Delta-Stepping (DS-" << dc_ds
<< ") time for " << num_sources << " sources = "
<< print_time(total_time) << " ("
<< print_time(total_time / num_sources) << " per source), delta = " << delta
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
<< ", messages = " << cumulative_messages << " (" << (cumulative_messages / num_sources) << " per source), "
<< " full buffers = " << cumulative_full << " (" << (cumulative_full / num_sources) << " per source)"
<< " partial flushes = " << buffers << " (" << (buffers / num_sources) << " per source) with "
<< msg_per_buf << " messages per buffer on average (-1 means buffer size is 0)."
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
<< "\nTests = " << (cumulative_tests / num_sources) << " (per source), hits = " << (cumulative_hits / num_sources)
<< " (per source), hit rate = " << (double(cumulative_hits) / double(cumulative_tests) * 100.) << "%"
#endif
#ifdef PBGL2_PRINT_WORK_STATS
PBGL2_DS_PRINT // The print macro for work stats
#endif
<< std::endl;
} /*else if (run_cc) { // run connected components
#ifdef CC_ALGORITHMS
std::cout << "Total data driven cc time for " << num_sources << " sources = "
<< print_time(total_cc_dd_time) << " ("
<< print_time(total_cc_dd_time / num_sources) << " per source)"
<< " Total shiloach-vishkin time " << print_time(total_cc_sv_time) << " ("
<< print_time(total_cc_sv_time / num_sources) << " per source)"
<< " Total parallel shiloach-vishkin time " << print_time(total_cc_sv_ps_time) << " ("
<< print_time(total_cc_sv_ps_time / num_sources) << " per source)"
<< " Total local difference time " << print_time(total_cc_ld_time) << " ("
<< print_time(total_cc_ld_time / num_sources) << " per source)."
<< " Running Scale : " << scale
#ifdef AMPLUSPLUS_ENABLE_PERFORMANCE_COUNTERS
<< ", messages = " << cumulative_messages << " (" << (cumulative_messages / num_sources) << " per source), "
<< " full buffers = " << cumulative_full << " (" << (cumulative_full / num_sources) << " per source)"
<< " partial flushes = " << buffers << " (" << (buffers / num_sources) << " per source) with "
<< msg_per_buf << " messages per buffer on average (-1 means buffer size is 0)."
#endif
#ifdef AMPLUSPLUS_PRINT_HIT_RATES
<< "\nTests = " << (cumulative_tests / num_sources) << " (per source), hits = " << (cumulative_hits / num_sources)
<< " (per source), hit rate = " << (double(cumulative_hits) / double(cumulative_tests) * 100.) << "%"
#endif
#ifdef PBGL2_PRINT_WORK_STATS
PBGL2_DS_PRINT // The print macro for work stats
#endif
<< std::endl;
#endif // end of CC_ALGORITHMS
}*/ else if(run_kla) { // run_kla
std::cout << "Total kla-sssp time for " << num_sources << " sources = "
<< print_time(total_time) << " ("
<< print_time(total_time / num_sources) << " per source), klevel = "
<< k_level << "%"
#ifdef PBGL2_PRINT_WORK_STATS
PBGL2_DS_PRINT // The print macro for work stats
#endif
<< std::endl;
}
time_type mean = total_time / num_sources;
time_type min = 0;
time_type q1 = 0;
time_type median = 0;
time_type q3 = 0;
time_type max = 0;
time_type stddev = 0;
time_statistics(all_times,
mean,
min,
q1,
median,
q3,
max,
stddev);
std::cout << "MEAN : " << print_time(mean)
<< " STDDEV : " << print_time(stddev)
<< " MIN : " << print_time(min)
<< " Q1 : " << print_time(q1)
<< " MEDIAN : " << print_time(median)
<< " Q3 : " << print_time(q3)
<< " MAX : " << print_time(max)
<< std::endl;
#ifdef CALCULATE_GTEPS
std::cout << "==============TEPS Statistics=================" << std::endl;
double *tm = (double*)malloc(sizeof(double)*num_sources);
double *stats = (double*)malloc(sizeof(double)*9);
// TODO We need to fix stat when num_sources < 4
if (!run_cc && num_sources > 4) {
for(int i = 0; i < num_sources; i++)
tm[i] = edge_traversed[i]/elapsed_time[i];
statistics (stats, tm, num_sources);
PRINT_GRAPH500_STATS("TEPS", 1);
}
free(tm);
free(stats);
#endif
free(edge_traversed);
free(elapsed_time);
}
}
template<typename Graph500Iter, typename Routing, typename Distribution, typename Trans, typename EdgeSize, typename UInt, typename Edges, typename WeightIterator>
void do_distribute(Distribution &distrib, Trans &trans, EdgeSize e_start, EdgeSize e_count, UInt a, UInt b, Edges &edges, WeightIterator weight_iter,
int num_threads) {
typedef amplusplus::routing_generator<amplusplus::counter_coalesced_message_type_gen, Routing> MessageGenerator;
MessageGenerator msg_gen(amplusplus::counter_coalesced_message_type_gen(distribution_coalescing_size), Routing(trans.rank(), trans.size()));
time_type start = get_time();
// Multithreaded distribution
trans.set_nthreads(num_threads);
#ifdef PRINT_DEBUG
std::cout << "Thread start : " << e_start << "Total edge count : " << e_count
<< " for rank :" << trans.rank()
<< std::endl;
#endif
Edges* thread_edges = new Edges[num_threads];
EdgeSize std_count_per_thread = (e_count + num_threads - 1) / num_threads;
// EdgeSize remainder = e_count % num_threads;
#ifdef PRINT_DEBUG
std::cout << "std_count_per_thread : " << std_count_per_thread << std::endl;
#endif
EdgeSize thread_start = e_start;
EdgeSize count_per_thread = std_count_per_thread;
// create message type
typedef typename std::iterator_traits<Graph500Iter>::value_type value_type;
typedef detail::vector_write_handler<Edges> vec_write_handler;
// not sure we need this here
amplusplus::register_mpi_datatype<value_type>();
typedef typename MessageGenerator::template call_result<value_type, vec_write_handler,
detail::distrib_to_pair_owner_map_t<Distribution>, amplusplus::no_reduction_t>::type
write_msg_type;
write_msg_type write_msg(msg_gen, trans, detail::distrib_to_pair_owner_map<Distribution>(distrib),
amplusplus::no_reduction);
// set the handler (must be in main thread)
write_msg.set_handler(vec_write_handler(thread_edges));
threaded_distributor<write_msg_type> td(write_msg);
boost::scoped_array<boost::thread> threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
#ifdef PRINT_DEBUG
if (_RANK == 0) {
std::cout << "Thread : " << i+1 << " start : " << thread_start
<< " thread end : " << (thread_start + count_per_thread)
<< std::endl;
}
#endif
boost::thread thr(boost::ref(td), i+1, Graph500Iter(scale, thread_start, a, b, weight_iter),
Graph500Iter(scale, thread_start + count_per_thread, a, b, weight_iter),
flip_pair(), trans);
thread_start = thread_start + count_per_thread;
threads[i].swap(thr);
}
// Allocate remainder to main thread
count_per_thread = std::min(std_count_per_thread, (e_count-thread_start));
#ifdef PRINT_DEBUG
std::cout << "Thread : " << 0 << " start : " << thread_start
<< " thread end : " << (thread_start + count_per_thread)
<< std::endl;
#endif
td(0, Graph500Iter(scale, thread_start, a, b, weight_iter),
Graph500Iter(scale, thread_start + count_per_thread, a, b, weight_iter),
flip_pair(), trans);
// Wait till all threads finish
for (int i = 0; i < num_threads - 1; ++i)
threads[i].join();
// Merge all edges - in threads
// time_type m_start = get_time();
typename Edges::size_type total_sz = 0;
std::vector<typename Edges::size_type> positions(num_threads);
for (int i = 0; i < num_threads; ++i) {
positions[i] = total_sz;
total_sz += thread_edges[i].size();
}
edges.resize(total_sz);
threaded_merger<Edges> tm(edges);
boost::scoped_array<boost::thread> m_threads(new boost::thread[num_threads - 1]);
for (int i = 0; i < num_threads - 1; ++i) {
typename Edges::iterator pos_ite = edges.begin();
std::advance(pos_ite, positions[i+1]);
boost::thread thr(boost::ref(tm), pos_ite,
thread_edges[i+1].begin(), thread_edges[i+1].end());
m_threads[i].swap(thr);
}
tm(edges.begin(), thread_edges[0].begin(), thread_edges[0].end());
// Wait till all threads finish
for (int i = 0; i < num_threads - 1; ++i)
m_threads[i].join();
//time_type m_end = get_time();
trans.set_nthreads(1);
delete[] thread_edges;
{ amplusplus::scoped_epoch epoch(trans); }
time_type end = get_time();
std::cout << "Graph distribution permutation took " << (end-start)
<< " time" << std::endl;
// sort edges in parallel
//__gnu_parallel::sort(edges.begin(), edges.end());
}
};
void q_test() {
typedef std::pair<int, int> vertex_distance_data;
struct default_comparer {
bool operator()(const vertex_distance_data& vd1, const vertex_distance_data& vd2) {
return vd1.second > vd2.second;
}
};
cds::Initialize();
{
// Initialize Hazard Pointer singleton
cds::gc::HP hpGC(72);
// Attach for the main thread
cds::threading::Manager::attachThread();
// template<typename vertex_distance, typename Compare>
/* struct reverse_compare {
private:
default_comparer c;
public:
inline bool operator()(const vertex_distance_data& vd1, const vertex_distance_data& vd2) {
return c(vd2, vd1);
}
};*/
graph::distributed::ms_node_priority_queue<vertex_distance_data, default_comparer> npq(10);
graph::distributed::node_priority_queue<vertex_distance_data, default_comparer> pq(10);
// graph::distributed::ellen_bin_priority_queue<vertex_distance_data, default_comparer> epq(10);
std::priority_queue<vertex_distance_data, std::vector<vertex_distance_data>, default_comparer> dpq;
vertex_distance_data vd1(10, 22);
vertex_distance_data vd2(1, 23);
vertex_distance_data vd3(5, 34);
vertex_distance_data vd4(8, 12);
vertex_distance_data vd5(11, 210);
vertex_distance_data vd6(7, 2);
vertex_distance_data vd7(8, 650);
vertex_distance_data vd8(5, 30);
vertex_distance_data vd9(2, 22);
vertex_distance_data vd10(9, 21);
npq.put(vd1,0);
npq.put(vd2,1);
npq.put(vd3,0);
npq.put(vd4,2);
npq.put(vd5,3);
npq.put(vd6,4);
npq.put(vd7,5);
npq.put(vd8,6);
npq.put(vd9,2);
npq.put(vd10,4);
pq.put(vd1,0);
pq.put(vd2,1);
pq.put(vd3,0);
pq.put(vd4,2);
pq.put(vd5,3);
pq.put(vd6,4);
pq.put(vd7,5);
pq.put(vd8,6);
pq.put(vd9,2);
pq.put(vd10,4);
/* epq.put(vd1,0);
epq.put(vd2,1);
epq.put(vd3,0);
epq.put(vd4,2);
epq.put(vd5,3);
epq.put(vd6,4);
epq.put(vd7,5);
epq.put(vd8,6);
epq.put(vd9,2);
epq.put(vd10,4);*/
dpq.push(vd1);
dpq.push(vd2);
dpq.push(vd3);
dpq.push(vd4);
dpq.push(vd5);
dpq.push(vd6);
dpq.push(vd7);
dpq.push(vd8);
dpq.push(vd9);
dpq.push(vd10);
std::cout << "========== cds :: mspq ===========" << std::endl;
// should give the shortest distance first
vertex_distance_data vdx1;
while(npq.pop(vdx1, 0)) {
std::cout << vdx1.second << std::endl;
}
assert(npq.empty());
std::cout << "========== cds :: fcpq ===========" << std::endl;
// should give the shortest distance first
vertex_distance_data vdx2;
while(pq.pop(vdx2, 0)) {
std::cout << vdx2.second << std::endl;
}
assert(pq.empty());
/* std::cout << "========== cds :: ellenbin ===========" << std::endl;
// should give the shortest distance first
vertex_distance_data vdx3;
while(epq.pop(vdx3, 0)) {
std::cout << vdx3.second << std::endl;
}
assert(epq.empty());*/
std::cout << "========== std::queue===========" << std::endl;
while(!dpq.empty()) {
std::cout << dpq.top().second << std::endl;
dpq.pop();
}
cds::threading::Manager::detachThread();
}
cds::Terminate();
exit(0);
}
int main(int argc, char* argv[]) {
// q_test();
dc_test t(argc, argv);
t.test_main(argc, argv);
}
| 31.594864
| 637
| 0.650848
|
thejkane
|
9a790e854bb7dd080b0f2c05900dcf25ae79e48e
| 1,049
|
cpp
|
C++
|
ColliderBit/src/models/SUSY.cpp
|
GambitBSM/gambit_2.0
|
a4742ac94a0352585a3b9dcb9b222048a5959b91
|
[
"Unlicense"
] | 1
|
2021-09-17T22:53:26.000Z
|
2021-09-17T22:53:26.000Z
|
ColliderBit/src/models/SUSY.cpp
|
GambitBSM/gambit_2.0
|
a4742ac94a0352585a3b9dcb9b222048a5959b91
|
[
"Unlicense"
] | 3
|
2021-07-22T11:23:48.000Z
|
2021-08-22T17:24:41.000Z
|
ColliderBit/src/models/SUSY.cpp
|
GambitBSM/gambit_2.0
|
a4742ac94a0352585a3b9dcb9b222048a5959b91
|
[
"Unlicense"
] | 1
|
2021-08-14T10:31:41.000Z
|
2021-08-14T10:31:41.000Z
|
// GAMBIT: Global and Modular BSM Inference Tool
// *********************************************
/// \file
///
/// SUSY-specific sources for ColliderBit.
///
/// *********************************************
///
/// Authors (add name and date if you modify):
///
/// \author Pat Scott
/// (p.scott@imperial.ac.uk)
/// \date 2019 Jan
///
/// \author Anders Kvellestad
/// (anders.kvellestad@fys.uio.no)
/// \date 2019
///
/// *********************************************
#include "gambit/ColliderBit/getPy8Collider.hpp"
#include "gambit/ColliderBit/generateEventPy8Collider.hpp"
namespace Gambit
{
namespace ColliderBit
{
// Get spectrum and decays for Pythia
GET_SPECTRUM_AND_DECAYS_FOR_PYTHIA_SUSY(getSpectrumAndDecaysForPythia, MSSM_spectrum)
// Get Monte Carlo event generator
GET_SPECIFIC_PYTHIA(getPythia, Pythia_default, /* blank MODEL_EXTENSION argument */ )
GET_PYTHIA_AS_BASE_COLLIDER(getPythiaAsBase)
// Run event generator
GET_PYTHIA_EVENT(generateEventPythia)
}
}
| 25.585366
| 89
| 0.602479
|
GambitBSM
|
9a79c2c2fa51bd1c9e2221f7d752573c9e3b04d5
| 1,540
|
cpp
|
C++
|
problemes/probleme0xx/probleme035.cpp
|
ZongoForSpeed/ProjectEuler
|
2e2d45f984d48a1da8275886c976f909a0de94ce
|
[
"MIT"
] | 6
|
2015-10-13T17:07:21.000Z
|
2018-05-08T11:50:22.000Z
|
problemes/probleme0xx/probleme035.cpp
|
ZongoForSpeed/ProjectEuler
|
2e2d45f984d48a1da8275886c976f909a0de94ce
|
[
"MIT"
] | null | null | null |
problemes/probleme0xx/probleme035.cpp
|
ZongoForSpeed/ProjectEuler
|
2e2d45f984d48a1da8275886c976f909a0de94ce
|
[
"MIT"
] | null | null | null |
#include "problemes.h"
#include "chiffres.h"
#include "premiers.h"
#include <set>
#include <iterator>
typedef unsigned long long nombre;
namespace {
nombre rotation(nombre n) {
auto liste = chiffres::extraire_chiffres(n);
liste.push_back(liste.front());
liste.pop_front();
nombre r = 0;
for (const auto &c: liste)
r = 10 * r + c;
return r;
}
bool valide(nombre n, const std::set<nombre> &premiers) {
auto chiffres = chiffres::extraire_chiffres(n);
if (std::count(chiffres.begin(), chiffres.end(), 0) != 0)
return false;
nombre tmp = n;
bool valide = true;
while (valide) {
tmp = rotation(tmp);
if (tmp == n)
break;
if (premiers.find(tmp) == premiers.end())
valide = false;
}
return valide;
};
}
ENREGISTRER_PROBLEME(35, "Circular primes") {
// The number, 197, is called a circular prime because all rotations of the digits:
// 197, 971, and 719, are themselves prime.
//
// There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
//
// How many circular primes are there below one million?
std::set<nombre> premiers;
premiers::crible2<nombre>(1000000, std::inserter(premiers, premiers.begin()));
nombre resultat = 0;
for (const auto p: premiers) {
if (valide(p, premiers)) ++resultat;
}
return std::to_string(resultat);
}
| 27.5
| 100
| 0.572727
|
ZongoForSpeed
|
9a7b0b6bba3acded392a03976227887f3a2be9d6
| 506
|
cc
|
C++
|
trash/trash/standard-template-library/csrc/stub.cc
|
uphere-co/nlp-prototype
|
c4623927e5c5c5f9c3e702eb36497ea1d9fd1ff3
|
[
"BSD-3-Clause"
] | null | null | null |
trash/trash/standard-template-library/csrc/stub.cc
|
uphere-co/nlp-prototype
|
c4623927e5c5c5f9c3e702eb36497ea1d9fd1ff3
|
[
"BSD-3-Clause"
] | null | null | null |
trash/trash/standard-template-library/csrc/stub.cc
|
uphere-co/nlp-prototype
|
c4623927e5c5c5f9c3e702eb36497ea1d9fd1ff3
|
[
"BSD-3-Clause"
] | null | null | null |
#include "template.hh"
w_printout(int)
w_printout(double)
w_push_back(int)
w_push_back(double)
w_new(int)
w_new(double)
w_at(int)
w_at(double)
w_delete(int)
w_delete(double)
// template void printout<int> (std::vector<int>*);
// template std::vector<int>* create();
// template void push_back<int> (std::vector<int>*, int);
// template void printout<double> (std::vector<double>*);
//template std::vector<double>* create();
// template void push_back<double> (std::vector<double>*, double);
| 15.333333
| 66
| 0.703557
|
uphere-co
|
9a830a8865590c235673400e4b769f04a41dc433
| 4,625
|
cpp
|
C++
|
android-28/org/xml/sax/helpers/AttributesImpl.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/org/xml/sax/helpers/AttributesImpl.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-29/org/xml/sax/helpers/AttributesImpl.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#include "../../../../JArray.hpp"
#include "../../../../JString.hpp"
#include "./AttributesImpl.hpp"
namespace org::xml::sax::helpers
{
// Fields
// QJniObject forward
AttributesImpl::AttributesImpl(QJniObject obj) : JObject(obj) {}
// Constructors
AttributesImpl::AttributesImpl()
: JObject(
"org.xml.sax.helpers.AttributesImpl",
"()V"
) {}
AttributesImpl::AttributesImpl(JObject arg0)
: JObject(
"org.xml.sax.helpers.AttributesImpl",
"(Lorg/xml/sax/Attributes;)V",
arg0.object()
) {}
// Methods
void AttributesImpl::addAttribute(JString arg0, JString arg1, JString arg2, JString arg3, JString arg4) const
{
callMethod<void>(
"addAttribute",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
arg0.object<jstring>(),
arg1.object<jstring>(),
arg2.object<jstring>(),
arg3.object<jstring>(),
arg4.object<jstring>()
);
}
void AttributesImpl::clear() const
{
callMethod<void>(
"clear",
"()V"
);
}
jint AttributesImpl::getIndex(JString arg0) const
{
return callMethod<jint>(
"getIndex",
"(Ljava/lang/String;)I",
arg0.object<jstring>()
);
}
jint AttributesImpl::getIndex(JString arg0, JString arg1) const
{
return callMethod<jint>(
"getIndex",
"(Ljava/lang/String;Ljava/lang/String;)I",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
jint AttributesImpl::getLength() const
{
return callMethod<jint>(
"getLength",
"()I"
);
}
JString AttributesImpl::getLocalName(jint arg0) const
{
return callObjectMethod(
"getLocalName",
"(I)Ljava/lang/String;",
arg0
);
}
JString AttributesImpl::getQName(jint arg0) const
{
return callObjectMethod(
"getQName",
"(I)Ljava/lang/String;",
arg0
);
}
JString AttributesImpl::getType(jint arg0) const
{
return callObjectMethod(
"getType",
"(I)Ljava/lang/String;",
arg0
);
}
JString AttributesImpl::getType(JString arg0) const
{
return callObjectMethod(
"getType",
"(Ljava/lang/String;)Ljava/lang/String;",
arg0.object<jstring>()
);
}
JString AttributesImpl::getType(JString arg0, JString arg1) const
{
return callObjectMethod(
"getType",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
JString AttributesImpl::getURI(jint arg0) const
{
return callObjectMethod(
"getURI",
"(I)Ljava/lang/String;",
arg0
);
}
JString AttributesImpl::getValue(jint arg0) const
{
return callObjectMethod(
"getValue",
"(I)Ljava/lang/String;",
arg0
);
}
JString AttributesImpl::getValue(JString arg0) const
{
return callObjectMethod(
"getValue",
"(Ljava/lang/String;)Ljava/lang/String;",
arg0.object<jstring>()
);
}
JString AttributesImpl::getValue(JString arg0, JString arg1) const
{
return callObjectMethod(
"getValue",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
void AttributesImpl::removeAttribute(jint arg0) const
{
callMethod<void>(
"removeAttribute",
"(I)V",
arg0
);
}
void AttributesImpl::setAttribute(jint arg0, JString arg1, JString arg2, JString arg3, JString arg4, JString arg5) const
{
callMethod<void>(
"setAttribute",
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
arg0,
arg1.object<jstring>(),
arg2.object<jstring>(),
arg3.object<jstring>(),
arg4.object<jstring>(),
arg5.object<jstring>()
);
}
void AttributesImpl::setAttributes(JObject arg0) const
{
callMethod<void>(
"setAttributes",
"(Lorg/xml/sax/Attributes;)V",
arg0.object()
);
}
void AttributesImpl::setLocalName(jint arg0, JString arg1) const
{
callMethod<void>(
"setLocalName",
"(ILjava/lang/String;)V",
arg0,
arg1.object<jstring>()
);
}
void AttributesImpl::setQName(jint arg0, JString arg1) const
{
callMethod<void>(
"setQName",
"(ILjava/lang/String;)V",
arg0,
arg1.object<jstring>()
);
}
void AttributesImpl::setType(jint arg0, JString arg1) const
{
callMethod<void>(
"setType",
"(ILjava/lang/String;)V",
arg0,
arg1.object<jstring>()
);
}
void AttributesImpl::setURI(jint arg0, JString arg1) const
{
callMethod<void>(
"setURI",
"(ILjava/lang/String;)V",
arg0,
arg1.object<jstring>()
);
}
void AttributesImpl::setValue(jint arg0, JString arg1) const
{
callMethod<void>(
"setValue",
"(ILjava/lang/String;)V",
arg0,
arg1.object<jstring>()
);
}
} // namespace org::xml::sax::helpers
| 21.118721
| 121
| 0.663568
|
YJBeetle
|
9a87f30402171d900d7ba8421b2866e86d6d186f
| 61,766
|
cpp
|
C++
|
src/shell/shell_misc.cpp
|
mediaexplorer74/dosbox-x
|
be9f94b740234f7813bf5a063a558cef9dc7f9a6
|
[
"MIT"
] | 3
|
2022-02-20T11:06:29.000Z
|
2022-03-11T08:16:55.000Z
|
src/shell/shell_misc.cpp
|
mediaexplorer74/dosbox-x
|
be9f94b740234f7813bf5a063a558cef9dc7f9a6
|
[
"MIT"
] | null | null | null |
src/shell/shell_misc.cpp
|
mediaexplorer74/dosbox-x
|
be9f94b740234f7813bf5a063a558cef9dc7f9a6
|
[
"MIT"
] | null | null | null |
/*
* Copyright (C) 2002-2021 The DOSBox Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 02110-1301, USA.
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm> //std::copy
#include <iterator> //std::front_inserter
#include <regex>
#include "logging.h"
#include "shell.h"
#include "timer.h"
#include "bios.h"
#include "control.h"
#include "regs.h"
#include "callback.h"
#include "support.h"
#include "inout.h"
#include "render.h"
#include "../ints/int10.h"
#include "../dos/drives.h"
#ifdef _MSC_VER
# if !defined(C_SDL2)
# include "process.h"
# endif
# define MIN(a,b) ((a) < (b) ? (a) : (b))
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#else
# define MIN(a,b) std::min(a,b)
# define MAX(a,b) std::max(a,b)
#endif
bool clearline=false, inshell=false, noassoc=false;
int autofixwarn=3;
extern int lfn_filefind_handle;
extern bool ctrlbrk, gbk, rtl, dbcs_sbcs;
extern bool DOS_BreakFlag, DOS_BreakConioFlag;
extern uint16_t cmd_line_seg;
#if defined(USE_TTF)
extern bool ttf_dosv;
#endif
extern std::map<int, int> pc98boxdrawmap;
void DOS_Shell::ShowPrompt(void) {
char dir[DOS_PATHLENGTH];
dir[0] = 0; //DOS_GetCurrentDir doesn't always return something. (if drive is messed up)
DOS_GetCurrentDir(0,dir,uselfn);
std::string line;
const char * promptstr = "\0";
inshell = true;
if(GetEnvStr("PROMPT",line)) {
std::string::size_type idx = line.find('=');
std::string value=line.substr(idx +1 , std::string::npos);
line = std::string(promptstr) + value;
promptstr = line.c_str();
}
while (*promptstr) {
if (!strcasecmp(promptstr,"$"))
WriteOut("\0");
else if(*promptstr != '$')
WriteOut("%c",*promptstr);
else switch (toupper(*++promptstr)) {
case 'A': WriteOut("&"); break;
case 'B': WriteOut("|"); break;
case 'C': WriteOut("("); break;
case 'D': WriteOut("%02d-%02d-%04d",dos.date.day,dos.date.month,dos.date.year); break;
case 'E': WriteOut("%c",27); break;
case 'F': WriteOut(")"); break;
case 'G': WriteOut(">"); break;
case 'H': WriteOut("\b"); break;
case 'L': WriteOut("<"); break;
case 'N': WriteOut("%c",DOS_GetDefaultDrive()+'A'); break;
case 'P': WriteOut("%c:\\",DOS_GetDefaultDrive()+'A'); WriteOut_NoParsing(dir, true); break;
case 'Q': WriteOut("="); break;
case 'S': WriteOut(" "); break;
case 'T': {
Bitu ticks=(Bitu)(((65536.0 * 100.0)/(double)PIT_TICK_RATE)* mem_readd(BIOS_TIMER));
reg_dl=(uint8_t)((Bitu)ticks % 100);
ticks/=100;
reg_dh=(uint8_t)((Bitu)ticks % 60);
ticks/=60;
reg_cl=(uint8_t)((Bitu)ticks % 60);
ticks/=60;
reg_ch=(uint8_t)((Bitu)ticks % 24);
WriteOut("%d:%02d:%02d.%02d",reg_ch,reg_cl,reg_dh,reg_dl);
break;
}
case 'V': WriteOut("DOSBox-X version %s. Reported DOS version %d.%d.",VERSION,dos.version.major,dos.version.minor); break;
case '$': WriteOut("$"); break;
case '_': WriteOut("\n"); break;
case 'M': break;
case '+': break;
}
promptstr++;
}
inshell = false;
}
static void outc(uint8_t c) {
uint16_t n=1;
DOS_WriteFile(STDOUT,&c,&n);
}
static void backone() {
BIOS_NCOLS;
uint8_t page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE);
if (CURSOR_POS_COL(page)>0)
outc(8);
else if (CURSOR_POS_ROW(page)>0)
INT10_SetCursorPos(CURSOR_POS_ROW(page)-1, ncols-1, page);
}
//! \brief Moves the caret to prev row/last column when column is 0 (video mode 0).
void MoveCaretBackwards()
{
uint8_t col, row;
const uint8_t page(0);
INT10_GetCursorPos(&row, &col, page);
if (col != 0)
return;
uint16_t cols;
INT10_GetScreenColumns(&cols);
INT10_SetCursorPos(row - 1, static_cast<uint8_t>(cols), page);
}
bool DOS_Shell::BuildCompletions(char * line, uint16_t str_len) {
// build new completion list
// Lines starting with CD/MD/RD will only get directories in the list
bool dir_only = (strncasecmp(ltrim(line),"CD ",3)==0)||(strncasecmp(ltrim(line),"MD ",3)==0)||(strncasecmp(ltrim(line),"RD ",3)==0)||
(strncasecmp(ltrim(line),"CHDIR ",6)==0)||(strncasecmp(ltrim(line),"MKDIR ",3)==0)||(strncasecmp(ltrim(line),"RMDIR ",6)==0);
int q=0, r=0, k=0;
// get completion mask
const char *p_completion_start = strrchr(line, ' ');
while (p_completion_start) {
q=0;
char *i;
for (i=line;i<p_completion_start;i++)
if (*i=='\"') q++;
if (q/2*2==q) break;
*i=0;
p_completion_start = strrchr(line, ' ');
*i=' ';
}
char c[]={'<','>','|'};
for (unsigned int j=0; j<sizeof(c); j++) {
const char *sp = strrchr_dbcs(line, c[j]);
while (sp) {
q=0;
char *i;
for (i=line;i<sp;i++)
if (*i=='\"') q++;
if (q/2*2==q) break;
*i=0;
sp = strrchr_dbcs(line, c[j]);
*i=c[j];
}
if (!p_completion_start || p_completion_start<sp)
p_completion_start = sp;
}
if (p_completion_start) {
p_completion_start ++;
completion_index = (uint16_t)(str_len - strlen(p_completion_start));
} else {
p_completion_start = line;
completion_index = 0;
}
k=completion_index;
const char *path;
if ((path = strrchr(line+completion_index,':'))) completion_index = (uint16_t)(path-line+1);
if ((path = strrchr_dbcs(line+completion_index,'\\'))) completion_index = (uint16_t)(path-line+1);
if ((path = strrchr(line+completion_index,'/'))) completion_index = (uint16_t)(path-line+1);
// build the completion list
char mask[DOS_PATHLENGTH+2] = {0}, smask[DOS_PATHLENGTH] = {0};
if (p_completion_start && strlen(p_completion_start) + 3 >= DOS_PATHLENGTH) {
// TODO: This really should be done in the CON driver so that this code can just print ASCII code 7 instead
if (IS_PC98_ARCH) {
// TODO: BEEP. I/O PORTS ARE DIFFERENT AS IS THE PIT CLOCK RATE
}
else {
// IBM PC/XT/AT
IO_Write(0x43,0xb6);
IO_Write(0x42,1750&0xff);
IO_Write(0x42,1750>>8);
IO_Write(0x61,IO_Read(0x61)|0x3);
for(Bitu i=0; i < 333; i++) CALLBACK_Idle();
IO_Write(0x61,IO_Read(0x61)&~0x3);
}
return false;
}
if (p_completion_start) {
safe_strncpy(mask, p_completion_start,DOS_PATHLENGTH);
const char* dot_pos = strrchr(mask, '.');
const char* bs_pos = strrchr_dbcs(mask, '\\');
const char* fs_pos = strrchr(mask, '/');
const char* cl_pos = strrchr(mask, ':');
// not perfect when line already contains wildcards, but works
if ((dot_pos-bs_pos>0) && (dot_pos-fs_pos>0) && (dot_pos-cl_pos>0))
strncat(mask, "*",DOS_PATHLENGTH - 1);
else strncat(mask, "*.*",DOS_PATHLENGTH - 1);
} else {
strcpy(mask, "*.*");
}
RealPt save_dta=dos.dta();
dos.dta(dos.tables.tempdta);
bool res = false;
if (DOS_GetSFNPath(mask,smask,false)) {
sprintf(mask,"\"%s\"",smask);
int fbak=lfn_filefind_handle;
lfn_filefind_handle=uselfn?LFN_FILEFIND_INTERNAL:LFN_FILEFIND_NONE;
res = DOS_FindFirst(mask, 0xffff & ~DOS_ATTR_VOLUME);
lfn_filefind_handle=fbak;
}
if (!res) {
dos.dta(save_dta);
// TODO: This really should be done in the CON driver so that this code can just print ASCII code 7 instead
if (IS_PC98_ARCH) {
// TODO: BEEP. I/O PORTS ARE DIFFERENT AS IS THE PIT CLOCK RATE
}
else {
// IBM PC/XT/AT
IO_Write(0x43,0xb6);
IO_Write(0x42,1750&0xff);
IO_Write(0x42,1750>>8);
IO_Write(0x61,IO_Read(0x61)|0x3);
for(Bitu i=0; i < 300; i++) CALLBACK_Idle();
IO_Write(0x61,IO_Read(0x61)&~0x3);
}
return false;
}
DOS_DTA dta(dos.dta());
char name[DOS_NAMELENGTH_ASCII], lname[LFN_NAMELENGTH], qlname[LFN_NAMELENGTH+2];
uint32_t sz;uint16_t date;uint16_t time;uint8_t att;
std::list<std::string> executable;
q=0;r=0;
while (*p_completion_start) {
k++;
if (*p_completion_start++=='\"') {
if (k<=completion_index)
q++;
else
r++;
}
}
int fbak=lfn_filefind_handle;
lfn_filefind_handle=uselfn?LFN_FILEFIND_INTERNAL:LFN_FILEFIND_NONE;
while (res) {
dta.GetResult(name,lname,sz,date,time,att);
if ((strchr(uselfn?lname:name,' ')!=NULL&&q/2*2==q)||r)
sprintf(qlname,q/2*2!=q?"%s\"":"\"%s\"",uselfn?lname:name);
else
strcpy(qlname,uselfn?lname:name);
// add result to completion list
if (strcmp(name, ".") && strcmp(name, "..")) {
if (dir_only) { //Handle the dir only case different (line starts with cd)
if(att & DOS_ATTR_DIRECTORY) l_completion.emplace_back(qlname);
} else {
const char *ext = strrchr(name, '.'); // file extension
if ((ext && (strcmp(ext, ".BAT") == 0 || strcmp(ext, ".COM") == 0 || strcmp(ext, ".EXE") == 0)) || hasAssociation(name).size())
// we add executables to a separate list and place that list in front of the normal files
executable.emplace_front(qlname);
else
l_completion.emplace_back(qlname);
}
}
res=DOS_FindNext();
}
lfn_filefind_handle=fbak;
/* Add executable list to front of completion list. */
std::copy(executable.begin(),executable.end(),std::front_inserter(l_completion));
dos.dta(save_dta);
return true;
}
extern bool isKanji1(uint8_t chr), isKanji2(uint8_t chr);
extern bool CheckHat(uint8_t code);
static uint16_t GetWideCount(char *line, uint16_t str_index)
{
bool kanji_flag = false;
uint16_t count = 1;
for(uint16_t pos = 0 ; pos < str_index ; pos++) {
if(!kanji_flag) {
if(isKanji1(line[pos])) {
kanji_flag = true;
}
count = 1;
} else {
if(isKanji2(line[pos])) {
count = 2;
}
kanji_flag = false;
}
}
return count;
}
static uint16_t GetLastCount(char *line, uint16_t str_index)
{
bool kanji_flag = false;
uint16_t count = 1;
for(uint16_t pos = 0 ; pos < str_index ; pos++) {
if(!kanji_flag) {
if(isKanji1(line[pos])) {
kanji_flag = true;
}
count = 1;
} else {
if(isKanji2(line[pos])) {
bool found=false;
if (IS_PC98_ARCH && line[pos-1] == 0xFFFFFF86) {
for (auto it = pc98boxdrawmap.begin(); it != pc98boxdrawmap.end(); ++it)
if (it->second ==line[pos]) {
found=true;
break;
}
}
if (!found) count = 2;
}
kanji_flag = false;
}
}
return count;
}
static uint16_t GetRemoveCount(char *line, uint16_t str_index)
{
bool kanji_flag = false;
uint16_t count = 1, total = 0;
for(uint16_t pos = 0 ; pos < str_index ; pos++) {
if(!kanji_flag) {
if(isKanji1(line[pos])) {
kanji_flag = true;
}
count = 1;
} else {
if(isKanji2(line[pos])) {
bool found=false;
if (IS_PC98_ARCH && line[pos-1] == 0xFFFFFF86) {
for (auto it = pc98boxdrawmap.begin(); it != pc98boxdrawmap.end(); ++it)
if (it->second ==line[pos]) {
found=true;
break;
}
}
count = found?0:1;
}
kanji_flag = false;
}
total += count;
}
return total;
}
static void RemoveAllChar(char *line, uint16_t str_index)
{
for ( ; str_index > 0 ; str_index--) {
// removes all characters
if(CheckHat(line[str_index])) {
backone(); backone(); outc(' '); outc(' '); backone(); backone();
} else {
backone(); outc(' '); backone();
}
}
if(CheckHat(line[0])) {
backone(); outc(' '); backone();
}
}
static uint16_t DeleteBackspace(bool delete_flag, char *line, uint16_t &str_index, uint16_t &str_len)
{
uint16_t count, pos, len;
pos = str_index;
if(delete_flag) {
if(isKanji1(line[pos])&&line[pos+1]) {
pos += 2;
} else {
pos += 1;
}
}
count = GetWideCount(line, pos);
pos = str_index;
while(pos < str_len) {
len = 1;
DOS_WriteFile(STDOUT, (uint8_t *)&line[pos], &len);
pos++;
}
if (delete_flag && str_index >= str_len)
return 0;
RemoveAllChar(line, GetRemoveCount(line, pos));
pos = delete_flag ? str_index : str_index - count;
while(pos < str_len - count) {
line[pos] = line[pos + count];
pos++;
}
line[pos] = 0;
if(!delete_flag) {
str_index -= count;
}
str_len -= count;
len = str_len;
DOS_WriteFile(STDOUT, (uint8_t *)line, &len);
pos = GetRemoveCount(line, str_len);
while(pos > str_index) {
backone();
if(CheckHat(line[pos - 1])) {
backone();
}
pos--;
}
return count;
}
extern bool isDBCSCP();
/* NTS: buffer pointed to by "line" must be at least CMD_MAXLINE+1 large */
void DOS_Shell::InputCommand(char * line) {
Bitu size=CMD_MAXLINE-2; //lastcharacter+0
uint8_t c;uint16_t n=1;
uint16_t str_len=0;uint16_t str_index=0;
uint16_t len=0;
bool current_hist=false; // current command stored in history?
uint16_t cr;
#if defined(USE_TTF)
if(IS_DOSV || ttf_dosv) {
#else
if(IS_DOSV) {
#endif
uint16_t int21_seg = mem_readw(0x0086);
if(int21_seg != 0xf000) {
if(real_readw(int21_seg - 1, 8) == 0x5a56) {
// Vz editor resident
real_writeb(cmd_line_seg, 0, 250);
reg_dx = 0;
reg_ah = 0x0a;
SegSet16(ds, cmd_line_seg);
CALLBACK_RunRealInt(0x21);
str_len = real_readb(cmd_line_seg, 1);
for(len = 0 ; len < str_len ; len++) {
line[len] = real_readb(cmd_line_seg, 2 + len);
}
line[str_len] = '\0';
return;
}
}
}
inshell = true;
input_eof = false;
line[0] = '\0';
std::list<std::string>::iterator it_history = l_history.begin(), it_completion = l_completion.begin();
while (size) {
dos.echo=false;
if (!DOS_ReadFile(input_handle,&c,&n)) {
LOG(LOG_MISC,LOG_ERROR)("SHELL: Lost the input handle, dropping shell input loop");
n = 0;
}
if (!n) {
input_eof = true;
size=0; //Kill the while loop
continue;
}
if (clearline) {
clearline = false;
*line=0;
if (l_completion.size()) l_completion.clear(); //reset the completion list.
str_index = 0;
str_len = 0;
}
if (input_handle != STDIN) { /* FIXME: Need DOS_IsATTY() or somesuch */
cr = (uint16_t)c; /* we're not reading from the console */
}
else if (IS_PC98_ARCH) {
extern uint16_t last_int16_code;
/* shift state is needed for some key combinations not directly supported by CON driver.
* bit 4 = CTRL
* bit 3 = GRPH/ALT
* bit 2 = kana
* bit 1 = caps
* bit 0 = SHIFT */
uint8_t shiftstate = mem_readb(0x52A + 0x0E);
/* NTS: PC-98 keyboards lack the US layout HOME / END keys, therefore there is no mapping here */
/* NTS: Since left arrow and backspace map to the same byte value, PC-98 treats it the same at the DOS prompt.
* However the PC-98 version of DOSKEY seems to be able to differentiate the two anyway and let the left
* arrow move the cursor back (perhaps it's calling INT 18h directly then?) */
if (c == 0x0B)
cr = 0x4800; /* IBM extended code up arrow */
else if (c == 0x0A)
cr = 0x5000; /* IBM extended code down arrow */
else if (c == 0x0C) {
if (shiftstate & 0x10/*CTRL*/)
cr = 0x7400; /* IBM extended code CTRL + right arrow */
else
cr = 0x4D00; /* IBM extended code right arrow */
}
else if (c == 0x08) {
/* IBM extended code left arrow OR backspace. use last scancode to tell which as DOSKEY apparently can. */
if (last_int16_code == 0x3B00) {
if (shiftstate & 0x10/*CTRL*/)
cr = 0x7300; /* CTRL + left arrow */
else
cr = 0x4B00; /* left arrow */
}
else {
cr = 0x08; /* backspace */
}
}
else if (c == 0x1B) { /* escape */
/* Either it really IS the ESC key, or an ANSI code */
if (last_int16_code != 0x001B) {
DOS_ReadFile(input_handle,&c,&n);
if (c == 0x44) // DEL
cr = 0x5300;
else if (c == 0x50) // INS
cr = 0x5200;
else if (c == 0x53) // F1
cr = 0x3B00;
else if (c == 0x54) // F2
cr = 0x3C00;
else if (c == 0x55) // F3
cr = 0x3D00;
else if (c == 0x56) // F4
cr = 0x3E00;
else if (c == 0x57) // F5
cr = 0x3F00;
else if (c == 0x45) // F6
cr = 0x4000;
else if (c == 0x4A) // F7
cr = 0x4100;
else if (c == 0x51) // F9
cr = 0x4300;
else if (c == 0x5A) // F10
cr = 0x4400;
else
cr = 0;
}
else {
cr = (uint16_t)c;
}
}
else {
cr = (uint16_t)c;
}
}
else {
if (c == 0) {
DOS_ReadFile(input_handle,&c,&n);
cr = (uint16_t)c << (uint16_t)8;
}
else {
cr = (uint16_t)c;
}
}
#if defined(USE_TTF)
if (ttf.inUse && rtl) {
if (cr == 0x4B00) cr = 0x4D00;
else if (cr == 0x4D00) cr = 0x4B00;
else if (cr == 0x7300) cr = 0x7400;
else if (cr == 0x7400) cr = 0x7300;
}
#endif
switch (cr) {
case 0x3d00: /* F3 */
if (!l_history.size()) break;
it_history = l_history.begin();
if (it_history != l_history.end() && it_history->length() > str_len) {
const char *reader = &(it_history->c_str())[str_len];
while ((c = (uint8_t)(*reader++))) {
line[str_index ++] = (char)c;
DOS_WriteFile(STDOUT,&c,&n);
}
str_len = str_index = (uint16_t)it_history->length();
size = (unsigned int)CMD_MAXLINE - str_index - 2u;
line[str_len] = 0;
}
break;
case 0x4B00: /* LEFT */
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
if (str_index) {
uint16_t count = GetLastCount(line, str_index);
uint8_t ch = line[str_index - 1];
while(count > 0) {
uint16_t wide = GetWideCount(line, str_index);
backone();
str_index --;
if (wide > count) str_index --;
count--;
}
if(CheckHat(ch)) {
backone();
}
}
} else {
if (isDBCSCP()
#if defined(USE_TTF)
&&dbcs_sbcs
#endif
&&str_index>1&&(line[str_index-1]<0||((dos.loaded_codepage==932||(dos.loaded_codepage==936&&gbk)||dos.loaded_codepage==950||dos.loaded_codepage==951)&&line[str_index-1]>=0x40))&&line[str_index-2]<0) {
backone();
str_index --;
MoveCaretBackwards();
}
if (str_index) {
backone();
str_index --;
MoveCaretBackwards();
}
}
break;
case 0x7400: /*CTRL + RIGHT : cmd.exe-like next word*/
{
auto pos = line + str_index;
auto spc = *pos == ' ';
const auto end = line + str_len;
while (pos < end) {
if (spc && *pos != ' ')
break;
if (*pos == ' ')
spc = true;
pos++;
}
const auto lgt = MIN(pos, end) - (line + str_index);
for (auto i = 0; i < lgt; i++)
outc(static_cast<uint8_t>(line[str_index++]));
}
break;
case 0x7300: /*CTRL + LEFT : cmd.exe-like previous word*/
{
auto pos = line + str_index - 1;
const auto beg = line;
const auto spc = *pos == ' ';
if (spc) {
while(*pos == ' ') pos--;
while(*pos != ' ') pos--;
pos++;
}
else {
while(*pos != ' ') pos--;
pos++;
}
const auto lgt = std::abs(MAX(pos, beg) - (line + str_index));
for (auto i = 0; i < lgt; i++) {
backone();
str_index--;
MoveCaretBackwards();
}
}
break;
case 0x4D00: /* RIGHT */
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
if (str_index < str_len) {
uint16_t count = 1;
if(str_index < str_len - 1) {
count = GetLastCount(line, str_index + 2);
}
while(count > 0) {
outc(line[str_index++]);
count--;
}
}
} else {
if (isDBCSCP()
#if defined(USE_TTF)
&&dbcs_sbcs
#endif
&&str_index<str_len-1&&line[str_index]<0&&(line[str_index+1]<0||((dos.loaded_codepage==932||(dos.loaded_codepage==936&&gbk)||dos.loaded_codepage==950||dos.loaded_codepage==951)&&line[str_index+1]>=0x40))) {
outc((uint8_t)line[str_index++]);
}
if (str_index < str_len) {
outc((uint8_t)line[str_index++]);
}
}
break;
case 0x4700: /* HOME */
while (str_index) {
backone();
str_index--;
}
break;
case 0x5200: /* INS */
if (IS_PC98_ARCH) { // INS state handled by IBM PC/AT BIOS, faked for PC-98 mode
extern bool pc98_doskey_insertmode;
// NTS: No visible change to the cursor, just like DOSKEY on PC-98 MS-DOS
pc98_doskey_insertmode = !pc98_doskey_insertmode;
}
break;
case 0x4F00: /* END */
while (str_index < str_len) {
outc((uint8_t)line[str_index++]);
}
break;
case 0x4800: /* UP */
if (l_history.empty() || it_history == l_history.end()) break;
// store current command in history if we are at beginning
if (it_history == l_history.begin() && !current_hist) {
current_hist=true;
l_history.emplace_front(line);
}
// ensure we're at end to handle all cases
while (str_index < str_len) {
outc((uint8_t)line[str_index++]);
}
for (;str_index>0; str_index--) {
// removes all characters
backone(); outc(' '); backone();
}
strcpy(line, it_history->c_str());
len = (uint16_t)it_history->length();
str_len = str_index = len;
size = (unsigned int)CMD_MAXLINE - str_index - 2u;
DOS_WriteFile(STDOUT, (uint8_t *)line, &len);
++it_history;
break;
case 0x5000: /* DOWN */
if (l_history.empty() || it_history == l_history.begin()) break;
// not very nice but works ..
--it_history;
if (it_history == l_history.begin()) {
// no previous commands in history
++it_history;
// remove current command from history
if (current_hist) {
current_hist=false;
l_history.pop_front();
}
break;
} else --it_history;
// ensure we're at end to handle all cases
while (str_index < str_len) {
outc((uint8_t)line[str_index++]);
}
for (;str_index>0; str_index--) {
// removes all characters
backone(); outc(' '); backone();
}
strcpy(line, it_history->c_str());
len = (uint16_t)it_history->length();
str_len = str_index = len;
size = (unsigned int)CMD_MAXLINE - str_index - 2u;
DOS_WriteFile(STDOUT, (uint8_t *)line, &len);
++it_history;
break;
case 0x5300:/* DELETE */
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
if(str_len) {
size += DeleteBackspace(true, line, str_index, str_len);
}
} else {
if(str_index>=str_len) break;
int k=1;
if (isDBCSCP()
#if defined(USE_TTF)
&&dbcs_sbcs
#endif
&&str_index<str_len-1&&line[str_index]<0&&(line[str_index+1]<0||((dos.loaded_codepage==932||(dos.loaded_codepage==936&&gbk)||dos.loaded_codepage==950||dos.loaded_codepage==951)&&line[str_index+1]>=0x40)))
k=2;
for (int i=0; i<k; i++) {
uint16_t a=str_len-str_index-1;
uint8_t* text=reinterpret_cast<uint8_t*>(&line[str_index+1]);
DOS_WriteFile(STDOUT,text,&a);//write buffer to screen
outc(' ');backone();
for(Bitu i=str_index;i<(str_len-1u);i++) {
line[i]=line[i+1u];
backone();
}
line[--str_len]=0;
size++;
}
}
break;
case 0x0F00: /* Shift-Tab */
if (!l_completion.size()) {
if (BuildCompletions(line, str_len))
it_completion = l_completion.end();
else
break;
}
if (l_completion.size()) {
if (it_completion == l_completion.begin()) it_completion = l_completion.end ();
--it_completion;
if (it_completion->length()) {
for (;str_index > completion_index; str_index--) {
// removes all characters
backone(); outc(' '); backone();
}
strcpy(&line[completion_index], it_completion->c_str());
len = (uint16_t)it_completion->length();
str_len = str_index = (Bitu)(completion_index + len);
size = (unsigned int)CMD_MAXLINE - str_index - 2u;
DOS_WriteFile(STDOUT, (uint8_t *)it_completion->c_str(), &len);
}
}
break;
case 0x08: /* BackSpace */
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
if(str_index) {
size += DeleteBackspace(false, line, str_index, str_len);
}
} else {
int k=1;
if (isDBCSCP()
#if defined(USE_TTF)
&&dbcs_sbcs
#endif
&&str_index>1&&(line[str_index-1]<0||((dos.loaded_codepage==932||(dos.loaded_codepage==936&&gbk)||dos.loaded_codepage==950||dos.loaded_codepage==951)&&line[str_index-1]>=0x40))&&line[str_index-2]<0)
k=2;
for (int i=0; i<k; i++)
if (str_index) {
backone();
uint32_t str_remain=(uint32_t)(str_len - str_index);
size++;
if (str_remain) {
memmove(&line[str_index-1],&line[str_index],str_remain);
line[--str_len]=0;
str_index --;
/* Go back to redraw */
for (uint16_t i=str_index; i < str_len; i++)
outc((uint8_t)line[i]);
} else {
line[--str_index] = '\0';
str_len--;
}
outc(' '); backone();
// moves the cursor left
while (str_remain--) backone();
}
}
if (l_completion.size()) l_completion.clear();
break;
case 0x0a: /* Give a new Line */
outc('\n');
break;
case '': // FAKE CTRL-C
*line = 0; // reset the line.
if (l_completion.size()) l_completion.clear(); //reset the completion list.
size = 0; // stop the next loop
str_len = 0; // prevent multiple adds of the same line
DOS_BreakFlag = false; // clear break flag so the next program doesn't get hit with it
DOS_BreakConioFlag = false;
break;
case 0x0d: /* Don't care, and return */
if(!echo) { outc('\r'); outc('\n'); }
size=0; //Kill the while loop
break;
case 0x9400: /* Ctrl-Tab */
{
if (!l_completion.size()) {
if (BuildCompletions(line, str_len))
it_completion = l_completion.begin();
else
break;
}
size_t w_count, p_count, col;
unsigned int max[15], total, tcols=IS_PC98_ARCH?80:real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
if (!tcols) tcols=80;
int mrow=tcols>80?15:10;
for (col=mrow; col>0; col--) {
for (int i=0; i<mrow; i++) max[i]=2;
if (col==1) break;
w_count=0;
for (std::list<std::string>::iterator source = l_completion.begin(); source != l_completion.end(); ++source) {
std::string name = source->c_str();
if (name.size()+2>max[w_count%col]) max[w_count%col]=(unsigned int)(name.size()+2);
++w_count;
}
total=0;
for (size_t i=0; i<col; i++) total+=max[i];
if (total<tcols) break;
}
w_count = p_count = 0;
bool lastcr=false;
if (l_completion.size()) {WriteOut_NoParsing("\n");lastcr=true;}
for (std::list<std::string>::iterator source = l_completion.begin(); source != l_completion.end(); ++source) {
std::string name = source->c_str();
if (col==1) {
WriteOut_NoParsing(name.c_str(), true);
WriteOut("\n");
lastcr=true;
p_count++;
} else {
WriteOut("%s%-*s", name.c_str(), max[w_count % col]-name.size(), "");
lastcr=false;
}
if (col>1) {
++w_count;
if (w_count % col == 0) {p_count++;WriteOut_NoParsing("\n");lastcr=true;}
}
size_t GetPauseCount();
if (p_count>GetPauseCount()) {
WriteOut(MSG_Get("SHELL_CMD_PAUSE"));
lastcr=false;
w_count = p_count = 0;
uint8_t c;uint16_t n=1;
DOS_ReadFile(STDIN,&c,&n);
if (c==3) {ctrlbrk=false;WriteOut("^C\r\n");break;}
if (c==0) DOS_ReadFile(STDIN,&c,&n);
}
}
if (l_completion.size()) {
if (!lastcr) WriteOut_NoParsing("\n");
ShowPrompt();
WriteOut("%s", line);
}
break;
}
case'\t':
if (l_completion.size()) {
++it_completion;
if (it_completion == l_completion.end()) it_completion = l_completion.begin();
} else if (BuildCompletions(line, str_len))
it_completion = l_completion.begin();
else
break;
if (l_completion.size() && it_completion->length()) {
for (;str_index > completion_index; str_index--) {
// removes all characters
backone(); outc(' '); backone();
}
strcpy(&line[completion_index], it_completion->c_str());
len = (uint16_t)it_completion->length();
str_len = str_index = (Bitu)(completion_index + len);
size = (unsigned int)CMD_MAXLINE - str_index - 2u;
DOS_WriteFile(STDOUT, (uint8_t *)it_completion->c_str(), &len);
}
break;
case 0x1b: /* ESC */
// NTS: According to real PC-98 DOS:
// If DOSKEY is loaded, ESC clears the prompt
// If DOSKEY is NOT loaded, ESC does nothing. In fact, after ESC,
// the next character input is thrown away before resuming normal keyboard input.
//
// DOSBox / DOSBox-X have always acted as if DOSKEY is loaded in a fashion, so
// we'll emulate the PC-98 DOSKEY behavior here.
//
// DOSKEY on PC-98 is able to clear the whole prompt and even bring the cursor
// back up to the first line if the input crosses multiple lines.
// NTS: According to real IBM/Microsoft PC/AT DOS:
// If DOSKEY is loaded, ESC clears the prompt
// If DOSKEY is NOT loaded, ESC prints a backslash and goes to the next line.
// The Windows 95 version of DOSKEY puts the cursor at a horizontal position
// that matches the DOS prompt (not emulated here).
//
// DOSBox / DOSBox-X have always acted as if DOSKEY is loaded in a fashion, so
// we'll emulate DOSKEY behavior here.
while (str_index < str_len) {
uint16_t count = 1, wide = 1;
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
count = GetLastCount(line, str_index+1);
wide = GetWideCount(line, str_index+1);
}
outc(' ');
str_index++;
if (wide > count) str_index ++;
}
while (str_index > 0) {
uint16_t count = 1, wide = 1;
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
count = GetLastCount(line, str_index);
wide = GetWideCount(line, str_index);
}
backone();
outc(' ');
backone();
MoveCaretBackwards();
str_index--;
if (wide > count) str_index --;
}
*line = 0; // reset the line.
if (l_completion.size()) l_completion.clear(); //reset the completion list.
str_index = 0;
str_len = 0;
break;
default:
if(IS_PC98_ARCH || (isDBCSCP()
#if defined(USE_TTF)
&& dbcs_sbcs
#endif
&& IS_DOS_JAPANESE)) {
bool kanji_flag = false;
uint16_t pos = str_index;
while(1) {
if (l_completion.size()) l_completion.clear();
if(str_index < str_len && true) {
for(Bitu i=str_len;i>str_index;i--) {
line[i]=line[i-1];
}
line[++str_len]=0;
size--;
}
line[str_index]=c;
str_index ++;
if (str_index > str_len) {
line[str_index] = '\0';
str_len++;
size--;
}
if(!isKanji1(c) || kanji_flag) {
break;
}
DOS_ReadFile(input_handle,&c,&n);
kanji_flag = true;
}
while(pos < str_len) {
outc(line[pos]);
pos++;
}
pos = GetRemoveCount(line, str_len);
while(pos > str_index) {
backone();
pos--;
if (CheckHat(line[pos])) {
backone();
}
}
} else {
if (cr >= 0x100) break;
if (l_completion.size()) l_completion.clear();
if(str_index < str_len && !INT10_GetInsertState()) { //mem_readb(BIOS_KEYBOARD_FLAGS1)&0x80) dev_con.h ?
outc(' ');//move cursor one to the right.
uint16_t a = str_len - str_index;
uint8_t* text=reinterpret_cast<uint8_t*>(&line[str_index]);
DOS_WriteFile(STDOUT,text,&a);//write buffer to screen
backone();//undo the cursor the right.
for(Bitu i=str_len;i>str_index;i--) {
line[i]=line[i-1]; //move internal buffer
backone(); //move cursor back (from write buffer to screen)
}
line[++str_len]=0;//new end (as the internal buffer moved one place to the right
size--;
}
line[str_index]=(char)(cr&0xFF);
str_index ++;
if (str_index > str_len){
line[str_index] = '\0';
str_len++;
size--;
}
DOS_WriteFile(STDOUT,&c,&n);
}
break;
}
}
inshell = false;
if (!str_len) return;
str_len++;
// remove current command from history if it's there
if (current_hist) {
// current_hist=false;
l_history.pop_front();
}
// add command line to history. Win95 behavior with DOSKey suggests
// that the original string is preserved, not the expanded string.
l_history.emplace_front(line); it_history = l_history.begin();
if (l_completion.size()) l_completion.clear();
/* DOS %variable% substitution */
ProcessCmdLineEnvVarStitution(line);
}
void XMS_DOS_LocalA20DisableIfNotEnabled(void);
/* Note: Buffer pointed to by "line" must be at least CMD_MAXLINE+1 bytes long! */
void DOS_Shell::ProcessCmdLineEnvVarStitution(char *line) {
// Wengier: Rewrote the code using regular expressions (a lot shorter)
// Tested by both myself and kcgen with various boundary cases
/* DOS7/Win95 testing:
*
* "%" = "%"
* "%%" = "%"
* "% %" = ""
* "% %" = ""
* "% % %" = " %"
*
* ^ WTF?
*
* So the below code has funny conditions to match Win95's weird rules on what
* consitutes valid or invalid %variable% names. */
/* continue scanning for the ending '%'. variable names are apparently meant to be
* alphanumeric, start with a letter, without spaces (if Windows 95 COMMAND.COM is
* any good example). If it doesn't end in '%' or is broken by space or starts with
* a number, substitution is not carried out. In the middle of the variable name
* it seems to be acceptable to use hyphens.
*
* since spaces break up a variable name to prevent substitution, these commands
* act differently from one another:
*
* C:\>echo %PATH%
* C:\DOS;C:\WINDOWS
*
* C:\>echo %PATH %
* %PATH % */
/* initial scan: is there anything to substitute? */
/* if not, then just return without modifying "line" */
/* not really needed but keep this code as is for now */
char *r=line;
while (*r != 0 && *r != '%') r++;
if (*r != '%') return;
/* if the incoming string is already too long, then that's a problem too! */
if (((size_t)(r+1-line)) >= CMD_MAXLINE) {
LOG_MSG("DOS_Shell::ProcessCmdLineEnvVarStitution WARNING incoming string to substitute is already too long!\n");
*line = 0; /* clear string (C-string chop with NUL) */
WriteOut("Command input error: string expansion overflow\n");
return;
}
// Begin the process of shell variable substitutions using regular expressions
// Variable names must start with non-digits. Space and special symbols like _ and ~ are apparently valid too (MS-DOS 7/Windows 9x).
constexpr char surrogate_percent = 8;
const static std::regex re("\\%([^%0-9][^%]*)?%");
bool isfor = !strncasecmp(ltrim(line),"FOR ",4);
char *p = isfor?strchr(line, '%'):NULL;
std::string text = p?p+1:line;
std::smatch match;
/* Iterate over potential %var1%, %var2%, etc matches found in the text string */
while (std::regex_search(text, match, re)) {
// Get the first matching %'s position and length
const auto percent_pos = static_cast<size_t>(match.position(0));
const auto percent_len = static_cast<size_t>(match.length(0));
std::string variable_name = match[1].str();
if (variable_name.empty()) {
/* Replace %% with the character "surrogate_percent", then (eventually) % */
text.replace(percent_pos, percent_len, std::string(1, surrogate_percent));
continue;
}
/* Trim preceding spaces from the variable name */
variable_name.erase(0, variable_name.find_first_not_of(' '));
std::string variable_value;
if (variable_name.size() && GetEnvStr(variable_name.c_str(), variable_value)) {
const size_t equal_pos = variable_value.find_first_of('=');
/* Replace the original %var% with its corresponding value from the environment */
const std::string replacement = equal_pos != std::string::npos ? variable_value.substr(equal_pos + 1) : "";
text.replace(percent_pos, percent_len, replacement);
} else
text.replace(percent_pos, percent_len, "");
}
std::replace(text.begin(), text.end(), surrogate_percent, '%');
if (p) {
*(p+1) = 0;
text = std::string(line) + text;
}
assert(text.size() <= CMD_MAXLINE);
strcpy(line, text.c_str());
}
int infix=-1;
std::string full_arguments = "";
bool dos_a20_disable_on_exec=false;
extern bool packerr, mountwarning, nowarn;
bool DOS_Shell::Execute(char* name, const char* args) {
/* return true => don't check for hardware changes in do_command
* return false => check for hardware changes in do_command */
char fullname[DOS_PATHLENGTH+4]; //stores results from Which
const char* p_fullname;
char line[CMD_MAXLINE];
if(strlen(args)!= 0){
if(*args != ' '){ //put a space in front
line[0]=' ';line[1]=0;
strncat(line,args,CMD_MAXLINE-2);
line[CMD_MAXLINE-1]=0;
}
else
{
safe_strncpy(line,args,CMD_MAXLINE);
}
}else{
line[0]=0;
}
const Section_prop* sec = static_cast<Section_prop*>(control->GetSection("dos"));
/* check for a drive change */
if (((strcmp(name + 1, ":") == 0) || (strcmp(name + 1, ":\\") == 0)) && isalpha(*name) && !control->SecureMode())
{
uint8_t c;uint16_t n;
if (strrchr_dbcs(name,'\\')) { WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),name); return true; }
if (!DOS_SetDrive(toupper(name[0])-'A')) {
#ifdef WIN32
if(!sec->Get_bool("automount")) { WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); return true; }
// automount: attempt direct letter to drive map.
int type=GetDriveType(name);
if(!mountwarning && type!=DRIVE_NO_ROOT_DIR) goto continue_1;
if(type==DRIVE_FIXED && (strcasecmp(name,"C:")==0)) WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_WIN"));
first_1:
if(type==DRIVE_CDROM) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_CDROM"),toupper(name[0]));
else if(type==DRIVE_REMOVABLE && (strcasecmp(name,"A:")==0||strcasecmp(name,"B:")==0)) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_FLOPPY"),toupper(name[0]));
else if(type==DRIVE_REMOVABLE) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_REMOVABLE"),toupper(name[0]));
else if(type==DRIVE_REMOTE) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_NETWORK"),toupper(name[0]));
else if(type==DRIVE_FIXED||type==DRIVE_RAMDISK||type==DRIVE_UNKNOWN) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_FIXED"),toupper(name[0]));
else { WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); return true; }
first_2:
n=1;
DOS_ReadFile (STDIN,&c,&n);
do switch (c) {
case 'n': case 'N':
{
DOS_WriteFile (STDOUT,&c, &n);
DOS_ReadFile (STDIN,&c,&n);
do switch (c) {
case 0xD: WriteOut("\n\n"); WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); return true;
case 0x3: return true;
case 0x8: WriteOut("\b \b"); goto first_2;
} while (DOS_ReadFile (STDIN,&c,&n));
}
case 'y': case 'Y':
{
DOS_WriteFile (STDOUT,&c, &n);
DOS_ReadFile (STDIN,&c,&n);
do switch (c) {
case 0xD: WriteOut("\n"); goto continue_1;
case 0x3: return true;
case 0x8: WriteOut("\b \b"); goto first_2;
} while (DOS_ReadFile (STDIN,&c,&n));
}
case 0x3: return true;
case 0xD: WriteOut("\n"); goto first_1;
case '\t': case 0x08: goto first_2;
default:
{
DOS_WriteFile (STDOUT,&c, &n);
DOS_ReadFile (STDIN,&c,&n);
do switch (c) {
case 0xD: WriteOut("\n");goto first_1;
case 0x3: return true;
case 0x8: WriteOut("\b \b"); goto first_2;
} while (DOS_ReadFile (STDIN,&c,&n));
goto first_2;
}
} while (DOS_ReadFile (STDIN,&c,&n));
continue_1:
char mountstring[DOS_PATHLENGTH+CROSS_LEN+20];
sprintf(mountstring,"MOUNT %s ",name);
if(type==DRIVE_CDROM) strcat(mountstring,"-t cdrom ");
else if(type==DRIVE_REMOVABLE && (strcasecmp(name,"A:")==0||strcasecmp(name,"B:")==0)) strcat(mountstring,"-t floppy ");
strcat(mountstring,name);
strcat(mountstring,"\\");
// if(GetDriveType(name)==5) strcat(mountstring," -ioctl");
nowarn=true;
this->ParseLine(mountstring);
nowarn=false;
//failed:
if (!DOS_SetDrive(toupper(name[0])-'A'))
#endif
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0]));
}
return true;
}
/* Check for a full name */
p_fullname = Which(name);
if (!p_fullname) return false;
strcpy(fullname,p_fullname);
std::string assoc = hasAssociation(fullname);
if (assoc.size()) {
noassoc=true;
DoCommand((char *)(assoc+" "+fullname).c_str());
noassoc=false;
return true;
}
const char* extension = strrchr(fullname,'.');
/*always disallow files without extension from being executed. */
/*only internal commands can be run this way and they never get in this handler */
if(extension == 0)
{
//Check if the result will fit in the parameters. Else abort
if(strlen(fullname) >( DOS_PATHLENGTH - 1) ) return false;
char temp_name[DOS_PATHLENGTH + 4];
const char* temp_fullname;
//try to add .com, .exe and .bat extensions to filename
strcpy(temp_name,fullname);
strcat(temp_name,".COM");
temp_fullname=Which(temp_name);
if (temp_fullname) { extension=".com";strcpy(fullname,temp_fullname); }
else
{
strcpy(temp_name,fullname);
strcat(temp_name,".EXE");
temp_fullname=Which(temp_name);
if (temp_fullname) { extension=".exe";strcpy(fullname,temp_fullname);}
else
{
strcpy(temp_name,fullname);
strcat(temp_name,".BAT");
temp_fullname=Which(temp_name);
if (temp_fullname) { extension=".bat";strcpy(fullname,temp_fullname);}
else
{
return false;
}
}
}
}
if (strcasecmp(extension, ".bat") == 0)
{ /* Run the .bat file */
/* delete old batch file if call is not active*/
bool temp_echo=echo; /*keep the current echostate (as delete bf might change it )*/
if(bf && !call) delete bf;
bf=new BatchFile(this,fullname,name,line);
echo=temp_echo; //restore it.
}
else
{ /* only .bat .exe .com extensions maybe be executed by the shell */
if(strcasecmp(extension, ".com") !=0)
{
if(strcasecmp(extension, ".exe") !=0) return false;
}
/* Run the .exe or .com file from the shell */
/* Allocate some stack space for tables in physical memory */
reg_sp-=0x200;
//Add Parameter block
DOS_ParamBlock block(SegPhys(ss)+reg_sp);
block.Clear();
//Add a filename
RealPt file_name=RealMakeSeg(ss,reg_sp+0x20);
MEM_BlockWrite(Real2Phys(file_name),fullname,(Bitu)(strlen(fullname)+1));
/* HACK: Store full commandline for mount and imgmount */
full_arguments.assign(line);
/* Fill the command line */
CommandTail cmdtail;
cmdtail.count = 0;
memset(&cmdtail.buffer,0,CTBUF); //Else some part of the string is unitialized (valgrind)
if (strlen(line)>=CTBUF) line[CTBUF-1]=0;
cmdtail.count=(uint8_t)strlen(line);
memcpy(cmdtail.buffer,line,strlen(line));
cmdtail.buffer[strlen(line)]=0xd;
/* Copy command line in stack block too */
MEM_BlockWrite(SegPhys(ss)+reg_sp+0x100,&cmdtail,CTBUF+1);
/* Split input line up into parameters, using a few special rules, most notable the one for /AAA => A\0AA
* Qbix: It is extremly messy, but this was the only way I could get things like /:aa and :/aa to work correctly */
//Prepare string first
char parseline[258] = { 0 };
for(char *pl = line,*q = parseline; *pl ;pl++,q++) {
if (*pl == '=' || *pl == ';' || *pl ==',' || *pl == '\t' || *pl == ' ') *q = 0; else *q = *pl; //Replace command seperators with 0.
} //No end of string \0 needed as parseline is larger than line
for(char* p = parseline; (p-parseline) < 250 ;p++) { //Stay relaxed within boundaries as we have plenty of room
if (*p == '/') { //Transform /Hello into H\0ello
*p = 0;
p++;
while ( *p == 0 && (p-parseline) < 250) p++; //Skip empty fields
if ((p-parseline) < 250) { //Found something. Lets get the first letter and break it up
p++;
memmove(static_cast<void*>(p + 1),static_cast<void*>(p),(250u-(unsigned int)(p-parseline)));
if ((p-parseline) < 250) *p = 0;
}
}
}
parseline[255] = parseline[256] = parseline[257] = 0; //Just to be safe.
/* Parse FCB (first two parameters) and put them into the current DOS_PSP */
uint8_t add;
uint16_t skip = 0;
//find first argument, we end up at parseline[256] if there is only one argument (similar for the second), which exists and is 0.
while(skip < 256 && parseline[skip] == 0) skip++;
FCB_Parsename(dos.psp(),0x5C,0x01,parseline + skip,&add);
skip += add;
//Move to next argument if it exists
while(parseline[skip] != 0) skip++; //This is safe as there is always a 0 in parseline at the end.
while(skip < 256 && parseline[skip] == 0) skip++; //Which is higher than 256
FCB_Parsename(dos.psp(),0x6C,0x01,parseline + skip,&add);
block.exec.fcb1=RealMake(dos.psp(),0x5C);
block.exec.fcb2=RealMake(dos.psp(),0x6C);
/* Set the command line in the block and save it */
block.exec.cmdtail=RealMakeSeg(ss,reg_sp+0x100);
block.SaveData();
#if 0
/* Save CS:IP to some point where i can return them from */
uint32_t oldeip=reg_eip;
uint16_t oldcs=SegValue(cs);
RealPt newcsip=CALLBACK_RealPointer(call_shellstop);
SegSet16(cs,RealSeg(newcsip));
reg_ip=RealOff(newcsip);
#endif
packerr=false;
/* Start up a dos execute interrupt */
reg_ax=0x4b00;
//Filename pointer
SegSet16(ds,SegValue(ss));
reg_dx=RealOff(file_name);
//Paramblock
SegSet16(es,SegValue(ss));
reg_bx=reg_sp;
SETFLAGBIT(IF,false);
CALLBACK_RunRealInt(0x21);
/* Restore CS:IP and the stack */
reg_sp+=0x200;
#if 0
reg_eip=oldeip;
SegSet16(cs,oldcs);
#endif
if (packerr&&infix<0&&sec->Get_bool("autoa20fix")) {
LOG(LOG_DOSMISC,LOG_DEBUG)("Attempting autoa20fix workaround for EXEPACK error");
if (autofixwarn==1||autofixwarn==3) WriteOut("\r\n\033[41;1m\033[1;37;1mDOSBox-X\033[0m Failed to load the executable\r\n\033[41;1m\033[37;1mDOSBox-X\033[0m Now try again with A20 fix...\r\n");
infix=0;
dos_a20_disable_on_exec=true;
Execute(name, args);
dos_a20_disable_on_exec=false;
infix=-1;
} else if (packerr&&infix<1&&sec->Get_bool("autoloadfix")) {
uint16_t segment;
uint16_t blocks = (uint16_t)(1); /* start with one paragraph, resize up later. see if it comes up below the 64KB mark */
if (DOS_AllocateMemory(&segment,&blocks)) {
DOS_MCB mcb((uint16_t)(segment-1));
if (segment < 0x1000) {
uint16_t needed = 0x1000 - segment;
DOS_ResizeMemory(segment,&needed);
}
mcb.SetPSPSeg(0x40); /* FIXME: Wouldn't 0x08, a magic value used to show ownership by MS-DOS, be more appropriate here? */
LOG(LOG_DOSMISC,LOG_DEBUG)("Attempting autoloadfix workaround for EXEPACK error");
if (autofixwarn==2||autofixwarn==3) WriteOut("\r\n\033[41;1m\033[1;37;1mDOSBox-X\033[0m Failed to load the executable\r\n\033[41;1m\033[37;1mDOSBox-X\033[0m Now try again with LOADFIX...\r\n");
infix=1;
Execute(name, args);
infix=-1;
DOS_FreeMemory(segment);
}
} else if (packerr&&infix<2&&!autofixwarn) {
WriteOut("Packed file is corrupt");
}
packerr=false;
}
return true; //Executable started
}
static const char * bat_ext=".BAT";
static const char * com_ext=".COM";
static const char * exe_ext=".EXE";
static char which_ret[DOS_PATHLENGTH+4], s_ret[DOS_PATHLENGTH+4];
extern bool wild_match(const char *haystack, char *needle);
static std::string assocs = "";
std::string DOS_Shell::hasAssociation(const char* name) {
if (noassoc) {
assocs = "";
return assocs;
}
std::string extension = strrchr(name, '.') ? strrchr(name, '.') : ".";
cmd_assoc_map_t::iterator iter = cmd_assoc.find(extension.c_str());
if (iter != cmd_assoc.end()) {
assocs = strcasecmp(extension.c_str(), iter->second.c_str()) ? iter->second : "";
return assocs;
}
std::transform(extension.begin(), extension.end(), extension.begin(), ::toupper);
for (cmd_assoc_map_t::iterator iter = cmd_assoc.begin(); iter != cmd_assoc.end(); ++iter) {
std::string ext = iter->first;
if (ext.find('*')==std::string::npos && ext.find('?')==std::string::npos) continue;
std::transform(ext.begin(), ext.end(), ext.begin(), ::toupper);
if (wild_match(extension.c_str(), (char *)ext.c_str())) {
assocs = strcasecmp(extension.c_str(), iter->second.c_str()) ? iter->second : "";
return assocs;
}
}
assocs = "";
return assocs;
}
bool DOS_Shell::hasExecutableExtension(const char* name) {
auto extension = strrchr(name, '.');
if (!extension) return false;
return (!strcasecmp(extension, com_ext) || !strcasecmp(extension, exe_ext) || !strcasecmp(extension, bat_ext));
}
char * DOS_Shell::Which(char * name) {
size_t name_len = strlen(name);
if(name_len >= DOS_PATHLENGTH) return 0;
/* Parse through the Path to find the correct entry */
/* Check if name is already ok but just misses an extension */
std::string upname = name;
std::transform(upname.begin(), upname.end(), upname.begin(), ::toupper);
if (hasAssociation(name).size() && DOS_FileExists(name))
return name;
else if (hasAssociation(name).size() && DOS_FileExists(upname.c_str())) {
strcpy(name, upname.c_str());
return name;
} else if (hasExecutableExtension(name)) {
if (DOS_FileExists(name)) return name;
strcpy(name, upname.c_str());
if (DOS_FileExists(name)) return name;
} else {
/* try to find .com .exe .bat */
strcpy(which_ret,name);
strcat(which_ret,com_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,name);
strcat(which_ret,exe_ext);
if (DOS_FileExists(which_ret)) return which_ret;
strcpy(which_ret,name);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return which_ret;
}
/* No Path in filename look through path environment string */
char path[DOS_PATHLENGTH];std::string temp;
if (!GetEnvStr("PATH",temp)) return 0;
const char * pathenv=temp.c_str();
if (!pathenv) return 0;
pathenv = strchr(pathenv,'=');
if (!pathenv) return 0;
pathenv++;
while (*pathenv) {
/* remove ; and ;; at the beginning. (and from the second entry etc) */
while(*pathenv == ';')
pathenv++;
/* get next entry */
Bitu i_path = 0; /* reset writer */
while(*pathenv && (*pathenv !=';') && (i_path < DOS_PATHLENGTH) )
path[i_path++] = *pathenv++;
if(i_path == DOS_PATHLENGTH) {
/* If max size. move till next ; and terminate path */
while(*pathenv && (*pathenv != ';'))
pathenv++;
path[DOS_PATHLENGTH - 1] = 0;
} else path[i_path] = 0;
int k=0;
for (int i=0;i<(int)strlen(path);i++)
if (path[i]!='\"')
path[k++]=path[i];
path[k]=0;
/* check entry */
if(size_t len = strlen(path)){
if(len >= (DOS_PATHLENGTH - 2)) continue;
if (uselfn&&len>3) {
if (path[len - 1]=='\\') path[len - 1]=0;
if (DOS_GetSFNPath(("\""+std::string(path)+"\"").c_str(), s_ret, false))
strcpy(path, s_ret);
len = strlen(path);
}
if(path[len - 1] != '\\') {
strcat(path,"\\");
len++;
}
//If name too long =>next
if((name_len + len + 1) >= DOS_PATHLENGTH) continue;
strcat(path,strchr(name, ' ')?("\""+std::string(name)+"\"").c_str():name);
if (hasAssociation(path).size() && DOS_FileExists(path)) {
strcpy(which_ret,path);
return strchr(which_ret, '\"')&&DOS_GetSFNPath(which_ret, s_ret, false)?s_ret:which_ret;
} else if (hasExecutableExtension(path)) {
strcpy(which_ret,path);
if (DOS_FileExists(which_ret)) return strchr(which_ret, '\"')&&DOS_GetSFNPath(which_ret, s_ret, false)?s_ret:which_ret;
} else {
strcpy(which_ret,path);
strcat(which_ret,com_ext);
if (DOS_FileExists(which_ret)) return strchr(which_ret, '\"')&&DOS_GetSFNPath(which_ret, s_ret, false)?s_ret:which_ret;
strcpy(which_ret,path);
strcat(which_ret,exe_ext);
if (DOS_FileExists(which_ret)) return strchr(which_ret, '\"')&&DOS_GetSFNPath(which_ret, s_ret, false)?s_ret:which_ret;
strcpy(which_ret,path);
strcat(which_ret,bat_ext);
if (DOS_FileExists(which_ret)) return strchr(which_ret, '\"')&&DOS_GetSFNPath(which_ret, s_ret, false)?s_ret:which_ret;
}
}
}
return 0;
}
| 36.853222
| 230
| 0.531862
|
mediaexplorer74
|
9a88cd7485d9be176cfdf7a7b72b2ff0da28b238
| 11,274
|
hpp
|
C++
|
ESMF/src/Infrastructure/Mesh/src/Moab/SweptElementData.hpp
|
joeylamcy/gchp
|
0e1676300fc91000ecb43539cabf1f342d718fb3
|
[
"NCSA",
"Apache-2.0",
"MIT"
] | 1
|
2018-07-05T16:48:58.000Z
|
2018-07-05T16:48:58.000Z
|
ESMF/src/Infrastructure/Mesh/src/Moab/SweptElementData.hpp
|
joeylamcy/gchp
|
0e1676300fc91000ecb43539cabf1f342d718fb3
|
[
"NCSA",
"Apache-2.0",
"MIT"
] | 1
|
2022-03-04T16:12:02.000Z
|
2022-03-04T16:12:02.000Z
|
ESMF/src/Infrastructure/Mesh/src/Moab/SweptElementData.hpp
|
joeylamcy/gchp
|
0e1676300fc91000ecb43539cabf1f342d718fb3
|
[
"NCSA",
"Apache-2.0",
"MIT"
] | null | null | null |
/**
* MOAB, a Mesh-Oriented datABase, is a software component for creating,
* storing and accessing finite element mesh data.
*
* Copyright 2004 Sandia Corporation. Under the terms of Contract
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
* retains certain rights in this software.
*
* 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; either
* version 2.1 of the License, or (at your option) any later version.
*
*/
#ifndef SWEPT_ELEMENT_DATA_HPP
#define SWEPT_ELEMENT_DATA_HPP
//
// Class: SweptElementData
//
// Purpose: represent a rectangular element of mesh
//
// A SweptElement represents a rectangular element of mesh, including both vertices and
// elements, and the parametric space used to address that element. Vertex data,
// i.e. coordinates, may not be stored directly in the element, but the element returns
// information about the vertex handles of vertices in the element. Vertex and element
// handles associated with the element are each contiguous.
#include "SequenceData.hpp"
#include "moab/HomXform.hpp"
#include "moab/CN.hpp"
#include "SweptVertexData.hpp"
#include "Internals.hpp"
#include "moab/Range.hpp"
#include <vector>
#include <algorithm>
namespace moab {
class SweptElementData : public SequenceData
{
//! structure to hold references to bounding vertex blocks
class VertexDataRef
{
private:
HomCoord minmax[2];
HomXform xform, invXform;
SweptVertexData *srcSeq;
public:
friend class SweptElementData;
VertexDataRef(const HomCoord &min, const HomCoord &max,
const HomXform &tmp_xform, SweptVertexData *this_seq);
bool contains(const HomCoord &coords) const;
};
private:
//! parameter min/max/stride, in homogeneous coords ijkh
HomCoord elementParams[3];
//! difference between max and min params plus one (i.e. # VERTICES in
//! each parametric direction)
int dIJK[3];
//! difference between max and min params (i.e. # ELEMENTS in
//! each parametric direction)
int dIJKm1[3];
//! bare constructor, so compiler doesn't create one for me
SweptElementData();
//! list of bounding vertex blocks
std::vector<VertexDataRef> vertexSeqRefs;
public:
//! constructor
SweptElementData( EntityHandle start_handle,
const int imin, const int jmin, const int kmin,
const int imax, const int jmax, const int kmax,
const int* Cq );
virtual ~SweptElementData();
//! get handle of vertex at homogeneous coords
inline EntityHandle get_vertex(const HomCoord &coords) const;
inline EntityHandle get_vertex(int i, int j, int k) const
{ return get_vertex(HomCoord(i,j,k)); }
//! get handle of element at i, j, k
EntityHandle get_element(const int i, const int j, const int k) const;
//! get min params for this element
const HomCoord &min_params() const;
//! get max params for this element
const HomCoord &max_params() const;
//! get the number of vertices in each direction, inclusive
void param_extents(int &di, int &dj, int &dk) const;
//! given a handle, get the corresponding parameters
ErrorCode get_params(const EntityHandle ehandle,
int &i, int &j, int &k) const;
//! convenience functions for parameter extents
int i_min() const {return (elementParams[0].hom_coord())[0];}
int j_min() const {return (elementParams[0].hom_coord())[1];}
int k_min() const {return (elementParams[0].hom_coord())[2];}
int i_max() const {return (elementParams[1].hom_coord())[0];}
int j_max() const {return (elementParams[1].hom_coord())[1];}
int k_max() const {return (elementParams[1].hom_coord())[2];}
//! test the bounding vertex sequences and determine whether they fully
//! define the vertices covering this element block's parameter space
bool boundary_complete() const;
//! test whether this sequence contains these parameters
inline bool contains(const HomCoord &coords) const;
//! get connectivity of an entity given entity's parameters
inline ErrorCode get_params_connectivity(const int i, const int j, const int k,
std::vector<EntityHandle>& connectivity) const;
//! add a vertex seq ref to this element sequence;
//! if bb_input is true, bounding box (in eseq-local coords) of vseq being added
//! is input in bb_min and bb_max (allows partial sharing of vseq rather than the whole
//! vseq); if it's false, the whole vseq is referenced and the eseq-local coordinates
//! is computed from the transformed bounding box of the vseq
ErrorCode add_vsequence(SweptVertexData *vseq,
const HomCoord &p1, const HomCoord &q1,
const HomCoord &p2, const HomCoord &q2,
const HomCoord &p3, const HomCoord &q3,
bool bb_input = false,
const HomCoord &bb_min = HomCoord::unitv[0],
const HomCoord &bb_max = HomCoord::unitv[0]);
SequenceData* subset( EntityHandle start,
EntityHandle end,
const int* sequence_data_sizes,
const int* tag_data_sizes ) const;
static EntityID calc_num_entities( EntityHandle start_handle,
int irange,
int jrange,
int krange );
unsigned long get_memory_use() const;
};
inline EntityHandle SweptElementData::get_element(const int i, const int j, const int k) const
{
return start_handle() + (i-i_min()) + (j-j_min())*dIJKm1[0] + (k-k_min())*dIJKm1[0]*dIJKm1[1];
}
inline const HomCoord &SweptElementData::min_params() const
{
return elementParams[0];
}
inline const HomCoord &SweptElementData::max_params() const
{
return elementParams[1];
}
//! get the number of vertices in each direction, inclusive
inline void SweptElementData::param_extents(int &di, int &dj, int &dk) const
{
di = dIJK[0];
dj = dIJK[1];
dk = dIJK[2];
}
inline ErrorCode SweptElementData::get_params(const EntityHandle ehandle,
int &i, int &j, int &k) const
{
if (TYPE_FROM_HANDLE(ehandle) != TYPE_FROM_HANDLE(start_handle())) return MB_FAILURE;
int hdiff = ehandle - start_handle();
// use double ?: test below because on some platforms, both sides of the : are
// evaluated, and if dIJKm1[1] is zero, that'll generate a divide-by-zero
k = (dIJKm1[1] > 0 ? hdiff / (dIJKm1[1] > 0 ? dIJKm1[0]*dIJKm1[1] : 1) : 0);
j = (hdiff - (k*dIJKm1[0]*dIJKm1[1])) / dIJKm1[0];
i = hdiff % dIJKm1[0];
k += elementParams[0].k();
j += elementParams[0].j();
i += elementParams[0].i();
return (ehandle >= start_handle() &&
ehandle < start_handle()+size() &&
i >= i_min() && i <= i_max() &&
j >= j_min() && j <= j_max() &&
k >= k_min() && k <= k_max()) ? MB_SUCCESS : MB_FAILURE;
}
inline bool SweptElementData::contains(const HomCoord &temp) const
{
// upper bound is < instead of <= because element params max is one less
// than vertex params max
return (temp >= elementParams[0] && temp < elementParams[1]);
}
inline bool SweptElementData::VertexDataRef::contains(const HomCoord &coords) const
{
return (minmax[0] <= coords && minmax[1] >= coords);
}
inline SweptElementData::VertexDataRef::VertexDataRef(const HomCoord &this_min, const HomCoord &this_max,
const HomXform &tmp_xform, SweptVertexData *this_seq)
: xform(tmp_xform), invXform(tmp_xform.inverse()), srcSeq(this_seq)
{
minmax[0] = HomCoord(this_min);
minmax[1] = HomCoord(this_max);
}
inline EntityHandle SweptElementData::get_vertex(const HomCoord &coords) const
{
assert(boundary_complete());
for (std::vector<VertexDataRef>::const_iterator it = vertexSeqRefs.begin();
it != vertexSeqRefs.end(); ++it) {
if ((*it).minmax[0] <= coords && (*it).minmax[1] >= coords) {
// first get the vertex block-local parameters
HomCoord local_coords = coords / (*it).xform;
// now get the vertex handle for those coords
return (*it).srcSeq->get_vertex(local_coords);
}
}
// got here, it's an error
return 0;
}
inline ErrorCode SweptElementData::add_vsequence(SweptVertexData *vseq,
const HomCoord &p1, const HomCoord &q1,
const HomCoord &p2, const HomCoord &q2,
const HomCoord &p3, const HomCoord &q3,
bool bb_input,
const HomCoord &bb_min,
const HomCoord &bb_max)
{
// compute the transform given the vseq-local parameters and the mapping to
// this element sequence's parameters passed in minmax
HomXform M;
M.three_pt_xform(p1, q1, p2, q2, p3, q3);
// min and max in element seq's parameter system may not be same as those in
// vseq's system, so need to take min/max
HomCoord minmax[2];
if (bb_input) {
minmax[0] = bb_min;
minmax[1] = bb_max;
}
else {
minmax[0] = vseq->min_params() * M;
minmax[1] = vseq->max_params() * M;
}
// check against other vseq's to make sure they don't overlap
for (std::vector<VertexDataRef>::const_iterator vsit = vertexSeqRefs.begin();
vsit != vertexSeqRefs.end(); ++vsit)
if ((*vsit).contains(minmax[0]) || (*vsit).contains(minmax[1]))
return MB_FAILURE;
HomCoord tmp_min(std::min(minmax[0].i(), minmax[1].i()),
std::min(minmax[0].j(), minmax[1].j()),
std::min(minmax[0].k(), minmax[1].k()));
HomCoord tmp_max(std::max(minmax[0].i(), minmax[1].i()),
std::max(minmax[0].j(), minmax[1].j()),
std::max(minmax[0].k(), minmax[1].k()));
// set up a new vertex sequence reference
VertexDataRef tmp_seq_ref(tmp_min, tmp_max, M, vseq);
// add to the list
vertexSeqRefs.push_back(tmp_seq_ref);
return MB_SUCCESS;
}
inline ErrorCode SweptElementData::get_params_connectivity(const int i, const int j, const int k,
std::vector<EntityHandle>& connectivity) const
{
if (contains(HomCoord(i, j, k)) == false) return MB_FAILURE;
connectivity.push_back(get_vertex(i, j, k));
connectivity.push_back(get_vertex(i+1, j, k));
if (CN::Dimension(TYPE_FROM_HANDLE(start_handle())) < 2) return MB_SUCCESS;
connectivity.push_back(get_vertex(i+1, j+1, k));
connectivity.push_back(get_vertex(i, j+1, k));
if (CN::Dimension(TYPE_FROM_HANDLE(start_handle())) < 3) return MB_SUCCESS;
connectivity.push_back(get_vertex(i, j, k+1));
connectivity.push_back(get_vertex(i+1, j, k+1));
connectivity.push_back(get_vertex(i+1, j+1, k+1));
connectivity.push_back(get_vertex(i, j+1, k+1));
return MB_SUCCESS;
}
} // namespace moab
#endif
| 36.134615
| 105
| 0.638283
|
joeylamcy
|
893c71e6fee5711ebd8b2e222cd3c594e69455d9
| 1,925
|
cpp
|
C++
|
firmware/examples/PinConfigure/source/main.cpp
|
2721Aperez/SJSU-Dev2
|
87052080d2754803dbd1dae2864bd9024d123086
|
[
"Apache-2.0"
] | 1
|
2018-07-07T01:41:34.000Z
|
2018-07-07T01:41:34.000Z
|
firmware/examples/PinConfigure/source/main.cpp
|
2721Aperez/SJSU-Dev2
|
87052080d2754803dbd1dae2864bd9024d123086
|
[
"Apache-2.0"
] | null | null | null |
firmware/examples/PinConfigure/source/main.cpp
|
2721Aperez/SJSU-Dev2
|
87052080d2754803dbd1dae2864bd9024d123086
|
[
"Apache-2.0"
] | 1
|
2018-09-19T01:58:48.000Z
|
2018-09-19T01:58:48.000Z
|
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include "config.hpp"
#include "L0_LowLevel/LPC40xx.h"
#include "L1_Drivers/pin_configure.hpp"
#include "L2_Utilities/debug_print.hpp"
int main(void)
{
// This application assumes that all pins are set to function 0 (GPIO)
DEBUG_PRINT("Pin Configure Application Starting...");
// Using constructor directly to constuct PinConfigure object
// This is discouraged, since this constructor does not perform any compile
// time checks on the port or pin value
PinConfigure p0_0(0, 7);
p0_0.SetPinMode(PinConfigureInterface::PinMode::kInactive);
DEBUG_PRINT("Disabling both pull up and down resistors for P0.0...");
// Prefered option of constructing PinConfigure, since this factory call is
// done in compile time and will perform compile time validation on the port
// and pin template parameters.
PinConfigure p1_24 = PinConfigure::CreatePinConfigure<1, 24>();
p1_24.SetPinMode(PinConfigureInterface::PinMode::kPullDown);
DEBUG_PRINT("Enabling P1.24 pull down resistor...");
PinConfigure p2_0 = PinConfigure::CreatePinConfigure<2, 0>();
p2_0.SetPinMode(PinConfigureInterface::PinMode::kPullUp);
DEBUG_PRINT("Enabling P2.0 pull up resistor...");
PinConfigure p4_28 = PinConfigure::CreatePinConfigure<4, 29>();
p4_28.SetPinMode(PinConfigureInterface::PinMode::kRepeater);
DEBUG_PRINT("Setting P4.29 to repeater mode...");
DEBUG_PRINT(
"Use some jumpers and a multimeter to test each pin to see if the "
"internal pull up and pull down resistors are working.");
DEBUG_PRINT(
"Use a jumper and resistor to pull P4.28 high or low. If you check the "
"pin with a multimeter you will see that the pin retains the previous "
"input value.");
DEBUG_PRINT("Halting any action.");
while (1) { continue; }
return 0;
}
| 40.104167
| 80
| 0.714805
|
2721Aperez
|
893dfb6e98893ed83575b82458c15e8f2a1ae6a6
| 3,405
|
cpp
|
C++
|
Source/Components/MenuComponent.cpp
|
Aavu/MIDI-Editor
|
4991beec683e75d5867117230dcafb2709192c81
|
[
"MIT"
] | 5
|
2020-06-06T02:14:00.000Z
|
2020-12-03T12:54:57.000Z
|
Source/Components/MenuComponent.cpp
|
Aavu/MIDI-Editor
|
4991beec683e75d5867117230dcafb2709192c81
|
[
"MIT"
] | 9
|
2020-03-28T22:26:10.000Z
|
2020-04-29T04:55:08.000Z
|
Source/Components/MenuComponent.cpp
|
Aavu/MIDI-Editor
|
4991beec683e75d5867117230dcafb2709192c81
|
[
"MIT"
] | 1
|
2020-12-01T22:42:48.000Z
|
2020-12-01T22:42:48.000Z
|
/*
==============================================================================
MenuComponent.cpp
Created: 12 Jan 2020 12:28:18pm
Author: Raghavasimhan Sankaranarayanan
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
#include "MenuComponent.h"
//==============================================================================
MenuComponent::MenuComponent()
{
// In your constructor, you should add any child components, and
// initialise any special settings that your component needs.
menuBar.reset(new MenuBarComponent(this));
addAndMakeVisible(menuBar.get());
setApplicationCommandManagerToWatch(&commandManager);
commandManager.registerAllCommandsForTarget(this);
addKeyListener(commandManager.getKeyMappings());
// addAndMakeVisible(editCommandTarget);
MenuBarModel::setMacMainMenu(this);
commandManager.setFirstCommandTarget(this);
}
MenuComponent::~MenuComponent()
{
MenuBarModel::setMacMainMenu(nullptr);
}
void MenuComponent::setPlayer(std::shared_ptr<PlayerComponent> player) {
m_pPlayer = std::move(player);
}
void MenuComponent::paint (Graphics& g) {}
void MenuComponent::resized() {}
StringArray MenuComponent::getMenuBarNames() {
return {"File"};
}
PopupMenu MenuComponent::getMenuForIndex(int menuIndex, const String& name) {
PopupMenu menu;
if (menuIndex == 0) {
menu.addCommandItem(&commandManager, fileOpen);
menu.addCommandItem(&commandManager, fileExportAudio);
// menu.addCommandItem(&commandManager, fileExportMIDI);
}
// else if (menuIndex == 1) {
// menu.addCommandItem(&commandManager, helpDocumentation);
// }
return menu;
}
ApplicationCommandTarget* MenuComponent::getNextCommandTarget() {
return nullptr;
}
void MenuComponent::getAllCommands (Array<CommandID>& c) {
Array<CommandID> commands { fileOpen, fileExportAudio };
c.addArray (commands);
}
void MenuComponent::getCommandInfo (CommandID commandID, ApplicationCommandInfo& result)
{
switch (commandID)
{
case fileOpen:
result.setInfo ("Open", "Open MIDI file", "File", 0);
result.addDefaultKeypress ('i', ModifierKeys::commandModifier);
break;
case fileExportAudio:
result.setInfo ("Export Audio", "Export Audio", "File", 0);
result.addDefaultKeypress ('b', ModifierKeys::commandModifier);
if (m_pPlayer)
result.setActive(m_pPlayer->isSequenceLoaded());
else
result.setActive(false);
break;
// case fileExportMIDI:
// result.setInfo ("Export MIDI", "Export MIDI", "File", 0);
// result.addDefaultKeypress ('b', ModifierKeys::shiftModifier | ModifierKeys::commandModifier);
// break;
default:
break;
}
}
void MenuComponent::menuItemSelected (int /*menuItemID*/, int /*topLevelMenuIndex*/) {}
bool MenuComponent::perform (const InvocationInfo& info)
{
return callbackFunc(static_cast<CommandIDs>(info.commandID));
}
void MenuComponent::setCallback(cbfunc func) {
callbackFunc = func;
}
void MenuComponent::actionListenerCallback (const String& message) {
if (message == Globals::ActionMessage::EnableTransport) {
commandManager.commandStatusChanged();
}
}
| 31.238532
| 107
| 0.636417
|
Aavu
|
893f27dd8c8dd25c02eaa7feec68cd3029314d8b
| 3,408
|
cpp
|
C++
|
src/apps/patchbay/MidiEventMeter.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 1,338
|
2015-01-03T20:06:56.000Z
|
2022-03-26T13:49:54.000Z
|
src/apps/patchbay/MidiEventMeter.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 15
|
2015-01-17T22:19:32.000Z
|
2021-12-20T12:35:00.000Z
|
src/apps/patchbay/MidiEventMeter.cpp
|
Kirishikesan/haiku
|
835565c55830f2dab01e6e332cc7e2d9c015b51e
|
[
"MIT"
] | 350
|
2015-01-08T14:15:27.000Z
|
2022-03-21T18:14:35.000Z
|
/* MidiEventMeter.cpp
* ------------------
* Implements the MidiEventMeter class.
*
* Copyright 2013, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Revisions by Pete Goodeve
*
* Copyright 1999, Be Incorporated. All Rights Reserved.
* This file may be used under the terms of the Be Sample Code License.
*/
#include "MidiEventMeter.h"
#include <stdio.h>
#include <MidiRoster.h>
#include <MidiProducer.h>
#include <MidiConsumer.h>
#include <View.h>
#include "CountEventConsumer.h"
static const BRect METER_BOUNDS(0, 0, 7, 31);
// If we get this number of events per pulse or greater, we will
// max out the event meter.
// Value was determined empirically based on my banging on a MIDI
// keyboard controller with a pulse of 200ms.
static const int32 METER_SCALE = 10;
MidiEventMeter::MidiEventMeter(int32 producerID)
:
fCounter(NULL),
fMeterLevel(0)
{
BMidiRoster* roster = BMidiRoster::MidiRoster();
if (roster != NULL) {
BMidiProducer* producer = roster->FindProducer(producerID);
if (producer != NULL) {
BString name;
name << producer->Name() << " Event Meter";
fCounter = new CountEventConsumer(name.String());
producer->Connect(fCounter);
producer->Release();
}
}
}
MidiEventMeter::~MidiEventMeter()
{
if (fCounter != NULL)
fCounter->Release();
}
void
MidiEventMeter::Pulse(BView* view)
{
int32 newLevel = fMeterLevel;
if (fCounter != NULL) {
newLevel = CalcMeterLevel(fCounter->CountEvents());
fCounter->Reset();
}
if (newLevel != fMeterLevel) {
fMeterLevel = newLevel;
view->Invalidate(BRect(METER_BOUNDS).InsetBySelf(1, 1));
}
}
BRect
MidiEventMeter::Bounds() const
{
return METER_BOUNDS;
}
void
MidiEventMeter::Draw(BView* view)
{
const rgb_color METER_BLACK = { 0, 0, 0, 255 };
const rgb_color METER_GREY = { 180, 180, 180, 255 };
const rgb_color METER_GREEN = { 0, 255, 0, 255 };
view->PushState();
// draw the frame
BPoint lt = METER_BOUNDS.LeftTop();
BPoint rb = METER_BOUNDS.RightBottom();
view->BeginLineArray(4);
view->AddLine(BPoint(lt.x, lt.y), BPoint(rb.x - 1, lt.y), METER_BLACK);
view->AddLine(BPoint(rb.x, lt.y), BPoint(rb.x, rb.y - 1), METER_BLACK);
view->AddLine(BPoint(rb.x, rb.y), BPoint(lt.x + 1, rb.y), METER_BLACK);
view->AddLine(BPoint(lt.x, rb.y), BPoint(lt.x, lt.y + 1), METER_BLACK);
view->EndLineArray();
// draw the cells
BRect cell = METER_BOUNDS;
cell.InsetBy(1, 1);
cell.bottom = cell.top + (cell.Height() + 1) / 5;
cell.bottom--;
const float kTintArray[] =
{B_DARKEN_4_TINT,
B_DARKEN_3_TINT,
B_DARKEN_2_TINT,
B_DARKEN_1_TINT,
B_NO_TINT};
for (int32 i = 4; i >= 0; i--) {
rgb_color color;
if (fMeterLevel > i) {
color = tint_color(METER_GREEN, kTintArray[i]);
} else {
color = METER_GREY;
}
view->SetHighColor(color);
view->FillRect(cell);
cell.OffsetBy(0, cell.Height() + 1);
}
view->PopState();
}
int32
MidiEventMeter::CalcMeterLevel(int32 eventCount) const
{
// we use an approximately logarithmic scale for determing the actual
// drawn meter level, so that low-density event streams show up well.
if (eventCount == 0)
return 0;
else if (eventCount < (int32)(0.5 * METER_SCALE))
return 1;
else if (eventCount < (int32)(0.75 * METER_SCALE))
return 2;
else if (eventCount < (int32)(0.9 * METER_SCALE))
return 3;
else if (eventCount < METER_SCALE)
return 4;
return 5;
}
| 23.342466
| 72
| 0.683392
|
Kirishikesan
|
894065a760a2faf36fd63bdbe81ef6b0315a143b
| 1,301
|
hpp
|
C++
|
include/cpp2py/signal_handler.hpp
|
Algomorph/cpp2py
|
0febc3f923f0a72e36796e6f2932382419e2b878
|
[
"ECL-2.0",
"Apache-2.0"
] | 1
|
2020-06-26T13:05:11.000Z
|
2020-06-26T13:05:11.000Z
|
include/cpp2py/signal_handler.hpp
|
Algomorph/cpp2py
|
0febc3f923f0a72e36796e6f2932382419e2b878
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
include/cpp2py/signal_handler.hpp
|
Algomorph/cpp2py
|
0febc3f923f0a72e36796e6f2932382419e2b878
|
[
"ECL-2.0",
"Apache-2.0"
] | 1
|
2020-12-28T00:47:14.000Z
|
2020-12-28T00:47:14.000Z
|
/*******************************************************************************
*
* TRIQS: a Toolbox for Research in Interacting Quantum Systems
*
* Copyright (C) 2014 by O. Parcollet
*
* TRIQS is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* TRIQS 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
* TRIQS. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
namespace cpp2py {
namespace signal_handler {
/// Start the signal handler
void start();
/// Stop it. ?
void stop();
/// A signal has been received. If pop, and there is a signal, pop it.
bool received(bool pop = false);
/// Last received.
int last();
/// pop the last signal
void pop();
} // namespace signal_handler
} // namespace cpp2py
| 31.731707
| 80
| 0.607225
|
Algomorph
|
8947090d3e9a56d48781d56c2698dc154885bdf0
| 420
|
cpp
|
C++
|
hackerrank/sansa-and-xor/solution.cpp
|
SamProkopchuk/coding-problems
|
fa0ca2c05ac90e41945de1a5751e5545a8459ac4
|
[
"MIT"
] | null | null | null |
hackerrank/sansa-and-xor/solution.cpp
|
SamProkopchuk/coding-problems
|
fa0ca2c05ac90e41945de1a5751e5545a8459ac4
|
[
"MIT"
] | null | null | null |
hackerrank/sansa-and-xor/solution.cpp
|
SamProkopchuk/coding-problems
|
fa0ca2c05ac90e41945de1a5751e5545a8459ac4
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
typedef signed long long ll;
typedef unsigned long long ull;
#define FOR(x, to) for (x = 0; x < (to); ++x)
#define FORR(x, arr) for (auto &x : arr)
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, i, x, ans;
ans = 0;
cin >> n;
FOR(i, n) {
cin >> x;
if (n % 2 && (i + 1) % 2) ans ^= x;
}
cout << ans << endl;
}
return 0;
}
| 16.153846
| 45
| 0.485714
|
SamProkopchuk
|
894745f19fa7a9f07ecace1540adf076cd461e69
| 2,180
|
hpp
|
C++
|
src/avatar.hpp
|
tilnewman/halloween
|
7cea37e31b2e566be76707cd8dc48527cec95bc5
|
[
"MIT"
] | null | null | null |
src/avatar.hpp
|
tilnewman/halloween
|
7cea37e31b2e566be76707cd8dc48527cec95bc5
|
[
"MIT"
] | null | null | null |
src/avatar.hpp
|
tilnewman/halloween
|
7cea37e31b2e566be76707cd8dc48527cec95bc5
|
[
"MIT"
] | null | null | null |
#ifndef AVATAR_HPP_INCLUDED
#define AVATAR_HPP_INCLUDED
//
// avatar.hpp
//
#include "avatar-anim.hpp"
#include "blood.hpp"
#include <vector>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Texture.hpp>
namespace halloween
{
struct Settings;
struct Context;
enum class Action
{
Idle,
Attack,
Run,
Jump,
Throw,
Dead
};
class Avatar
{
public:
Avatar();
void setup(const Settings & settings);
void draw(sf::RenderTarget & target, sf::RenderStates states) const;
sf::FloatRect collisionRect() const;
sf::FloatRect attackCollisionRect() const;
void setPosition(const sf::FloatRect & RECT);
void update(Context & context, const float FRAME_TIME_SEC);
private:
void moveMap(Context & context);
void setAction(const Action ACTION);
bool handleDeath(Context & context, const float FRAME_TIME_SEC);
bool handleAttacking(Context & context, const float FRAME_TIME_SEC);
bool handleThrowing(Context & context, const float FRAME_TIME_SEC);
void sideToSideMotion(Context & context, const float FRAME_TIME_SEC);
void jumping(Context & context);
void walkCollisions(Context & context);
void killCollisions(Context & context);
void exitCollisions(Context & context) const;
void coinCollisions(Context & context) const;
void preventBacktracking(const Context & context);
void respawnIfOutOfBounds(Context & context);
private:
Blood m_blood;
AvatarAnim m_runAnim;
AvatarAnim m_attackAnim;
AvatarAnim m_deathAnim;
AvatarAnim m_throwAnim;
sf::Texture m_idleTexture;
sf::Texture m_jumpTexture;
sf::Sprite m_sprite;
sf::Vector2f m_velocity;
sf::Vector2f m_acceleration;
Action m_action;
bool m_hasLanded;
bool m_isFacingRight;
const float m_jumpSpeed;
const float m_walkSpeed;
const float m_walkSpeedLimit;
float m_deadDelaySec;
};
} // namespace halloween
#endif // AVATAR_HPP_INCLUDED
| 27.25
| 77
| 0.649083
|
tilnewman
|
89475fdf52859e38581f578ec22f6a95c93fd0e6
| 61,755
|
cpp
|
C++
|
lighthub/main.cpp
|
anklimov/lighthub
|
99e9c1a27aca52bf38efec000547720fb8f82860
|
[
"Apache-2.0"
] | 83
|
2017-11-05T14:05:16.000Z
|
2022-02-21T16:34:53.000Z
|
lighthub/main.cpp
|
anklimov/lighthub
|
99e9c1a27aca52bf38efec000547720fb8f82860
|
[
"Apache-2.0"
] | 27
|
2018-03-12T21:49:33.000Z
|
2022-01-20T19:06:05.000Z
|
lighthub/main.cpp
|
anklimov/lighthub
|
99e9c1a27aca52bf38efec000547720fb8f82860
|
[
"Apache-2.0"
] | 20
|
2017-11-20T08:27:17.000Z
|
2022-03-28T02:26:17.000Z
|
/* Copyright © 2017-2018 Andrey Klimov. 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.
Homepage: http://lazyhome.ru
GIT: https://github.com/anklimov/lighthub
e-mail anklimov@gmail.com
*
*
* Done:
* MQMT/openhab
* 1-wire
* DMX - out
* DMX IN
* 1809 strip out (discarded)
* Modbus master Out
* DHCP
* JSON config
* cli
* PWM Out 7,8,9
* 1-w relay out
* Termostat out
Todo (backlog)
===
rotary encoder local ctrl ?
analog in local ctrl
Smooth regulation/fading
PID Termostat out ?
dmx relay out
Relay array channel
Relay DMX array channel
Config URL & MQTT password commandline configuration
1-wire Update refactoring (save memory)
Topic configuration
Timer
Modbus response check
control/debug (Commandline) over MQTT
more Modbus dimmers
todo DUE related:
PWM freq fix
Config webserver
SSL
todo ESP:
Config webserver
SSL
ESP32
PWM Out
*/
#include "main.h"
#include "statusled.h"
extern long timer0_overflow_count;
#ifdef WIFI_ENABLE
WiFiClient ethClient;
#if not defined(WIFI_MANAGER_DISABLE)
WiFiManager wifiManager;
#endif
#else
#include <Dhcp.h>
EthernetClient ethClient;
#endif
#if defined(OTA)
#include <ArduinoOTA.h>
//bool OTA_initialized=false;
#endif
#if defined(__SAM3X8E__)
DueFlashStorage EEPROM;
#endif
#ifdef ARDUINO_ARCH_ESP32
NRFFlashStorage EEPROM;
#endif
#ifdef ARDUINO_ARCH_STM32
NRFFlashStorage EEPROM;
#endif
#ifdef NRF5
NRFFlashStorage EEPROM;
#endif
#ifdef SYSLOG_ENABLE
#include <Syslog.h>
#ifndef WIFI_ENABLE
EthernetUDP udpSyslogClient;
#else
WiFiUDP udpSyslogClient;
#endif
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
unsigned long timerSyslogPingTime;
static char syslogDeviceHostname[16];
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
#else
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
#endif
statusLED LED(ledRED);
lan_status lanStatus = INITIAL_STATE;
const char configserver[] PROGMEM = CONFIG_SERVER;
const char verval_P[] PROGMEM = QUOTE(PIO_SRC_REV);
#if defined(__SAM3X8E__)
UID UniqueID;
#endif
char *deviceName = NULL;
aJsonObject *topics = NULL;
aJsonObject *root = NULL;
aJsonObject *items = NULL;
aJsonObject *inputs = NULL;
aJsonObject *mqttArr = NULL;
#ifdef _modbus
aJsonObject *modbusObj = NULL;
#endif
#ifdef _owire
aJsonObject *owArr = NULL;
#endif
#ifdef _dmxout
aJsonObject *dmxArr = NULL;
#endif
#ifdef SYSLOG_ENABLE
bool syslogInitialized = false;
#endif
uint32_t timerPollingCheck = 0;
uint32_t timerInputCheck = 0;
uint32_t timerLanCheckTime = 0;
uint32_t timerThermostatCheck = 0;
uint32_t timerSensorCheck =0;
uint32_t WiFiAwaitingTime =0;
aJsonObject *pollingItem = NULL;
bool owReady = false;
bool configOk = false; // At least once connected to MQTT
bool configLoaded = false;
bool initializedListeners = false;
int8_t ethernetIdleCount =0;
int8_t configLocked = 0;
#if defined (_modbus)
ModbusMaster node;
#endif
byte mac[6];
PubSubClient mqttClient(ethClient);
bool wifiInitialized;
int mqttErrorRate;
#if defined(__SAM3X8E__)
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
#endif
void cleanConf()
{
if (!root) return;
debugSerial<<F("Unlocking config ...")<<endl;
while (configLocked)
{
//wdt_res();
cmdPoll();
#ifdef _owire
if (owReady && owArr) owLoop();
#endif
#ifdef _dmxin
DMXCheck();
#endif
if (isNotRetainingStatus()) pollingLoop();
thermoLoop();
inputLoop();
yield();
}
debugSerial<<F("Stopping channels ...")<<endl;
//Stoping the channels
aJsonObject * item = items->child;
while (items && item)
{
if (item->type == aJson_Array && aJson.getArraySize(item)>0)
{
Item it(item->name);
if (it.isValid()) it.Stop();
yield();
}
item = item->next;
}
pollingItem = NULL;
debugSerial<<F("Stopped")<<endl;
#ifdef SYSLOG_ENABLE
syslogInitialized=false; //Garbage in memory
#endif
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
aJson.deleteItem(root);
root = NULL;
inputs = NULL;
items = NULL;
topics = NULL;
mqttArr = NULL;
#ifdef _dmxout
dmxArr = NULL;
#endif
#ifdef _owire
owArr = NULL;
#endif
#ifdef _modbus
modbusObj = NULL;
#endif
debugSerial<<F(" is ")<<freeRam()<<endl;
configLoaded=false;
configOk=false;
}
bool isNotRetainingStatus() {
return (lanStatus != RETAINING_COLLECTING);
}
void mqttCallback(char *topic, byte *payload, unsigned int length) {
debugSerial<<F("\n[")<<topic<<F("] ");
if (!payload) return;
payload[length] = 0;
int fr = freeRam();
if (fr < 250) {
errorSerial<<F("OutOfMemory!")<<endl;
return;
}
LED.flash(ledBLUE);
for (unsigned int i = 0; i < length; i++)
debugSerial<<((char) payload[i]);
debugSerial<<endl;
short intopic = 0;
short pfxlen = 0;
char * itemName = NULL;
char * subItem = NULL;
{
char buf[MQTT_TOPIC_LENGTH + 1];
if (lanStatus == RETAINING_COLLECTING)
{
setTopic(buf,sizeof(buf),T_OUT);
pfxlen = strlen(buf);
intopic = strncmp(topic, buf, pfxlen);
}
else
{
setTopic(buf,sizeof(buf),T_BCST);
pfxlen = strlen(buf);
intopic = strncmp(topic, buf, pfxlen );
if (intopic)
{
setTopic(buf,sizeof(buf),T_DEV);
pfxlen = strlen(buf);
intopic = strncmp(topic, buf, pfxlen);
}
}
}
// in Retaining status - trying to restore previous state from retained output topic. Retained input topics are not relevant.
if (intopic) {
debugSerial<<F("Skipping..");
return;
}
itemName=topic+pfxlen;
if(!strcmp(itemName,CMDTOPIC) && payload && (strlen((char*) payload)>1)) {
// mqttClient.publish(topic, "");
cmd_parse((char *)payload);
return;
}
if (subItem = strchr(itemName, '/'))
{
*subItem = 0;
subItem++;
if (*subItem=='$') return; //Skipping homie stuff
// debugSerial<<F("Subitem:")<<subItem<<endl;
}
// debugSerial<<F("Item:")<<itemName<<endl;
if (itemName[0]=='$') return; //Skipping homie stuff
Item item(itemName);
if (item.isValid()) {
/*
if (item.itemType == CH_GROUP && (lanStatus == RETAINING_COLLECTING))
return; //Do not restore group channels - they consist not relevant data */
item.Ctrl((char *)payload,subItem);
} //valid item
}
void printMACAddress() {
infoSerial<<F("MAC:");
for (byte i = 0; i < 6; i++)
{
if (mac[i]<16) infoSerial<<"0";
#ifdef WITH_PRINTEX_LIB
(i < 5) ?infoSerial<<hex <<(mac[i])<<F(":"):infoSerial<<hex<<(mac[i])<<endl;
#else
(i < 5) ?infoSerial<<_HEX(mac[i])<<F(":"):infoSerial<<_HEX(mac[i])<<endl;
#endif
}
}
char* getStringFromConfig(aJsonObject * a, int i)
{
aJsonObject * element = NULL;
if (!a) return NULL;
if (a->type == aJson_Array)
element = aJson.getArrayItem(a, i);
// TODO - human readable JSON objects as alias
if (element && element->type == aJson_String) return element->valuestring;
return NULL;
}
char* getStringFromConfig(aJsonObject * a, char * name)
{
aJsonObject * element = NULL;
if (!a) return NULL;
if (a->type == aJson_Object)
element = aJson.getObjectItem(a, name);
if (element && element->type == aJson_String) return element->valuestring;
return NULL;
}
void setupOTA(void)
{
#ifdef OTA
//if (OTA_initialized) return;
// ArduinoOTA.end();
// start the OTEthernet library with internal (flash) based storage
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
infoSerial<<F("OTA initialized\n");
//OTA_initialized=true;
#endif
}
void setupSyslog()
{
#ifdef SYSLOG_ENABLE
int syslogPort = 514;
short n = 0;
aJsonObject *udpSyslogArr = NULL;
if (syslogInitialized) return;
if (lanStatus<HAVE_IP_ADDRESS) return;
if (!root) return;
udpSyslogClient.begin(SYSLOG_LOCAL_SOCKET);
udpSyslogArr = aJson.getObjectItem(root, "syslog");
if (udpSyslogArr && (n = aJson.getArraySize(udpSyslogArr))) {
char *syslogServer = getStringFromConfig(udpSyslogArr, 0);
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
_inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
infoSerial<<F("Syslog params:")<<syslogServer<<":"<<syslogPort<<":"<<syslogDeviceHostname<<endl;
udpSyslog.server(syslogServer, syslogPort);
udpSyslog.deviceHostname(syslogDeviceHostname);
if (mqttArr) deviceName = getStringFromConfig(mqttArr, 0);
if (deviceName) udpSyslog.appName(deviceName);
udpSyslog.defaultPriority(LOG_KERN);
syslogInitialized=true;
infoSerial<<F("UDP Syslog initialized.\n");
}
#endif
}
lan_status lanLoop() {
#ifdef NOETHER
lanStatus=DO_NOTHING;//-14;
#endif
//Serial.println(lanStatus);
switch (lanStatus) {
case INITIAL_STATE:
// LED.set(ledRED|((configLoaded)?ledBLINK:0));
LED.set(ledRED|((configLoaded)?ledBLINK:0));
#if defined(WIFI_ENABLE)
onInitialStateInitLAN(); // Moves state to AWAITING_ADDRESS or HAVE_IP_ADDRESS
#else
if (Ethernet.linkStatus() != LinkOFF) onInitialStateInitLAN(); // Moves state to AWAITING_ADDRESS or HAVE_IP_ADDRESS
#endif
break;
case AWAITING_ADDRESS:
#if defined(WIFI_ENABLE)
if (WiFi.status() == WL_CONNECTED)
{
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
wifiInitialized = true;
lanStatus = HAVE_IP_ADDRESS;
}
else
// if (millis()>WiFiAwaitingTime)
if (isTimeOver(WiFiAwaitingTime,millis(),WIFI_TIMEOUT))
{
errorSerial<<F("\nProblem with WiFi!");
return lanStatus = DO_REINIT;
}
#else
lanStatus = HAVE_IP_ADDRESS;
#endif
break;
case HAVE_IP_ADDRESS:
if (!initializedListeners)
{
setupSyslog();
setupOTA();
#ifdef _artnet
if (artnet) artnet->begin();
#endif
initializedListeners = true;
}
lanStatus = LIBS_INITIALIZED;
break;
case LIBS_INITIALIZED:
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
if (configLocked) return LIBS_INITIALIZED;
if (!configOk)
lanStatus = loadConfigFromHttp(0, NULL);
else lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
break;
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
wdt_res();
LED.set(ledRED|ledGREEN|((configLoaded)?ledBLINK:0));
ip_ready_config_loaded_connecting_to_broker();
break;
case RETAINING_COLLECTING:
//if (millis() > timerLanCheckTime)
if (isTimeOver(timerLanCheckTime,millis(),TIMEOUT_RETAIN))
{
char buf[MQTT_TOPIC_LENGTH+1];
//Unsubscribe from status topics..
//strncpy_P(buf, outprefix, sizeof(buf));
setTopic(buf,sizeof(buf),T_OUT);
strncat(buf, "+/+/#", sizeof(buf)); // Subscribing only on separated command/parameters topics
mqttClient.unsubscribe(buf);
lanStatus = OPERATION;//3;
infoSerial<<F("Accepting commands...\n");
}
break;
case OPERATION:
LED.set(ledGREEN|((configLoaded)?ledBLINK:0));
if (!mqttClient.connected()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
break;
case DO_REINIT: // Pause and re-init LAN
//if (mqttClient.connected()) mqttClient.disconnect(); // Hmm hungs then cable disconnected
timerLanCheckTime = millis();// + 5000;
lanStatus = REINIT;
LED.set(ledRED|((configLoaded)?ledBLINK:0));
break;
case REINIT: // Pause and re-init LAN
//if (millis() > timerLanCheckTime)
if (isTimeOver(timerLanCheckTime,millis(),TIMEOUT_REINIT))
{
lanStatus = INITIAL_STATE;
}
break;
case DO_RECONNECT: // Pause and re-connect MQTT
if (mqttClient.connected()) mqttClient.disconnect();
timerLanCheckTime = millis();// + 5000;
lanStatus = RECONNECT;
break;
case RECONNECT:
//if (millis() > timerLanCheckTime)
if (isTimeOver(timerLanCheckTime,millis(),TIMEOUT_RECONNECT))
lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
break;
case READ_RE_CONFIG: // Restore config from FLASH, re-init LAN
if (loadConfigFromEEPROM()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
else {
//timerLanCheckTime = millis();// + 5000;
lanStatus = DO_REINIT;//-10;
}
break;
case DO_NOTHING:;
}
{
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined (NRF5)
wdt_dis();
if (lanStatus >= HAVE_IP_ADDRESS)
{
int etherStatus = Ethernet.maintain();
#ifndef Wiz5500
#define NO_LINK 5
if (Ethernet.linkStatus() == LinkOFF) etherStatus = NO_LINK;
#endif
switch (etherStatus) {
case NO_LINK:
errorSerial<<F("\nNo link")<<endl;
lanStatus = DO_REINIT;
break;
case DHCP_CHECK_RENEW_FAIL:
errorSerial<<F("Error: renewed fail");
lanStatus = DO_REINIT;
break;
case DHCP_CHECK_RENEW_OK:
infoSerial<<F("Renewed success. IP address:");
printIPAddress(Ethernet.localIP());
break;
case DHCP_CHECK_REBIND_FAIL:
errorSerial<<F("Error: rebind fail");
if (mqttClient.connected()) mqttClient.disconnect();
//timerLanCheckTime = millis();// + 1000;
lanStatus = DO_REINIT;
break;
case DHCP_CHECK_REBIND_OK:
infoSerial<<F("Rebind success. IP address:");
printIPAddress(Ethernet.localIP());
break;
default:
break;
}
}
wdt_en();
#endif
}
return lanStatus;
}
void onMQTTConnect(){
char topic[64] = "";
char buf[128] = "";
// High level homie topics publishing
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, state_P, sizeof(topic));
strncpy_P(buf, ready_P, sizeof(buf));
mqttClient.publish(topic,buf,true);
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, name_P, sizeof(topic));
strncpy_P(buf, nameval_P, sizeof(buf));
strncat_P(buf,(verval_P),sizeof(buf));
mqttClient.publish(topic,buf,true);
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, stats_P, sizeof(topic));
strncpy_P(buf, statsval_P, sizeof(buf));
mqttClient.publish(topic,buf,true);
#ifndef NO_HOMIE
// strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, homie_P, sizeof(topic));
strncpy_P(buf, homiever_P, sizeof(buf));
mqttClient.publish(topic,buf,true);
configLocked++;
if (items) {
char datatype[32]="\0";
char format [64]="\0";
aJsonObject * item = items->child;
while (items && item)
if (item->type == aJson_Array && aJson.getArraySize(item)>0) {
/// strncat(buf,item->name,sizeof(buf));
/// strncat(buf,",",sizeof(buf));
switch ( aJson.getArrayItem(item, I_TYPE)->valueint) {
case CH_THERMO:
strncpy_P(datatype,float_P,sizeof(datatype));
format[0]=0;
break;
case CH_RELAY:
case CH_GROUP:
strncpy_P(datatype,enum_P,sizeof(datatype));
strncpy_P(format,enumformat_P,sizeof(format));
break;
case CH_RGBW:
case CH_RGB:
strncpy_P(datatype,color_P,sizeof(datatype));
strncpy_P(format,hsv_P,sizeof(format));
break;
case CH_DIMMER:
case CH_MODBUS:
case CH_PWM:
case CH_VCTEMP:
case CH_VC:
strncpy_P(datatype,int_P,sizeof(datatype));
strncpy_P(format,intformat_P,sizeof(format));
break;
} //switch
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat(topic,item->name,sizeof(topic));
strncat(topic,"/",sizeof(topic));
strncat_P(topic,datatype_P,sizeof(topic));
mqttClient.publish(topic,datatype,true);
if (format[0])
{
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat(topic,item->name,sizeof(topic));
strncat(topic,"/",sizeof(topic));
strncat_P(topic,format_P,sizeof(topic));
mqttClient.publish(topic,format,true);
}
yield();
item = item->next;
} //if
//strncpy_P(topic, outprefix, sizeof(topic));
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, nodes_P, sizeof(topic));
/// mqttClient.publish(topic,buf,true);
}
configLocked--;
#endif
}
void ip_ready_config_loaded_connecting_to_broker() {
int port = 1883;
char empty = 0;
short n = 0;
char *user = ∅
char passwordBuf[16] = "";
char *password = passwordBuf;
if (mqttClient.connected())
{
lanStatus = RETAINING_COLLECTING;
return;
}
if (!mqttArr || ((n = aJson.getArraySize(mqttArr)) < 2)) //At least device name and broker IP must be configured
{
lanStatus = READ_RE_CONFIG;
return;
}
deviceName = getStringFromConfig(mqttArr, 0);
infoSerial<<F("Device Name:")<<deviceName<<endl;
debugSerial<<F("N:")<<n<<endl;
char *servername = getStringFromConfig(mqttArr, 1);
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
if (n >= 4) user = getStringFromConfig(mqttArr, 3);
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5))
{
password = getStringFromConfig(mqttArr, 4);
infoSerial<<F("Using MQTT password from config")<<endl;
}
mqttClient.setServer(servername, port);
mqttClient.setCallback(mqttCallback);
char willMessage[16];
char willTopic[32];
strncpy_P(willMessage,disconnected_P,sizeof(willMessage));
// strncpy_P(willTopic, outprefix, sizeof(willTopic));
setTopic(willTopic,sizeof(willTopic),T_DEV);
strncat_P(willTopic, state_P, sizeof(willTopic));
infoSerial<<F("\nAttempting MQTT connection to ")<<servername<<F(":")<<port<<F(" user:")<<user<<F(" ...");
if (!strlen(user))
{
user = NULL;
password= NULL;
}
// wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
if (mqttClient.connect(deviceName, user, password,willTopic,MQTTQOS1,true,willMessage))
{
mqttErrorRate = 0;
infoSerial<<F("connected as ")<<deviceName <<endl;
configOk = true;
// ... Temporary subscribe to status topic
char buf[MQTT_TOPIC_LENGTH+1];
setTopic(buf,sizeof(buf),T_OUT);
strncat(buf, "+/+/#", sizeof(buf)); // Only on separated cmd/val topics
mqttClient.subscribe(buf);
//Subscribing for command topics
//strncpy_P(buf, inprefix, sizeof(buf));
setTopic(buf,sizeof(buf),T_BCST);
strncat(buf, "#", sizeof(buf));
Serial.println(buf);
mqttClient.subscribe(buf);
setTopic(buf,sizeof(buf),T_DEV);
strncat(buf, "#", sizeof(buf));
Serial.println(buf);
mqttClient.subscribe(buf);
onMQTTConnect();
// if (_once) {DMXput(); _once=0;}
lanStatus = RETAINING_COLLECTING;//4;
timerLanCheckTime = millis();// + 5000;
infoSerial<<F("Awaiting for retained topics");
} else
{
errorSerial<<F("failed, rc=")<<mqttClient.state()<<F(" try again in 5 seconds")<<endl;
timerLanCheckTime = millis();// + 5000;
#ifdef RESTART_LAN_ON_MQTT_ERRORS
mqttErrorRate++;
if(mqttErrorRate>50){
errorSerial<<F("Too many MQTT connection errors. Restart LAN"));
mqttErrorRate=0;
#ifdef RESET_PIN
resetHard();
#endif
lanStatus=DO_REINIT;// GO INITIAL_STATE;
return;
}
#endif
lanStatus = DO_RECONNECT;//12;
}
}
void onInitialStateInitLAN() {
#if defined(WIFI_ENABLE)
#if defined(WIFI_MANAGER_DISABLE)
if(WiFi.status() != WL_CONNECTED) {
WiFi.mode(WIFI_STA); // ESP 32 - WiFi.disconnect(); instead
infoSerial<<F("WIFI AP/Password:")<<QUOTE(ESP_WIFI_AP)<<F("/")<<QUOTE(ESP_WIFI_PWD)<<endl;
#ifndef ARDUINO_ARCH_ESP32
wifi_set_macaddr(STATION_IF,mac); //ESP32 to check
#endif
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
// int wifi_connection_wait = 10000;
// while (WiFi.status() != WL_CONNECTED && wifi_connection_wait > 0) {
// delay(500);
// wifi_connection_wait -= 500;
// debugSerial<<".";
// yield();
// }
// wifiInitialized = true; //???
}
#endif
lanStatus = AWAITING_ADDRESS;
WiFiAwaitingTime = millis();// + 60000L;
return;
/*
if (WiFi.status() == WL_CONNECTED) {
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
wifiInitialized = true;
lanStatus = HAVE_IP_ADDRESS;//1;
//setupOTA();
} else
{
errorSerial<<F("\nProblem with WiFi!");
lanStatus = DO_REINIT;
//timerLanCheckTime = millis() + DHCP_RETRY_INTERVAL;
}
*/
#else // Ethernet connection
IPAddress ip, dns, gw, mask;
int res = 1;
infoSerial<<F("Starting lan")<<endl;
if (ipLoadFromFlash(OFFSET_IP, ip)) {
infoSerial<<F("Loaded from flash IP:");
printIPAddress(ip);
if (ipLoadFromFlash(OFFSET_DNS, dns)) {
infoSerial<<F(" DNS:");
printIPAddress(dns);
if (ipLoadFromFlash(OFFSET_GW, gw)) {
infoSerial<<F(" GW:");
printIPAddress(gw);
if (ipLoadFromFlash(OFFSET_MASK, mask)) {
infoSerial<<F(" MASK:");
printIPAddress(mask);
Ethernet.begin(mac, ip, dns, gw, mask);
} else Ethernet.begin(mac, ip, dns, gw);
} else Ethernet.begin(mac, ip, dns);
} else Ethernet.begin(mac, ip);
infoSerial<<endl;
lanStatus = HAVE_IP_ADDRESS;
}
else {
infoSerial<<F("\nuses DHCP\n");
wdt_dis();
#if defined(ARDUINO_ARCH_STM32)
res = Ethernet.begin(mac);
#else
res = Ethernet.begin(mac, 12000);
#endif
wdt_en();
wdt_res();
if (res == 0) {
errorSerial<<F("Failed to configure Ethernet using DHCP. You can set ip manually!")<<F("'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n");
lanStatus = DO_REINIT;//-10;
//timerLanCheckTime = millis();// + DHCP_RETRY_INTERVAL;
#ifdef RESET_PIN
resetHard();
#endif
} else {
infoSerial<<F("Got IP address:");
printIPAddress(Ethernet.localIP());
lanStatus = HAVE_IP_ADDRESS;
}
}
#endif
}
void resetHard() {
#ifdef RESET_PIN
infoSerial<<F("Reset Arduino with digital pin ");
infoSerial<<QUOTE(RESET_PIN);
delay(500);
pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN,LOW);
delay(500);
digitalWrite(RESET_PIN,HIGH);
delay(500);
#endif
}
#ifdef _owire
void Changed(int i, DeviceAddress addr, float currentTemp) {
char addrstr[32] = "NIL";
//char addrbuf[17];
//char valstr[16] = "NIL";
//char *owEmitString = NULL;
char *owItem = NULL;
SetBytes(addr, 8, addrstr);
addrstr[17] = 0;
if (!root) return;
//printFloatValueToStr(currentTemp,valstr);
debugSerial<<endl<<F("T:")<<currentTemp<<F("<")<<addrstr<<F(">")<<endl;
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
executeCommand(owObj,-1,itemCmd(currentTemp));
/*
if (owObj) {
owEmitString = getStringFromConfig(owObj, "emit");
debugSerial<<owEmitString<<F(">")<<endl;
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
{
if (owEmitString) // publish temperature to MQTT if configured
{
#ifdef WITH_DOMOTICZ
aJsonObject *idx = aJson.getObjectItem(owObj, "idx");
if (idx && && idx->type ==aJson_String && idx->valuestring) {//DOMOTICZ json format support
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
char valstr[50];
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
debugSerial << valstr;
if (mqttClient.connected() && !ethernetIdleCount)
mqttClient.publish(owEmitString, valstr);
return;
}
#endif
//strcpy_P(addrstr, outprefix);
setTopic(addrstr,sizeof(addrstr),T_OUT);
strncat(addrstr, owEmitString, sizeof(addrstr));
if (mqttClient.connected() && !ethernetIdleCount)
mqttClient.publish(addrstr, valstr);
}
// And translate temp to internal items
owItem = getStringFromConfig(owObj, "item");
if (owItem)
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
} // if valid temperature
} // if Address in config
else debugSerial<<addrstr<<F(">")<<endl; // No item found
*/
}
#endif //_owire
void cmdFunctionHelp(int arg_cnt, char **args)
{
printFirmwareVersionAndBuildOptions();
printCurentLanConfig();
// printFreeRam();
infoSerial<<F("\nUse these commands: 'help' - this text\n"
"'mac de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
"'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"
"'save' - save config in NVRAM\n"
"'get' [config addr]' - get config from pre-configured URL and store addr\n"
"'load' - load config from NVRAM\n"
"'pwd' - define MQTT password\n"
"'kill' - test watchdog\n"
"'clear' - clear EEPROM\n"
"'reboot' - reboot controller");
}
void printCurentLanConfig() {
infoSerial << F("Current LAN config(ip,dns,gw,subnet):");
printIPAddress(Ethernet.localIP());
// printIPAddress(Ethernet.dnsServerIP());
printIPAddress(Ethernet.gatewayIP());
printIPAddress(Ethernet.subnetMask());
}
void cmdFunctionKill(int arg_cnt, char **args) {
for (byte i = 1; i < 20; i++) {
delay(1000);
infoSerial<<i;
};
}
void cmdFunctionReboot(int arg_cnt, char **args) {
infoSerial<<F("Soft rebooting...");
softRebootFunc();
}
void applyConfig() {
if (!root) return;
configLocked++;
items = aJson.getObjectItem(root, "items");
topics = aJson.getObjectItem(root, "topics");
inputs = aJson.getObjectItem(root, "in");
mqttArr = aJson.getObjectItem(root, "mqtt");
setupSyslog();
#ifdef _dmxin
int itemsCount;
dmxArr = aJson.getObjectItem(root, "dmxin");
if (dmxArr && (itemsCount = aJson.getArraySize(dmxArr))) {
DMXinSetup(itemsCount * 4);
infoSerial<<F("DMX in started. Channels:")<<itemsCount * 4<<endl;
}
#endif
#ifdef _dmxout
int maxChannels;
short numParams;
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
if (dmxoutArr && (numParams=aJson.getArraySize(dmxoutArr)) >=1 ) {
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, numParams-1)->valueint);
infoSerial<<F("DMX out started. Channels: ")<<maxChannels<<endl;
debugSerial<<F("Free:")<<freeRam()<<endl;
}
#endif
#ifdef _modbus
modbusObj = aJson.getObjectItem(root, "modbus");
#endif
#ifdef _owire
owArr = aJson.getObjectItem(root, "ow");
if (owArr && !owReady) {
aJsonObject *item = owArr->child;
owReady = owSetup(&Changed);
if (owReady) infoSerial<<F("One wire Ready\n");
t_count = 0;
while (item && owReady) {
if ((item->type == aJson_Object)) {
DeviceAddress addr;
//infoSerial<<F("Add:")),infoSerial<<item->name);
SetAddr(item->name, addr);
owAdd(addr);
}
yield();
item = item->next;
}
}
#endif
// Digital output related Items initialization
pollingItem=NULL;
if (items) {
aJsonObject * item = items->child;
while (items && item)
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
Item it(item);
if (it.isValid() && !it.Setup()) {
//Legacy Setup
short inverse = 0;
int pin=it.getArg();
if (pin<0) {pin=-pin; inverse = 1;}
int cmd = it.getCmd();
switch (it.itemType) {
case CH_THERMO:
if (cmd<1) it.setCmd(CMD_OFF);
pinMode(pin, OUTPUT);
digitalWrite(pin, false); //Initially, all thermostates are LOW (OFF for electho heaters, open for water NO)
debugSerial<<F("Thermo:")<<pin<<F("=LOW")<<F(";");
break;
case CH_RELAY:
{
int k;
pinMode(pin, OUTPUT);
if (inverse)
digitalWrite(pin, k = ((cmd == CMD_ON) ? LOW : HIGH));
else
digitalWrite(pin, k = ((cmd == CMD_ON) ? HIGH : LOW));
debugSerial<<F("Pin:")<<pin<<F("=")<<k<<F(";");
}
break;
} //switch
} //isValid
yield();
item = item->next;
} //if
pollingItem = items->child;
}
debugSerial<<endl;
inputSetup();
printConfigSummary();
configLoaded=true;
configLocked--;
}
void printConfigSummary() {
infoSerial<<F("\nConfigured:")<<F("\nitems ");
printBool(items);
infoSerial<<F("\ninputs ");
printBool(inputs);
#ifndef MODBUS_DISABLE
infoSerial<<F("\nmodbus v1 (+)");
// printBool(modbusObj);
#endif
#ifndef MBUS_DISABLE
infoSerial<<F("\nmodbus v2");
printBool(modbusObj);
#endif
infoSerial<<F("\nmqtt ");
printBool(mqttArr);
#ifdef _owire
infoSerial<<F("\n1-wire ");
printBool(owArr);
#endif
/*
#ifdef SYSLOG_ENABLE
infoSerial<<F("\nudp syslog ");
printBool(udpSyslogArr);
#endif
*/
infoSerial << endl;
infoSerial<<F("RAM=")<<freeRam()<<endl;
}
void cmdFunctionLoad(int arg_cnt, char **args) {
loadConfigFromEEPROM();
}
int loadConfigFromEEPROM()
{
char ch;
infoSerial<<F("Loading Config from EEPROM")<<endl;
ch = EEPROM.read(EEPROM_offsetJSON);
if (ch == '{') {
aJsonEEPROMStream as = aJsonEEPROMStream(EEPROM_offsetJSON);
cleanConf();
root = aJson.parse(&as);
if (!root) {
errorSerial<<F("load failed")<<endl;
return 0;
}
infoSerial<<F("Loaded")<<endl;
applyConfig();
ethClient.stop(); //Refresh MQTT connect to get retained info
return 1;
} else {
infoSerial<<F("No stored config")<<endl;
return 0;
}
return 0;
}
void cmdFunctionReq(int arg_cnt, char **args) {
mqttConfigRequest(arg_cnt, args);
}
int mqttConfigRequest(int arg_cnt, char **args)
{
char buf[25] = "/";
infoSerial<<F("\nrequest MQTT Config");
SetBytes((uint8_t *) mac, 6, buf + 1);
buf[13] = 0;
strncat(buf, "/resp/#", 25);
debugSerial<<buf;
mqttClient.subscribe(buf);
buf[13] = 0;
strncat(buf, "/req/conf", 25);
debugSerial<<buf;
mqttClient.publish(buf, "1");
return 1;
}
int mqttConfigResp(char *as) {
infoSerial<<F("got MQTT Config");
root = aJson.parse(as);
if (!root) {
errorSerial<<F("\nload failed\n");
return 0;
}
infoSerial<<F("\nLoaded");
applyConfig();
return 1;
}
#if defined(__SAM3X8E__)
#define saveBufLen 16000
void cmdFunctionSave(int arg_cnt, char **args)
{
char* outBuf = (char*) malloc(saveBufLen); /* XXX: Dynamic size. */
if (outBuf == NULL)
{
return;
}
infoSerial<<F("Saving config to EEPROM..");
aJsonStringStream stringStream(NULL, outBuf, saveBufLen);
aJson.print(root, &stringStream);
int len = strlen(outBuf);
outBuf[len++]= EOF;
EEPROM.write(EEPROM_offsetJSON,(byte*) outBuf,len);
free (outBuf);
infoSerial<<F("Saved to EEPROM");
}
#else
void cmdFunctionSave(int arg_cnt, char **args)
{
aJsonEEPROMStream jsonEEPROMStream = aJsonEEPROMStream(EEPROM_offsetJSON);
infoSerial<<F("Saving config to EEPROM..");
aJson.print(root, &jsonEEPROMStream);
jsonEEPROMStream.putEOF();
infoSerial<<F("Saved to EEPROM");
}
#endif
void cmdFunctionIp(int arg_cnt, char **args)
{
IPAddress ip0(0, 0, 0, 0);
IPAddress ip;
/*
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
DNSClient dns;
#define _inet_aton(cp, addr) dns._inet_aton(cp, addr)
#else
#define _inet_aton(cp, addr) _inet_aton(cp, addr)
#endif
*/
// switch (arg_cnt) {
// case 5:
if (arg_cnt>4 && _inet_aton(args[4], ip)) saveFlash(OFFSET_MASK, ip);
else saveFlash(OFFSET_MASK, ip0);
// case 4:
if (arg_cnt>3 && _inet_aton(args[3], ip)) saveFlash(OFFSET_GW, ip);
else saveFlash(OFFSET_GW, ip0);
// case 3:
if (arg_cnt>2 && _inet_aton(args[2], ip)) saveFlash(OFFSET_DNS, ip);
else saveFlash(OFFSET_DNS, ip0);
// case 2:
if (arg_cnt>1 && _inet_aton(args[1], ip)) saveFlash(OFFSET_IP, ip);
else saveFlash(OFFSET_IP, ip0);
// break;
// case 1: //dynamic IP
if (arg_cnt==1)
{
saveFlash(OFFSET_IP,ip0);
infoSerial<<F("Set dynamic IP\n");
}
/*
IPAddress current_ip = Ethernet.localIP();
IPAddress current_mask = Ethernet.subnetMask();
IPAddress current_gw = Ethernet.gatewayIP();
IPAddress current_dns = Ethernet.dnsServerIP();
saveFlash(OFFSET_IP, current_ip);
saveFlash(OFFSET_MASK, current_mask);
saveFlash(OFFSET_GW, current_gw);
saveFlash(OFFSET_DNS, current_dns);
debugSerial<<F("Saved current config(ip,dns,gw,subnet):");
printIPAddress(current_ip);
printIPAddress(current_dns);
printIPAddress(current_gw);
printIPAddress(current_mask); */
//}
infoSerial<<F("Saved\n");
}
void cmdFunctionClearEEPROM(int arg_cnt, char **args){
for (int i = OFFSET_MAC; i < OFFSET_MAC+EEPROM_FIX_PART_LEN+1; i++) //Fi[ part +{]
EEPROM.write(i, 0);
for (int i = 0; i < EEPROM_SIGNATURE_LENGTH; i++)
EEPROM.write(i+OFFSET_SIGNATURE,EEPROM_signature[i]);
infoSerial<<F("EEPROM cleared\n");
}
void cmdFunctionPwd(int arg_cnt, char **args)
{ char empty[]="";
if (arg_cnt)
saveFlash(OFFSET_MQTT_PWD,args[1]);
else saveFlash(OFFSET_MQTT_PWD,empty);
infoSerial<<F("Password updated\n");
}
void cmdFunctionSetMac(int arg_cnt, char **args) {
char dummy;
if (sscanf(args[1], "%x:%x:%x:%x:%x:%x%c", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5], &dummy) < 6) {
errorSerial<<F("could not parse: ")<<args[1];
return;
}
printMACAddress();
for (short i = 0; i < 6; i++) { EEPROM.write(i, mac[i]); }
infoSerial<<F("Updated\n");
}
void cmdFunctionGet(int arg_cnt, char **args) {
lanStatus= loadConfigFromHttp(arg_cnt, args);
ethClient.stop(); //Refresh MQTT connect to get retained info
//restoreState();
}
void printBool(bool arg) { (arg) ? infoSerial<<F("+") : infoSerial<<F("-"); }
void saveFlash(short n, char *str) {
short len=strlen(str);
if (len>MAXFLASHSTR-1) len=MAXFLASHSTR-1;
for(int i=0;i<len;i++) EEPROM.write(n+i,str[i]);
EEPROM.write(n+len,0);
#if defined(ARDUINO_ARCH_ESP8266)
// write the data to EEPROM
short res = EEPROM.commitReset();
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
#endif
}
int loadFlash(short n, char *str, short l) {
short i;
uint8_t ch = EEPROM.read(n);
if (!ch || (ch == 0xff)) return 0;
for (i=0;i<l-1 && (str[i] = EEPROM.read(n++));i++);
str[i]=0;
return 1;
}
void saveFlash(short n, IPAddress& ip) {
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
#if defined(ARDUINO_ARCH_ESP8266)
// write the data to EEPROM
short res = EEPROM.commitReset();
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
#endif
}
int ipLoadFromFlash(short n, IPAddress &ip) {
for (int i = 0; i < 4; i++)
ip[i] = EEPROM.read(n++);
return (ip[0] && ((ip[0] != 0xff) || (ip[1] != 0xff) || (ip[2] != 0xff) || (ip[3] != 0xff)));
}
lan_status loadConfigFromHttp(int arg_cnt, char **args)
{
int responseStatusCode = 0;
char URI[64];
char configServer[32]="";
if (arg_cnt > 1) {
strncpy(configServer, args[1], sizeof(configServer) - 1);
saveFlash(OFFSET_CONFIGSERVER, configServer);
infoSerial<<configServer<<F(" Saved")<<endl;
} else if (!loadFlash(OFFSET_CONFIGSERVER, configServer))
{
strncpy_P(configServer,configserver,sizeof(configServer));
infoSerial<<F(" Default config server used: ")<<configServer<<endl;
}
#ifndef DEVICE_NAME
snprintf(URI, sizeof(URI), "/cnf/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
mac[5]);
#else
#ifndef FLASH_64KB
snprintf(URI, sizeof(URI), "/cnf/%s_config.json",QUOTE(DEVICE_NAME));
#else
strncpy(URI, "/cnf/", sizeof(URI));
strncat(URI, QUOTE(DEVICE_NAME), sizeof(URI));
strncat(URI, "_config.json", sizeof(URI));
#endif
#endif
infoSerial<<F("Config URI: http://")<<configServer<<URI<<endl;
#if defined(ARDUINO_ARCH_AVR)
FILE *configStream;
//wdt_dis();
//if (freeRam()<512) cleanConf();
HTTPClient hclient(configServer, 80);
// FILE is the return STREAM type of the HTTPClient
configStream = hclient.getURI(URI);
responseStatusCode = hclient.getLastReturnCode();
//wdt_en();
if (configStream != NULL) {
if (responseStatusCode == 200) {
infoSerial<<F("got Config\n");
char c;
aJsonFileStream as = aJsonFileStream(configStream);
noInterrupts();
cleanConf();
root = aJson.parse(&as);
interrupts();
hclient.closeStream(configStream); // this is very important -- be sure to close the STREAM
if (!root) {
errorSerial<<F("Config parsing failed\n");
// timerLanCheckTime = millis();// + 15000;
return READ_RE_CONFIG;//-11;
} else {
infoSerial<<F("Applying.\n");
applyConfig();
infoSerial<<F("Done.\n");
}
} else {
errorSerial<<F("ERROR: Server returned ");
errorSerial<<responseStatusCode<<endl;
// timerLanCheckTime = millis();// + 5000;
return READ_RE_CONFIG;//-11;
}
} else {
debugSerial<<F("failed to connect\n");
// debugSerial<<F(" try again in 5 seconds\n");
// timerLanCheckTime = millis();// + 5000;
return READ_RE_CONFIG;//-11;
}
#endif
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32) || defined (NRF5) //|| defined(ARDUINO_ARCH_ESP32) //|| defined(ARDUINO_ARCH_ESP8266)
#if defined(WIFI_ENABLE)
WiFiClient configEthClient;
#else
EthernetClient configEthClient;
#endif
String response;
HttpClient htclient = HttpClient(configEthClient, configServer, 80);
//htclient.stop(); //_socket =MAX
htclient.setHttpResponseTimeout(4000);
wdt_res();
//debugSerial<<"making GET request");get
htclient.beginRequest();
responseStatusCode = htclient.get(URI);
htclient.endRequest();
if (responseStatusCode == HTTP_SUCCESS)
{
// read the status code and body of the response
responseStatusCode = htclient.responseStatusCode();
response = htclient.responseBody();
htclient.stop();
wdt_res();
infoSerial<<F("HTTP Status code: ")<<responseStatusCode<<endl;
//delay(1000);
if (responseStatusCode == 200) {
debugSerial<<F("GET Response: ")<<response<<endl;
debugSerial<<F("Free:")<<freeRam()<<endl;
cleanConf();
debugSerial<<F("Configuration cleaned")<<endl;
debugSerial<<F("Free:")<<freeRam()<<endl;
root = aJson.parse((char *) response.c_str());
if (!root) {
errorSerial<<F("Config parsing failed\n");
return READ_RE_CONFIG;//-11; //Load from NVRAM
} else {
debugSerial<<F("Parsed. Free:")<<freeRam()<<endl;
//debugSerial<<response;
applyConfig();
infoSerial<<F("Done.\n");
}
} else {
errorSerial<<F("Config retrieving failed\n");
return READ_RE_CONFIG;//-11; //Load from NVRAM
}
} else {
errorSerial<<F("Connect failed\n");
return READ_RE_CONFIG;//-11; //Load from NVRAM
}
#endif
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) //|| defined (NRF5)
HTTPClient httpClient;
#if defined(WIFI_ENABLE)
WiFiClient configEthClient;
#else
EthernetClient configEthClient;
#endif
String fullURI = "http://";
fullURI+=configServer;
fullURI+=URI;
#if defined(ARDUINO_ARCH_ESP8266)
httpClient.begin(configEthClient,fullURI);
#else
httpClient.begin(fullURI);
#endif
int httpResponseCode = httpClient.GET();
if (httpResponseCode > 0) {
infoSerial.printf("[HTTP] GET... code: %d\n", httpResponseCode);
if (httpResponseCode == HTTP_CODE_OK) {
String response = httpClient.getString();
debugSerial<<response;
cleanConf();
root = aJson.parse((char *) response.c_str());
if (!root) {
errorSerial<<F("Config parsing failed\n");
return READ_RE_CONFIG;
} else {
infoSerial<<F("Config OK, Applying\n");
applyConfig();
infoSerial<<F("Done.\n");
}
} else {
errorSerial<<F("Config retrieving failed\n");
return READ_RE_CONFIG;//-11; //Load from NVRAM
}
} else {
errorSerial.printf("[HTTP] GET... failed, error: %s\n", httpClient.errorToString(httpResponseCode).c_str());
httpClient.end();
return READ_RE_CONFIG;
}
httpClient.end();
#endif
return IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
}
void preTransmission() {
#ifdef CONTROLLINO
// set DE and RE on HIGH
PORTJ |= B01100000;
#else
digitalWrite(TXEnablePin, 1);
#endif
}
void postTransmission() {
#ifdef CONTROLLINO
// set DE and RE on LOW
PORTJ &= B10011111;
#else
digitalWrite(TXEnablePin, 0);
#endif
}
void setup_main() {
#if defined(__SAM3X8E__)
memset(&UniqueID,0,sizeof(UniqueID));
#endif
#if defined(M5STACK)
// Initialize the M5Stack object
M5.begin();
#endif
setupCmdArduino();
printFirmwareVersionAndBuildOptions();
//Checkin EEPROM integrity (signature)
for (int i=0;i<EEPROM_SIGNATURE_LENGTH;i++)
if (EEPROM.read(i+OFFSET_SIGNATURE)!=EEPROM_signature[i])
{
cmdFunctionClearEEPROM(0,NULL);
break;
}
// scan_i2c_bus();
#ifdef SD_CARD_INSERTED
sd_card_w5100_setup();
#endif
setupMacAddress();
#if defined(ARDUINO_ARCH_ESP8266)
EEPROM.begin(ESP_EEPROM_SIZE);
#endif
#ifdef _modbus
#ifdef CONTROLLINO
//set PORTJ pin 5,6 direction (RE,DE)
DDRJ |= B01100000;
//set RE,DE on LOW
PORTJ &= B10011111;
#else
pinMode(TXEnablePin, OUTPUT);
#endif
modbusSerial.begin(MODBUS_SERIAL_BAUD);
node.idle(&modbusIdle);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
#endif
delay(20);
//owReady = 0;
#ifdef _owire
setupOwIdle(&owIdle);
#endif
mqttClient.setCallback(mqttCallback);
#ifdef _artnet
ArtnetSetup();
#endif
#if defined(WIFI_ENABLE) and not defined(WIFI_MANAGER_DISABLE)
// WiFiManager wifiManager;
wifiManager.setTimeout(180);
#if defined(ESP_WIFI_AP) and defined(ESP_WIFI_PWD)
wifiInitialized = wifiManager.autoConnect(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
#else
wifiInitialized = wifiManager.autoConnect();
#endif
#endif
delay(LAN_INIT_DELAY);//for LAN-shield initializing
//TODO: checkForRemoteSketchUpdate();
#if defined(W5500_CS_PIN) && ! defined(WIFI_ENABLE)
Ethernet.init(W5500_CS_PIN);
infoSerial<<F("Use W5500 pin: ");
infoSerial<<QUOTE(W5500_CS_PIN)<<endl;
#endif
loadConfigFromEEPROM();
}
void printFirmwareVersionAndBuildOptions() {
infoSerial<<F("\nLazyhome.ru LightHub controller ")<<F(QUOTE(PIO_SRC_REV))<<F(" C++ version:")<<F(QUOTE(__cplusplus))<<endl;
#ifdef CONTROLLINO
infoSerial<<F("\n(+)CONTROLLINO");
#endif
#ifndef WATCH_DOG_TICKER_DISABLE
infoSerial<<F("\n(+)WATCHDOG");
#else
infoSerial<<F("\n(-)WATCHDOG");
#endif
infoSerial<<F("\nConfig server:")<<F(CONFIG_SERVER)<<F("\nFirmware MAC Address ")<<F(QUOTE(CUSTOM_FIRMWARE_MAC));
#ifdef DISABLE_FREERAM_PRINT
infoSerial<<F("\n(-)FreeRam printing");
#else
infoSerial<<F("\n(+)FreeRam printing");
#endif
#ifdef USE_1W_PIN
infoSerial<<F("\n(-)DS2482-100 USE_1W_PIN=")<<QUOTE(USE_1W_PIN);
#else
infoSerial<<F("\n(+)DS2482-100");
#endif
#ifdef WIFI_ENABLE
infoSerial<<F("\n(+)WiFi");
#elif Wiz5500
infoSerial<<F("\n(+)WizNet5500");
#elif Wiz5100
infoSerial<<F("\n(+)Wiznet5100");
#else
infoSerial<<F("\n(+)Wiznet5x00");
#endif
#ifndef DMX_DISABLE
infoSerial<<F("\n(+)DMX");
#ifdef FASTLED
infoSerial<<F("\n(+)FASTLED");
#else
infoSerial<<F("\n(+)ADAFRUIT LED");
#endif
#else
infoSerial<<F("\n(-)DMX");
#endif
#ifdef _modbus
infoSerial<<F("\n(+)MODBUS");
#else
infoSerial<<F("\n(-)MODBUS");
#endif
#ifndef OWIRE_DISABLE
infoSerial<<F("\n(+)OWIRE");
#else
infoSerial<<F("\n(-)OWIRE");
#endif
#ifndef DHT_DISABLE
infoSerial<<F("\n(+)DHT");
#else
infoSerial<<F("\n(-)DHT");
#endif
#ifndef COUNTER_DISABLE
infoSerial<<F("\n(+)COUNTER");
#else
infoSerial<<F("\n(-)COUNTER");
#endif
#ifdef SD_CARD_INSERTED
infoSerial<<F("\n(+)SDCARD");
#endif
#ifdef RESET_PIN
infoSerial<<F("\n(+)HARDRESET on pin=")<<QUOTE(RESET_PIN);
#else
infoSerial<<F("\n(-)HARDRESET, using soft");
#endif
#ifdef RESTART_LAN_ON_MQTT_ERRORS
infoSerial<<F("\n(+)RESTART_LAN_ON_MQTT_ERRORS");
#else
infoSerial<<F("\n(-)RESTART_LAN_ON_MQTT_ERRORS");
#endif
#ifndef CSSHDC_DISABLE
infoSerial<<F("\n(+)CCS811 & HDC1080");
#else
infoSerial<<F("\n(-)CCS811 & HDC1080");
#endif
#ifndef AC_DISABLE
infoSerial<<F("\n(+)AC HAIER");
#else
infoSerial<<F("\n(-)AC HAIER");
#endif
#ifndef MOTOR_DISABLE
infoSerial<<F("\n(+)MOTOR CTR");
#else
infoSerial<<F("\n(-)MOTOR CTR");
#endif
#ifndef SPILED_DISABLE
infoSerial<<F("\n(+)SPI LED");
#else
infoSerial<<F("\n(-)SPI LED");
#endif
#ifdef OTA
infoSerial<<F("\n(+)OTA");
#else
infoSerial<<F("\n(-)OTA");
#endif
#ifdef ARTNET_ENABLE
infoSerial<<F("\n(+)ARTNET");
#else
infoSerial<<F("\n(-)ARTNET");
#endif
#ifdef MCP23017
infoSerial<<F("\n(+)MCP23017");
#else
infoSerial<<F("\n(-)MCP23017");
#endif
#ifndef PID_DISABLE
infoSerial<<F("\n(+)PID");
#else
infoSerial<<F("\n(-)PID");
#endif
#ifdef SYSLOG_ENABLE
//udpSyslogClient.begin(SYSLOG_LOCAL_SOCKET);
infoSerial<<F("\n(+)SYSLOG");
#else
infoSerial<<F("\n(-)SYSLOG");
#endif
infoSerial<<endl;
// WDT_Disable( WDT ) ;
#if defined(__SAM3X8E__)
debugSerial<<F("Reading 128 bits unique identifier")<<endl ;
ReadUniqueID( UniqueID.UID_Long ) ;
infoSerial<< F ("ID: ");
for (byte b = 0 ; b < 4 ; b++)
infoSerial<< _HEX((unsigned int) UniqueID.UID_Long [b]);
infoSerial<< endl;
#endif
}
void publishStat(){
long fr = freeRam();
char topic[64];
char intbuf[16];
uint32_t ut = millis()/1000UL;
if (!mqttClient.connected() || ethernetIdleCount) return;
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, stats_P, sizeof(topic));
strncat(topic, "/", sizeof(topic));
strncat_P(topic, freeheap_P, sizeof(topic));
printUlongValueToStr(intbuf, fr);
mqttClient.publish(topic,intbuf,true);
setTopic(topic,sizeof(topic),T_DEV);
strncat_P(topic, stats_P, sizeof(topic));
strncat(topic, "/", sizeof(topic));
strncat_P(topic, uptime_P, sizeof(topic));
printUlongValueToStr(intbuf, ut);
mqttClient.publish(topic,intbuf,true);
}
void setupMacAddress() {
//Check MAC, stored in NVRAM
bool isMacValid = false;
for (short i = 0; i < 6; i++) {
mac[i] = EEPROM.read(i);
if (mac[i] != 0 && mac[i] != 0xff) isMacValid = true;
}
if (!isMacValid) {
infoSerial<<F("No MAC configured: set firmware's MAC\n");
#if defined (CUSTOM_FIRMWARE_MAC) //Forced MAC from compiler's directive
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
parseBytes(macStr, ':', mac, 6, 16);
mac[0]&=0xFE;
mac[0]|=2;
#elif defined(WIFI_ENABLE)
//Using original MPU MAC
WiFi.begin();
WiFi.macAddress(mac);
#elif defined(__SAM3X8E__)
//Lets make MAC from MPU serial#
mac[0]=0xDE;
for (byte b = 0 ; b < 5 ; b++)
mac[b+1]=UniqueID.UID_Byte [b*3] + UniqueID.UID_Byte [b*3+1] + UniqueID.UID_Byte [b*3+2];
#elif defined DEFAULT_FIRMWARE_MAC
uint8_t defaultMac[6] = DEFAULT_FIRMWARE_MAC;//comma(,) separated hex-array, hard-coded
memcpy(mac,defaultMac,6);
#endif
}
printMACAddress();
}
void setupCmdArduino() {
cmdInit(uint32_t(SERIAL_BAUD));
debugSerial<<(F(">>>"));
cmdAdd("help", cmdFunctionHelp);
cmdAdd("save", cmdFunctionSave);
cmdAdd("load", cmdFunctionLoad);
cmdAdd("get", cmdFunctionGet);
#ifndef FLASH_64KB
cmdAdd("mac", cmdFunctionSetMac);
#endif
cmdAdd("kill", cmdFunctionKill);
cmdAdd("req", cmdFunctionReq);
cmdAdd("ip", cmdFunctionIp);
cmdAdd("pwd", cmdFunctionPwd);
cmdAdd("clear",cmdFunctionClearEEPROM);
cmdAdd("reboot",cmdFunctionReboot);
}
void loop_main() {
LED.poll();
#if defined(M5STACK)
// Initialize the M5Stack object
yield();
M5.update();
#endif
wdt_res();
yield();
cmdPoll();
if (lanLoop() > HAVE_IP_ADDRESS) {
mqttClient.loop();
#if defined(OTA)
yield();
ArduinoOTA.poll();
#endif
#ifdef _artnet
yield();
if (artnet) artnet->read(); ///hung
#endif
}
#ifdef _owire
yield();
if (owReady && owArr) owLoop();
#endif
#ifdef _dmxin
yield();
DMXCheck();
#endif
if (items) {
if (isNotRetainingStatus()) pollingLoop();
yield();
thermoLoop();
}
yield();
inputLoop();
#if defined (_espdmx)
yield();
dmxout.update();
#endif
}
void owIdle(void) {
#ifdef _artnet
if (artnet && (lanStatus>=HAVE_IP_ADDRESS)) artnet->read();
#endif
wdt_res();
return;
#ifdef _dmxin
yield();
DMXCheck();
#endif
#if defined (_espdmx)
yield();
dmxout.update();
#endif
}
void ethernetIdle(void){
ethernetIdleCount++;
wdt_res();
yield();
inputLoop();
ethernetIdleCount--;
};
void modbusIdle(void) {
LED.poll();
yield();
cmdPoll();
wdt_res();
if (lanLoop() > HAVE_IP_ADDRESS) {
yield();
mqttClient.loop();
#ifdef _artnet
if (artnet) artnet->read();
#endif
yield();
inputLoop();
}
#ifdef _dmxin
DMXCheck();
#endif
#if defined (_espdmx)
dmxout.update();
#endif
}
void inputLoop(void) {
if (!inputs) return;
configLocked++;
//if (millis() > timerInputCheck)
if (isTimeOver(timerInputCheck,millis(),INTERVAL_CHECK_INPUT))
{
aJsonObject *input = inputs->child;
while (input) {
if (input->type == aJson_Object) {
// Check for nested inputs
aJsonObject * inputArray = aJson.getObjectItem(input, "act");
if (inputArray && (inputArray->type == aJson_Array))
{
aJsonObject *inputObj = inputArray->child;
while(inputObj)
{
Input in(inputObj,input);
in.Poll(CHECK_INPUT);
yield();
inputObj = inputObj->next;
}
}
else
{
Input in(input);
in.Poll(CHECK_INPUT);
}
}
yield();
input = input->next;
}
timerInputCheck = millis();// + INTERVAL_CHECK_INPUT;
inCache.invalidateInputCache();
}
//if (millis() > timerSensorCheck)
if (isTimeOver(timerSensorCheck,millis(),INTERVAL_CHECK_SENSOR))
{
aJsonObject *input = inputs->child;
while (input) {
if ((input->type == aJson_Object)) {
Input in(input);
in.Poll(CHECK_SENSOR);
}
yield();
input = input->next;
}
timerSensorCheck = millis();// + INTERVAL_CHECK_SENSOR;
}
configLocked--;
}
void inputSetup(void) {
if (!inputs) return;
configLocked++;
aJsonObject *input = inputs->child;
while (input) {
if ((input->type == aJson_Object)) {
Input in(input);
in.setup();
}
yield();
input = input->next;
}
configLocked--;
}
void pollingLoop(void) {
// FAST POLLINT - as often AS possible every item
configLocked++;
if (items) {
aJsonObject * item = items->child;
while (items && item)
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
Item it(item);
if (it.isValid()) {
it.Poll(POLLING_FAST);
} //isValid
yield();
item = item->next;
} //if
}
configLocked--;
// SLOW POLLING
boolean done = false;
if (lanStatus == RETAINING_COLLECTING) return;
//if (millis() > timerPollingCheck)
if (isTimeOver(timerPollingCheck,millis(),INTERVAL_SLOW_POLLING))
{
while (pollingItem && !done) {
if (pollingItem->type == aJson_Array) {
Item it(pollingItem);
uint32_t ret = it.Poll(POLLING_SLOW);
if (ret)
{
timerPollingCheck = millis();// + ret; //INTERVAL_CHECK_MODBUS;
done = true;
}
}//if
if (!pollingItem) return; //Config was re-readed
yield();
pollingItem = pollingItem->next;
if (!pollingItem) {
pollingItem = items->child;
return;
} //start from 1-st element
} //while
}//if
}
////// Legacy Thermostat code below - to be moved in module /////
void thermoRelay(int pin, bool on)
{
int thermoPin = abs(pin);
pinMode(thermoPin, OUTPUT);
if (on)
{
digitalWrite(thermoPin, (pin<0)?LOW:HIGH);
debugSerial<<F(" ON")<<endl;
}
else
{
digitalWrite(thermoPin, (pin<0)?HIGH:LOW);
debugSerial<<F(" OFF")<<endl;
}
}
void thermoLoop(void) {
if (!isTimeOver(timerThermostatCheck,millis(),THERMOSTAT_CHECK_PERIOD))
return;
if (!items) return;
bool thermostatCheckPrinted = false;
configLocked++;
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
if ((thermoItem->type == aJson_Array) && (aJson.getArrayItem(thermoItem, I_TYPE)->valueint == CH_THERMO))
{
Item thermostat(thermoItem); //Init Item
if (!thermostat.isValid()) continue;
itemCmd thermostatCmd(&thermostat); // Got itemCmd
thermostatStore tStore;
tStore.asint=thermostat.getExt();
int thermoPin = thermostat.getArg(0);
float thermoSetting = thermostatCmd.getFloat();
int thermoStateCommand = thermostat.getCmd();
float curTemp = (float) tStore.tempX100/100.;
bool active = thermostat.isActive();
debugSerial << F(" Set:") << thermoSetting << F(" Cur:") << curTemp
<< F(" cmd:") << thermoStateCommand;
if (tStore.timestamp16) //Valid temperature
{
if (isTimeOver(tStore.timestamp16,millisNZ(8) & 0xFFFF,PERIOD_THERMOSTAT_FAILED,0xFFFF))
{
errorSerial<<thermoItem->name<<F(" Alarm Expired\n");
mqttClient.publish("/alarm/snsr", thermoItem->name);
tStore.timestamp16=0; //Stop termostat
thermostat.setExt(tStore.asint);
thermoRelay(thermoPin,false);
}
else
{ // Not expired yet
if (curTemp > THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", thermoItem->name);
if (!active) thermoRelay(thermoPin,false);//OFF
else if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) thermoRelay(thermoPin,true);//ON
else if (curTemp >= thermoSetting) thermoRelay(thermoPin,false);//OFF
else debugSerial<<F(" -target zone-")<<endl; // Nothing to do
}
}
else debugSerial<<F(" Expired\n");
thermostatCheckPrinted = true;
} //item is termostat
} //for
configLocked--;
timerThermostatCheck = millis();// + THERMOSTAT_CHECK_PERIOD;
publishStat();
#ifndef DISABLE_FREERAM_PRINT
(thermostatCheckPrinted) ? debugSerial<<F("\nRAM=")<<freeRam()<<" " : debugSerial<<F(" ")<<freeRam()<<F(" ");
#endif
}
| 28.160055
| 146
| 0.580147
|
anklimov
|
8947c0699f9f8d747a3eea649857d17fb32f2382
| 284
|
hpp
|
C++
|
include/Pomdog/Math/Vector3.hpp
|
ValtoForks/pomdog
|
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
|
[
"MIT"
] | null | null | null |
include/Pomdog/Math/Vector3.hpp
|
ValtoForks/pomdog
|
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
|
[
"MIT"
] | null | null | null |
include/Pomdog/Math/Vector3.hpp
|
ValtoForks/pomdog
|
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2013-2018 mogemimi. Distributed under the MIT license.
#pragma once
#include "Pomdog/Math/detail/FloatingPointVector3.hpp"
namespace Pomdog {
///@brief vector in three-dimensional space.
using Vector3 = Detail::FloatingPointVector3<float>;
} // namespace Pomdog
| 21.846154
| 71
| 0.767606
|
ValtoForks
|
8949109c19fa8629dfda11dd3767539f2739ed2f
| 2,028
|
hpp
|
C++
|
firmware/battery_board/include/hal/analogInput.hpp
|
introlab/securbot
|
0652ddf3e2dbcf0bb6ffcf76898749b67e443327
|
[
"Apache-2.0"
] | 20
|
2019-03-13T13:37:51.000Z
|
2022-01-25T16:56:35.000Z
|
firmware/battery_board/include/hal/analogInput.hpp
|
introlab/securbot
|
0652ddf3e2dbcf0bb6ffcf76898749b67e443327
|
[
"Apache-2.0"
] | 15
|
2019-02-27T20:29:34.000Z
|
2020-08-24T19:44:20.000Z
|
firmware/battery_board/include/hal/analogInput.hpp
|
introlab/securbot
|
0652ddf3e2dbcf0bb6ffcf76898749b67e443327
|
[
"Apache-2.0"
] | 13
|
2019-07-31T00:47:49.000Z
|
2021-04-15T01:33:02.000Z
|
/**
* @file analogInput.hpp
* @author Cedric Godin (cedric.godin@me.com)
* @brief Driver to read analog inputs
* @version 0.1
* @date 2019-10-02
*
* @copyright Copyright (c) 2019
*
*/
#pragma once
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include "chip/ADS1015.hpp"
/**
* @brief Driver for all analog input.
* Driver that allows reading from analog input
* A single driver reads from all input.
*/
class AnalogInput
{
public:
/**
* @brief get the AnalogInput instance.
* Get the instance of AnalogInput. Create it if it doesnt exist
* @return AnalogInput* pointer to the AnalogInput object
*/
static AnalogInput* instance();
/**
* @brief Initialize the analogInput driver.
* Configure the ADCs. Must be called before any reading is performed.
* @return esp_err_t driver initialization result. Check against ESP_OK
*/
esp_err_t begin();
/**
* @brief Read a channel.
* Reads the voltage between the specified channel and ground
* Thread safe
* @param channel_number The channel number (0-7)
* @param value channel voltage (V)
* @return esp_err_t operation success. Check agaist ESP_OK
*/
esp_err_t read(uint8_t channel_number, float &value);
private:
/**
* @brief Construct a new Analog Input object.
* Construct a new Analog Input object
* Is called automatically when an instance is requested
*/
AnalogInput();
/**
* @brief Pointer to the AnalogInput instance.
* Point to the unique AnalogInput instance
* There is one object shared amongst all instances
*/
static AnalogInput* _instance;
/**
* @brief ADCs instance.
* Array of ADCs instance from which are used to read analog values
*/
ADS1015* _adcs[2];
/**
* @brief Instance mutex.
* Mutex to make read calls thread-safe
* There is on per ADC
*/
SemaphoreHandle_t _mutex[2];
};
| 25.35
| 75
| 0.658777
|
introlab
|
8949c49dccf37d5502a34bb34760e119946a12fb
| 1,422
|
cpp
|
C++
|
Code/LeetCode/Linked List Cycle/Linked List Cycle.cpp
|
myhgew/CodePractice
|
c3313623d973192d6c2f20255bb01088b970ee80
|
[
"MIT"
] | null | null | null |
Code/LeetCode/Linked List Cycle/Linked List Cycle.cpp
|
myhgew/CodePractice
|
c3313623d973192d6c2f20255bb01088b970ee80
|
[
"MIT"
] | null | null | null |
Code/LeetCode/Linked List Cycle/Linked List Cycle.cpp
|
myhgew/CodePractice
|
c3313623d973192d6c2f20255bb01088b970ee80
|
[
"MIT"
] | null | null | null |
/*
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
*/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
#include <iostream>
#include <stdlib.h>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
bool hasCycle(ListNode *head) {
if (head == NULL) {
return false;
}
if (head->next == NULL) {
return false;
}
ListNode *slow = head;
ListNode *fast = head;
while(fast != NULL && fast->next != NULL) {
fast = fast->next->next;
slow = slow->next;
if (fast == slow) {
return true;
}
}
return false;
}
};
int main(int argc, char *argv[]) {
ListNode *a = new ListNode(1);
ListNode *b = new ListNode(2);
ListNode *c = new ListNode(3);
ListNode *d = new ListNode(4);
ListNode *e = new ListNode(5);
a->next = b;
b->next = c;
c->next = d;
d->next = e;
e->next = b;
Solution s;
cout << "Has cycle:" << s.hasCycle(a) << endl;
// Clean up "new" node
delete a;
delete b;
delete c;
delete d;
delete e;
return EXIT_SUCCESS;
}
| 18.230769
| 55
| 0.517581
|
myhgew
|
894a65414c61aa2a3ce16e79e32541ec2d1c6570
| 5,939
|
cpp
|
C++
|
KolFloat.cpp
|
ekoly/kollang
|
824b6a3cccad8316874485d0ead63d38b6a9699b
|
[
"MIT"
] | null | null | null |
KolFloat.cpp
|
ekoly/kollang
|
824b6a3cccad8316874485d0ead63d38b6a9699b
|
[
"MIT"
] | null | null | null |
KolFloat.cpp
|
ekoly/kollang
|
824b6a3cccad8316874485d0ead63d38b6a9699b
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <cmath>
#include <cstdlib>
#include "KolMain.h"
#include "KolScopes.h"
#include "KolInt.h"
#include "KolString.h"
#include "KolFloat.h"
using namespace std;
// class methods
KolFloat::KolFloat(double value) : KolObject("float") {
this->value = value;
}
double KolFloat::getValue() {
return this->value;
}
// accessible methods
KolObject *protoFloat__str__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolString *result = new KolString(to_string(self->getValue()));
return result;
}
KolObject *protoFloat__add__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
KolFloat *result = new KolFloat(self->getValue() + ((KolInt *)other)->getValue());
return result;
} else if (other->getClassname() == "float") {
KolFloat *result = new KolFloat(self->getValue() + ((KolFloat *)other)->getValue());
return result;
}
return NULL;
}
KolObject *protoFloat__sub__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
KolFloat *result = new KolFloat(self->getValue() - ((KolInt *)other)->getValue());
return result;
} else if (other->getClassname() == "float") {
KolFloat *result = new KolFloat(self->getValue() - ((KolFloat *)other)->getValue());
return result;
}
return NULL;
}
KolObject *protoFloat__mul__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
KolFloat *result = new KolFloat(self->getValue() * ((KolInt *)other)->getValue());
return result;
} else if (other->getClassname() == "float") {
KolFloat *result = new KolFloat(self->getValue() * ((KolFloat *)other)->getValue());
return result;
}
return NULL;
}
KolObject *protoFloat__div__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
KolFloat *result = new KolFloat(self->getValue() / ((KolInt *)other)->getValue());
return result;
} else if (other->getClassname() == "float") {
KolFloat *result = new KolFloat(self->getValue() / ((KolFloat *)other)->getValue());
return result;
}
return NULL;
}
KolObject *protoFloat__floordiv__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
KolInt *result = new KolInt(self->getValue() / ((KolInt *)other)->getValue());
return result;
} else if (other->getClassname() == "float") {
KolInt *result = new KolInt(self->getValue() / ((KolFloat *)other)->getValue());
return result;
}
return NULL;
}
KolObject *protoFloat__pow__callback(vector<KolObject *> &args) {
KolFloat *self = (KolFloat *)args[0];
KolObject *other = args[1];
if (other->getClassname() == "int") {
#if DEBUG >= 2
cout << "protoFloat__pow__callback(" << to_string(self->getValue()) << ", " << to_string(((KolInt *)other)->getValue()) << ")\n";
#endif
KolFloat *result = new KolFloat(pow(self->getValue(), ((KolInt *)other)->getValue()));
return result;
} else if (other->getClassname() == "float") {
#if DEBUG >= 2
cout << "protoFloat__pow__callback(" << to_string(self->getValue()) << ", " << to_string(((KolFloat *)other)->getValue()) << ")\n";
#endif
KolFloat *result = new KolFloat(pow(self->getValue(), ((KolFloat *)other)->getValue()));
return result;
}
return NULL;
}
bool kolFloatSetup() {
#if DEBUG >= 2
cout << "kolFloatSetup(): setting up float built-ins\n";
#endif
KolObject *protoFloat = new KolFloat(0.0);
if (protoFloat == NULL) return false;
// float buitin functions
KolMethodWrapper *protoFloat__str__ = new KolMethodWrapper();
if (protoFloat__str__ == NULL) return false;
protoFloat__str__->call = protoFloat__str__callback;
protoFloat->setMember("__str__", protoFloat__str__);
KolMethodWrapper *protoFloat__mul__ = new KolMethodWrapper();
if (protoFloat__mul__ == NULL) return false;
protoFloat__mul__->call = protoFloat__mul__callback;
protoFloat->setMember("__mul__", protoFloat__mul__);
KolMethodWrapper *protoFloat__div__ = new KolMethodWrapper();
if (protoFloat__div__ == NULL) return false;
protoFloat__div__->call = protoFloat__div__callback;
protoFloat->setMember("__div__", protoFloat__div__);
KolMethodWrapper *protoFloat__floordiv__ = new KolMethodWrapper();
if (protoFloat__floordiv__ == NULL) return false;
protoFloat__floordiv__->call = protoFloat__floordiv__callback;
protoFloat->setMember("__floordiv__", protoFloat__floordiv__);
KolMethodWrapper *protoFloat__pow__ = new KolMethodWrapper();
if (protoFloat__pow__ == NULL) return false;
protoFloat__pow__->call = protoFloat__pow__callback;
protoFloat->setMember("__pow__", protoFloat__pow__);
KolMethodWrapper *protoFloat__add__ = new KolMethodWrapper();
if (protoFloat__add__ == NULL) return false;
protoFloat__add__->call = protoFloat__add__callback;
protoFloat->setMember("__add__", protoFloat__add__);
KolMethodWrapper *protoFloat__sub__ = new KolMethodWrapper();
if (protoFloat__sub__ == NULL) return false;
protoFloat__sub__->call = protoFloat__sub__callback;
protoFloat->setMember("__sub__", protoFloat__sub__);
kolScopeInsertBuiltin(protoFloat->getClassname(), protoFloat);
#if DEBUG >= 2
cout << "kolFloatSetup(): finished setting up float built-ins\n";
#endif
return true;
}
| 32.812155
| 139
| 0.653814
|
ekoly
|
894e2e35083a65042d02fb0e8fae5f3caef5d4e8
| 1,749
|
cpp
|
C++
|
code/client/src/core/hooks/camera.cpp
|
mufty/MafiaMP
|
2dc0e3362c505079e26e598bd4a7f4b5de7400bc
|
[
"OpenSSL"
] | 16
|
2021-10-08T17:47:04.000Z
|
2022-03-28T13:26:37.000Z
|
code/client/src/core/hooks/camera.cpp
|
mufty/MafiaMP
|
2dc0e3362c505079e26e598bd4a7f4b5de7400bc
|
[
"OpenSSL"
] | 4
|
2022-01-19T08:11:57.000Z
|
2022-01-29T19:02:24.000Z
|
code/client/src/core/hooks/camera.cpp
|
mufty/MafiaMP
|
2dc0e3362c505079e26e598bd4a7f4b5de7400bc
|
[
"OpenSSL"
] | 4
|
2021-10-09T11:15:08.000Z
|
2022-01-27T22:42:26.000Z
|
#include <MinHook.h>
#include <utils/hooking/hook_function.h>
#include <utils/hooking/hooking.h>
#include <logging/logger.h>
typedef int64_t(__fastcall *C_Camera__ModeChangeImmediate_t)(void *_this, int, void *, bool, bool, bool);
C_Camera__ModeChangeImmediate_t C_Camera__ModeChangeImmediate_original = nullptr;
typedef int64_t(__fastcall *C_Camera__SendCommand_t)(void *, unsigned int, void *, void *);
C_Camera__SendCommand_t C_Camera__SendCommand_original = nullptr;
int64_t C_Camera__ModeChangeImmediate(void* _this, int mode, void* data, bool unk1, bool unk2, bool unk3) {
Framework::Logging::GetLogger("Hooks")->debug("[Camera::ModeChangeImmediate]: id {}, ptr {:p}, {} {} {}", mode, fmt::ptr(data), unk1, unk2, unk3);
return C_Camera__ModeChangeImmediate_original(_this, mode, data, unk1, unk2, unk3);
}
int64_t C_Camera__SendCommand(void* _this, unsigned int mode, void*unk1, void*unk2) {
Framework::Logging::GetLogger("Hooks")->debug("[Camera::SendCommand]: id {}, unk1 {:p}, unk2 {:p}", mode, fmt::ptr(unk1), fmt::ptr(unk2));
return C_Camera__SendCommand_original(_this, mode, unk1, unk2);
}
static InitFunction init([]() {
const auto modeChangePattern = reinterpret_cast<uint64_t>(hook::pattern("48 89 5C 24 ? 57 48 83 EC 30 0F B6 44 24 ? 48 8B D9").get_first());
MH_CreateHook((LPVOID)modeChangePattern, (PBYTE)C_Camera__ModeChangeImmediate, reinterpret_cast<void **>(&C_Camera__ModeChangeImmediate_original));
const auto sendCommandPattern = reinterpret_cast<uint64_t>(hook::pattern("48 8B 81 ? ? ? ? 48 8B 48 F8 48 8B 01 48 FF A0 D8 01 00 00").get_first());
MH_CreateHook((LPVOID)sendCommandPattern, (PBYTE)C_Camera__SendCommand, reinterpret_cast<void **>(&C_Camera__SendCommand_original));
});
| 58.3
| 152
| 0.748428
|
mufty
|
89511bba821f84f6fb0f43bbb73432eb9e6f8772
| 1,665
|
cpp
|
C++
|
google/code_jam/2018/r3/raise_the_roof__pnd.cpp
|
Loks-/competitions
|
3bb231ba9dd62447048832f45b09141454a51926
|
[
"MIT"
] | 4
|
2018-06-05T14:15:52.000Z
|
2022-02-08T05:14:23.000Z
|
google/code_jam/2018/r3/raise_the_roof__pnd.cpp
|
Loks-/competitions
|
3bb231ba9dd62447048832f45b09141454a51926
|
[
"MIT"
] | null | null | null |
google/code_jam/2018/r3/raise_the_roof__pnd.cpp
|
Loks-/competitions
|
3bb231ba9dd62447048832f45b09141454a51926
|
[
"MIT"
] | 1
|
2018-10-21T11:01:35.000Z
|
2018-10-21T11:01:35.000Z
|
#include "common/geometry/d3/base.h"
#include "common/geometry/d3/plane_pn.h"
#include "common/geometry/d3/point_io.h"
#include "common/geometry/d3/utils/plane_pn_from_points.h"
#include "common/geometry/d3/vector.h"
#include "common/stl/base.h"
int main_raise_the_roof__pnd() {
struct Point {
unsigned index;
D3Point p;
};
unsigned T;
cin >> T;
for (unsigned it = 1; it <= T; ++it) {
unsigned N;
cin >> N;
vector<Point> v(N);
for (unsigned i = 0; i < N; ++i) {
v[i].index = i + 1;
cin >> v[i].p;
}
unsigned mi = 0;
for (unsigned i = 1; i < N; ++i) {
if (v[mi].p.z < v[i].p.z) mi = i;
}
swap(v[0], v[mi]);
mi = N;
double mvalue = 1.;
for (unsigned i = 1; i < N; ++i) {
auto vi = v[0].p - v[i].p;
assert(!vi.Empty());
vi.Normalize();
if (vi.dz < mvalue) {
mvalue = vi.dz;
mi = i;
}
}
assert(mi < N);
swap(v[1], v[mi]);
for (unsigned k = 2; k < N; ++k) {
mi = N;
for (unsigned i = k; i < N; ++i) {
auto p = PlanePNFromPoints(v[k - 2].p, v[k - 1].p, v[i].p);
assert(p.Valid() && (p.n.dz != 0));
if (p.n.dz < 0) p.SetOppositeNormal();
bool ok = true;
for (unsigned j = k; j < N; ++j) {
if ((j != i) && (p(v[j].p) > 0)) {
ok = false;
break;
}
}
if (ok) {
mi = i;
break;
}
}
assert(mi < N);
swap(v[k], v[mi]);
}
reverse(v.begin(), v.end());
cout << "Case #" << it << ":";
for (auto p : v) cout << " " << p.index;
cout << endl;
}
return 0;
}
| 23.785714
| 67
| 0.44985
|
Loks-
|
89521a2f8e08b3841fc650e84cc9d2fa32279159
| 6,844
|
cc
|
C++
|
src/renderer/renderers/gl/renderer.cc
|
cptaffe/actor
|
4faf785fba098481b5e5582f53e15cfa5d431a73
|
[
"MIT"
] | null | null | null |
src/renderer/renderers/gl/renderer.cc
|
cptaffe/actor
|
4faf785fba098481b5e5582f53e15cfa5d431a73
|
[
"MIT"
] | null | null | null |
src/renderer/renderers/gl/renderer.cc
|
cptaffe/actor
|
4faf785fba098481b5e5582f53e15cfa5d431a73
|
[
"MIT"
] | null | null | null |
// Copyright 2016 Connor Taffe
#include "src/renderer/renderers/gl/renderer.h"
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <fstream>
#include <iostream>
#include <map>
#include <random>
#include <stdexcept>
#include <vector>
#include "src/renderer/event/event.h"
#include "src/renderer/renderer.h"
#include "src/renderer/renderers/gl/buffer.h"
#include "src/renderer/renderers/gl/shader.h"
#include "src/renderer/renderers/gl/shapes.h"
#include "src/renderer/renderers/gl/window.h"
#include "src/spool.h"
namespace gl {
namespace {
template <typename T>
class VertexAttributePointer {
public:
VertexAttributePointer(Buffer<T> *b, GLuint i, size_t size, GLenum type,
std::ptrdiff_t stride)
: buffer{b}, handle{i} {
buffer->Bind();
// TODO(cptaffe): figure out type from T
glVertexAttribPointer(i, size, type, false, stride, nullptr);
glEnableVertexAttribArray(i);
}
VertexAttributePointer(const VertexAttributePointer &other) = delete;
~VertexAttributePointer() { glDisableVertexAttribArray(handle); }
private:
Buffer<T> *buffer;
GLuint handle;
};
} // namespace
RenderPass::RenderPass(
std::shared_ptr<Rasterizable> rend, std::vector<size_t> ind,
std::shared_ptr<renderer::Renderable> view,
std::shared_ptr<renderer::Renderable> projection,
const std::vector<std::vector<std::shared_ptr<renderer::Renderable>>>
&model,
GLint h)
: rasterizable{rend}, indices{ind}, mvpHandle{h} {
auto v = glm::mat4(1.0), p = glm::mat4(1.0);
for (auto i : view->Render()) {
v *= i;
}
for (auto i : projection->Render()) {
p *= i;
}
for (auto i : indices) {
for (auto m : ([&] {
std::vector<glm::mat4> matrices = {glm::mat4(1.0)};
for (auto r : model[i]) {
matrices = r->Apply(matrices);
}
return matrices;
})()) {
mvp.push_back(p * v * m);
}
}
}
void RenderPass::Render() {
glUniformMatrix4fv(mvpHandle, mvp.size(), false, &mvp.data()[0][0][0]);
auto random = std::bind(std::uniform_real_distribution<GLfloat>(0, 1),
std::mt19937_64());
vertices.clear();
rasterizable->Rasterize(&vertices);
colors.clear();
for (size_t i = 0; i < vertices.size(); i++) {
for (size_t j = 0; j < 3; j++) {
colors.push_back(random());
}
}
Buffer<GLfloat> cb{colors}, vb{vertices};
auto vptrs = std::vector<std::shared_ptr<VertexAttributePointer<GLfloat>>>();
{
auto buffers = std::vector<Buffer<GLfloat> *>({&vb, &cb});
for (size_t i = 0; i < buffers.size(); i++) {
vptrs.push_back(std::shared_ptr<VertexAttributePointer<GLfloat>>(
new VertexAttributePointer<GLfloat>(
buffers[i], static_cast<GLuint>(i), 3, GL_FLOAT, 0)));
}
}
glDrawArraysInstanced(rasterizable->Type(), 0, vb.Size() * sizeof(GLfloat),
indices.size());
}
RenderThread::RenderThread(
std::function<std::vector<RenderPass>(Window *, GLint)> renderf)
: window{"basilisk", 400, 400},
program{([&] {
auto b = window.Bind(); // bind gl for scope
auto vshader =
std::ifstream("src/renderer/renderers/gl/shaders/triangle.vert");
auto fshader =
std::ifstream("src/renderer/renderers/gl/shaders/triangle.frag");
return ProgramBuilder()
.AddVertexShader(&vshader)
.AddFragmentShader(&fshader)
.Build();
})()},
mvpHandle{([&] {
auto b = window.Bind();
return program->UniformLocation("model_view_projection");
})()},
renderFunc(renderf) {
window.Swapiness(0);
}
void RenderThread::Run() {
for (;;) {
if (!Render(renderFunc(&window, mvpHandle))) {
return;
}
}
}
bool RenderThread::Render(std::vector<RenderPass> renders) {
auto b = window.Bind();
// pre-rendering
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
program->Use();
for (auto &r : renders) {
r.Render();
}
window.Swap();
glfwPollEvents();
if (window.Key(GLFW_KEY_ESCAPE) == GLFW_PRESS || window.ShouldClose()) {
return false;
}
return true;
}
Renderer::Renderer(
std::shared_ptr<renderer::Renderable> v,
std::function<std::shared_ptr<renderer::Renderable>(size_t w, size_t h)> p)
: view{v}, projection{p}, renderThread{[&] {
renderer::Timer::Start();
renderer = new RenderThread{[&](Window *win, GLint mvpHandle) {
renderer::Timer::Instance()->Stop();
// Do rendering
std::vector<RenderPass> renders;
{
std::unique_lock<std::mutex> lock(displayLock);
displayCondition.wait(lock, [&] { return display.size() > 0; });
for (auto m : ([&] {
std::map<std::shared_ptr<Rasterizable>, std::vector<size_t>>
map;
for (size_t i = 0; i < display.size(); i++) {
map[display[i]].push_back(i);
}
return map;
})()) {
renders.push_back({m.first, m.second, view,
projection(static_cast<uint>(win->Width()),
static_cast<uint>(win->Height())),
model, mvpHandle});
}
}
return renders;
}};
renderer->Run();
}} {
if (display.size() != model.size()) {
throw std::runtime_error(static_cast<std::stringstream &>(
std::stringstream()
<< "gl::Renderer: Display and model vectors "
"must be the same size, "
<< display.size() << " != " << model.size())
.str());
}
}
std::unique_ptr<renderer::shapes::Factory> Renderer::ShapeFactory() {
return std::unique_ptr<renderer::shapes::Factory>(new shapes::Factory());
}
void Renderer::Handle(std::shared_ptr<Event> const e) {
([&](std::shared_ptr<event::Spawn> spawn) {
if (spawn != nullptr) {
auto d = std::dynamic_pointer_cast<Rasterizable>(spawn->Display());
if (d == nullptr) {
// TODO(cptaffe): throw rejection event
throw std::runtime_error(
"gl::Renderer.Handle: Spawn event contains .Display "
"renderer::Rasterizable which does not "
"inherit from gl::Rasterizable");
}
std::unique_lock<std::mutex> lock(displayLock);
model.push_back(spawn->Model());
display.push_back(std::shared_ptr<Rasterizable>(d));
displayCondition.notify_one();
}
})(std::dynamic_pointer_cast<event::Spawn>(e));
}
} // namespace gl
| 31.109091
| 79
| 0.577732
|
cptaffe
|
89552baf8354d476b1f83329e5ae979335d68843
| 3,562
|
cpp
|
C++
|
librtt/Rtt_FillTesselatorStream.cpp
|
agramonte/corona
|
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
|
[
"MIT"
] | 1,968
|
2018-12-30T21:14:22.000Z
|
2022-03-31T23:48:16.000Z
|
librtt/Rtt_FillTesselatorStream.cpp
|
agramonte/corona
|
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
|
[
"MIT"
] | 303
|
2019-01-02T19:36:43.000Z
|
2022-03-31T23:52:45.000Z
|
librtt/Rtt_FillTesselatorStream.cpp
|
agramonte/corona
|
3a6892f14eea92fdab5fa6d41920aa1e97bc22b1
|
[
"MIT"
] | 254
|
2019-01-02T19:05:52.000Z
|
2022-03-30T06:32:28.000Z
|
//////////////////////////////////////////////////////////////////////////////
//
// This file is part of the Corona game engine.
// For overview and more information on licensing please refer to README.md
// Home page: https://github.com/coronalabs/corona
// Contact: support@coronalabs.com
//
//////////////////////////////////////////////////////////////////////////////
#include "Core/Rtt_Build.h"
#include "Rtt_FillTesselatorStream.h"
#include "Rtt_Matrix.h"
#include "Display/Rtt_VertexCache.h"
// ----------------------------------------------------------------------------
namespace Rtt
{
// ----------------------------------------------------------------------------
FillTesselatorStream::FillTesselatorStream( const Matrix* srcToDstSpace, VertexCache& cache )
: Super( srcToDstSpace, cache )
{
}
void
FillTesselatorStream::Submit( const VertexArray& vertices )
{
Rtt_ASSERT_NOT_IMPLEMENTED();
}
void
FillTesselatorStream::Submit( const Quad vertices )
{
Rtt_ASSERT_NOT_REACHED();
}
void
FillTesselatorStream::Submit( const Vertex2& origin, Real rectHalfW, Real rectHalfH, Real radius )
{
if ( Rtt_RealIsZero( radius ) )
{
AppendRectangle( rectHalfW, rectHalfH );
}
else
{
ArrayVertex2& vertices = fCache.Vertices();
Rtt_ASSERT( vertices.Length() == 0 );
// The "corners" of the rounded rect are just circle segments
AppendCircle( radius, true );
S32 length = vertices.Length(); Rtt_ASSERT( ( length & 0x3 ) == 0 );
Real halfW = rectHalfW - radius;
Real halfH = rectHalfH - radius;
length = length >> 2;
Vertex2* pVertices = vertices.WriteAccess();
// Position origin of each circle segment appropriately
Vertex2_Translate( pVertices, length, halfW, halfH ); pVertices += length;
Vertex2_Translate( pVertices, length, -halfW, halfH ); pVertices += length;
Vertex2_Translate( pVertices, length, -halfW, -halfH ); pVertices += length;
Vertex2_Translate( pVertices, length, halfW, -halfH );
// Add rest of rounded rectangle
halfH = rectHalfH;
const Vertex2 bottomLeft = { -halfW, -halfH };
const Vertex2 upperLeft = { -halfW, halfH };
const Vertex2 upperRight = { halfW, halfH };
const Vertex2 bottomRight = { halfW, -halfH };
// Middle rect
vertices.Append( bottomLeft );
vertices.Append( upperLeft );
vertices.Append( upperRight );
vertices.Append( bottomRight );
ArrayS32& counts = fCache.Counts();
counts.Append( 4 );
halfW = rectHalfW;
halfH -= radius;
// Left trapezoid
vertices.Append( bottomLeft );
Vertex2 p = { -halfW, -halfH };
vertices.Append( p );
p.y = halfH;
vertices.Append( p );
vertices.Append( upperLeft );
counts.Append( 4 );
// Right trapezoid
vertices.Append( bottomRight );
vertices.Append( upperRight );
p.x = halfW;
vertices.Append( p );
p.y = -halfH;
vertices.Append( p );
counts.Append( 4 );
}
ApplyTransform( origin );
}
void
FillTesselatorStream::Submit( const Vertex2& origin, Real a, Real b )
{
Rtt_ASSERT_NOT_IMPLEMENTED();
}
void
FillTesselatorStream::Submit( const Vertex2& origin, Real radius )
{
// TODO: Everytime this is called, we subdivide the same exact unit circle
// Precalculate this and put it into a constant table for lookup.
// This would completely eliminate the need to call Subdivide
// Also can be used for the rounded rects
AppendCircle( radius, false );
ApplyTransform( origin );
}
// ----------------------------------------------------------------------------
} // namespace Rtt
// ----------------------------------------------------------------------------
| 26.191176
| 98
| 0.613981
|
agramonte
|
8955f6a271f64452ec97e572e655f66fc1c54a7f
| 2,488
|
cpp
|
C++
|
libs/fnd/algorithm/test/src/ranges/unit_test_fnd_algorithm_ranges_set_union.cpp
|
myoukaku/bksge
|
0f8b60e475a3f1709723906e4796b5e60decf06e
|
[
"MIT"
] | 4
|
2018-06-10T13:35:32.000Z
|
2021-06-03T14:27:41.000Z
|
libs/fnd/algorithm/test/src/ranges/unit_test_fnd_algorithm_ranges_set_union.cpp
|
myoukaku/bksge
|
0f8b60e475a3f1709723906e4796b5e60decf06e
|
[
"MIT"
] | 566
|
2017-01-31T05:36:09.000Z
|
2022-02-09T05:04:37.000Z
|
libs/fnd/algorithm/test/src/ranges/unit_test_fnd_algorithm_ranges_set_union.cpp
|
myoukaku/bksge
|
0f8b60e475a3f1709723906e4796b5e60decf06e
|
[
"MIT"
] | 1
|
2018-07-05T04:40:53.000Z
|
2018-07-05T04:40:53.000Z
|
/**
* @file unit_test_fnd_algorithm_ranges_set_union.cpp
*
* @brief ranges::set_union のテスト
*
* @author myoukaku
*/
#include <bksge/fnd/algorithm/ranges/set_union.hpp>
#include <bksge/fnd/algorithm/ranges/equal.hpp>
#include <bksge/fnd/functional/ranges/greater.hpp>
#include <bksge/fnd/iterator/ranges/next.hpp>
#include <gtest/gtest.h>
#include "constexpr_test.hpp"
#include "ranges_test.hpp"
namespace bksge_algorithm_test
{
namespace ranges_set_union_test
{
#define VERIFY(...) if (!(__VA_ARGS__)) { return false; }
inline BKSGE_CXX14_CONSTEXPR bool test01()
{
namespace ranges = bksge::ranges;
{
int const x[] = { 1,3,3,5,5,5 };
int const y[] = { 2,3,4,5 };
int z[8] = {};
test_range<int const, input_iterator_wrapper> rx(x);
test_range<int const, input_iterator_wrapper> ry(y);
test_range<int, output_iterator_wrapper> rz(z);
auto res = ranges::set_union(rx, ry, rz.begin());
VERIFY(res.in1 == rx.end());
VERIFY(res.in2 == ry.end());
VERIFY(res.out == rz.end());
int const a[] = { 1,2,3,3,4,5,5,5 };
VERIFY(ranges::equal(z, a));
}
{
int const x[] = { 4,2,1,1,0 };
int const y[] = { 3,2,1 };
int z[6] = {};
test_range<int const, input_iterator_wrapper> rx(x);
test_range<int const, input_iterator_wrapper> ry(y);
test_range<int, output_iterator_wrapper> rz(z);
auto res = ranges::set_union(rx, ry, rz.begin(), ranges::greater{});
VERIFY(res.in1 == ranges::next(rx.begin(), 5));
VERIFY(res.in2 == ranges::next(ry.begin(), 3));
VERIFY(res.out == rz.end());
int const a[] = { 4,3,2,1,1,0 };
VERIFY(ranges::equal(z, a));
}
return true;
}
struct X
{
int i;
};
inline bool test02()
{
namespace ranges = bksge::ranges;
{
X const x[] = { {1},{3},{5} };
X const y[] = { {2},{4},{6} };
X z[6] = {};
test_range<X const, input_iterator_wrapper> rx(x);
test_range<X const, input_iterator_wrapper> ry(y);
test_range<X, output_iterator_wrapper> rz(z);
auto res = ranges::set_union(rx, ry, rz.begin(), {}, &X::i, &X::i);
VERIFY(res.in1 == rx.end());
VERIFY(res.in2 == ry.end());
VERIFY(res.out == rz.end());
int const a[] = { 1,2,3,4,5,6 };
VERIFY(ranges::equal(z, a, {}, &X::i));
}
return true;
}
#undef VERIFY
GTEST_TEST(AlgorithmTest, RangesSetUnionTest)
{
BKSGE_CXX14_CONSTEXPR_EXPECT_TRUE(test01());
EXPECT_TRUE(test02());
}
} // namespace ranges_set_union_test
} // namespace bksge_algorithm_test
| 26.189474
| 71
| 0.62701
|
myoukaku
|
895a7fdd0a6c74066df90a4cb3b37716808a4e9d
| 1,153
|
cpp
|
C++
|
galois/utilities/friend_close_helper.cpp
|
7starsea/galois
|
a83c2b57baca3e09d6ec9258e16d37e35e1e404b
|
[
"MIT"
] | null | null | null |
galois/utilities/friend_close_helper.cpp
|
7starsea/galois
|
a83c2b57baca3e09d6ec9258e16d37e35e1e404b
|
[
"MIT"
] | null | null | null |
galois/utilities/friend_close_helper.cpp
|
7starsea/galois
|
a83c2b57baca3e09d6ec9258e16d37e35e1e404b
|
[
"MIT"
] | null | null | null |
///
/// Copyright(c) 2018 Aimin Huang
/// Distributed under the MIT License (http://opensource.org/licenses/MIT)
///
#include "friend_close_helper.h"
#include <iostream>
#include <chrono> ///std::chrono::seconds
#include <thread>
#include <csignal>
#include <boost/predef.h>
void FriendCloseHelperImpl::registerSignals(){
void(*handler) (int) = FriendCloseHelperImpl::static_signal_handler;
std::signal(SIGINT, handler);
std::signal(SIGTERM, handler);
std::signal(SIGABRT, handler);
// std::signal(SIGILL, handler);
// std::signal(SIGSEGV, handler);
#if BOOST_OS_WINDOWS
std::signal(SIGBREAK, handler);
#else
std::signal(SIGILL, handler);
#endif
}
void FriendCloseHelperImpl::static_signal_handler(int signum){
FriendCloseHelper & close_helper = FriendCloseHelper::create();
close_helper.signalHandler(signum);
}
FriendCloseHelperImpl::FriendCloseHelperImpl()
:stopped_(-1){
FriendCloseHelperImpl::registerSignals();
}
void FriendCloseHelperImpl::signalHandler( int signum )
{
(void)(signum);
std::cout<<"Please waiting for the program to clean up the resources..."<<std::endl;
if(-1 == stopped_.load() ) stopped_.store(0);
}
| 24.531915
| 85
| 0.738942
|
7starsea
|
895d8d8fa1e492c2c93fb1b44909c01965beb426
| 2,147
|
cpp
|
C++
|
src/bonefish/roles/wamp_role_type.cpp
|
aiwc/extlib-bonefish
|
2f0d15960b5178d2ab24fd8e11965a80ace2cb5a
|
[
"Apache-2.0"
] | 58
|
2015-08-24T18:43:56.000Z
|
2022-01-09T00:55:06.000Z
|
src/bonefish/roles/wamp_role_type.cpp
|
aiwc/extlib-bonefish
|
2f0d15960b5178d2ab24fd8e11965a80ace2cb5a
|
[
"Apache-2.0"
] | 47
|
2015-08-25T11:04:51.000Z
|
2018-02-28T22:38:12.000Z
|
src/bonefish/roles/wamp_role_type.cpp
|
aiwc/extlib-bonefish
|
2f0d15960b5178d2ab24fd8e11965a80ace2cb5a
|
[
"Apache-2.0"
] | 32
|
2015-08-25T15:14:45.000Z
|
2020-03-23T09:35:31.000Z
|
/**
* Copyright (C) 2015 Topology LP
*
* 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 <bonefish/roles/wamp_role_type.hpp>
#include <cassert>
#include <stdexcept>
namespace bonefish {
const char* role_type_to_string(const wamp_role_type& type)
{
const char* str = nullptr;
switch(type)
{
case wamp_role_type::CALLEE:
str = "callee";
break;
case wamp_role_type::CALLER:
str = "caller";
break;
case wamp_role_type::PUBLISHER:
str = "publisher";
break;
case wamp_role_type::SUBSCRIBER:
str = "subscriber";
break;
case wamp_role_type::DEALER:
str = "dealer";
break;
case wamp_role_type::BROKER:
str = "broker";
break;
default:
throw std::invalid_argument("unknown role type");
break;
}
return str;
}
wamp_role_type role_type_from_string(const std::string& type)
{
if (type.compare("callee") == 0) {
return wamp_role_type::CALLEE;
}
if (type.compare("caller") == 0) {
return wamp_role_type::CALLER;
}
if (type.compare("publisher") == 0) {
return wamp_role_type::PUBLISHER;
}
if (type.compare("subscriber") == 0) {
return wamp_role_type::SUBSCRIBER;
}
if (type.compare("dealer") == 0) {
return wamp_role_type::DEALER;
}
if (type.compare("broker") == 0) {
return wamp_role_type::BROKER;
}
throw std::invalid_argument("unknown role type");
}
} // namespace bonefish
| 25.258824
| 76
| 0.607825
|
aiwc
|
89602bfa213172311b2146bed903d2192a822b2f
| 397
|
cpp
|
C++
|
MOS_6502_Emulator/ProcessingUnit_Shift.cpp
|
yu830425/MOS-6502-Simulator
|
b08495e1225b65df51ba2ad561f27b048a506c31
|
[
"MIT"
] | null | null | null |
MOS_6502_Emulator/ProcessingUnit_Shift.cpp
|
yu830425/MOS-6502-Simulator
|
b08495e1225b65df51ba2ad561f27b048a506c31
|
[
"MIT"
] | null | null | null |
MOS_6502_Emulator/ProcessingUnit_Shift.cpp
|
yu830425/MOS-6502-Simulator
|
b08495e1225b65df51ba2ad561f27b048a506c31
|
[
"MIT"
] | null | null | null |
#include "ProcessingUnit.h"
BYTE ProcessingUnit::ASL(BYTE value)
{
BYTE result = value << 1;
m_negative = (result & 0x80) != 0;
m_zero = result == 0;
m_carry = (value & 0x80) != 0;
return result;
}
BYTE ProcessingUnit::LSR(BYTE value)
{
BYTE result = value >> 1;
m_zero = result == 0;
m_carry = (value & 0x01) != 0;
m_negative = false; //bit 7 will always be zero
return result;
}
| 17.26087
| 49
| 0.639798
|
yu830425
|
89632196bcc20b530d1612c02a82d34e5a9764cd
| 2,086
|
cpp
|
C++
|
Phoenix/Server/Source/Server.cpp
|
NicolasRicard/Phoenix
|
5eae2bd716a933fd405487d93c0e91e5ca56b3e4
|
[
"BSD-3-Clause"
] | 1
|
2020-05-02T14:46:39.000Z
|
2020-05-02T14:46:39.000Z
|
Phoenix/Server/Source/Server.cpp
|
NicolasRicard/Phoenix
|
5eae2bd716a933fd405487d93c0e91e5ca56b3e4
|
[
"BSD-3-Clause"
] | null | null | null |
Phoenix/Server/Source/Server.cpp
|
NicolasRicard/Phoenix
|
5eae2bd716a933fd405487d93c0e91e5ca56b3e4
|
[
"BSD-3-Clause"
] | null | null | null |
// Copyright 2019-20 Genten Studios
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE 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.
#include <Server/Server.hpp>
#include <Common/Settings.hpp>
#include <iostream>
using namespace phx::server;
using namespace phx;
void Server::run() {
std::cout << "Hello, Server!\nType \"exit\" to exit" << std::endl;
Settings::get()->load("config.txt");
m_running = true;
while(m_running == true){
std::cout << "\n>";
std::string input;
std::cin >> input;
if (input == "exit"){
m_running = false;
}
std::cout << input;
}
Settings::get()->save("config.txt");
}
| 40.901961
| 80
| 0.719559
|
NicolasRicard
|
896328db15c7251956079514284a32b07b515624
| 311
|
cpp
|
C++
|
package/standalone_kr_usn/lib/nvs_flash/src/cpp_config.cpp
|
teledatics/nrc7292_sdk
|
d0ba3f17e1bef3d6fec7370e7f0ffa77db56e3a4
|
[
"MIT"
] | 7
|
2020-07-20T03:58:40.000Z
|
2022-03-15T13:29:18.000Z
|
package/standalone_kr_usn/lib/nvs_flash/src/cpp_config.cpp
|
teledatics/nrc7292_sdk
|
d0ba3f17e1bef3d6fec7370e7f0ffa77db56e3a4
|
[
"MIT"
] | 3
|
2021-07-16T12:39:36.000Z
|
2022-02-02T18:19:51.000Z
|
package/standalone_kr_usn/lib/nvs_flash/src/cpp_config.cpp
|
teledatics/nrc7292_sdk
|
d0ba3f17e1bef3d6fec7370e7f0ffa77db56e3a4
|
[
"MIT"
] | 4
|
2020-09-19T18:03:04.000Z
|
2022-02-02T13:17:34.000Z
|
/* below parameters defined to get around build error */
/* must check if there's any side effect */
void *__dso_handle = 0;
extern "C" int __aeabi_atexit(void *object,
void (*destructor)(void *),
void *dso_handle)
{
return 0;
}
namespace __gnu_cxx {
void __verbose_terminate_handler()
{
while(1);
}
}
| 17.277778
| 56
| 0.700965
|
teledatics
|
896535198381655801c4caebea02bd10f7724930
| 6,599
|
cpp
|
C++
|
svntrunk/src/BlueMatter/probspec/src/ffheaderhandler.cpp
|
Bhaskers-Blu-Org1/BlueMatter
|
1ab2c41af870c19e2e1b1095edd1d5c85eeb9b5e
|
[
"BSD-2-Clause"
] | 7
|
2020-02-25T15:46:18.000Z
|
2022-02-25T07:04:47.000Z
|
svntrunk/src/BlueMatter/probspec/src/ffheaderhandler.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | null | null | null |
svntrunk/src/BlueMatter/probspec/src/ffheaderhandler.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | 5
|
2019-06-06T16:30:21.000Z
|
2020-11-16T19:43:01.000Z
|
/* Copyright 2001, 2019 IBM Corporation
*
* 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.
*/
// ***************************************************************************
// File: ffheaderhandler.cpp
// Date: November 21, 2000
// Author: RSG
// Description: Class derived from interface class
// FFHandler to deal with processing header
// records that need to be "pushed" into Mike Pitman's
// setup code
// ***************************************************************************
#ifndef PKFXLOG_FFHEADERHANDLER
#define PKFXLOG_FFHEADERHANDLER (0)
#endif
#include "BlueMatter/ffheaderhandler.hpp"
#include "BlueMatter/headerhandler.hpp"
#undef assert
//#include <pk/fxlogger.hpp>
// fxlogger has its own version of assert, so undef the system one
//#undef assert
#include <assert.h>
char* FFHeaderHandler::s_key[ELEM_COUNT] =
{"charge", "vdw", "vdwcombine", "charge14", "charge14scale", "vdw14",
"vdw14scale", "improper", "torsioninput", "ureybradley", "grouping",
"water", "units"};
FFHeaderHandler::~FFHeaderHandler()
{
}
void FFHeaderHandler::startElement(const char* elem)
{
d_mode = FFHandler::findString(elem, s_key, ELEM_COUNT);
#if defined(USE_PKFXLOG)
BegLogLine( PKFXLOG_FFHEADERHANDLER )
<< "FFHeaderHandler::startElement mode = " << d_mode
<< " for element: " << elem << EndLogLine;
#endif
}
void FFHeaderHandler::endElement(const char* elem)
{
#if defined(USE_PKFXLOG)
BegLogLine( PKFXLOG_FFHEADERHANDLER )
<< "FFHeaderHandler::endElement mode = " << d_mode
<< " before mode reset"
<< " for element: " << elem << EndLogLine;
#endif
d_mode = UNKNOWN;
#if defined(USE_PKFXLOG)
BegLogLine( PKFXLOG_FFHEADERHANDLER )
<< "FFHeaderHandler::endElement mode = " << d_mode
<< " after mode reset"
<< " for element: " << elem << EndLogLine;
#endif
}
void FFHeaderHandler::charData(char* data)
{
switch(d_mode)
{
default:
case UNKNOWN:
break;
case CHARGE:
HeaderHandler::instance()->setCharge(atoi(data));
break;
case VDW:
HeaderHandler::instance()->setVDW(atoi(data));
break;
case VDWCOMBINE:
HeaderHandler::instance()->setVDWCombine(atoi(data));
break;
case CHARGE14:
HeaderHandler::instance()->setCharge14(atoi(data));
break;
case CHARGE14SCALE:
HeaderHandler::instance()->setCharge14Scale(atof(data));
break;
case VDW14:
HeaderHandler::instance()->setVDW14(atoi(data));
break;
case VDW14SCALE:
HeaderHandler::instance()->setVDW14Scale(atof(data));
break;
case IMPROPER:
HeaderHandler::instance()->setImproper(atoi(data));
break;
case TORSIONINPUT:
HeaderHandler::instance()->setTorsionInput(atoi(data));
break;
case UREYBRADLEY:
HeaderHandler::instance()->setUreyBradley(atoi(data));
break;
case GROUPING:
HeaderHandler::instance()->setGrouping(atoi(data));
break;
case WATER:
HeaderHandler::instance()->setWater(atoi(data));
break;
case UNITS:
HeaderHandler::instance()->setUnits(atoi(data));
break;
}
#if defined(USE_PKFXLOG)
BegLogLine( PKFXLOG_FFHEADERHANDLER )
<< "FFHeaderHandler::charData in mode = " << d_mode
<< " finished with "
<< "charge: "
<< HeaderHandler::instance()->getCharge()
<< " vdw: "
<< HeaderHandler::instance()->getVDW()
<< " vdwcombine: "
<< HeaderHandler::instance()->getVDWCombine()
<< " charge14: "
<< HeaderHandler::instance()->getCharge14()
<< " charge14scale: "
<< HeaderHandler::instance()->getCharge14Scale()
<< " vdw14: "
<< HeaderHandler::instance()->getVDW14()
<< " vdw14scale: "
<< HeaderHandler::instance()->getVDW14Scale()
<< " improper: "
<< HeaderHandler::instance()->getImproper()
<< " torsioninput: "
<< HeaderHandler::instance()->getTorsionInput()
<< " ureybradley: "
<< HeaderHandler::instance()->getUreyBradley()
<< " grouping: "
<< HeaderHandler::instance()->getGrouping()
<< " water: "
<< HeaderHandler::instance()->getWater()
<< " units: "
<< HeaderHandler::instance()->getUnits()
<< EndLogLine;
#endif
}
void FFHeaderHandler::initialize()
{
HeaderHandler::instance()->initialize();
}
void FFHeaderHandler::finalize()
{
HeaderHandler::instance()->finalize();
#if defined(USE_PKFXLOG)
BegLogLine( PKFXLOG_FFHEADERHANDLER )
<< "charge: "
<< HeaderHandler::instance()->getCharge()
<< " vdw: "
<< HeaderHandler::instance()->getVDW()
<< " vdwcombine: "
<< HeaderHandler::instance()->getVDWCombine()
<< " charge14: "
<< HeaderHandler::instance()->getCharge14()
<< " charge14scale: "
<< HeaderHandler::instance()->getCharge14Scale()
<< " vdw14: "
<< HeaderHandler::instance()->getVDW14()
<< " vdw14scale: "
<< HeaderHandler::instance()->getVDW14Scale()
<< " improper: "
<< HeaderHandler::instance()->getImproper()
<< " torsioninput: "
<< HeaderHandler::instance()->getTorsionInput()
<< " ureybradley: "
<< HeaderHandler::instance()->getUreyBradley()
<< " grouping: "
<< HeaderHandler::instance()->getGrouping()
<< " water: "
<< HeaderHandler::instance()->getWater()
<< " units: "
<< HeaderHandler::instance()->getUnits()
<< EndLogLine;
#endif
}
| 32.995
| 118
| 0.651462
|
Bhaskers-Blu-Org1
|
8966877555ac45ef7737404533a0b76718f8289b
| 2,530
|
cpp
|
C++
|
ModelViewer/ViewerFoundation/Utilities/Mac/NuoMathVectorMac.cpp
|
erpapa/NuoModelViewer
|
0dcb8bf99cb49c6e2c9535ed178e01674fa26824
|
[
"MIT"
] | 265
|
2017-03-15T17:11:27.000Z
|
2022-03-30T07:50:00.000Z
|
ModelViewer/ViewerFoundation/Utilities/Mac/NuoMathVectorMac.cpp
|
erpapa/NuoModelViewer
|
0dcb8bf99cb49c6e2c9535ed178e01674fa26824
|
[
"MIT"
] | 6
|
2017-07-03T01:57:49.000Z
|
2020-01-24T19:28:22.000Z
|
ModelViewer/ViewerFoundation/Utilities/Mac/NuoMathVectorMac.cpp
|
erpapa/NuoModelViewer
|
0dcb8bf99cb49c6e2c9535ed178e01674fa26824
|
[
"MIT"
] | 39
|
2016-09-30T03:26:44.000Z
|
2022-01-24T07:37:20.000Z
|
//
// NuoMathVectorMac.cpp
// ModelViewer
//
// Created by Dong on 5/11/18.
// Copyright © 2018 middleware. All rights reserved.
//
#include "NuoMathVector.h"
NuoMatrix<float, 4> NuoMatrixPerspective(float aspect, float fovy, float near, float far)
{
// NOT use OpenGL persepctive!
// Metal uses a 2x2x1 canonical cube (z in [0,1]), rather than the 2x2x2 one in OpenGL.
// glm::mat4x4 gmat = glm::perspective(fovy, aspect, near, far);
/*
T const tanHalfFovy = tan(fovy / static_cast<T>(2));
tmat4x4<T, defaultp> Result(static_cast<T>(0));
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - static_cast<T>(1);
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
return Result;
*/
float yScale = 1 / tan(fovy * 0.5);
float xScale = yScale / aspect;
float zRange = far - near;
float zScale = -(far) / zRange;
float wzScale = - far * near / zRange;
vector_float4 P = { xScale, 0, 0, 0 };
vector_float4 Q = { 0, yScale, 0, 0 };
vector_float4 R = { 0, 0, zScale, -1 };
vector_float4 S = { 0, 0, wzScale, 0 };
matrix_float4x4 mat = { P, Q, R, S };
return mat;
}
NuoMatrix<float, 4> NuoMatrixOrthor(float left, float right, float top, float bottom, float near, float far)
{
/* Ortho in OpenGL
tmat4x4<T, defaultp> Result(1);
Result[0][0] = static_cast<T>(2) / (right - left);
Result[1][1] = static_cast<T>(2) / (top - bottom);
Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
Result[3][0] = - (right + left) / (right - left);
Result[3][1] = - (top + bottom) / (top - bottom);
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
*/
// Ortho in Metal
// http://blog.athenstean.com/post/135771439196/from-opengl-to-metal-the-projection-matrix
float yScale = 2 / (top - bottom);
float xScale = 2 / (right - left);
float zRange = far - near;
float zScale = - 1 / zRange;
float wzScale = - near / zRange;
float wyScale = - (top + bottom) / (top - bottom);
float wxScale = - (right + left) / (right - left);
vector_float4 P = { xScale, 0, 0, 0 };
vector_float4 Q = { 0, yScale, 0, 0 };
vector_float4 R = { 0, 0, zScale, 0 };
vector_float4 S = { wxScale, wyScale, wzScale, 1 };
matrix_float4x4 mat = { P, Q, R, S };
return mat;
}
| 32.025316
| 108
| 0.574308
|
erpapa
|
89695b0c3ce7a7ca5653d58a6d4d5ac2992fa841
| 5,038
|
cpp
|
C++
|
src/3d/terrain/qgsterraintexturegenerator_p.cpp
|
dyna-mis/Hilabeling
|
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
|
[
"MIT"
] | null | null | null |
src/3d/terrain/qgsterraintexturegenerator_p.cpp
|
dyna-mis/Hilabeling
|
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
|
[
"MIT"
] | null | null | null |
src/3d/terrain/qgsterraintexturegenerator_p.cpp
|
dyna-mis/Hilabeling
|
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
|
[
"MIT"
] | 1
|
2021-12-25T08:40:30.000Z
|
2021-12-25T08:40:30.000Z
|
/***************************************************************************
qgsterraintexturegenerator_p.cpp
--------------------------------------
Date : July 2017
Copyright : (C) 2017 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsterraintexturegenerator_p.h"
#include <qgsmaprenderercustompainterjob.h>
#include <qgsmaprenderersequentialjob.h>
#include <qgsmapsettings.h>
#include <qgsmapthemecollection.h>
#include <qgsproject.h>
#include "qgs3dmapsettings.h"
///@cond PRIVATE
QgsTerrainTextureGenerator::QgsTerrainTextureGenerator( const Qgs3DMapSettings &map )
: mMap( map )
, mLastJobId( 0 )
{
}
int QgsTerrainTextureGenerator::render( const QgsRectangle &extent, const QString &debugText )
{
QgsMapSettings mapSettings( baseMapSettings() );
mapSettings.setExtent( extent );
QgsMapRendererSequentialJob *job = new QgsMapRendererSequentialJob( mapSettings );
connect( job, &QgsMapRendererJob::finished, this, &QgsTerrainTextureGenerator::onRenderingFinished );
job->start();
JobData jobData;
jobData.jobId = ++mLastJobId;
jobData.job = job;
jobData.extent = extent;
jobData.debugText = debugText;
mJobs.insert( job, jobData );
//qDebug() << "added job: " << jobData.jobId << " .... in queue: " << jobs.count();
return jobData.jobId;
}
void QgsTerrainTextureGenerator::cancelJob( int jobId )
{
Q_FOREACH ( const JobData &jd, mJobs )
{
if ( jd.jobId == jobId )
{
//qDebug() << "canceling job " << jobId;
jd.job->cancelWithoutBlocking();
disconnect( jd.job, &QgsMapRendererJob::finished, this, &QgsTerrainTextureGenerator::onRenderingFinished );
jd.job->deleteLater();
mJobs.remove( jd.job );
return;
}
}
Q_ASSERT( false && "requested job ID does not exist!" );
}
QImage QgsTerrainTextureGenerator::renderSynchronously( const QgsRectangle &extent, const QString &debugText )
{
QgsMapSettings mapSettings( baseMapSettings() );
mapSettings.setExtent( extent );
QImage img = QImage( mapSettings.outputSize(), mapSettings.outputImageFormat() );
img.setDotsPerMeterX( 1000 * mapSettings.outputDpi() / 25.4 );
img.setDotsPerMeterY( 1000 * mapSettings.outputDpi() / 25.4 );
img.fill( Qt::transparent );
QPainter p( &img );
QgsMapRendererCustomPainterJob job( mapSettings, &p );
job.renderSynchronously();
if ( mMap.showTerrainTilesInfo() )
{
// extra tile information for debugging
p.setPen( Qt::white );
p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
p.drawText( img.rect(), debugText, QTextOption( Qt::AlignCenter ) );
}
p.end();
return img;
}
void QgsTerrainTextureGenerator::onRenderingFinished()
{
QgsMapRendererSequentialJob *mapJob = static_cast<QgsMapRendererSequentialJob *>( sender() );
Q_ASSERT( mJobs.contains( mapJob ) );
JobData jobData = mJobs.value( mapJob );
QImage img = mapJob->renderedImage();
if ( mMap.showTerrainTilesInfo() )
{
// extra tile information for debugging
QPainter p( &img );
p.setPen( Qt::white );
p.drawRect( 0, 0, img.width() - 1, img.height() - 1 );
p.drawText( img.rect(), jobData.debugText, QTextOption( Qt::AlignCenter ) );
p.end();
}
mapJob->deleteLater();
mJobs.remove( mapJob );
//qDebug() << "finished job " << jobData.jobId << " ... in queue: " << jobs.count();
// pass QImage further
emit tileReady( jobData.jobId, img );
}
QgsMapSettings QgsTerrainTextureGenerator::baseMapSettings()
{
QgsMapSettings mapSettings;
mapSettings.setOutputSize( QSize( mMap.mapTileResolution(), mMap.mapTileResolution() ) );
mapSettings.setDestinationCrs( mMap.crs() );
mapSettings.setBackgroundColor( mMap.backgroundColor() );
mapSettings.setFlag( QgsMapSettings::DrawLabeling, mMap.showLabels() );
mapSettings.setTransformContext( mMap.transformContext() );
mapSettings.setPathResolver( mMap.pathResolver() );
QgsMapThemeCollection *mapThemes = mMap.mapThemeCollection();
QString mapThemeName = mMap.terrainMapTheme();
if ( mapThemeName.isEmpty() || !mapThemes || !mapThemes->hasMapTheme( mapThemeName ) )
{
mapSettings.setLayers( mMap.layers() );
}
else
{
mapSettings.setLayers( mapThemes->mapThemeVisibleLayers( mapThemeName ) );
mapSettings.setLayerStyleOverrides( mapThemes->mapThemeStyleOverrides( mapThemeName ) );
}
return mapSettings;
}
/// @endcond
| 32.503226
| 113
| 0.636364
|
dyna-mis
|
896a764a59b612ca80555b65214fb7f02534698c
| 2,823
|
cpp
|
C++
|
services/minijail/av_services_minijail_unittest.cpp
|
Dreadwyrm/lhos_frameworks_av
|
62c63ccfdf5c79a3ad9be4836f473da9398c671b
|
[
"Apache-2.0"
] | null | null | null |
services/minijail/av_services_minijail_unittest.cpp
|
Dreadwyrm/lhos_frameworks_av
|
62c63ccfdf5c79a3ad9be4836f473da9398c671b
|
[
"Apache-2.0"
] | null | null | null |
services/minijail/av_services_minijail_unittest.cpp
|
Dreadwyrm/lhos_frameworks_av
|
62c63ccfdf5c79a3ad9be4836f473da9398c671b
|
[
"Apache-2.0"
] | 2
|
2021-07-08T07:42:11.000Z
|
2021-07-09T21:56:10.000Z
|
// Copyright (C) 2017 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>
#include <android-base/file.h>
#include <android-base/unique_fd.h>
#include <gtest/gtest.h>
#include "minijail.h"
class WritePolicyTest : public ::testing::Test
{
protected:
const std::string base_policy_ =
"read: 1\n"
"write: 1\n"
"rt_sigreturn: 1\n"
"exit: 1\n";
const std::string additional_policy_ =
"mmap: 1\n"
"munmap: 1\n";
const std::string third_policy_ =
"open: 1\n"
"close: 1\n";
const std::string full_policy_ = base_policy_ + std::string("\n") + additional_policy_;
const std::string triple_policy_ = base_policy_ +
std::string("\n") + additional_policy_ +
std::string("\n") + third_policy_;
};
TEST_F(WritePolicyTest, OneFile)
{
std::string final_string;
// vector with an empty pathname
android::base::unique_fd fd(android::WritePolicyToPipe(base_policy_, {std::string()}));
EXPECT_LE(0, fd.get());
bool success = android::base::ReadFdToString(fd.get(), &final_string);
EXPECT_TRUE(success);
EXPECT_EQ(final_string, base_policy_);
}
TEST_F(WritePolicyTest, OneFileAlternate)
{
std::string final_string;
// empty vector
android::base::unique_fd fd(android::WritePolicyToPipe(base_policy_, {}));
EXPECT_LE(0, fd.get());
bool success = android::base::ReadFdToString(fd.get(), &final_string);
EXPECT_TRUE(success);
EXPECT_EQ(final_string, base_policy_);
}
TEST_F(WritePolicyTest, TwoFiles)
{
std::string final_string;
android::base::unique_fd fd(android::WritePolicyToPipe(base_policy_, {additional_policy_}));
EXPECT_LE(0, fd.get());
bool success = android::base::ReadFdToString(fd.get(), &final_string);
EXPECT_TRUE(success);
EXPECT_EQ(final_string, full_policy_);
}
TEST_F(WritePolicyTest, ThreeFiles)
{
std::string final_string;
android::base::unique_fd fd(android::WritePolicyToPipe(base_policy_, {additional_policy_, third_policy_}));
EXPECT_LE(0, fd.get());
bool success = android::base::ReadFdToString(fd.get(), &final_string);
EXPECT_TRUE(success);
EXPECT_EQ(final_string, triple_policy_);
}
| 32.079545
| 111
| 0.678711
|
Dreadwyrm
|
896ca4d778cd2355e08c687be98e524c1b250c5c
| 38,985
|
cc
|
C++
|
L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc
|
NTrevisani/cmssw
|
a212a27526f34eb9507cf8b875c93896e6544781
|
[
"Apache-2.0"
] | 2
|
2020-01-21T11:23:39.000Z
|
2020-01-21T11:23:42.000Z
|
L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc
|
NTrevisani/cmssw
|
a212a27526f34eb9507cf8b875c93896e6544781
|
[
"Apache-2.0"
] | 8
|
2020-03-20T23:18:36.000Z
|
2020-05-27T11:00:06.000Z
|
L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc
|
NTrevisani/cmssw
|
a212a27526f34eb9507cf8b875c93896e6544781
|
[
"Apache-2.0"
] | 3
|
2019-03-09T13:06:43.000Z
|
2020-07-03T00:47:30.000Z
|
#include "L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h"
#include "DataFormats/MuonDetId/interface/DTChamberId.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/MuonDetId/interface/GEMDetId.h"
#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h"
#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h"
#include "helper.h" // merge_map_into_map, assert_no_abort
// 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector.
// Arranged in FW as 6 stations, 9 chambers per station.
#define NUM_CSC_CHAMBERS 6 * 9
// 6x2 in RE1,2; 12x2 in RE3,4; 6 from neighbor sector.
// Arranged in FW as 7 stations, 6 chambers per station. (8 with iRPC)
#define NUM_RPC_CHAMBERS 7 * 8
// 6 in GE1/1; 3 in GE2/1; 2 from neighbor sector.
// Arranged in FW as 6 stations, 9 chambers per station, mimicking CSC. (unconfirmed!)
#define NUM_GEM_CHAMBERS 6 * 9
void PrimitiveSelection::configure(int verbose,
int endcap,
int sector,
int bx,
int bxShiftCSC,
int bxShiftRPC,
int bxShiftGEM,
bool includeNeighbor,
bool duplicateTheta,
bool bugME11Dupes) {
verbose_ = verbose;
endcap_ = endcap;
sector_ = sector;
bx_ = bx;
bxShiftCSC_ = bxShiftCSC;
bxShiftRPC_ = bxShiftRPC;
bxShiftGEM_ = bxShiftGEM;
includeNeighbor_ = includeNeighbor;
duplicateTheta_ = duplicateTheta;
bugME11Dupes_ = bugME11Dupes;
}
// _____________________________________________________________________________
// Specialized process() for CSC
template <>
void PrimitiveSelection::process(CSCTag tag,
const TriggerPrimitiveCollection& muon_primitives,
std::map<int, TriggerPrimitiveCollection>& selected_csc_map) const {
TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
for (; tp_it != tp_end; ++tp_it) {
TriggerPrimitive new_tp = *tp_it; // make a copy and apply patches to this copy
// Patch the CLCT pattern number
// It should be 0-10, see: L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
bool patchPattern = true;
if (patchPattern && new_tp.subsystem() == TriggerPrimitive::kCSC) {
if (new_tp.getCSCData().pattern == 11 || new_tp.getCSCData().pattern == 12 || new_tp.getCSCData().pattern == 13 ||
new_tp.getCSCData().pattern == 14) { // 11, 12, 13, 14 -> 10
edm::LogWarning("L1T") << "EMTF patching corrupt CSC LCT pattern: changing " << new_tp.getCSCData().pattern
<< " to 10";
new_tp.accessCSCData().pattern = 10;
}
}
// Patch the LCT quality number
// It should be 1-15, see: L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
bool patchQuality = true;
if (patchQuality && new_tp.subsystem() == TriggerPrimitive::kCSC) {
if (new_tp.getCSCData().quality == 0) { // 0 -> 1
edm::LogWarning("L1T") << "EMTF patching corrupt CSC LCT quality: changing " << new_tp.getCSCData().quality
<< " to 1";
new_tp.accessCSCData().quality = 1;
}
}
int selected_csc = select_csc(new_tp); // Returns CSC "link" index (0 - 53)
if (selected_csc >= 0) {
if (not(selected_csc < NUM_CSC_CHAMBERS)) {
edm::LogError("L1T") << "selected_csc = " << selected_csc << ", NUM_CSC_CHAMBERS = " << NUM_CSC_CHAMBERS;
return;
}
if (selected_csc_map[selected_csc].size() < 2) {
selected_csc_map[selected_csc].push_back(new_tp);
} else {
edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber";
for (int ii = 0; ii < 3; ii++) {
TriggerPrimitive tp_err = (ii < 2 ? selected_csc_map[selected_csc].at(ii) : new_tp);
edm::LogWarning("L1T") << "LCT #" << ii + 1 << ": BX " << tp_err.getBX() << ", endcap "
<< tp_err.detId<CSCDetId>().endcap() << ", sector "
<< tp_err.detId<CSCDetId>().triggerSector() << ", station "
<< tp_err.detId<CSCDetId>().station() << ", ring " << tp_err.detId<CSCDetId>().ring()
<< ", chamber " << tp_err.detId<CSCDetId>().chamber() << ", CSC ID "
<< tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire "
<< tp_err.getWire();
}
edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
}
} // End conditional: if (selected_csc >= 0)
} // End loop: for (; tp_it != tp_end; ++tp_it)
// Duplicate CSC muon primitives
// If there are 2 LCTs in the same chamber with (strip, wire) = (s1, w1) and (s2, w2)
// make all combinations with (s1, w1), (s2, w1), (s1, w2), (s2, w2)
if (duplicateTheta_) {
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_csc_map.begin();
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_csc_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
int selected = map_tp_it->first;
TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
if (tmp_primitives.size() >= 4) {
edm::LogWarning("L1T") << "EMTF found 4 or more CSC LCTs in one chamber: keeping only two";
tmp_primitives.erase(tmp_primitives.begin() + 4, tmp_primitives.end()); // erase 5th element++
tmp_primitives.erase(tmp_primitives.begin() + 2); // erase 3rd element
tmp_primitives.erase(tmp_primitives.begin() + 1); // erase 2nd element
} else if (tmp_primitives.size() == 3) {
edm::LogWarning("L1T") << "EMTF found 3 CSC LCTs in one chamber: keeping only two";
tmp_primitives.erase(tmp_primitives.begin() + 2); // erase 3rd element
}
if (not(tmp_primitives.size() <= 2)) // at most 2 hits
{
edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size();
return;
}
if (tmp_primitives.size() == 2) {
if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) &&
(tmp_primitives.at(0).getWire() != tmp_primitives.at(1).getWire())) {
// Swap wire numbers
TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
uint16_t tmp_keywire = tp0.accessCSCData().keywire;
tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos
tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos
}
const bool is_csc_me11 = (0 <= selected && selected <= 2) || (9 <= selected && selected <= 11) ||
(selected == 45); // ME1/1 sub 1 or ME1/1 sub 2 or ME1/1 from neighbor
if (bugME11Dupes_ && is_csc_me11) {
// For ME1/1, always make 4 LCTs without checking strip & wire combination
if (tmp_primitives.size() == 2) {
// Swap wire numbers
TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
uint16_t tmp_keywire = tp0.accessCSCData().keywire;
tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos
tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos
}
if (not(tmp_primitives.size() == 1 || tmp_primitives.size() == 4)) {
edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size();
return;
}
}
} // end if tmp_primitives.size() == 2
} // end loop over selected_csc_map
} // end if duplicate theta
}
// _____________________________________________________________________________
// Specialized process() for RPC
template <>
void PrimitiveSelection::process(RPCTag tag,
const TriggerPrimitiveCollection& muon_primitives,
std::map<int, TriggerPrimitiveCollection>& selected_rpc_map) const {
TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
for (; tp_it != tp_end; ++tp_it) {
int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index (0 - 41)
if (selected_rpc >= 0) {
if (not(selected_rpc < NUM_RPC_CHAMBERS)) {
edm::LogError("L1T") << "selected_rpc = " << selected_rpc << ", NUM_RPC_CHAMBERS = " << NUM_RPC_CHAMBERS;
return;
}
selected_rpc_map[selected_rpc].push_back(*tp_it);
}
}
// Apply truncation as in firmware: keep first 2 clusters, max cluster
// size = 3 strips.
// According to Karol Bunkowski, for one chamber (so 3 eta rolls) only up
// to 2 hits (cluster centres) are produced. First two 'first' clusters are
// chosen, and only after the cut on the cluster size is applied. So if
// there are 1 large cluster and 2 small clusters, it is possible that
// one of the two small clusters is discarded first, and the large cluster
// then is removed by the cluster size cut, leaving only one cluster.
bool apply_truncation = true;
if (apply_truncation) {
struct {
typedef TriggerPrimitive value_type;
bool operator()(const value_type& x) const {
int sz = x.getRPCData().strip_hi - x.getRPCData().strip_low + 1;
return sz > 3;
}
} cluster_size_cut;
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
//int selected = map_tp_it->first;
TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
// Check to see if unpacked CPPF digis have <= 2 digis per chamber, as expected
if (tmp_primitives.size() > 2 && tmp_primitives.at(0).getRPCData().isCPPF) {
edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
edm::LogWarning("L1T") << "Found " << tmp_primitives.size() << " CPPF digis in the same chamber";
for (const auto& tp : tmp_primitives)
tp.print(std::cout);
edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
}
// Keep the first two clusters
if (tmp_primitives.size() > 2)
tmp_primitives.erase(tmp_primitives.begin() + 2, tmp_primitives.end());
// Skip cluster size cut if primitives are from CPPF emulator or EMTF unpacker (already clustered)
if (!tmp_primitives.empty() && tmp_primitives.at(0).getRPCData().isCPPF)
break;
// Apply cluster size cut
tmp_primitives.erase(std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
tmp_primitives.end());
}
} // end if apply_truncation
// Map RPC subsector and chamber to CSC chambers
// Note: RE3/2 & RE3/3 are considered as one chamber; RE4/2 & RE4/3 too.
bool map_rpc_to_csc = true;
if (map_rpc_to_csc) {
std::map<int, TriggerPrimitiveCollection> tmp_selected_rpc_map;
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
int selected = map_tp_it->first;
TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
int rpc_sub = selected / 8;
int rpc_chm = selected % 8;
int pc_station = -1;
int pc_chamber = -1;
if (rpc_sub != 6) { // native
if (rpc_chm == 0) { // RE1/2
if (0 <= rpc_sub && rpc_sub < 3) {
pc_station = 0;
pc_chamber = 3 + rpc_sub;
} else if (3 <= rpc_sub && rpc_sub < 6) {
pc_station = 1;
pc_chamber = 3 + (rpc_sub - 3);
}
} else if (rpc_chm == 1) { // RE2/2
pc_station = 2;
pc_chamber = 3 + rpc_sub;
} else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3
pc_station = 3;
pc_chamber = 3 + rpc_sub;
} else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3
pc_station = 4;
pc_chamber = 3 + rpc_sub;
}
} else { // neighbor
pc_station = 5;
if (rpc_chm == 0) { // RE1/2
pc_chamber = 1;
} else if (rpc_chm == 1) { // RE2/2
pc_chamber = 4;
} else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3
pc_chamber = 6;
} else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3
pc_chamber = 8;
}
}
if (not(pc_station != -1 && pc_chamber != -1)) {
edm::LogError("L1T") << "pc_station = " << pc_station << ", pc_chamber = " << pc_chamber;
return;
}
selected = (pc_station * 9) + pc_chamber;
bool ignore_this_rpc_chm = false;
if (rpc_chm == 3 || rpc_chm == 5) { // special case of RE3,4/2 and RE3,4/3 chambers
// if RE3,4/2 exists, ignore RE3,4/3. In C++, this assumes that the loop
// over selected_rpc_map will always find RE3,4/2 before RE3,4/3
if (tmp_selected_rpc_map.find(selected) != tmp_selected_rpc_map.end())
ignore_this_rpc_chm = true;
}
if (ignore_this_rpc_chm) {
// Set RPC stubs as invalid
for (auto&& tp : tmp_primitives) {
tp.accessRPCData().valid = 0;
}
}
if (tmp_selected_rpc_map.find(selected) == tmp_selected_rpc_map.end()) {
tmp_selected_rpc_map[selected] = tmp_primitives;
} else {
tmp_selected_rpc_map[selected].insert(
tmp_selected_rpc_map[selected].end(), tmp_primitives.begin(), tmp_primitives.end());
}
} // end loop over selected_rpc_map
std::swap(selected_rpc_map, tmp_selected_rpc_map); // replace the original map
} // end if map_rpc_to_csc
}
// _____________________________________________________________________________
// Specialized process() for GEM
template <>
void PrimitiveSelection::process(GEMTag tag,
const TriggerPrimitiveCollection& muon_primitives,
std::map<int, TriggerPrimitiveCollection>& selected_gem_map) const {
TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
for (; tp_it != tp_end; ++tp_it) {
int selected_gem = select_gem(*tp_it); // Returns GEM "link" index (0 - 53)
if (selected_gem >= 0) {
if (not(selected_gem < NUM_GEM_CHAMBERS)) {
edm::LogError("L1T") << "selected_gem = " << selected_gem << ", NUM_GEM_CHAMBERS = " << NUM_GEM_CHAMBERS;
return;
}
selected_gem_map[selected_gem].push_back(*tp_it);
}
}
// Apply truncation: max cluster size = 8 pads, keep first 8 clusters.
bool apply_truncation = true;
if (apply_truncation) {
struct {
typedef TriggerPrimitive value_type;
bool operator()(const value_type& x) const {
int sz = x.getGEMData().pad_hi - x.getGEMData().pad_low + 1;
return sz > 8;
}
} cluster_size_cut;
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_gem_map.begin();
std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_gem_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
//int selected = map_tp_it->first;
TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
// Apply cluster size cut
tmp_primitives.erase(std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
tmp_primitives.end());
// Keep the first 8 clusters
if (tmp_primitives.size() > 8)
tmp_primitives.erase(tmp_primitives.begin() + 8, tmp_primitives.end());
}
} // end if apply_truncation
}
// _____________________________________________________________________________
// Put the hits from CSC, RPC, GEM together in one collection
// Notes from Alex (2017-03-28):
//
// The RPC inclusion logic is very simple currently:
// - each CSC is analyzed for having track stubs in each BX
// - IF a CSC chamber is missing at least one track stub,
// AND there is an RPC overlapping with it in phi and theta,
// AND that RPC has hits,
// THEN RPC hit is inserted instead of missing CSC stub.
//
// This is done at the output of coord_delay module, so such
// inserted RPC hits can be matched to patterns by match_ph_segments
// module, just like any CSC stubs. Note that substitution of missing
// CSC stubs with RPC hits happens regardless of what's going on in
// other chambers, regardless of whether a pattern has been detected
// or not, basically regardless of anything. RPCs are treated as a
// supplemental source of stubs for CSCs.
void PrimitiveSelection::merge(const std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
const std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
const std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
std::map<int, TriggerPrimitiveCollection>& selected_prim_map) const {
// First, put CSC hits
std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_csc_map.begin();
std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_csc_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
int selected_csc = map_tp_it->first;
const TriggerPrimitiveCollection& csc_primitives = map_tp_it->second;
if (not(csc_primitives.size() <= 4)) // at most 4 hits, including duplicated hits
{
edm::LogError("L1T") << "csc_primitives.size() = " << csc_primitives.size();
return;
}
// Insert all CSC hits
selected_prim_map[selected_csc] = csc_primitives;
}
// Second, insert GEM stubs if there is no CSC hits
map_tp_it = selected_gem_map.begin();
map_tp_end = selected_gem_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
int selected_gem = map_tp_it->first;
const TriggerPrimitiveCollection& gem_primitives = map_tp_it->second;
if (gem_primitives.empty())
continue;
if (not(gem_primitives.size() <= 8)) // at most 8 hits
{
edm::LogError("L1T") << "gem_primitives.size() = " << gem_primitives.size();
return;
}
bool found = (selected_prim_map.find(selected_gem) != selected_prim_map.end());
if (!found) {
// No CSC hits, insert all GEM hits
selected_prim_map[selected_gem] = gem_primitives;
} else {
// Do nothing
}
}
// Third, insert RPC stubs if there is no CSC/GEM hits
map_tp_it = selected_rpc_map.begin();
map_tp_end = selected_rpc_map.end();
for (; map_tp_it != map_tp_end; ++map_tp_it) {
int selected_rpc = map_tp_it->first;
const TriggerPrimitiveCollection& rpc_primitives = map_tp_it->second;
if (rpc_primitives.empty())
continue;
if (not(rpc_primitives.size() <= 4)) // at most 4 hits
{
edm::LogError("L1T") << "rpc_primitives.size() = " << rpc_primitives.size();
return;
}
bool found = (selected_prim_map.find(selected_rpc) != selected_prim_map.end());
if (!found) {
// No CSC/GEM hits, insert all RPC hits
//selected_prim_map[selected_rpc] = rpc_primitives;
// No CSC/GEM hits, insert the valid RPC hits
TriggerPrimitiveCollection tmp_rpc_primitives;
for (const auto& tp : rpc_primitives) {
if (tp.getRPCData().valid != 0) {
tmp_rpc_primitives.push_back(tp);
}
}
if (not(tmp_rpc_primitives.size() <= 2)) // at most 2 hits
{
edm::LogError("L1T") << "tmp_rpc_primitives.size() = " << tmp_rpc_primitives.size();
return;
}
selected_prim_map[selected_rpc] = tmp_rpc_primitives;
} else {
// Initial FW in 2017; was disabled on June 7.
// If only one CSC/GEM hit, insert the first RPC hit
//TriggerPrimitiveCollection& tmp_primitives = selected_prim_map[selected_rpc]; // pass by reference
//if (tmp_primitives.size() < 2) {
// tmp_primitives.push_back(rpc_primitives.front());
//}
}
}
}
void PrimitiveSelection::merge_no_truncate(const std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
const std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
const std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
std::map<int, TriggerPrimitiveCollection>& selected_prim_map) const {
// First, put CSC hits
merge_map_into_map(selected_csc_map, selected_prim_map);
// Second, insert GEM hits
merge_map_into_map(selected_gem_map, selected_prim_map);
// Third, insert RPC hits
merge_map_into_map(selected_rpc_map, selected_prim_map);
}
// _____________________________________________________________________________
// CSC functions
int PrimitiveSelection::select_csc(const TriggerPrimitive& muon_primitive) const {
int selected = -1;
if (muon_primitive.subsystem() == TriggerPrimitive::kCSC) {
const CSCDetId& tp_detId = muon_primitive.detId<CSCDetId>();
const CSCData& tp_data = muon_primitive.getCSCData();
int tp_endcap = tp_detId.endcap();
int tp_sector = tp_detId.triggerSector();
int tp_station = tp_detId.station();
int tp_ring = tp_detId.ring();
int tp_chamber = tp_detId.chamber();
int tp_bx = tp_data.bx;
int tp_csc_ID = tp_data.cscID;
if (!(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_endcap = " << tp_endcap;
return selected;
}
if (!(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_sector = " << tp_sector;
return selected;
}
if (!(1 <= tp_station && tp_station <= 4)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_station = " << tp_station;
return selected;
}
if (!(1 <= tp_csc_ID && tp_csc_ID <= 9)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_csc_ID = " << tp_csc_ID;
return selected;
}
if (!(tp_data.valid == true)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.valid = " << tp_data.valid;
return selected;
}
if (!(tp_data.pattern <= 10)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.pattern = " << tp_data.pattern;
return selected;
}
if (!(tp_data.quality > 0)) {
edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.quality = " << tp_data.quality;
return selected;
}
int max_strip = 0;
int max_wire = 0;
if (tp_station == 1 && tp_ring == 4) { // ME1/1a
max_strip = 96;
max_wire = 48;
} else if (tp_station == 1 && tp_ring == 1) { // ME1/1b
max_strip = 128;
max_wire = 48;
} else if (tp_station == 1 && tp_ring == 2) { // ME1/2
max_strip = 160;
max_wire = 64;
} else if (tp_station == 1 && tp_ring == 3) { // ME1/3
max_strip = 128;
max_wire = 32;
} else if (tp_station == 2 && tp_ring == 1) { // ME2/1
max_strip = 160;
max_wire = 112;
} else if (tp_station >= 3 && tp_ring == 1) { // ME3/1, ME4/1
max_strip = 160;
max_wire = 96;
} else if (tp_station >= 2 && tp_ring == 2) { // ME2/2, ME3/2, ME4/2
max_strip = 160;
max_wire = 64;
}
if (!(tp_data.strip < max_strip)) {
edm::LogWarning("L1T") << "EMTF CSC format error in station " << tp_station << ", ring " << tp_ring
<< ": tp_data.strip = " << tp_data.strip << " (max = " << max_strip - 1 << ")"
<< std::endl;
return selected;
}
if (!(tp_data.keywire < max_wire)) {
edm::LogWarning("L1T") << "EMTF CSC format error in station " << tp_station << ", ring " << tp_ring
<< ": tp_data.keywire = " << tp_data.keywire << " (max = " << max_wire - 1 << ")"
<< std::endl;
return selected;
}
// station 1 --> subsector 1 or 2
// station 2,3,4 --> subsector 0
int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
// Selection
if (is_in_bx_csc(tp_bx)) {
if (is_in_sector_csc(tp_endcap, tp_sector)) {
selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, false);
} else if (is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, true);
}
}
}
return selected;
}
bool PrimitiveSelection::is_in_sector_csc(int tp_endcap, int tp_sector) const {
return ((endcap_ == tp_endcap) && (sector_ == tp_sector));
}
bool PrimitiveSelection::is_in_neighbor_sector_csc(
int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
auto get_neighbor = [](int sector) { return (sector == 1) ? 6 : sector - 1; };
if (includeNeighbor_) {
if ((endcap_ == tp_endcap) && (get_neighbor(sector_) == tp_sector)) {
if (tp_station == 1) {
if ((tp_subsector == 2) && (tp_csc_ID == 3 || tp_csc_ID == 6 || tp_csc_ID == 9))
return true;
} else {
if (tp_csc_ID == 3 || tp_csc_ID == 9)
return true;
}
}
}
return false;
}
bool PrimitiveSelection::is_in_bx_csc(int tp_bx) const {
tp_bx += bxShiftCSC_;
return (bx_ == tp_bx);
}
// Returns CSC input "link". Index used by FW for unique chamber identification.
int PrimitiveSelection::get_index_csc(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const {
int selected = -1;
if (!is_neighbor) {
if (tp_station == 1) { // ME1: 0 - 8, 9 - 17
selected = (tp_subsector - 1) * 9 + (tp_csc_ID - 1);
} else { // ME2,3,4: 18 - 26, 27 - 35, 36 - 44
selected = (tp_station)*9 + (tp_csc_ID - 1);
}
} else {
if (tp_station == 1) { // ME1: 45 - 47
selected = (5) * 9 + (tp_csc_ID - 1) / 3;
} else { // ME2,3,4: 48 - 53
selected = (5) * 9 + (tp_station)*2 - 1 + (tp_csc_ID - 1 < 3 ? 0 : 1);
}
}
return selected;
}
// _____________________________________________________________________________
// RPC functions
int PrimitiveSelection::select_rpc(const TriggerPrimitive& muon_primitive) const {
int selected = -1;
if (muon_primitive.subsystem() == TriggerPrimitive::kRPC) {
const RPCDetId& tp_detId = muon_primitive.detId<RPCDetId>();
const RPCData& tp_data = muon_primitive.getRPCData();
int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
int tp_endcap = (tp_region == -1) ? 2 : tp_region;
int tp_sector = tp_detId.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg)
int tp_subsector = tp_detId.subsector(); // 1 - 6 (10 degrees in phi; staggered in z)
int tp_station = tp_detId.station(); // 1 - 4
int tp_ring = tp_detId.ring(); // 2 - 3 (increasing theta)
int tp_roll = tp_detId.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp)
//int tp_layer = tp_detId.layer();
int tp_bx = tp_data.bx;
int tp_strip = tp_data.strip;
int tp_emtf_sect = tp_data.emtf_sector;
bool tp_CPPF = tp_data.isCPPF;
// In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors
if (tp_CPPF && (tp_emtf_sect != sector_))
return selected;
if (!(tp_region != 0)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_region = " << tp_region;
return selected;
}
if (!(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_endcap = " << tp_endcap;
return selected;
}
if (!(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_sector = " << tp_sector;
return selected;
}
if (!(1 <= tp_subsector && tp_subsector <= 6)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_subsector = " << tp_subsector;
return selected;
}
if (!(1 <= tp_station && tp_station <= 4)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station;
return selected;
}
if (!(2 <= tp_ring && tp_ring <= 3)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_ring = " << tp_ring;
return selected;
}
if (!(1 <= tp_roll && tp_roll <= 3)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_roll = " << tp_roll;
return selected;
}
if (!(tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_data.strip = " << tp_data.strip;
return selected;
}
if (!(tp_station > 2 || tp_ring != 3)) {
edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station << ", tp_ring = " << tp_ring;
return selected;
}
// Selection
if (is_in_bx_rpc(tp_bx)) {
if (is_in_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) {
selected = get_index_rpc(tp_station, tp_ring, tp_subsector, false);
} else if (is_in_neighbor_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) {
selected = get_index_rpc(tp_station, tp_ring, tp_subsector, true);
}
}
}
return selected;
}
bool PrimitiveSelection::is_in_sector_rpc(
int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const {
// RPC sector X, subsectors 1-2 corresponds to CSC sector X-1
// RPC sector X, subsectors 3-6 corresponds to CSC sector X
auto get_csc_sector = [](int tp_station, int tp_ring, int tp_sector, int tp_subsector) {
// 10 degree chamber
int corr = (tp_subsector < 3) ? (tp_sector == 1 ? +5 : -1) : 0;
return tp_sector + corr;
};
return ((endcap_ == tp_endcap) && (sector_ == get_csc_sector(tp_station, tp_ring, tp_sector, tp_subsector)));
}
bool PrimitiveSelection::is_in_neighbor_sector_rpc(
int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const {
auto get_csc_neighbor_subsector = [](int tp_station, int tp_ring) {
// 10 degree chamber
return 2;
};
return (includeNeighbor_ && (endcap_ == tp_endcap) && (sector_ == tp_sector) &&
(tp_subsector == get_csc_neighbor_subsector(tp_station, tp_ring)));
}
bool PrimitiveSelection::is_in_bx_rpc(int tp_bx) const {
tp_bx += bxShiftRPC_;
return (bx_ == tp_bx);
}
int PrimitiveSelection::get_index_rpc(int tp_station, int tp_ring, int tp_subsector, bool is_neighbor) const {
int selected = -1;
// CPPF RX data come in 3 frames x 64 bits, for 7 links. Each 64-bit data
// carry 2 words of 32 bits. Each word carries phi (11 bits) and theta (5 bits)
// of 2 segments (x2).
//
// Firmware uses 'rpc_sub' as RPC subsector index and 'rpc_chm' as RPC chamber index
// rpc_sub [0,6] = RPC subsector 3, 4, 5, 6, 1 from neighbor, 2 from neighbor, 2. They correspond to
// CSC sector phi 0-10 deg, 10-20, 20-30, 30-40, 40-50, 50-60, 50-60 from neighbor
// rpc_chm [0,5] = RPC chamber RE1/2, RE2/2, RE3/2, RE3/3, RE4/2, RE4/3
//
int rpc_sub = -1;
int rpc_chm = -1;
if (!is_neighbor) {
rpc_sub = ((tp_subsector + 3) % 6);
} else {
rpc_sub = 6;
}
if (tp_station <= 2) {
rpc_chm = (tp_station - 1);
} else {
rpc_chm = 2 + (tp_station - 3) * 2 + (tp_ring - 2);
}
if (not(rpc_sub != -1 && rpc_chm != -1)) {
edm::LogError("L1T") << "rpc_sub = " << rpc_sub << ", rpc_chm = " << rpc_chm;
return selected;
}
selected = (rpc_sub * 8) + rpc_chm;
return selected;
}
// _____________________________________________________________________________
// GEM functions
int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const {
int selected = -1;
if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) {
const EMTFGEMDetId& tp_detId = emtf::construct_EMTFGEMDetId(muon_primitive);
const GEMData& tp_data = muon_primitive.getGEMData();
int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
int tp_endcap = (tp_region == -1) ? 2 : tp_region;
int tp_station = tp_detId.station();
int tp_ring = tp_detId.ring();
int tp_roll = tp_detId.roll();
int tp_layer = tp_detId.layer();
int tp_chamber = tp_detId.chamber();
int tp_bx = tp_data.bx;
int tp_pad = tp_data.pad;
// Use CSC trigger sector definitions
// Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
auto get_trigger_sector = [](int ring, int station, int chamber) {
int result = 0;
if (station > 1 && ring > 1) {
result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
} else if (station == 1 && ring != 4) {
result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
} else {
result = ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1; // ch 2-4-> 1, 5-7->2, ...
}
return (result <= 6)
? result
: 6; // max sector is 6, some calculations give a value greater than six but this is expected.
};
// Use CSC trigger "CSC ID" definitions
// Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
auto get_trigger_csc_ID = [](int ring, int station, int chamber) {
int result = 0;
if (station == 1) {
result = (chamber) % 3 + 1; // 1,2,3
switch (ring) {
case 1:
break;
case 2:
result += 3; // 4,5,6
break;
case 3:
result += 6; // 7,8,9
break;
}
} else {
if (ring == 1) {
result = (chamber + 1) % 3 + 1; // 1,2,3
} else {
result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9
}
}
return result;
};
int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber);
int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
// station 1 --> subsector 1 or 2
// station 2,3,4 --> subsector 0
int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
if (!(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_endcap = " << tp_endcap;
return selected;
}
if (!(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_sector = " << tp_sector;
return selected;
}
if (!(1 <= tp_station && tp_station <= 2)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station;
return selected;
}
if (!(1 <= tp_ring && tp_ring <= 1)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_ring = " << tp_ring;
return selected;
}
if (!(1 <= tp_csc_ID && tp_csc_ID <= 9)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_csc_ID = " << tp_csc_ID;
return selected;
}
if (!(tp_station == 1 && 1 <= tp_roll && tp_roll <= 8) || (tp_station != 1)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_roll = " << tp_roll;
return selected;
}
if (!(tp_station == 2 && 1 <= tp_roll && tp_roll <= 12) || (tp_station != 2)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_roll = " << tp_roll;
return selected;
}
if (!(1 <= tp_layer && tp_layer <= 2)) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_layer = " << tp_layer;
return selected;
}
if (!((tp_station == 1 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 1))) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_pad = " << tp_pad;
return selected;
}
if (!((tp_station == 2 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 2))) {
edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_pad = " << tp_pad;
return selected;
}
// Selection
if (is_in_bx_gem(tp_bx)) {
if (is_in_sector_gem(tp_endcap, tp_sector)) {
selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, false);
} else if (is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, true);
}
}
}
return selected;
}
bool PrimitiveSelection::is_in_sector_gem(int tp_endcap, int tp_sector) const {
// Identical to the corresponding CSC function
return is_in_sector_csc(tp_endcap, tp_sector);
}
bool PrimitiveSelection::is_in_neighbor_sector_gem(
int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
// Identical to the corresponding CSC function
return is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID);
}
bool PrimitiveSelection::is_in_bx_gem(int tp_bx) const {
tp_bx += bxShiftGEM_;
return (bx_ == tp_bx);
}
int PrimitiveSelection::get_index_gem(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const {
// Identical to the corresponding CSC function
return get_index_csc(tp_subsector, tp_station, tp_csc_ID, is_neighbor);
}
| 41.473404
| 120
| 0.61085
|
NTrevisani
|
896ec41d3f737e552a62203d2087690a18c7e4c8
| 3,819
|
hpp
|
C++
|
opencv/sources/modules/videoio/src/precomp.hpp
|
vrushank-agrawal/opencv-x64-cmake
|
3f9486510d706c8ac579ac82f5d58f667f948124
|
[
"Apache-2.0"
] | null | null | null |
opencv/sources/modules/videoio/src/precomp.hpp
|
vrushank-agrawal/opencv-x64-cmake
|
3f9486510d706c8ac579ac82f5d58f667f948124
|
[
"Apache-2.0"
] | null | null | null |
opencv/sources/modules/videoio/src/precomp.hpp
|
vrushank-agrawal/opencv-x64-cmake
|
3f9486510d706c8ac579ac82f5d58f667f948124
|
[
"Apache-2.0"
] | null | null | null |
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation 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.
//
//M*/
#ifndef __VIDEOIO_H_
#define __VIDEOIO_H_
#if defined(__OPENCV_BUILD) && defined(BUILD_PLUGIN)
#undef __OPENCV_BUILD // allow public API only
#define OPENCV_HAVE_CVCONFIG_H 1 // but we still have access to cvconfig.h (TODO remove this)
#include <opencv2/core.hpp>
#include <opencv2/core/utils/trace.hpp>
#endif
#if defined __linux__ || defined __APPLE__ || defined __HAIKU__
#include <unistd.h> // -D_FORTIFY_SOURCE=2 workaround: https://github.com/opencv/opencv/issues/15020
#endif
#include "opencv2/videoio.hpp"
#include "opencv2/videoio/legacy/constants_c.h"
#include "opencv2/core/utility.hpp"
#ifdef __OPENCV_BUILD
#include "opencv2/core/private.hpp"
#endif
#include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/logger.defines.hpp>
#ifdef NDEBUG
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1
#else
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
#endif
#include <opencv2/core/utils/logger.hpp>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/videoio/videoio_c.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <assert.h> // FIXIT remove this
#if defined _WIN32 || defined WINCE
#if !defined _WIN32_WINNT
#ifdef HAVE_MSMF
#define _WIN32_WINNT 0x0600 // Windows Vista
#else
#define _WIN32_WINNT 0x0501 // Windows XP
#endif
#endif
#include <windows.h>
#undef small
#undef min
#undef max
#undef abs
#endif
#include "cap_interface.hpp"
#endif /* __VIDEOIO_H_ */
| 36.028302
| 102
| 0.701231
|
vrushank-agrawal
|
89702e71cf3a93e27441480fdfd461f2bff7935b
| 522
|
hpp
|
C++
|
lock_screen_widget.hpp
|
eggfly/singsang
|
d59ec88f7ad1dcc89f4c86f7e4b20256e32225ec
|
[
"MIT"
] | 1
|
2022-02-14T13:48:32.000Z
|
2022-02-14T13:48:32.000Z
|
lock_screen_widget.hpp
|
eggfly/singsang
|
d59ec88f7ad1dcc89f4c86f7e4b20256e32225ec
|
[
"MIT"
] | null | null | null |
lock_screen_widget.hpp
|
eggfly/singsang
|
d59ec88f7ad1dcc89f4c86f7e4b20256e32225ec
|
[
"MIT"
] | null | null | null |
#ifndef SINGSANG_LOCK_SCREEN_WIDGET_HPP
#define SINGSANG_LOCK_SCREEN_WIDGET_HPP
#include "base_widget.hpp"
namespace singsang
{
class CLockScreenWidget : public CBaseWidget
{
public:
CLockScreenWidget() : CBaseWidget(251, 30, 64, 64) {}
void update() {}
void draw(const bool f_updateOnly)
{
M5.Lcd.drawPngFile(SD, "/media/icon-lock-screen.png", m_positionX,
m_positionY, m_sizeX, m_sizeY);
}
};
} // namespace singsang
#endif // SINGSANG_LOCK_SCREEN_WIDGET_HPP
| 20.88
| 72
| 0.693487
|
eggfly
|
89704a7a5083eedf076c0369a1476f54670b12a5
| 3,127
|
cpp
|
C++
|
first/src/tests/test3d_textures/Test3dTextures.cpp
|
DeeJack/opengl_first_project
|
29a6ec89d80046ceb575c02d009e611b835f49fe
|
[
"MIT"
] | null | null | null |
first/src/tests/test3d_textures/Test3dTextures.cpp
|
DeeJack/opengl_first_project
|
29a6ec89d80046ceb575c02d009e611b835f49fe
|
[
"MIT"
] | null | null | null |
first/src/tests/test3d_textures/Test3dTextures.cpp
|
DeeJack/opengl_first_project
|
29a6ec89d80046ceb575c02d009e611b835f49fe
|
[
"MIT"
] | null | null | null |
#include "Test3dTextures.h"
#include "../../textures/Texture.h"
#include "imgui/imgui.h"
namespace test
{
Test3dTextures::Test3dTextures()
: _shader("res/shaders/basic3d_texture.shader")
{
_shader.bind();
glDisable(GL_BLEND);
/*float colors[] = {
1.F, 0.F, 0.F,
1.F, 0.3F, 0.F,
1.F, 0.6F, 0.F,
0.5F, 1.F, 0.F,
0.F, 1.F, 0.F,
0.F, 1.F, 1.F,
0.F, 0.6F, 1.F,
0.6F, 0.F, 1.F,
};*/
_cube = new Cube(glm::vec3(100, 100, 100), glm::vec3(300, 300, 300));
_cube->fillWithoutIndexes();
float textureCoords[] = {
0.0F, 0.0F,
1.0F, 0.0F,
1.0F, 1.0F,
0.0F, 1.0F
};
int texInds[6] = { 0, 1, 3, 1, 2, 3 };
float textureBuffer[2 * 6 * 6];
int index = 0;
for (int i = 0; i < 36 * 2; i += 2) {
textureBuffer[i] = textureCoords[texInds[index % 6] * 2];
textureBuffer[i + 1] = textureCoords[texInds[index % 6] * 2 + 1];
index++;
}
std::cout << "Texture buffer: \n";
for (int i = 1; i <= 36 * 2; i++) {
std::cout << textureBuffer[i - 1] << ", ";
if (i % 2 == 0)
std::cout << "\n";
}
_cube->add_data(textureBuffer, 2 * 6 * 6);
_shader.bind();
texture.load("res/textures/earth.png");
texture.bind();
_shader.set_uniform1i("u_texture", 0);
glm::vec3 firstBase(400, 100, 100);
glm::vec3 secondBase(700, 100, 400);
glm::vec3 top(550, 400, 200);
//_pyramid = new Pyramid(firstBase, secondBase, top, &_shader);
}
Test3dTextures::~Test3dTextures()
{
delete _cube;
//delete _pyramid;
}
void Test3dTextures::on_update(float deltaTime)
{
}
void Test3dTextures::on_render()
{
glm::mat4 model = glm::translate(glm::mat4(1.0F), translation);
if (_camera_rotations[0] != _last_rotations[0]) {
view = glm::rotate(glm::mat4(1.0F), glm::radians(_camera_rotations[0]), glm::vec3(1, 0, 0));
_last_rotations[0] = _camera_rotations[0];
}
if (_camera_rotations[1] != _last_rotations[1]) {
view = glm::rotate(glm::mat4(1.F), glm::radians(_camera_rotations[1]), glm::vec3(0, 1, 0));
_last_rotations[1] = _camera_rotations[1];
}
if (_camera_rotations[2] != _last_rotations[2]) {
view = glm::rotate(glm::mat4(1.F), glm::radians(_camera_rotations[2]), glm::vec3(0, 0, 1));
_last_rotations[2] = _camera_rotations[2];
}
if (_camera_rotations[3] != _last_rotations[3]) {
view = glm::rotate(glm::mat4(1.F), glm::radians(_camera_rotations[3]), glm::vec3(1, 1, 0));
_last_rotations[3] = _camera_rotations[3];
}
const glm::mat4 mvp = proj * view * model;
_shader.set_uniform_mat4f("u_mvp", mvp);
//_renderer.draw(*_cube);
_renderer.draw_without_indexes(*_cube, _shader);
}
void Test3dTextures::on_imgui_render()
{
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
ImGui::SliderFloat3("Translation", &translation.x, -500.0F, 500.0F);
ImGui::SliderFloat("Rotation X", &_camera_rotations[0], 0.0F, 360.0F);
ImGui::SliderFloat("Rotation Y", &_camera_rotations[1], 0.0F, 360.0F);
ImGui::SliderFloat("Rotation Z", &_camera_rotations[2], 0.0F, 360.0F);
ImGui::SliderFloat("Rotation XY", &_camera_rotations[3], 0.0F, 360.0F);
ImGui::End();
}
}
| 29.780952
| 96
| 0.62552
|
DeeJack
|
89705103fc7ceb3592557f9cbbc1f57c2b7479ee
| 431
|
cc
|
C++
|
examples/0006.file_io/file_loader.cc
|
clayne/fast_io
|
1d7e12ea551d87e187a5a8881d9227ba3ea3b8a0
|
[
"MIT"
] | 157
|
2021-07-12T07:19:15.000Z
|
2022-02-16T02:22:45.000Z
|
examples/0006.file_io/file_loader.cc
|
clayne/fast_io
|
1d7e12ea551d87e187a5a8881d9227ba3ea3b8a0
|
[
"MIT"
] | 7
|
2021-08-02T05:06:23.000Z
|
2021-12-26T10:32:18.000Z
|
examples/0006.file_io/file_loader.cc
|
clayne/fast_io
|
1d7e12ea551d87e187a5a8881d9227ba3ea3b8a0
|
[
"MIT"
] | 17
|
2022-02-19T20:16:18.000Z
|
2022-03-29T20:50:49.000Z
|
#include<fast_io.h>
int main(int argc,char** argv)
{
if(argc!=2)
{
perr("Usage: ",fast_io::mnp::os_c_str(*argv)," <file>\n");
return 1;
}
fast_io::native_file_loader loader(::fast_io::mnp::os_c_str(argv[1]));
//This will load entire file to memory through memory mapping.
/*
This is a contiguous container of the file.
You can do these things:
std::size_t sum{};
for(auto e:loader)
sum+=e;
*/
print(loader);
}
| 20.52381
| 71
| 0.663573
|
clayne
|
897085571ccad7980acbdf142423925e953d4f52
| 927
|
hpp
|
C++
|
include/State/Menu.hpp
|
sarahkittyy/platform.sh
|
8ddd8f412a70041153f555b4ba5bb56056e804e4
|
[
"MIT"
] | null | null | null |
include/State/Menu.hpp
|
sarahkittyy/platform.sh
|
8ddd8f412a70041153f555b4ba5bb56056e804e4
|
[
"MIT"
] | null | null | null |
include/State/Menu.hpp
|
sarahkittyy/platform.sh
|
8ddd8f412a70041153f555b4ba5bb56056e804e4
|
[
"MIT"
] | null | null | null |
#pragma once
#include <SFML/Graphics.hpp>
#include <cmath>
#include <iostream>
#include "GFX/Tilemap.hpp"
#include "State/Edit.hpp"
#include "State/Game.hpp"
#include "State/State.hpp"
#include "Util/ImGuiShell.hpp"
#include "imgui/imgui-SFML.h"
#include "imgui/imgui.h"
namespace State
{
/**
* @brief The main menu. This is the first state the app loads into.
*
*/
class Menu : public State
{
public:
Menu();
~Menu();
void init();
void update();
private:
/// Sets up all menu gui onto the screen. Run before rendering, each frame.
void drawGUI();
/// Update all title animations.
void updateAnimations();
/// For animation timing.
sf::Clock mClock;
/// The menu background music.
sf::Music* mBGMusic;
/// The title.
sf::Text mTitle;
/// The input shell.
Util::ImGuiShell mShell;
/// Initializes shell programs.
void initShell();
/// The background demo map to run.
GFX::Tilemap mDemoMap;
};
}
| 17.490566
| 76
| 0.686084
|
sarahkittyy
|
8972776657dfc55ad0be921f0f03d98ba0191869
| 4,079
|
cpp
|
C++
|
cpp/0_check/modernes_cpp_source/source/newAlgorithm.cpp
|
shadialameddin/numerical_tools_and_friends
|
cc9f10f58886ee286ed89080e38ebd303d3c72a5
|
[
"Unlicense"
] | null | null | null |
cpp/0_check/modernes_cpp_source/source/newAlgorithm.cpp
|
shadialameddin/numerical_tools_and_friends
|
cc9f10f58886ee286ed89080e38ebd303d3c72a5
|
[
"Unlicense"
] | null | null | null |
cpp/0_check/modernes_cpp_source/source/newAlgorithm.cpp
|
shadialameddin/numerical_tools_and_friends
|
cc9f10f58886ee286ed89080e38ebd303d3c72a5
|
[
"Unlicense"
] | null | null | null |
// newAlgorithm.cpp
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/include/parallel_numeric.hpp>
#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/iostreams.hpp>
#include <string>
#include <vector>
int hpx_main(){
hpx::cout << hpx::endl;
// for_each_n
std::vector<int> intVec{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // 1
hpx::parallel::for_each_n(hpx::parallel::execution::par, // 2
intVec.begin(), 5, [](int& arg){ arg *= arg; });
hpx::cout << "for_each_n: ";
for (auto v: intVec) hpx::cout << v << " ";
hpx::cout << "\n\n";
// exclusive_scan and inclusive_scan
std::vector<int> resVec{1, 2, 3, 4, 5, 6, 7, 8, 9};
hpx::parallel::exclusive_scan(hpx::parallel::execution::par, // 3
resVec.begin(), resVec.end(), resVec.begin(), 1,
[](int fir, int sec){ return fir * sec; });
hpx::cout << "exclusive_scan: ";
for (auto v: resVec) hpx::cout << v << " ";
hpx::cout << hpx::endl;
std::vector<int> resVec2{1, 2, 3, 4, 5, 6, 7, 8, 9};
hpx::parallel::inclusive_scan(hpx::parallel::execution::par, // 5
resVec2.begin(), resVec2.end(), resVec2.begin(),
[](int fir, int sec){ return fir * sec; }, 1);
hpx::cout << "inclusive_scan: ";
for (auto v: resVec2) hpx::cout << v << " ";
hpx::cout << "\n\n";
// transform_exclusive_scan and transform_inclusive_scan
std::vector<int> resVec3{1, 2, 3, 4, 5, 6, 7, 8, 9};
std::vector<int> resVec4(resVec3.size());
hpx::parallel::transform_exclusive_scan(hpx::parallel::execution::par, // 6
resVec3.begin(), resVec3.end(),
resVec4.begin(), 0,
[](int fir, int sec){ return fir + sec; },
[](int arg){ return arg *= arg; });
hpx::cout << "transform_exclusive_scan: ";
for (auto v: resVec4) hpx::cout << v << " ";
hpx::cout << hpx::endl;
std::vector<std::string> strVec{"Only","for","testing","purpose"}; // 7
std::vector<int> resVec5(strVec.size());
hpx::parallel::transform_inclusive_scan(hpx::parallel::execution::par, // 8
strVec.begin(), strVec.end(),
resVec5.begin(), 0,
[](auto fir, auto sec){ return fir + sec; },
[](auto s){ return s.length(); });
hpx::cout << "transform_inclusive_scan: ";
for (auto v: resVec5) hpx::cout << v << " ";
hpx::cout << "\n\n";
// reduce and transform_reduce
std::vector<std::string> strVec2{"Only","for","testing","purpose"};
std::string res = hpx::parallel::reduce(hpx::parallel::execution::par, // 9
strVec2.begin() + 1, strVec2.end(), strVec2[0],
[](auto fir, auto sec){ return fir + ":" + sec; });
hpx::cout << "reduce: " << res << hpx::endl;
// 11
std::size_t res7 = hpx::parallel::parallel::transform_reduce(hpx::parallel::execution::par,
strVec2.begin(), strVec2.end(),
[](std::string s){ return s.length(); },
0, [](std::size_t a, std::size_t b){ return a + b; });
hpx::cout << "transform_reduce: " << res7 << hpx::endl;
hpx::cout << hpx::endl;
return hpx::finalize();
}
int main(int argc, char* argv[]){
// By default this should run on all available cores
std::vector<std::string> const cfg = {"hpx.os_threads=all"};
// Initialize and run HPX
return hpx::init(argc, argv, cfg);
}
| 38.847619
| 149
| 0.471439
|
shadialameddin
|
897499ebbbd3e9d568eacbfdc6527aaac1a4bd89
| 8,295
|
cpp
|
C++
|
src/runtime/regiondataraw.cpp
|
petabricks/petabricks
|
b498b93880b0c4ac3924ddb82cff2e6541e60bd1
|
[
"MIT"
] | 10
|
2015-03-12T18:09:57.000Z
|
2022-03-17T03:18:36.000Z
|
src/runtime/regiondataraw.cpp
|
petabricks/petabricks
|
b498b93880b0c4ac3924ddb82cff2e6541e60bd1
|
[
"MIT"
] | 2
|
2021-01-12T15:12:21.000Z
|
2022-03-22T07:47:37.000Z
|
src/runtime/regiondataraw.cpp
|
petabricks/petabricks
|
b498b93880b0c4ac3924ddb82cff2e6541e60bd1
|
[
"MIT"
] | 3
|
2017-06-28T06:01:03.000Z
|
2021-01-12T15:05:34.000Z
|
#include "regiondataraw.h"
#include "matrixio.h"
using namespace petabricks;
using namespace petabricks::RegionDataRemoteMessage;
RegionDataRaw::RegionDataRaw(const int dimensions, const IndexT* size) {
init(dimensions, size, NULL);
}
RegionDataRaw::RegionDataRaw(const int dimensions, const IndexT* size, const ElementT* data) {
init(dimensions, size, data);
}
RegionDataRaw::RegionDataRaw(const char* filename) {
distributed::MatrixIO matrixio(filename, "r");
MatrixReaderScratch o = matrixio.readToMatrixReaderScratch();
init(o.dimensions, o.sizes, o.storage->data());
}
void RegionDataRaw::init(const int dimensions, const IndexT* size, const ElementT* data) {
_D = dimensions;
_type = RegionDataTypes::REGIONDATARAW;
memcpy(_size, size, sizeof(IndexT) * _D);
if (data) {
int numData = allocData();
memcpy(_storage->data(), data, sizeof(ElementT) * numData);
}
_multipliers[0] = 1;
for (int i = 1; i < _D; i++) {
_multipliers[i] = _multipliers[i - 1] * _size[i - 1];
}
}
int RegionDataRaw::allocData() {
if (_storage) {
return 0;
}
int numData = 1;
for (int i = 0; i < _D; i++) {
numData *= _size[i];
}
_storage = new MatrixStorage(numData);
return numData;
}
ElementT* RegionDataRaw::coordToPtr(const IndexT* coord) const {
return _storage->data() + coordOffset(coord);
}
IndexT RegionDataRaw::coordOffset(const IndexT* coord) const {
IndexT offset = 0;
for(int i = 0; i < _D; i++){
offset += _multipliers[i] * coord[i];
}
return offset;
}
ElementT& RegionDataRaw::value0D(const IndexT* coord) const {
return *this->coordToPtr(coord);
}
ElementT RegionDataRaw::readCell(const IndexT* coord) const {
return *this->coordToPtr(coord);
}
void RegionDataRaw::writeCell(const IndexT* coord, ElementT value) {
// Do not write nan
// JASSERT(fabs(value) >= 0)(value);
ElementT* cell = this->coordToPtr(coord);
*cell = value;
}
RegionDataIPtr RegionDataRaw::copyToScratchMatrixStorage(CopyToMatrixStorageMessage* origMsg, size_t, MatrixStoragePtr scratchStorage, RegionMatrixMetadata* scratchMetadata, const IndexT* scratchStorageSize, RegionDataI** /*newScratchRegionData*/) {
RegionMatrixMetadata* origMetadata = &(origMsg->srcMetadata);
#ifdef DEBUG
JASSERT(origMetadata->dimensions == scratchMetadata->dimensions);
#endif
int d = origMetadata->dimensions;
IndexT* size = origMetadata->size();
IndexT coord[d];
memset(coord, 0, sizeof coord);
IndexT scratchMultipliers[d];
sizeToMultipliers(scratchMetadata->dimensions, scratchStorageSize, scratchMultipliers);
do {
IndexT origIndex = toRegionDataIndex(d, coord, origMetadata->numSliceDimensions, origMetadata->splitOffset, origMetadata->sliceDimensions(), origMetadata->slicePositions(), _multipliers);
IndexT scratchIndex = toRegionDataIndex(d, coord, scratchMetadata->numSliceDimensions, scratchMetadata->splitOffset, scratchMetadata->sliceDimensions(), scratchMetadata->slicePositions(), scratchMultipliers);
scratchStorage->data()[scratchIndex] = _storage->data()[origIndex];
} while(incCoord(d, size, coord) >= 0);
return NULL;
}
void RegionDataRaw::copyFromScratchMatrixStorage(CopyFromMatrixStorageMessage* origMsg, size_t, MatrixStoragePtr scratchStorage, RegionMatrixMetadata* scratchMetadata, const IndexT* scratchStorageSize) {
// Debug
// RegionDataRawPtr sc = new RegionDataRaw(_D, scratchStorageSize);
// sc->setStorage(scratchStorage);
// sc->print();
RegionMatrixMetadata* origMetadata = &(origMsg->srcMetadata);
int d = origMetadata->dimensions;
IndexT* size = origMetadata->size();
IndexT coord[d];
memset(coord, 0, sizeof coord);
IndexT scratchMultipliers[d];
sizeToMultipliers(d, scratchStorageSize, scratchMultipliers);
do {
IndexT origIndex = toRegionDataIndex(d, coord, origMetadata->numSliceDimensions, origMetadata->splitOffset, origMetadata->sliceDimensions(), origMetadata->slicePositions(), _multipliers);
IndexT scratchIndex = toRegionDataIndex(d, coord, scratchMetadata->numSliceDimensions, scratchMetadata->splitOffset, scratchMetadata->sliceDimensions(), scratchMetadata->slicePositions(), scratchMultipliers);
_storage->data()[origIndex] = scratchStorage->data()[scratchIndex];
} while(incCoord(d, size, coord) >= 0);
}
RegionDataIPtr RegionDataRaw::hosts(const IndexT* begin, const IndexT* end, DataHostPidList& list) {
size_t count = 1;
for(int i = 0; i < _D; i++){
count *= (end[i] - begin[i]);
}
DataHostPidListItem item = {HostPid::self(), count};
list.push_back(item);
return NULL;
}
RemoteHostPtr RegionDataRaw::dataHost() {
// local
return NULL;
}
void RegionDataRaw::processReadCellCacheMsg(const BaseMessageHeader* base, size_t, IRegionReplyProxy* caller) {
ReadCellCacheMessage* msg = (ReadCellCacheMessage*)base->content();
IndexT coordOffset = this->coordOffset(msg->coord);
IndexT startOffset = coordOffset - (coordOffset % msg->cacheLineSize);
size_t numValues = _storage->count() - startOffset;
if (numValues > msg->cacheLineSize) {
numValues = msg->cacheLineSize;
}
size_t values_sz = sizeof(ElementT) * numValues;
size_t sz = sizeof(ReadCellCacheReplyMessage) + values_sz;
char buf[sz];
ReadCellCacheReplyMessage* reply = (ReadCellCacheReplyMessage*)buf;
reply->start = 0;
reply->end = numValues - 1;
memcpy(reply->values, _storage->data() + startOffset, values_sz);
caller->sendReply(buf, sz, base);
}
void RegionDataRaw::processWriteCellCacheMsg(const BaseMessageHeader* base, size_t, IRegionReplyProxy* caller) {
WriteCellCacheMessage* msg = (WriteCellCacheMessage*)base->content();
IndexT coordOffset = this->coordOffset(msg->coord);
IndexT startOffset = coordOffset - (coordOffset % msg->cacheLineSize);
size_t values_sz = sizeof(ElementT) * msg->cacheLineSize;
size_t sz = sizeof(WriteCellCacheReplyMessage) + values_sz;
char buf[sz];
WriteCellCacheReplyMessage* reply = (WriteCellCacheReplyMessage*)buf;
reply->start = 0;
reply->end = msg->cacheLineSize - 1;
memcpy(reply->values, _storage->data() + startOffset, values_sz);
caller->sendReply(buf, sz, base);
}
//
// Copy MatrixStorage and send it to the requested node. Only send what the
// requester needs.
void RegionDataRaw::processCopyToMatrixStorageMsg(const BaseMessageHeader* base, size_t, IRegionReplyProxy* caller) {
CopyToMatrixStorageMessage* msg = (CopyToMatrixStorageMessage*)base->content();
RegionMatrixMetadata* metadata = &(msg->srcMetadata);
int d = metadata->dimensions;
IndexT* size = metadata->size();
size_t storage_count = 1;
for (int i = 0; i < d; i++) {
storage_count *= size[i];
}
size_t sz = sizeof(CopyToMatrixStorageReplyMessage) + (sizeof(ElementT) * storage_count);
char* buf = new char[sz];
CopyToMatrixStorageReplyMessage* reply = (CopyToMatrixStorageReplyMessage*)buf;
reply->count = storage_count;
IndexT n = 0;
IndexT coord[d];
memset(coord, 0, sizeof coord);
do {
IndexT index = toRegionDataIndex(d, coord, metadata->numSliceDimensions, metadata->splitOffset, metadata->sliceDimensions(), metadata->slicePositions(), _multipliers);
reply->storage[n] = _storage->data()[index];
n++;
} while(incCoord(d, size, coord) >= 0);
caller->sendReply(buf, sz, base, MessageTypes::TOSCRATCHSTORAGE);
delete [] buf;
}
void RegionDataRaw::processCopyFromMatrixStorageMsg(const BaseMessageHeader* base, size_t, IRegionReplyProxy* caller) {
CopyFromMatrixStorageMessage* msg = (CopyFromMatrixStorageMessage*)base->content();
RegionMatrixMetadata* metadata = &(msg->srcMetadata);
int d = metadata->dimensions;
IndexT* size = metadata->size();
ElementT* storage = msg->storage();
size_t sz = sizeof(CopyFromMatrixStorageReplyMessage);
char buf[sz];
IndexT n = 0;
IndexT coord[d];
memset(coord, 0, sizeof coord);
do {
unsigned int index = toRegionDataIndex(d, coord, metadata->numSliceDimensions, metadata->splitOffset, metadata->sliceDimensions(), metadata->slicePositions(), _multipliers);
#ifdef DEBUG
JASSERT(index <= _storage->count())(index)(_storage->count());
#endif
_storage->data()[index] = storage[n];
n++;
} while(incCoord(d, size, coord) >= 0);
caller->sendReply(buf, sz, base, MessageTypes::FROMSCRATCHSTORAGE);
}
| 33.995902
| 249
| 0.729837
|
petabricks
|
89767ac7fa89a5fa716a4ebbcc997fddb5c791c1
| 674
|
cpp
|
C++
|
Source/DemoScene/Vector2.cpp
|
ookumaneko/PC-Psp-Cross-Platform-Demoscene
|
0c192f9ecf5a4fd9db3c9a2c9998b365bf480c1e
|
[
"MIT"
] | null | null | null |
Source/DemoScene/Vector2.cpp
|
ookumaneko/PC-Psp-Cross-Platform-Demoscene
|
0c192f9ecf5a4fd9db3c9a2c9998b365bf480c1e
|
[
"MIT"
] | null | null | null |
Source/DemoScene/Vector2.cpp
|
ookumaneko/PC-Psp-Cross-Platform-Demoscene
|
0c192f9ecf5a4fd9db3c9a2c9998b365bf480c1e
|
[
"MIT"
] | null | null | null |
#include "Vector2.h"
//--------------------------------------//
//---------------Common Methods---------//
//--------------------------------------//
Vector2::Vector2(void)
{
_vec.x = 0;
_vec.y = 0;
}
Vector2::Vector2(float x, float y)
{
_vec.x = x;
_vec.y = y;
}
Vector2::~Vector2(void)
{
}
float& Vector2::X()
{
return _vec.x;
}
float Vector2::X() const
{
return _vec.x;
}
float& Vector2::Y()
{
return _vec.y;
}
float Vector2::Y() const
{
return _vec.y;
}
float Vector2::GetX() const
{
return _vec.x;
}
float Vector2::GetY() const
{
return _vec.y;
}
void Vector2::SetX(float x)
{
_vec.x = x;
}
inline void Vector2::SetY(float y)
{
_vec.y = y;
}
| 10.369231
| 42
| 0.510386
|
ookumaneko
|
8977a8c6504a2a0c971d8880dbe16757ec3d590f
| 297
|
cpp
|
C++
|
getdate.cpp
|
eqvpkbz/old.eqvpkbz.github.io
|
0adb4b7400248d3caf4a8e12525279d19c2ba83f
|
[
"MIT"
] | null | null | null |
getdate.cpp
|
eqvpkbz/old.eqvpkbz.github.io
|
0adb4b7400248d3caf4a8e12525279d19c2ba83f
|
[
"MIT"
] | null | null | null |
getdate.cpp
|
eqvpkbz/old.eqvpkbz.github.io
|
0adb4b7400248d3caf4a8e12525279d19c2ba83f
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<ctime>
#include<cstdio>
using namespace std;
int main()
{
time_t tt;time(&tt);
tt = tt + 8*3600;
tm* t= gmtime(&tt);
printf("%d-%02d-%02d %02d:%02d:%02d\n",t->tm_year + 1900,t->tm_mon + 1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
return 0;
}
| 17.470588
| 118
| 0.599327
|
eqvpkbz
|
897b1f2443e279c14f2cb3ebcb348f03175a96c1
| 2,440
|
cc
|
C++
|
ash/capture_mode/capture_mode_source_view.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
ash/capture_mode/capture_mode_source_view.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
ash/capture_mode/capture_mode_source_view.cc
|
mghgroup/Glide-Browser
|
6a4c1eaa6632ec55014fee87781c6bbbb92a2af5
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2
|
2021-01-05T23:43:46.000Z
|
2021-01-07T23:36:34.000Z
|
// Copyright 2020 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.
#include "ash/capture_mode/capture_mode_source_view.h"
#include <memory>
#include "ash/capture_mode/capture_mode_controller.h"
#include "ash/capture_mode/capture_mode_toggle_button.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ui/views/layout/box_layout.h"
namespace ash {
CaptureModeSourceView::CaptureModeSourceView()
: fullscreen_toggle_button_(
AddChildView(std::make_unique<CaptureModeToggleButton>(
this,
kCaptureModeFullscreenIcon))),
region_toggle_button_(AddChildView(
std::make_unique<CaptureModeToggleButton>(this,
kCaptureModeRegionIcon))),
window_toggle_button_(AddChildView(
std::make_unique<CaptureModeToggleButton>(this,
kCaptureModeWindowIcon))) {
auto* box_layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(),
capture_mode::kBetweenChildSpacing));
box_layout->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
OnCaptureSourceChanged(CaptureModeController::Get()->source());
}
CaptureModeSourceView::~CaptureModeSourceView() = default;
void CaptureModeSourceView::OnCaptureSourceChanged(
CaptureModeSource new_source) {
fullscreen_toggle_button_->SetToggled(new_source ==
CaptureModeSource::kFullscreen);
region_toggle_button_->SetToggled(new_source == CaptureModeSource::kRegion);
window_toggle_button_->SetToggled(new_source == CaptureModeSource::kWindow);
}
const char* CaptureModeSourceView::GetClassName() const {
return "CaptureModeSourceView";
}
void CaptureModeSourceView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
auto* controller = CaptureModeController::Get();
if (sender == fullscreen_toggle_button_) {
controller->SetSource(CaptureModeSource::kFullscreen);
} else if (sender == region_toggle_button_) {
controller->SetSource(CaptureModeSource::kRegion);
} else {
DCHECK_EQ(sender, window_toggle_button_);
controller->SetSource(CaptureModeSource::kWindow);
}
}
} // namespace ash
| 38.730159
| 79
| 0.707377
|
mghgroup
|
897b956ca89388f61334f61f6fb6d5126ee42123
| 26,785
|
cpp
|
C++
|
CPP/Targets/GlobeLib/globe/src/gbGlobe.cpp
|
wayfinder/Wayfinder-S60-Navigator
|
14d1b729b2cea52f726874687e78f17492949585
|
[
"BSD-3-Clause"
] | 6
|
2015-12-01T01:12:33.000Z
|
2021-07-24T09:02:34.000Z
|
CPP/Targets/GlobeLib/globe/src/gbGlobe.cpp
|
wayfinder/Wayfinder-S60-Navigator
|
14d1b729b2cea52f726874687e78f17492949585
|
[
"BSD-3-Clause"
] | null | null | null |
CPP/Targets/GlobeLib/globe/src/gbGlobe.cpp
|
wayfinder/Wayfinder-S60-Navigator
|
14d1b729b2cea52f726874687e78f17492949585
|
[
"BSD-3-Clause"
] | 2
|
2017-02-02T19:31:29.000Z
|
2018-12-17T21:00:45.000Z
|
/*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
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 the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "gbGlobe.h"
#include "gbMemory.h"
#include "gbRle.h"
#include "gbBitmap.h"
#include "gbRect.h"
#include "gbRayMath.h"
#define POLYGON_GLOBE
#if defined(POLYGON_GLOBE) || defined(USE_GLES)
# include "gbPolySphere.h"
# define SPHERE_CLASS GBPolySphere
# define SPHERE_CREATE GBPolySphere_create
# define SPHERE_DESTROY GBPolySphere_destroy
# define SPHERE_SETDISPLAY GBPolySphere_setDisplay
# define SPHERE_UPDATE GBPolySphere_update
# define SPHERE_DRAW GBPolySphere_draw
#else
# include "gbRaySphere.h"
# define SPHERE_CLASS GBRaySphere
# define SPHERE_CREATE GBRaySphere_create
# define SPHERE_DESTROY GBRaySphere_destroy
# define SPHERE_SETDISPLAY GBRaySphere_setDisplay
# define SPHERE_UPDATE GBRaySphere_update
# define SPHERE_DRAW GBRaySphere_draw
#endif
#include <stdlib.h>
#include <math.h>
#include <string.h>
//--------------------------------------------------------------------------//
// Filenames
//--------------------------------------------------------------------------//
const char* const GB_COUNTRY_DATA_FILENAME = "country.dat";
const char* const GB_TIMEZONE_DATA_FILENAME = "timezone.dat";
const char* const GB_COUNTRY_LIST_FILENAME = "country.txt";
const char* const GB_TIMEZONE_LIST_FILENAME = "timezone.txt";
#ifdef POLYGON_GLOBE
//const char* const GB_TEXTURE_FILENAME = "earth1024poly.gtx";
const char* const GB_TEXTURE_FILENAME = "earth2048poly.gtx";
#else
//const char* const GB_TEXTURE_FILENAME = "earth1024.gtx";
const char* const GB_TEXTURE_FILENAME = "earth2048.gtx";
#endif
const char* const GB_CITIES_FILENAME = "cities.txt";
const char* const GB_CITYDOT_FILENAME = "citydot.tga";
const char* const GB_CROSS_FILENAME = "cross.tga";
//--------------------------------------------------------------------------//
// Some static data sizes
//--------------------------------------------------------------------------//
#define GB_STRING_LENGTH 256
#define GB_MAX_COUNTRIES 300
#define GB_MAX_TIMEZONES 50
//--------------------------------------------------------------------------//
// Limit for the internal memory pool
//--------------------------------------------------------------------------//
//const GBuint32 GB_MEMORY_LIMIT = 360 * 1024;
const GBuint32 GB_MEMORY_LIMIT = 2 * 1024 * 1024;
//--------------------------------------------------------------------------//
// City struct
//--------------------------------------------------------------------------//
typedef struct GBCity_s
{
float x;
float y;
char* name;
GBint32 sx;
GBint32 sy;
} GBCity;
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
struct GBGlobe_s
{
char* dataPath;
char* countryListFileName;
char* cityListFileName;
GBDisplayParams displayParams;
GBMemory* mem;
GBint32 pointer[2];
GBuint32 currentTime;
GBfloat coords[2];
GBfloat distance;
GBint32 cameraZ;
GBfloat finalMatrixF[9];
GBuint16* countryData;
GBuint16 countryDataHeight;
GBuint16* timezoneData;
GBuint16 timezoneDataHeight;
char countryStr[GB_STRING_LENGTH];
char timezoneStr[GB_STRING_LENGTH];
char* countryList[GB_MAX_COUNTRIES];
GBuint32 countryCount;
char* timezoneList[GB_MAX_TIMEZONES];
GBuint32 timezoneCount;
GBCity* cities;
GBuint32 cityCount;
GBBitmap* cityDotBitmap;
GBBitmap* crossBitmap;
GBFontInterface* fontInterface;
void* fontContext;
GBRectList* rectList;
SPHERE_CLASS* sphere;
};
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
static GBbool GBGlobe_init (GBGlobe* globe);
static GBbool GBGlobe_renderCities (GBGlobe* globe);
static GBuint32 GBGlobe_loadStrings (GBGlobe* globe, const char* filename, GBuint32 max, char** out);
static GBbool GBGlobe_loadCities (GBGlobe* globe);
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBGlobe* GBGlobe_create (const char* dataPath,
const char* countryListFileName,
const char* cityListFileName)
{
GBGlobe* globe;
GB_ASSERT(dataPath);
globe = (GBGlobe*)malloc(sizeof(GBGlobe));
if (!globe)
return NULL;
globe->dataPath = gbStrDuplicate(dataPath);
if (!globe->dataPath)
{
free(globe);
return NULL;
}
if ( countryListFileName ) {
globe->countryListFileName = gbStrDuplicate( countryListFileName );
} else {
globe->countryListFileName = gbStrDuplicate( GB_COUNTRY_LIST_FILENAME );
}
if ( !globe->countryListFileName ) {
free(globe);
return NULL;
}
if ( cityListFileName ) {
globe->cityListFileName = gbStrDuplicate( cityListFileName );
} else {
globe->cityListFileName = gbStrDuplicate( GB_CITIES_FILENAME );
}
if ( !globe->cityListFileName ) {
free(globe);
return NULL;
}
GBDisplayParams_init(&globe->displayParams);
globe->mem = NULL;
globe->pointer[0] = 0;
globe->pointer[1] = 0;
globe->currentTime = 0;
globe->coords[0] = 0.0f;
globe->coords[1] = 0.0f;
globe->distance = 0.0f;
globe->cameraZ = 0;
globe->countryData = NULL;
globe->countryDataHeight = 0;
globe->timezoneData = NULL;
globe->timezoneDataHeight = 0;
memset(globe->countryStr, 0, GB_STRING_LENGTH);
memset(globe->timezoneStr, 0, GB_STRING_LENGTH);
memset(globe->countryList, 0, sizeof(char*) * GB_MAX_COUNTRIES);
globe->countryCount = 0;
memset(globe->timezoneList, 0, sizeof(char*) * GB_MAX_TIMEZONES);
globe->timezoneCount = 0;
globe->cities = NULL;
globe->cityCount = 0;
globe->cityDotBitmap = NULL;
globe->crossBitmap = NULL;
globe->fontInterface = NULL;
globe->fontContext = NULL;
globe->rectList = NULL;
globe->sphere = NULL;
if (!GBGlobe_init(globe))
{
GBGlobe_destroy(globe);
return NULL;
}
return globe;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_init (GBGlobe* globe)
{
GB_ASSERT(globe);
if (!gbLoadRLE(globe->dataPath, GB_COUNTRY_DATA_FILENAME, &globe->countryDataHeight, &globe->countryData))
return GB_FALSE;
if (!gbLoadRLE(globe->dataPath, GB_TIMEZONE_DATA_FILENAME, &globe->timezoneDataHeight, &globe->timezoneData))
return GB_FALSE;
globe->countryCount = GBGlobe_loadStrings(globe, globe->countryListFileName, GB_MAX_COUNTRIES, globe->countryList);
globe->timezoneCount = GBGlobe_loadStrings(globe, GB_TIMEZONE_LIST_FILENAME, GB_MAX_TIMEZONES, globe->timezoneList);
globe->mem = GBMemory_create(GB_MEMORY_LIMIT);
if (!globe->mem)
return GB_FALSE;
{
char full[256];
gbStrCopy(full, globe->dataPath);
strcat(full, GB_TEXTURE_FILENAME);
globe->sphere = SPHERE_CREATE(full, globe->mem);
if (!globe->sphere)
return GB_FALSE;
}
GBGlobe_loadCities(globe);
globe->cityDotBitmap = GBBitmap_createFromTga(globe->dataPath, GB_CITYDOT_FILENAME, globe->mem);
if (!globe->cityDotBitmap)
return GB_FALSE;
globe->crossBitmap = GBBitmap_createFromTga(globe->dataPath, GB_CROSS_FILENAME, globe->mem);
if (!globe->crossBitmap)
return GB_FALSE;
return GB_TRUE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_destroy (GBGlobe* globe)
{
GBuint32 i;
GB_ASSERT(globe);
gbClearRectList(&globe->rectList);
if (globe->crossBitmap)
GBBitmap_destroy(globe->crossBitmap, globe->mem);
if (globe->cityDotBitmap)
GBBitmap_destroy(globe->cityDotBitmap, globe->mem);
for (i = 0; i < globe->cityCount; i++)
free(globe->cities[i].name);
if (globe->mem && globe->cities)
GBMemory_free(globe->mem, globe->cities);
SPHERE_DESTROY(globe->sphere);
if (globe->mem)
GBMemory_destroy(globe->mem);
for (i = 0; i < globe->timezoneCount; i++)
free(globe->timezoneList[i]);
for (i = 0; i < globe->countryCount; i++)
free(globe->countryList[i]);
free(globe->timezoneData);
free(globe->countryData);
free(globe->dataPath);
free(globe->countryListFileName);
free(globe->cityListFileName);
free(globe);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_setDisplay (GBGlobe* globe, GBDisplayParams* displayParams)
{
GB_ASSERT(globe && displayParams);
globe->displayParams = *displayParams;
return SPHERE_SETDISPLAY(globe->sphere, displayParams);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_setFont (GBGlobe* globe, GBFontInterface* fontInterface, void* fontContext)
{
GB_ASSERT(globe && fontInterface);
globe->fontInterface = fontInterface;
globe->fontContext = fontContext;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_update (GBGlobe* globe, const GBvec2 coords,
GBfloat distance, const GBivec2 pointer)
{
GBfloat rotationMatrixF[9];
GB_ASSERT(globe);
globe->coords[0] = coords[0];
globe->coords[1] = coords[1];
gbFMatrixRotationX(-globe->coords[1], rotationMatrixF);
gbFMatrixRotationY(-globe->coords[0], globe->finalMatrixF);
gbFMatrixMultiply(globe->finalMatrixF, rotationMatrixF, globe->finalMatrixF);
globe->distance = distance;
globe->cameraZ = gbDistanceToCameraZ(globe->distance);
globe->pointer[0] = pointer[0];
globe->pointer[1] = pointer[1];
SPHERE_UPDATE(globe->sphere, coords, distance);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_render (GBGlobe* globe)
{
GB_ASSERT(globe);
if (!SPHERE_DRAW(globe->sphere))
return GB_FALSE;
if (globe->distance <= 0.75f)
if (!GBGlobe_renderCities(globe))
return GB_FALSE;
GBBitmap_draw(globe->crossBitmap, globe->pointer[0] - (16 >> 1),
globe->pointer[1] - (16 >> 1), 256, &globe->displayParams);
return GB_TRUE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
#define sinf(v) ((GBfloat)sin(v))
#define cosf(v) ((GBfloat)cos(v))
GBbool GBGlobe_renderCities (GBGlobe* globe)
{
GBuint32 i;
GB_ASSERT(globe);
for (i = 0; i < globe->cityCount; i++)
{
GBCity* city = &globe->cities[i];
GBfloat pos[3];
GBfloat xa = -((city->x - globe->coords[0]) * GB_PI) / 180.0f;
GBfloat ya = (city->y * GB_PI) / 180.0f;
GBfloat xrot = (-globe->coords[1] * GB_PI) / 180.0f;
GBfloat t[2];
const GBfloat zclip = 0.25f;
pos[0] = sinf(xa) * cosf(ya);
pos[1] = sinf(ya);
pos[2] = cosf(xa) * cosf(ya);
t[0] = cosf(xrot) * pos[1] + sinf(xrot) * pos[2];
t[1] = cosf(xrot) * pos[2] - sinf(xrot) * pos[1];
pos[1] = t[0];
pos[2] = t[1];
if (pos[2] > zclip)
{
#ifdef POLYGON_GLOBE
GBint32 mul = 256;
#else
GBint32 mul = (GBint32)(((pos[2] - zclip) / (1.0f - zclip)) * 255.0f);
#endif
pos[2] = pos[2] - (GBfloat)globe->cameraZ / 256.0f;
city->sx = (GBint32)((pos[0] * (GBfloat)globe->displayParams.height * GB_FOV_CONSTANT) / pos[2] + (GBfloat)globe->displayParams.width / 2.0f);
city->sy = (GBint32)((pos[1] * (GBfloat)globe->displayParams.height * GB_FOV_CONSTANT) / pos[2] + (GBfloat)globe->displayParams.height / 2.0f);
GBBitmap_draw(globe->cityDotBitmap, city->sx - (10 >> 1), city->sy - (10 >> 1), mul, &globe->displayParams);
}
else
{
city->sx = GB_INT32_MAX;
city->sy = GB_INT32_MAX;
}
}
return GB_TRUE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_renderTexts (GBGlobe* globe)
{
GBuint32 i;
GB_ASSERT(globe);
if (globe->distance > 0.75f)
return GB_TRUE;
if (!globe->fontInterface)
return GB_FALSE;
gbClearRectList(&globe->rectList);
for (i = 0; i < globe->cityCount; i++)
{
GBbool draw = GB_FALSE;
GBint32 width;
GBint32 height;
GBint32 x1;
GBint32 y1;
GBint32 x2;
GBint32 y2;
GBCity* city = &globe->cities[i];
if (city->sx == GB_INT32_MAX && city->sy == GB_INT32_MAX)
continue;
width = (GBint32)globe->fontInterface->getWidth(globe->fontContext, city->name);
height = (GBint32)globe->fontInterface->getHeight(globe->fontContext) - 4;
x1 = city->sx;
y1 = city->sy;
x2 = city->sx + width;
y2 = city->sy + height;
if (!gbCheckOverlap(globe->rectList, x1, y1, x2, y2))
if (gbAddRect(&globe->rectList, x1, y1, x2, y2))
draw = GB_TRUE;
if (!draw)
{
y1 -= height;
y2 -= height;
if (!gbCheckOverlap(globe->rectList, x1, y1, x2, y2))
if (gbAddRect(&globe->rectList, x1, y1, x2, y2))
draw = GB_TRUE;
}
if (draw)
{
GBFontParams params;
GBTextRect pos;
pos.x = x1;
pos.y = y1 - 2;
pos.left = globe->displayParams.x;
pos.top = globe->displayParams.y;
pos.right = globe->displayParams.x + globe->displayParams.width;
pos.bottom = globe->displayParams.y + globe->displayParams.height;
GBFontParams_init(¶ms);
params.color = 0x00ffffff;
globe->fontInterface->setParams(globe->fontContext, ¶ms);
globe->fontInterface->render(globe->fontContext, city->name, &pos);
}
}
return GB_TRUE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_worldToTexCoord (GBGlobe* globe, const GBfloat* coords, GBuint32 width, GBuint32 height, GBuint16* tex)
{
GB_ASSERT(globe && coords && tex);
tex[0] = (GBuint16)((GBint32)(coords[0] * width / 360.0f + width / 2.0f) & (width - 1));
tex[1] = (GBuint16)((GBint32)((90.0f + coords[1]) * height / 180.0f) & (height - 1));
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
const char* GBGlobe_lookupCountry (GBGlobe* globe, const GBvec2 coords)
{
GBuint16 tex[2];
GBbool countryFocused = GB_FALSE;
GB_ASSERT(globe);
GBGlobe_worldToTexCoord(globe, coords, 1024, 512, tex);
tex[0] = (tex[0] + 1) & 1023;
{
GBuint16 v = gbReadFromRLE(tex[0], tex[1], globe->countryData);
if (v < globe->countryCount)
{
countryFocused = GB_TRUE;
gbStrCopy(globe->countryStr, globe->countryList[v]);
}
}
if (!countryFocused)
gbStrCopy(globe->countryStr, "");
return globe->countryStr;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
const char* GBGlobe_lookupTimezone (GBGlobe* globe, const GBvec2 coords)
{
GBuint16 tex[2];
GBbool timezoneFocused = GB_FALSE;
GB_ASSERT(globe);
GBGlobe_worldToTexCoord(globe, coords, 1024, 512, tex);
{
GBuint16 v = gbReadFromRLE(511 - tex[1], tex[0], globe->timezoneData);
if (v < globe->timezoneCount)
{
timezoneFocused = GB_TRUE;
gbStrCopy(globe->timezoneStr, globe->timezoneList[v]);
}
}
if (!timezoneFocused)
gbStrCopy(globe->timezoneStr, "");
return globe->timezoneStr;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_lookupCity (GBGlobe* globe, const GBvec2 coords, GBCityOut* out)
{
GBuint32 i;
GB_ASSERT(globe && coords);
for (i = 0; i < globe->cityCount; i++)
{
GBCity* city = &globe->cities[i];
if (gbFAbs(coords[0] - city->x) < 1.5f && gbFAbs(coords[1] - city->y) < 1.5f)
{
gbStrCopy(out->name, city->name);
out->coords[0] = city->x;
out->coords[1] = city->y;
return GB_TRUE;
}
}
return GB_FALSE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBuint32 GBGlobe_loadStrings (GBGlobe* globe, const char* filename, GBuint32 max, char** out)
{
FILE* f;
GBuint32 count = 0;
GBbool exit = 0;
GBuint32 fileEnd;
GB_ASSERT(globe && filename && out);
f = gbOpenFileFromPath(globe->dataPath, filename, "rb");
if (!f)
return 0;
fseek(f, 0, SEEK_END);
fileEnd = ftell(f);
fseek(f, 0, SEEK_SET);
while (!exit)
{
char buf[256];
GBuint32 i = 0;
buf[0] = 0;
for (;;)
{
fread(buf + i, 1, 1, f);
if (buf[i] == '\n' || buf[i] == '\r' || (GBuint32)ftell(f) == fileEnd)
break;
i++;
}
buf[i] = 0;
out[count] = gbStrDuplicate(buf);
if (!out[count])
exit = 1;
else
count++;
if (count == max || (GBuint32)ftell(f) == fileEnd)
exit = 1;
}
fclose(f);
return count;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_loadCities (GBGlobe* globe)
{
FILE* f;
GBuint32 i;
GBbool stop = GB_FALSE;
GB_ASSERT(globe);
GB_ASSERT(globe->cityCount == 0 && !globe->cities);
f = gbOpenFileFromPath(globe->dataPath, globe->cityListFileName, "rb");
if (!f)
return GB_FALSE;
while (!stop)
{
char buf[256];
gbSkipChars(f, "\n\r");
gbReadWord(f, buf, "\n\r");
if (buf[0] == 0)
break;
globe->cityCount++;
}
fseek(f, 0, SEEK_SET);
globe->cities = (GBCity*)GBMemory_alloc(globe->mem, sizeof(GBCity) * globe->cityCount);
if (!globe->cities)
{
fclose(f);
return GB_FALSE;
}
for (i = 0; i < globe->cityCount; i++)
{
char buf[256];
gbSkipChars(f, "\n\r");
gbReadWord(f, buf, "\t\n\r");
if (buf[0] == 0)
GB_ASSERT(0);
globe->cities[i].y = (GBfloat)atof(buf);
gbReadWord(f, buf, "\t\n\r");
if (buf[0] == 0)
GB_ASSERT(0);
globe->cities[i].x = (GBfloat)atof(buf);
gbReadWord(f, buf, "\t\n\r");
if (buf[0] == 0)
GB_ASSERT(0);
globe->cities[i].name = gbStrDuplicate(buf);
globe->cities[i].sx = 0;
globe->cities[i].sy = 0;
}
fclose(f);
return GB_TRUE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_worldToScreen (GBGlobe* globe, GBfloat lat, GBfloat lon, GBfloat* out)
{
GBfloat pos[3];
GBfloat xa;
GBfloat ya;
GBfloat xrot;
GBfloat t[2];
const GBfloat zclip = 0.1f;
GB_ASSERT(globe && out);
xa = (globe->coords[0] - lat) * GB_PI / 180.0f;
ya = lon * GB_PI / 180.0f;
xrot = -globe->coords[1] * GB_PI / 180.0f;
pos[0] = sinf(xa) * cosf(ya);
pos[1] = sinf(ya);
pos[2] = cosf(xa) * cosf(ya);
t[0] = cosf(xrot) * pos[1] + sinf(xrot) * pos[2];
t[1] = cosf(xrot) * pos[2] - sinf(xrot) * pos[1];
pos[1] = t[0];
pos[2] = t[1];
if (pos[2] < zclip)
{
GBfloat len;
pos[2] = zclip;
len = (GBfloat)sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
pos[0] /= len;
pos[1] /= len;
}
pos[2] = pos[2] - (GBfloat)globe->cameraZ / 256.0f;
out[0] = (pos[0] * (GBfloat)globe->displayParams.height * GB_FOV_CONSTANT) / pos[2] + (GBfloat)globe->displayParams.width / 2.0f;
out[1] = (pos[1] * (GBfloat)globe->displayParams.height * GB_FOV_CONSTANT) / pos[2] + (GBfloat)globe->displayParams.height / 2.0f;
/* if (out[0] >= 0.0f && out[0] < globe->displayParams.width &&
out[1] >= 0.0f && out[1] < globe->displayParams.height)
{
GBuint32 x = (GBuint32)out[0];
GBuint32 y = (GBuint32)out[1];
((GBOutputFormat*)globe->displayParams.buffer)[(x + globe->displayParams.x) + (y + globe->displayParams.y) * globe->displayParams.bufferWidth] = 0xffffff;
}*/
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_screenToNormal (GBGlobe* globe, GBfloat x, GBfloat y, GBfloat* out)
{
GB_ASSERT(globe && out);
if (x < 0.0f)
x = 0.0f;
else if (x >= (float)globe->displayParams.width)
x = (float)globe->displayParams.width - 1.0f;
if (y < 0.0f)
y = 0.0f;
else if (y >= (float)globe->displayParams.height)
y = (float)globe->displayParams.height - 1;
if (!gbCastRayF(x, y, globe->displayParams.width, globe->displayParams.height, globe->cameraZ, out))
{
out[0] = x * 2.0f - (GBfloat)globe->displayParams.width;
out[1] = y * 2.0f - (GBfloat)globe->displayParams.height;
out[2] = 1.5f / (((GBfloat)globe->cameraZ) / 256.0f) * ((GBfloat)globe->displayParams.height);
}
{
GBfloat len = (GBfloat)sqrt(out[0] * out[0] + out[1] * out[1] + out[2] * out[2]);
out[0] /= len;
out[1] /= len;
out[2] /= len;
}
gbFVec3Transform(out, globe->finalMatrixF, out);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_worldToScreenNormal (GBGlobe* globe, GBfloat lat, GBfloat lon, GBfloat* out)
{
GBfloat xa;
GBfloat ya;
GBfloat xrot;
GBfloat t[2];
const GBfloat zclip = 0.1f;
GB_ASSERT(globe && out);
xa = (globe->coords[0] - lat) * GB_PI / 180.0f;
ya = lon * GB_PI / 180.0f;
xrot = -globe->coords[1] * GB_PI / 180.0f;
out[0] = sinf(xa) * cosf(ya);
out[1] = sinf(ya);
out[2] = cosf(xa) * cosf(ya);
t[0] = cosf(xrot) * out[1] + sinf(xrot) * out[2];
t[1] = cosf(xrot) * out[2] - sinf(xrot) * out[1];
out[1] = t[0];
out[2] = t[1];
if (out[2] < zclip)
{
GBfloat len;
out[2] = zclip;
len = (GBfloat)sqrt(out[0] * out[0] + out[1] * out[1]);
out[0] /= len;
out[1] /= len;
}
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_worldToWorldNormal (GBGlobe* globe, GBfloat lon, GBfloat lat, GBfloat* out)
{
GBfloat xa;
GBfloat ya;
// GBfloat w[2];
GB_ASSERT(globe && out);
xa = lon * GB_PI / 180.0f;
ya = -lat * GB_PI / 180.0f;
out[0] = sinf(xa) * cosf(ya);
out[1] = sinf(ya);
out[2] = cosf(xa) * cosf(ya);
// printf("normal %f %f %f\n", out[0], out[1], out[2]);
// GBGlobe_normalToWorld(globe, out, w);
// printf("world %f %f\n", w[0], w[1]);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_normalToWorld (GBGlobe* globe, const GBfloat* normal, GBfloat* out)
{
GBfloat v;
GB_ASSERT(globe && normal && out);
out[0] = (GBfloat)atan2(normal[0], normal[2]) * 180.0f / GB_PI;
v = (GBfloat)acos(normal[1]) * 180.0f / GB_PI;
if (v < 0.0f)
v = -v;
out[1] = -(90.0f - v);
// some rounding
out[0] = ((GBfloat)((GBint32)(out[0] * 10.0f))) / 10.0f;
out[1] = ((GBfloat)((GBint32)(out[1] * 10.0f))) / 10.0f;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
void GBGlobe_screenToWorld (GBGlobe* globe, GBfloat x, GBfloat y, GBfloat* out)
{
GBfloat n[3];
GB_ASSERT(globe && out);
GBGlobe_screenToNormal(globe, x, y, n);
GBGlobe_normalToWorld(globe, n, out);
// GBGlobe_worldToWorldNormal(globe, out[0], out[1], n);
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
GBbool GBGlobe_isPointInside (GBGlobe* globe, GBfloat x, GBfloat y)
{
GB_ASSERT(globe);
if (x < 0.0f)
x = 0.0f;
else if (x >= (float)globe->displayParams.width)
x = (float)globe->displayParams.width - 1.0f;
if (y < 0.0f)
y = 0.0f;
else if (y >= (float)globe->displayParams.height)
y = (float)globe->displayParams.height - 1;
if (gbCastRayF(x, y, globe->displayParams.width, globe->displayParams.height, globe->cameraZ, NULL))
return GB_TRUE;
else
return GB_FALSE;
}
//--------------------------------------------------------------------------//
//
//--------------------------------------------------------------------------//
| 27.843035
| 756
| 0.532612
|
wayfinder
|
897d147d0850d676513a5ba5caea01cb3371d90d
| 2,007
|
cpp
|
C++
|
DiscoveryService.cpp
|
jambamamba/DiscoveryService
|
0eae060bb9ac43ee91ca7c5596862588d130a4f6
|
[
"Apache-2.0"
] | null | null | null |
DiscoveryService.cpp
|
jambamamba/DiscoveryService
|
0eae060bb9ac43ee91ca7c5596862588d130a4f6
|
[
"Apache-2.0"
] | null | null | null |
DiscoveryService.cpp
|
jambamamba/DiscoveryService
|
0eae060bb9ac43ee91ca7c5596862588d130a4f6
|
[
"Apache-2.0"
] | null | null | null |
#include "DiscoveryService.h"
#include <arpa/inet.h>
#include <iostream>
#include <netinet/in.h>
#include <regex>
#include <string>
#include <sys/socket.h>
#include <sys/stat.h>
#include "Utils.h"
namespace {
}//namespace
//-------------------------------------------------------------------------------
DiscoveryService::DiscoveryService(const std::string &device_id_file)
: m_udp_socket(SERVER_PORT,
sizeof(DiscoveryData),
MAX_QUEUE_SIZE,
"DiscoveryService",
false,
[this](const uint8_t *dataFromClient, size_t dataLen, const sockaddr_in &sa){
HandleUdpDatagram(dataFromClient, dataLen, sa);
})
{
Utils::ReadDeviceId(m_discover_message, device_id_file);
std::cout << "Device Name: " << m_discover_message.m_name << ", Device Serial Number: " << m_discover_message.m_serial_number << "\n";
}
//-------------------------------------------------------------------------------
DiscoveryService::~DiscoveryService()
{
m_udp_socket.Stop();
std::cout << "dtor\n";
}
void DiscoveryService::UpdateDeviceId(const std::string &device_id_file)
{
Utils::ReadDeviceId(m_discover_message, device_id_file);
}
//-------------------------------------------------------------------------------
void DiscoveryService::HandleUdpDatagram(const uint8_t *dataFromClient, size_t dataLen, const sockaddr_in &sa)
{
auto msg = reinterpret_cast<const DiscoveryData*>(dataFromClient);
// std::cout << "Received discovery datagram from " <<
// inet_ntoa(sa.sin_addr) << ":" << ntohs(sa.sin_port) << "\n";
if(msg->m_version != DiscoveryData::DISCOVERY_VERSION)
{
std::cout << "Failed: Incompatible Discovery message received\n";
return;
}
Utils::SaveServerIpAddress(inet_ntoa(sa.sin_addr));
m_udp_socket.SendToClient(sa, reinterpret_cast<char*>(&m_discover_message));
}
| 35.839286
| 139
| 0.567015
|
jambamamba
|
897d896ac45b96e0c76ab0c732c90bfafc71e0c0
| 2,054
|
cpp
|
C++
|
Engine/Plugins/Tests/EditorTests/Source/EditorTests/Private/UnrealEd/EditorOpenAssetAutomationTests.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | 1
|
2022-01-29T18:36:12.000Z
|
2022-01-29T18:36:12.000Z
|
Engine/Plugins/Tests/EditorTests/Source/EditorTests/Private/UnrealEd/EditorOpenAssetAutomationTests.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
Engine/Plugins/Tests/EditorTests/Source/EditorTests/Private/UnrealEd/EditorOpenAssetAutomationTests.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Misc/Paths.h"
#include "Misc/AutomationTest.h"
#include "Misc/App.h"
#include "UObject/Object.h"
#include "Tests/AutomationTestSettings.h"
#include "Tests/AutomationEditorCommon.h"
#include "Tests/AutomationCommon.h"
#include "Toolkits/AssetEditorManager.h"
/**
* Test to open the sub editor windows for a specified list of assets.
* This list can be setup in the Editor Preferences window within the editor or the DefaultEngine.ini file for that particular project.
*/
IMPLEMENT_COMPLEX_AUTOMATION_TEST(FOpenAssetEditors, "Project.Editor.Open Assets", EAutomationTestFlags::EditorContext | EAutomationTestFlags::ProductFilter);
void FOpenAssetEditors::GetTests(TArray<FString>& OutBeautifiedNames, TArray<FString>& OutTestCommands) const
{
const UAutomationTestSettings* AutomationTestSettings = GetDefault<UAutomationTestSettings>();
for ( FSoftObjectPath AssetRef : AutomationTestSettings->AssetsToOpen )
{
OutBeautifiedNames.Add(AssetRef.GetAssetName());
OutTestCommands.Add(AssetRef.GetLongPackageName());
}
}
bool FOpenAssetEditors::RunTest(const FString& LongAssetPath)
{
//start with all editors closed
FAssetEditorManager::Get().CloseAllAssetEditors();
// below is all latent action, so before sending there, verify the asset exists
UObject* Object = FSoftObjectPath(LongAssetPath).TryLoad();
if ( Object == nullptr )
{
UE_LOG(LogEditorAutomationTests, Error, TEXT("Failed to Open Asset '%s'."), *LongAssetPath);
return false;
}
AddCommand(new FOpenEditorForAssetCommand(LongAssetPath));
AddCommand(new FWaitLatentCommand(0.5f));
AddCommand(new FDelayedFunctionLatentCommand([=] {
if ( Object->GetOutermost()->IsDirty() )
{
UE_LOG(LogEditorAutomationTests, Error, TEXT("Asset '%s' was dirty after opening it."), *LongAssetPath);
}
}));
AddCommand(new FCloseAllAssetEditorsCommand());
AddCommand(new FDelayedFunctionLatentCommand([=] {
CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS);
}));
return true;
}
| 35.413793
| 158
| 0.777507
|
windystrife
|
897effcc6d0ab478ccc799fb07f40f44c35f68e9
| 769
|
cpp
|
C++
|
ECOO/ECOO_21_P4_Chris_Candy.cpp
|
Togohogo1/pg
|
ee3c36acde47769c66ee13a227762ee677591375
|
[
"MIT"
] | null | null | null |
ECOO/ECOO_21_P4_Chris_Candy.cpp
|
Togohogo1/pg
|
ee3c36acde47769c66ee13a227762ee677591375
|
[
"MIT"
] | 1
|
2021-10-14T18:26:56.000Z
|
2021-10-14T18:26:56.000Z
|
ECOO/ECOO_21_P4_Chris_Candy.cpp
|
Togohogo1/pg
|
ee3c36acde47769c66ee13a227762ee677591375
|
[
"MIT"
] | 1
|
2021-08-06T03:39:55.000Z
|
2021-08-06T03:39:55.000Z
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll K, cnt, sqrtK;
vector<ll> nums;
void fetch(ll x) {
cnt++;
for (ll i = 0; i < x; i++) {
nums.push_back(cnt);
if (nums.size() > 1e5) {
return;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> K;
K++;
sqrtK = sqrt(K) + 1;
for (ll i = 2; i <= sqrtK; i++) {
while (K % i == 0) {
fetch(i-1);
K /= i;
}
}
if (K > 2)
fetch(K-1);
if (nums.size() > 1e5) {
cout << "Sad Chris\n";
} else {
cout << nums.size() << '\n';
for (ll i : nums) {
cout << i << ' ';
}
cout << '\n';
}
}
| 14.509434
| 37
| 0.383615
|
Togohogo1
|
89869fe4cb06b29a57c1a2e7077528ea2a55a90d
| 12,463
|
cpp
|
C++
|
test/OpenDDLIntegrationTest.cpp
|
lerppana/openddl-parser
|
a9bc8a5dee880d546136e33a5977d7a0a28eaa20
|
[
"MIT"
] | 24
|
2015-02-08T23:16:05.000Z
|
2021-07-15T07:31:08.000Z
|
test/OpenDDLIntegrationTest.cpp
|
lerppana/openddl-parser
|
a9bc8a5dee880d546136e33a5977d7a0a28eaa20
|
[
"MIT"
] | 64
|
2015-01-28T21:42:06.000Z
|
2021-11-01T07:49:24.000Z
|
test/OpenDDLIntegrationTest.cpp
|
lerppana/openddl-parser
|
a9bc8a5dee880d546136e33a5977d7a0a28eaa20
|
[
"MIT"
] | 10
|
2015-11-17T09:18:57.000Z
|
2021-10-06T18:59:05.000Z
|
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)
Copyright (c) 2014-2020 Kim Kulling
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 "gtest/gtest.h"
#include <openddlparser/OpenDDLParser.h>
#include "UnitTestCommon.h"
#include <vector>
BEGIN_ODDLPARSER_NS
class OpenDDLIntegrationTest : public testing::Test {
// empty
};
TEST_F( OpenDDLIntegrationTest, parseMetricTest ) {
char token[] = "Metric( key = \"distance\" ) { float{ 1 } }\n"
"Metric( key = \"up\" ) { float{ 1 } }\n";
bool result( false );
OpenDDLParser theParser;
theParser.setBuffer( token, strlen( token ) );
result = theParser.parse();
EXPECT_TRUE( result );
DDLNode *myNode = theParser.getRoot();
ASSERT_FALSE(nullptr == myNode);
Context *ctx = theParser.getContext();
ASSERT_FALSE(nullptr == ctx);
DDLNode::DllNodeList myList = myNode->getChildNodeList();
ASSERT_EQ( 2U, myList.size() );
DDLNode *child = myList[ 0 ];
ASSERT_FALSE(nullptr == child);
EXPECT_EQ( "Metric", child->getType() );
Property *prop = child->getProperties();
ASSERT_FALSE(nullptr == prop);
const char *data1 = ( const char * ) prop->m_value->m_data;
int res( ::strncmp( "distance", data1, strlen( "distance" ) ) );
EXPECT_EQ(Value::ValueType::ddl_string, prop->m_value->m_type);
EXPECT_EQ( 0, res );
child = myList[ 1 ];
ASSERT_FALSE(nullptr == child);
EXPECT_EQ( "Metric", child->getType() );
prop = child->getProperties();
const char *data2 = ( const char * ) prop->m_value->m_data;
res = ::strncmp( "up", data2, strlen( "up" ) );
EXPECT_EQ(Value::ValueType::ddl_string, prop->m_value->m_type);
EXPECT_EQ( 0, res );
}
TEST_F( OpenDDLIntegrationTest, parseEmbeddedStructureTest ) {
char token[] =
"GeometryNode $node1\n"
"{\n"
" string\n"
" {\n"
" \"test\"\n"
" }\n"
"}";
bool result( false );
OpenDDLParser theParser;
theParser.setBuffer( token, strlen( token ) );
result = theParser.parse();
EXPECT_TRUE( result );
DDLNode *root( theParser.getRoot() );
ASSERT_FALSE(nullptr == root);
}
TEST_F( OpenDDLIntegrationTest, parseEmbeddedStructureWithRefTest ) {
char token[] =
"GeometryNode $node1\n"
"{\n"
" Name{ string{ \"Box001\" } }\n"
" ObjectRef{ ref{ $geometry1 } }\n"
" MaterialRef{ ref{ $material1 } }\n"
"}";
bool result( false );
OpenDDLParser theParser;
theParser.setBuffer( token, strlen( token ) );
result = theParser.parse();
EXPECT_TRUE( result );
DDLNode *root( theParser.getRoot() );
ASSERT_FALSE(nullptr == root);
DDLNode::DllNodeList childs = root->getChildNodeList();
ASSERT_EQ( 1U, childs.size() );
DDLNode::DllNodeList childChilds = childs[ 0 ]->getChildNodeList();
ASSERT_EQ( 3U, childChilds.size() );
DDLNode *currentNode = nullptr;
currentNode = childChilds[ 0 ];
EXPECT_EQ( "Name", currentNode->getType() );
currentNode = childChilds[ 1 ];
EXPECT_EQ( "ObjectRef", currentNode->getType() );
currentNode = childChilds[ 2 ];
EXPECT_EQ( "MaterialRef", currentNode->getType() );
}
static void dataArrayList2StdVector( DataArrayList *dataArrayList, std::vector<float> &container ) {
if (nullptr == dataArrayList) {
return;
}
Value *val( dataArrayList->m_dataList );
if (nullptr == val) {
return;
}
while (nullptr != val) {
container.push_back( val->getFloat() );
val = val->m_next;
}
}
TEST_F( OpenDDLIntegrationTest, parseTransformDataTest ) {
char token[] =
"Transform\n"
"{\n"
" float[ 16 ]\n"
" {\n"
" {0x3F800000, 0x00000000, 0x00000000, 0x00000000, // {1, 0, 0, 0\n"
" 0x00000000, 0x3F800000, 0x00000000, 0x00000000, // 0, 1, 0, 0\n"
" 0x00000000, 0x00000000, 0x3F800000, 0x00000000, // 0, 0, 1, 0\n"
" 0xBEF33B00, 0x411804DE, 0x00000000, 0x3F800000} // -0.47506, 9.50119, 0, 1}\n"
" }\n"
"}\n";
bool result( false );
OpenDDLParser theParser;
theParser.setBuffer( token, strlen( token ) );
result = theParser.parse();
EXPECT_TRUE( result );
DDLNode *root( theParser.getRoot() );
EXPECT_TRUE(nullptr != root);
const DDLNode::DllNodeList &childs( root->getChildNodeList() );
EXPECT_EQ( 1U, childs.size() );
DDLNode *transform( childs[ 0 ] );
EXPECT_TRUE(nullptr != transform);
DataArrayList *transformData( transform->getDataArrayList() );
EXPECT_TRUE(nullptr != transformData);
EXPECT_EQ( 16U, transformData->m_numItems );
std::vector<float> container;
dataArrayList2StdVector( transformData, container );
EXPECT_FLOAT_EQ( 1.0f, container[ 0 ] );
EXPECT_FLOAT_EQ( 0.0f, container[ 1 ] );
EXPECT_FLOAT_EQ( 0.0f, container[ 2 ] );
EXPECT_FLOAT_EQ( 0.0f, container[ 3 ] );
}
TEST_F( OpenDDLIntegrationTest, exportDataTest ) {
char token [] =
"Metric( key = \"distance\" ) { float{ 1 } }\n"
"Metric( key = \"angle\" ) { float{ 1 } }\n"
"Metric( key = \"time\" ) { float{ 1 } }\n"
"Metric( key = \"up\" ) { string{ \"z\" } }\n"
"\n"
"GeometryNode $node1\n"
"{\n"
" Name{ string{ \"Box001\" } }\n"
" ObjectRef{ ref{ $geometry1 } }\n"
" MaterialRef{ ref{ $material1 } }\n"
"\n"
"Transform\n"
"{\n"
" float[ 16 ]\n"
" {\n"
" { 0x3F800000, 0x00000000, 0x00000000, 0x00000000, // {1, 0, 0, 0\n"
" 0x00000000, 0x3F800000, 0x00000000, 0x00000000, // 0, 1, 0, 0\n"
" 0x00000000, 0x00000000, 0x3F800000, 0x00000000, // 0, 0, 1, 0\n"
" 0xBEF33B00, 0x411804DE, 0x00000000, 0x3F800000 } // -0.47506, 9.50119, 0, 1}\n"
" }\n"
" }\n"
"}\n"
"\n"
"GeometryNode $node2\n"
"{\n"
" Name{ string{ \"Box002\" } }\n"
" ObjectRef{ ref{ $geometry1 } }\n"
" MaterialRef{ ref{ $material1 } }\n"
"\n"
" Transform\n"
" {\n"
" float[ 16 ]\n"
" {\n"
" { 0x3F800000, 0x00000000, 0x00000000, 0x00000000, // {1, 0, 0, 0\n"
" 0x00000000, 0x3F800000, 0x00000000, 0x00000000, // 0, 1, 0, 0\n"
" 0x00000000, 0x00000000, 0x3F800000, 0x00000000, // 0, 0, 1, 0\n"
" 0x43041438, 0x411804DE, 0x00000000, 0x3F800000 } // 132.079, 9.50119, 0, 1}\n"
" }\n"
" }\n"
"}\n"
"\n"
"GeometryObject $geometry1 // Box001, Box002\n"
"{ \n"
" Mesh( primitive = \"triangles\" )\n"
" {\n"
" VertexArray( attrib = \"position\" )\n"
" {\n"
" float[ 3 ] // 24\n"
" { \n"
" { 0xC2501375, 0xC24C468A, 0x00000000 },{ 0xC2501375, 0x424C468A, 0x00000000 },{ 0x42501375, 0x424C468A, 0x00000000 },{ 0x42501375, 0xC24C468A, 0x00000000 },{ 0xC2501375, 0xC24C468A, 0x42BA3928 },{ 0x42501375, 0xC24C468A, 0x42BA3928 },{ 0x42501375, 0x424C468A, 0x42BA3928 },{ 0xC2501375, 0x424C468A, 0x42BA3928 }, \n"
" { 0xC2501375, 0xC24C468A, 0x00000000 },{ 0x42501375, 0xC24C468A, 0x00000000 },{ 0x42501375, 0xC24C468A, 0x42BA3928 },{ 0xC2501375, 0xC24C468A, 0x42BA3928 },{ 0x42501375, 0xC24C468A, 0x00000000 },{ 0x42501375, 0x424C468A, 0x00000000 },{ 0x42501375, 0x424C468A, 0x42BA3928 },{ 0x42501375, 0xC24C468A, 0x42BA3928 }, \n"
" { 0x42501375, 0x424C468A, 0x00000000 },{ 0xC2501375, 0x424C468A, 0x00000000 },{ 0xC2501375, 0x424C468A, 0x42BA3928 },{ 0x42501375, 0x424C468A, 0x42BA3928 },{ 0xC2501375, 0x424C468A, 0x00000000 },{ 0xC2501375, 0xC24C468A, 0x00000000 },{ 0xC2501375, 0xC24C468A, 0x42BA3928 },{ 0xC2501375, 0x424C468A, 0x42BA3928 }\n"
" }\n"
" }\n"
"\n"
" VertexArray( attrib = \"normal\" )\n"
" {\n"
" float[ 3 ] // 24\n"
" { \n"
" { 0x00000000, 0x00000000, 0xBF800000 },{ 0x00000000, 0x00000000, 0xBF800000 },{ 0x00000000, 0x00000000, 0xBF800000 },{ 0x00000000, 0x00000000, 0xBF800000 },{ 0x00000000, 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000, 0x3F800000 }, \n"
" { 0x00000000, 0xBF800000, 0x00000000 },{ 0x00000000, 0xBF800000, 0x00000000 },{ 0x00000000, 0xBF800000, 0x00000000 },{ 0x80000000, 0xBF800000, 0x00000000 },{ 0x3F800000, 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000, 0x00000000 }, \n"
" { 0x00000000, 0x3F800000, 0x00000000 },{ 0x00000000, 0x3F800000, 0x00000000 },{ 0x00000000, 0x3F800000, 0x00000000 },{ 0x80000000, 0x3F800000, 0x00000000 },{ 0xBF800000, 0x00000000, 0x00000000 },{ 0xBF800000, 0x00000000, 0x00000000 },{ 0xBF800000, 0x00000000, 0x00000000 },{ 0xBF800000, 0x00000000, 0x00000000 }\n"
" }\n"
" }\n"
"\n"
" VertexArray( attrib = \"texcoord\" )\n"
" {\n"
" float[ 2 ] // 24\n"
" { \n"
" { 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000 },{ 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 }, \n"
" { 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 }, \n"
" { 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 },{ 0x00000000, 0x00000000 },{ 0x3F800000, 0x00000000 },{ 0x3F800000, 0x3F800000 },{ 0x00000000, 0x3F800000 }\n"
" }\n"
" }\n"
"\n"
" IndexArray\n"
" {\n"
" unsigned_int32[ 3 ] // 12\n"
" { \n"
" { 0, 1, 2 },{ 2, 3, 0 },{ 4, 5, 6 },{ 6, 7, 4 },{ 8, 9, 10 },{ 10, 11, 8 },{ 12, 13, 14 },{ 14, 15, 12 },{ 16, 17, 18 },{ 18, 19, 16 },{ 20, 21, 22 },{ 22, 23, 20 }\n"
" }\n"
" }\n"
" }\n"
"}\n"
"\n"
"Material $material1\n"
"{\n"
" Name{ string{ \"03 - Default\" } }\n"
"\n"
" Color( attrib = \"diffuse\" ) { float[ 3 ]{ { 0.588235, 0.588235, 0.588235 } } }\n"
" Texture( attrib = \"diffuse\" )\n"
" {\n"
" string{ \"texture/Concrete.tga\" }\n"
" }\n"
"}\n";
bool result( false );
OpenDDLParser theParser;
theParser.setBuffer( token, strlen( token ) );
result = theParser.parse();
EXPECT_TRUE( result );
result = theParser.exportContext( theParser.getContext(), "" );
EXPECT_TRUE( result );
}
END_ODDLPARSER_NS
| 43.425087
| 340
| 0.569686
|
lerppana
|
8986eef35057cab8245c6d8823d2b202f636f0a1
| 1,126
|
cpp
|
C++
|
PhysicalLayer/Crc.cpp
|
roncato/PhysicalLayerSimulator
|
06570f402f2aef230ebf3cb36a4372c03c08e504
|
[
"BSD-3-Clause"
] | 1
|
2021-09-23T08:25:37.000Z
|
2021-09-23T08:25:37.000Z
|
PhysicalLayer/Crc.cpp
|
roncato/PhysicalLayerSimulator
|
06570f402f2aef230ebf3cb36a4372c03c08e504
|
[
"BSD-3-Clause"
] | null | null | null |
PhysicalLayer/Crc.cpp
|
roncato/PhysicalLayerSimulator
|
06570f402f2aef230ebf3cb36a4372c03c08e504
|
[
"BSD-3-Clause"
] | null | null | null |
#include "Crc.h"
Crc::Crc()
{
Initialize();
}
void Crc::Initialize(void)
{
uint16_T remainder;
/*
* Compute the remainder of each possible dividend.
*/
for (int dividend = 0; dividend < 256; ++dividend)
{
/*
* Start with the dividend followed by zeros.
*/
remainder = dividend << (WIDTH - 8);
/*
* Perform modulo-2 division, a bit at a time.
*/
for (uint8_T bit = 8; bit > 0; --bit)
{
/*
* Try to divide the current data bit.
*/
if (remainder & TOPBIT)
{
remainder = (remainder << 1) ^ POLYNOMIAL;
}
else
{
remainder = (remainder << 1);
}
}
/*
* Store the result into the table.
*/
_crcTable[dividend] = remainder;
}
}
uint16_T
Crc::Calculate(uint8_T const message[], int offset, int length)
{
uint8_T data;
uint16_T remainder = 0;
/*
* Divide the message by the polynomial, a byte at a time.
*/
for (int byte = 0; byte < length; ++byte)
{
data = message[offset + byte] ^ (remainder >> (WIDTH - 8));
remainder = _crcTable[data] ^ (remainder << 8);
}
/*
* The final remainder is the CRC.
*/
return (remainder);
} /* crcFast() */
| 16.558824
| 63
| 0.595027
|
roncato
|
898a9117b2f5593cd6a8e6350897187ab58b7a28
| 6,746
|
cpp
|
C++
|
ProjectEuler+/euler-0058.cpp
|
sarvekash/HackerRank_Solutions
|
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
|
[
"Apache-2.0"
] | null | null | null |
ProjectEuler+/euler-0058.cpp
|
sarvekash/HackerRank_Solutions
|
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
|
[
"Apache-2.0"
] | null | null | null |
ProjectEuler+/euler-0058.cpp
|
sarvekash/HackerRank_Solutions
|
8f48e5b1a6e792a85a10d8c328cd1f5341fb16a8
|
[
"Apache-2.0"
] | 1
|
2021-05-28T11:14:34.000Z
|
2021-05-28T11:14:34.000Z
|
// ////////////////////////////////////////////////////////
// # Title
// Spiral primes
//
// # URL
// https://projecteuler.net/problem=58
// http://euler.stephan-brumme.com/58/
//
// # Problem
// Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.
//
// ''__37__ 36 35 34 33 32 31''
// ''38 17 16 15 14 13 30''
// ''39 18 5 4 3 12 29''
// ''40 19 6 1 2 11 28''
// ''41 20 7 8 9 10 27''
// ''42 21 22 23 24 25 26''
// ''43 44 45 46 47 48 49''
//
// It is interesting to note that the odd squares lie along the bottom right diagonal, but what is more interesting is that
// 8 out of the 13 numbers lying along both diagonals are prime; that is, a ratio of `frac{8}{13} approx 62%`.
//
// If one complete new layer is wrapped around the spiral above, a square spiral with side length 9 will be formed.
// If this process is continued, what is the side length of the square spiral for which the ratio of primes along both diagonals first falls below 10%?
//
// # Solved by
// Stephan Brumme
// February 2017
//
// # Algorithm
// My solution consists almost entirely of "old code":
// - the Miller-Rabin primality test from problem 50 ...
// - which in turn requires modular arithmetic from problem 48
//
// That code can be found in my [toolbox](../toolbox/), too.
//
// # Hackerrank
// My portable ''mulmod'' was a little bit too slow for Hackerrank, therefore I added the "GCC"-Hack:
// the GCC-extension ''__int128'' simplifies ''mulmod'' to a one-line function (which is much faster, too).
#include <iostream>
// return (a*b) % modulo
unsigned long long mulmod(unsigned long long a, unsigned long long b, unsigned long long modulo)
{
#ifdef __GNUC__
// use GCC's optimized 128 bit code
return ((unsigned __int128)a * b) % modulo;
#endif
// (a * b) % modulo = (a % modulo) * (b % modulo) % modulo
a %= modulo;
b %= modulo;
// fast path
if (a <= 0xFFFFFFF && b <= 0xFFFFFFF)
return (a * b) % modulo;
// we might encounter overflows (slow path)
// the number of loops depends on b, therefore try to minimize b
if (b > a)
std::swap(a, b);
// bitwise multiplication
unsigned long long result = 0;
while (a > 0 && b > 0)
{
// b is odd ? a*b = a + a*(b-1)
if (b & 1)
{
result += a;
if (result >= modulo)
result -= modulo;
// skip b-- because the bit-shift at the end will remove the lowest bit anyway
}
// b is even ? a*b = (2*a)*(b/2)
a <<= 1;
if (a >= modulo)
a -= modulo;
// next bit
b >>= 1;
}
return result;
}
// return (base^exponent) % modulo
unsigned long long powmod(unsigned long long base, unsigned long long exponent, unsigned long long modulo)
{
unsigned long long result = 1;
while (exponent > 0)
{
// fast exponentation:
// odd exponent ? a^b = a*a^(b-1)
if (exponent & 1)
result = mulmod(result, base, modulo);
// even exponent ? a^b = (a*a)^(b/2)
base = mulmod(base, base, modulo);
exponent >>= 1;
}
return result;
}
// Miller-Rabin-test
bool isPrime(unsigned long long p)
{
// IMPORTANT: requires mulmod(a, b, modulo) and powmod(base, exponent, modulo)
// some code from https://ronzii.wordpress.com/2012/03/04/miller-rabin-primality-test/
// with optimizations from http://ceur-ws.org/Vol-1326/020-Forisek.pdf
// good bases can be found at http://miller-rabin.appspot.com/
// trivial cases
const unsigned int bitmaskPrimes2to31 = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 7) |
(1 << 11) | (1 << 13) | (1 << 17) | (1 << 19) |
(1 << 23) | (1 << 29); // = 0x208A28Ac
if (p < 31)
return (bitmaskPrimes2to31 & (1 << p)) != 0;
if (p % 2 == 0 || p % 3 == 0 || p % 5 == 0 || p % 7 == 0 || // divisible by a small prime
p % 11 == 0 || p % 13 == 0 || p % 17 == 0)
return false;
if (p < 17*19) // we filtered all composite numbers < 17*19, all others below 17*19 must be prime
return true;
// test p against those numbers ("witnesses")
// good bases can be found at http://miller-rabin.appspot.com/
const unsigned int STOP = 0;
const unsigned int TestAgainst1[] = { 377687, STOP };
const unsigned int TestAgainst2[] = { 31, 73, STOP };
const unsigned int TestAgainst3[] = { 2, 7, 61, STOP };
// first three sequences are good up to 2^32
const unsigned int TestAgainst4[] = { 2, 13, 23, 1662803, STOP };
const unsigned int TestAgainst7[] = { 2, 325, 9375, 28178, 450775, 9780504, 1795265022, STOP };
// good up to 2^64
const unsigned int* testAgainst = TestAgainst7;
// use less tests if feasible
if (p < 5329)
testAgainst = TestAgainst1;
else if (p < 9080191)
testAgainst = TestAgainst2;
else if (p < 4759123141ULL)
testAgainst = TestAgainst3;
else if (p < 1122004669633ULL)
testAgainst = TestAgainst4;
// find p - 1 = d * 2^j
auto d = p - 1;
d >>= 1;
unsigned int shift = 0;
while ((d & 1) == 0)
{
shift++;
d >>= 1;
}
// test p against all bases
do
{
auto x = powmod(*testAgainst++, d, p);
// is test^d % p == 1 or -1 ?
if (x == 1 || x == p - 1)
continue;
// now either prime or a strong pseudo-prime
// check test^(d*2^r) for 0 <= r < shift
bool maybePrime = false;
for (unsigned int r = 0; r < shift; r++)
{
// x = x^2 % p
// (initial x was test^d)
x = powmod(x, 2, p);
// x % p == 1 => not prime
if (x == 1)
return false;
// x % p == -1 => prime or an even stronger pseudo-prime
if (x == p - 1)
{
// next iteration
maybePrime = true;
break;
}
}
// not prime
if (!maybePrime)
return false;
} while (*testAgainst != STOP);
// prime
return true;
}
int main()
{
unsigned int percentage = 10;
std::cin >> percentage;
// the lower right diagonal contains only squares
unsigned long long numPrimes = 0;
unsigned long long sideLength = 1;
unsigned long long diagonals = 1;
do
{
sideLength += 2;
diagonals += 4;
unsigned long long lowerRight = sideLength * sideLength;
unsigned long long lowerLeft = lowerRight - (sideLength - 1);
unsigned long long upperLeft = lowerLeft - (sideLength - 1);
unsigned long long upperRight = upperLeft - (sideLength - 1);
// no need to test lowerRight since it's a square and never prime
if (isPrime(lowerLeft) != 0)
numPrimes++;
if (isPrime(upperLeft) != 0)
numPrimes++;
if (isPrime(upperRight) != 0)
numPrimes++;
} while (numPrimes * 100 / diagonals >= percentage);
std::cout << sideLength << std::endl;
return 0;
}
| 29.203463
| 151
| 0.589386
|
sarvekash
|
898b35ac17755bdec68108bcf95660ead020c425
| 499
|
cpp
|
C++
|
ch1/Babylonian_sqr/algorithm.cpp
|
omar659/Algorithms-Sequential-Parallel-Distributed
|
3543631139a20625f413cea2ba1f013f3a40d123
|
[
"MIT"
] | 2
|
2020-02-19T09:27:20.000Z
|
2020-02-19T09:28:21.000Z
|
ch1/Babylonian_sqr/algorithm.cpp
|
omar-3/Algorithms-Sequential-Parallel-Distributed
|
3543631139a20625f413cea2ba1f013f3a40d123
|
[
"MIT"
] | null | null | null |
ch1/Babylonian_sqr/algorithm.cpp
|
omar-3/Algorithms-Sequential-Parallel-Distributed
|
3543631139a20625f413cea2ba1f013f3a40d123
|
[
"MIT"
] | null | null | null |
/*
sqrt(a) * sqrt(a) = a
so sqrt(a) is the side of square with area a
and we keep two numbers as the side of a polygon with area a
and make them get closer together by averaging <3
*/
#include <iostream>
using namespace std;
typedef long double number; //you need to use double so the while condition would work
number square(number a, double error=0.0001) {
number x = a;
while (abs(x - a/x) > error) {
x = (x+(a/x))/2;
}
return x;
}
| 24.95
| 107
| 0.607214
|
omar659
|
89909eaa0da1334b197f4a98dac4e37d652b9dbe
| 6,066
|
cpp
|
C++
|
nohotspot-skiplist/skiplist.cpp
|
jyizheng/hydralist
|
910dad17eab4815057e3ea3e46b02f6ce45d7e46
|
[
"Apache-2.0"
] | 17
|
2020-11-25T17:45:21.000Z
|
2021-12-24T06:18:33.000Z
|
nohotspot-skiplist/skiplist.cpp
|
jyizheng/hydralist
|
910dad17eab4815057e3ea3e46b02f6ce45d7e46
|
[
"Apache-2.0"
] | null | null | null |
nohotspot-skiplist/skiplist.cpp
|
jyizheng/hydralist
|
910dad17eab4815057e3ea3e46b02f6ce45d7e46
|
[
"Apache-2.0"
] | 6
|
2020-11-20T17:21:46.000Z
|
2022-01-21T04:35:24.000Z
|
/*
* skiplist.c: definitions of the skip list data stucture
*
* Author: Ian Dick, 2013
*
*/
/*
Module overview
This module provides the basic structures used to create the
skip list data structure, as described in:
Crain, T., Gramoli, V., Raynal, M. (2013)
"No Hot-Spot Non-Blocking Skip List", to appear in
The 33rd IEEE International Conference on Distributed Computing
Systems (ICDCS).
One approach to designing a skip list data structure is to have
one kind of node, and to assign each node in the list a level.
A node with level l has l backwards pointers and l forward pointers,
one for each level of the skip list. Skip lists designed this
way have index level nodes that are implicit, are are handled by
multiple pointers per node.
The approach taken here is to explicitly create the index nodes and
have these as separate structures to regular nodes. The reason for
this is that the background maintenance method used here is much easier
to implement this way.
*/
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "skiplist.h"
#include "background.h"
#include "garbagecoll.h"
#include "ptst.h"
static int gc_id[NUM_LEVELS];
/* - Public skiplist interface - */
/**
* node_new - create a new bottom-level node
* @key: the key for the new node
* @val: the val for the new node
* @prev: the prev node pointer for the new node
* @next: the next node pointer for the new node
* @level: the level for the new node
* @ptst: the per-thread state
*
* Note: All nodes are originally created with
* marker set to 0 (i.e. they are unmarked).
*/
node_t* node_new(sl_key_t key, val_t val, node_t *prev, node_t *next,
unsigned int level, ptst_t *ptst)
{
node_t *node;
node = (node_t *)gc_alloc(ptst, gc_id[NODE_LEVEL]);
node->key = key;
node->val = val;
node->prev = prev;
node->next = next;
node->level = level;
node->marker = 0;
assert (node->next != node);
return node;
}
/**
* inode_new - create a new index node
* @right: the right inode pointer for the new inode
* @down: the down inode pointer for the new inode
* @node: the node pointer for the new inode
* @ptst: per-thread state
*/
inode_t* inode_new(inode_t *right, inode_t *down, node_t *node, ptst_t *ptst)
{
inode_t *inode;
inode = (inode_t *)gc_alloc(ptst, gc_id[INODE_LEVEL]);
inode->right = right;
inode->down = down;
inode->node = node;
return inode;
}
/**
* node_delete - delete a bottom-level node
* @node: the node to delete
*/
void node_delete(node_t *node, ptst_t *ptst)
{
gc_free(ptst, (void*)node, gc_id[NODE_LEVEL]);
}
/**
* inode_delete - delete an index node
* @inode: the index node to delete
*/
void inode_delete(inode_t *inode, ptst_t *ptst)
{
gc_free(ptst, (void*)inode, gc_id[INODE_LEVEL]);
}
/**
* set_new - create a new set implemented as a skip list
* @bg_start: if 1 start the bg thread, otherwise don't
*
* Returns a newly created skip list set.
* Note: A background thread to update the index levels of the
* skip list is created and kick-started as part of this routine.
*/
set_t* set_new(int start)
{
set_t *set;
set = (set_t *)malloc(sizeof(set_t));
if (!set) {
perror("Failed to malloc a set\n");
exit(1);
}
set->head = (node_t *)malloc(sizeof(node_t));
set->head->key = 0;
set->head->val = NULL;
set->head->prev = NULL;
set->head->next = NULL;
set->head->level = 1;
set->head->marker = 0;
set->top = (inode_t *)malloc(sizeof(inode_t));
set->top->right = NULL;
set->top->down = NULL;
set->top->node = set->head;
set->raises = 0;
bg_init(set);
if (start)
bg_start(0);
return set;
}
/**
* set_delete - delete the set
* @set: the set to delete
*/
void set_delete(set_t *set)
{
inode_t *top;
inode_t *icurr;
inode_t *inext;
node_t *curr;
node_t *next;
/* stop the background thread */
bg_stop();
/* warning - we are not deallocating the memory for the skip list */
}
/**
* set_print - print the set
* @set: the skip list set to print
* @flag: if non-zero include logically deleted nodes in the count
*/
void set_print(set_t *set, int flag)
{
node_t *node = set->head;
inode_t *ihead = set->top;
inode_t *itemp = set->top;
/* print the index items */
while (NULL != ihead) {
while (NULL != itemp) {
//printf("%lu ", itemp->node->key);
itemp = itemp->right;
}
printf("\n");
ihead = ihead->down;
itemp = ihead;
}
/*
while (NULL != node) {
if (flag && (NULL != node->val && node->val != node))
printf("%lu ", node->key);
else if (!flag)
printf("%lu ", node->key);
node = node->next;
}
*/
printf("\n");
}
/**
* set_size - print the size of the set
* @set: the set to print the size of
* @flag: if non-zero include logically deleted nodes in the count
*
* Return the size of the set.
*/
int set_size(set_t *set, int flag)
{
struct sl_node *node = set->head;
int size = 0;
node = node->next;
while (NULL != node) {
if (flag && (NULL != node->val && node != node->val))
++size;
else if (!flag)
++size;
node = node->next;
}
return size;
}
/**
* set_subsystem_init - initialise the set subsystem
*/
void set_subsystem_init(void)
{
gc_id[NODE_LEVEL] = gc_add_allocator(sizeof(node_t));
gc_id[INODE_LEVEL] = gc_add_allocator(sizeof(inode_t));
}
| 25.487395
| 77
| 0.5788
|
jyizheng
|
8993ddc93dcddec9532c3760f4c4a6294eb18841
| 2,032
|
cpp
|
C++
|
Blake2/Blake2/MacDescription.cpp
|
Steppenwolfe65/Blake2
|
9444e194323f98bb797816bc774d202276d17243
|
[
"Intel",
"MIT"
] | 1
|
2016-11-09T05:34:58.000Z
|
2016-11-09T05:34:58.000Z
|
Blake2/Blake2/MacDescription.cpp
|
Steppenwolfe65/Blake2
|
9444e194323f98bb797816bc774d202276d17243
|
[
"Intel",
"MIT"
] | null | null | null |
Blake2/Blake2/MacDescription.cpp
|
Steppenwolfe65/Blake2
|
9444e194323f98bb797816bc774d202276d17243
|
[
"Intel",
"MIT"
] | null | null | null |
#include "MacDescription.h"
#include "StreamWriter.h"
NAMESPACE_PROCESSING
MacDescription MacDescription::HMACSHA256()
{
return MacDescription(64, Digests::SHA256);
}
MacDescription MacDescription::HMACSHA512()
{
return MacDescription(128, Digests::SHA512);
}
MacDescription MacDescription::CMACAES256()
{
return MacDescription(32, BlockCiphers::Rijndael, IVSizes::V128);
}
int MacDescription::GetHeaderSize()
{
return MACHDR_SIZE;
}
void MacDescription::Reset()
{
m_macType = 0;
m_keySize = 0;
m_ivSize = 0;
m_hmacEngine = 0;
m_engineType = 0;
m_blockSize = 0;
m_roundCount = 0;
m_kdfEngine = 0;
}
std::vector<byte> MacDescription::ToBytes()
{
IO::StreamWriter writer(GetHeaderSize());
writer.Write(static_cast<byte>(m_macType));
writer.Write(static_cast<short>(m_keySize));
writer.Write(static_cast<byte>(m_ivSize));
writer.Write(static_cast<byte>(m_hmacEngine));
writer.Write(static_cast<byte>(m_engineType));
writer.Write(static_cast<byte>(m_blockSize));
writer.Write(static_cast<byte>(m_roundCount));
writer.Write(static_cast<byte>(m_kdfEngine));
return writer.GetBytes();
}
IO::MemoryStream* MacDescription::ToStream()
{
IO::StreamWriter writer(GetHeaderSize());
writer.Write(static_cast<byte>(m_macType));
writer.Write(static_cast<short>(m_keySize));
writer.Write(static_cast<byte>(m_ivSize));
writer.Write(static_cast<byte>(m_hmacEngine));
writer.Write(static_cast<byte>(m_engineType));
writer.Write(static_cast<byte>(m_blockSize));
writer.Write(static_cast<byte>(m_roundCount));
writer.Write(static_cast<byte>(m_kdfEngine));
return writer.GetStream();
}
int MacDescription::GetHashCode()
{
int hash = 31 * m_macType;
hash += 31 * m_keySize;
hash += 31 * m_ivSize;
hash += 31 * m_hmacEngine;
hash += 31 * m_engineType;
hash += 31 * m_blockSize;
hash += 31 * m_roundCount;
hash += 31 * m_kdfEngine;
return hash;
}
bool MacDescription::Equals(MacDescription &Obj)
{
if (this->GetHashCode() != Obj.GetHashCode())
return false;
return true;
}
NAMESPACE_PROCESSINGEND
| 22.086957
| 66
| 0.745079
|
Steppenwolfe65
|
899427e31a052756f875032d960f415a91e758b1
| 1,295
|
cpp
|
C++
|
Demo/widget.cpp
|
Skycoder42/qtrng
|
4bb840d80ff270c3c8cbe5bcd8bdda0503ce030e
|
[
"BSD-3-Clause"
] | 2
|
2019-03-21T12:32:11.000Z
|
2020-09-25T01:00:17.000Z
|
Demo/widget.cpp
|
Skycoder42/qtrng
|
4bb840d80ff270c3c8cbe5bcd8bdda0503ce030e
|
[
"BSD-3-Clause"
] | null | null | null |
Demo/widget.cpp
|
Skycoder42/qtrng
|
4bb840d80ff270c3c8cbe5bcd8bdda0503ce030e
|
[
"BSD-3-Clause"
] | null | null | null |
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget),
random(new QRng(this))
{
ui->setupUi(this);
on_entropyButton_clicked();
connect(ui->securityLevelComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
random, [this](int index) {
random->setSecurityLevel((QRng::SecurityLevel)index);
});
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_generateButton_clicked()
{
try {
auto data = random->generateRandom(ui->generateSpinBox->value());
switch (ui->encodingComboBox->currentIndex()) {
case 0: //base64
ui->textBrowser->setPlainText(QString::fromLatin1(data.toBase64()));
break;
case 1: //hex
ui->textBrowser->setPlainText(QString::fromLatin1(data.toHex()));
break;
case 2: //raw
ui->textBrowser->setPlainText(QString::fromLatin1(data));
break;
default:
Q_UNREACHABLE();
break;
}
on_entropyButton_clicked();
} catch(QException &e) {
qWarning() << e.what();
}
}
void Widget::on_entropyButton_clicked()
{
try {
auto e = random->currentEntropy();
if(e == QRng::UnlimitedEntropy)
ui->entropyEdit->setText(tr("Unlimited"));
else
ui->entropyEdit->setText(tr("%L1 bit").arg(e));
} catch(QException &e) {
qWarning() << e.what();
}
}
| 21.583333
| 88
| 0.677992
|
Skycoder42
|
8997b298451bb1e58de3c8a7830040160a7c6ace
| 2,028
|
cpp
|
C++
|
Src/Plugin/Wonderland/WonderlandPlugin.cpp
|
prophecy/Pillar
|
a60b07857e66312ee94d69678b1ca8c97b1a19eb
|
[
"MIT"
] | 2
|
2017-07-19T03:23:27.000Z
|
2018-01-16T04:26:53.000Z
|
Src/Plugin/Wonderland/WonderlandPlugin.cpp
|
prophecy/Pillar
|
a60b07857e66312ee94d69678b1ca8c97b1a19eb
|
[
"MIT"
] | null | null | null |
Src/Plugin/Wonderland/WonderlandPlugin.cpp
|
prophecy/Pillar
|
a60b07857e66312ee94d69678b1ca8c97b1a19eb
|
[
"MIT"
] | null | null | null |
/*
* This source file is part of Wonderland, the C++ Cross-platform middleware for game
*
* For the latest information, see https://github.com/prophecy/Wonderland
*
* The MIT License (MIT)
* Copyright (c) 2015 Adawat Chanchua
*
* 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 "WonderlandPlugin.h"
#include "IScene.h"
#include "SceneManager.h"
#include "Utility/Log/Log.h"
#include "Florist.h"
void WonderlandPlugin::Create(WonderPtr<IApplication> application)
{
// Create log
Log::GetPtr()->Create("Wonderland.log");
LogDebug("Create WonderlandPlugin");
// Application
this->application = application;
// Scene manager
application->sceneManager = CreateElement<SceneManager>().To<ISceneManager>();
// Create application
application->Create();
application->sceneManager->GetCurrentScene()->Create();
}
void WonderlandPlugin::Update()
{
application->sceneManager->OnChangeScene();
application->sceneManager->GetCurrentScene()->taskManager->UpdateTasks();
}
| 34.965517
| 85
| 0.751972
|
prophecy
|
89a3b1a7c81e269e6830dee582b3d8210e6fa052
| 315
|
cxx
|
C++
|
example/wake_ptr.cxx
|
usagi/usagi
|
2d57d21eeb92eadfdf4154a3e470aebfc3e388e5
|
[
"MIT"
] | 2
|
2016-11-20T04:59:17.000Z
|
2017-02-13T01:44:37.000Z
|
example/wake_ptr.cxx
|
usagi/usagi
|
2d57d21eeb92eadfdf4154a3e470aebfc3e388e5
|
[
"MIT"
] | 3
|
2015-09-28T12:00:02.000Z
|
2015-09-28T12:03:21.000Z
|
example/wake_ptr.cxx
|
usagi/usagi
|
2d57d21eeb92eadfdf4154a3e470aebfc3e388e5
|
[
"MIT"
] | 3
|
2017-07-02T06:09:47.000Z
|
2018-07-09T01:00:57.000Z
|
#include <usagi/memory/wake_ptr.hxx>
#include <vector>
#include <iostream>
auto main() -> int
{
using t = std::vector<int>;
auto b = std::make_shared< t >();
using namespace usagi::memory;
wake_ptr< t > a = b;
a->emplace_back( 123 );
a->emplace_back( 456 );
std::cout << a->front() << (*a)[1];
}
| 18.529412
| 37
| 0.6
|
usagi
|
89aa380bf9a9743deae08388709215a54b70e8cb
| 12,846
|
cpp
|
C++
|
MACHINATH/MACHINATH/sound.cpp
|
susajin/MACHINATH
|
1e75097f86218f143411885240bbcf211a6e9c99
|
[
"MIT"
] | null | null | null |
MACHINATH/MACHINATH/sound.cpp
|
susajin/MACHINATH
|
1e75097f86218f143411885240bbcf211a6e9c99
|
[
"MIT"
] | null | null | null |
MACHINATH/MACHINATH/sound.cpp
|
susajin/MACHINATH
|
1e75097f86218f143411885240bbcf211a6e9c99
|
[
"MIT"
] | null | null | null |
//=============================================================================
//
// �T�E���h���� [sound.cpp]
//
//=============================================================================
#include <XAudio2.h>
#include <mmsystem.h>
#include "sound.h"
#include "common.h"
#pragma comment (lib, "xaudio2.lib")
#pragma comment (lib, "winmm.lib")
//*****************************************************************************
// sound parameters
//*****************************************************************************
struct SOUNDPARAM
{
const char *pFilename; // path to sound file
int nCntLoop; // -1 == LOOP EDNLESSLY, 0 == DONT LOOP, >= 1 == LOOP
};
//*****************************************************************************
// methods
//*****************************************************************************
HRESULT CheckChunk(HANDLE hFile, DWORD format, DWORD *pChunkSize, DWORD *pChunkDataPosition);
HRESULT ReadChunkData(HANDLE hFile, void *pBuffer, DWORD dwBuffersize, DWORD dwBufferoffset);
void UpdateFadeSound();
//*****************************************************************************
// globals
//*****************************************************************************
IXAudio2 *g_pXAudio2 = NULL; // XAudio2 interface
IXAudio2MasteringVoice *g_pMasteringVoice = NULL; // master voice
IXAudio2SourceVoice *g_apSourceVoice[SOUND_LABEL_MAX] = {}; // source voice
BYTE *g_apDataAudio[SOUND_LABEL_MAX] = {};
DWORD g_aSizeAudio[SOUND_LABEL_MAX] = {};
float g_DeltaTime;
float g_targetTime, g_targetVolume;
bool g_FadeFlag;
float g_curVolume;
SOUND_LABEL g_curFadeSound;
// sound files to load
SOUNDPARAM g_aParam[SOUND_LABEL_MAX] =
{
{"asset/sound/BGM/title.wav", -1},
{"asset/sound/BGM/game.wav", -1},
{"asset/sound/SE/pickup.wav", 0},
{"asset/sound/SE/get_ready.wav", 0},
{"asset/sound/SE/one.wav", 0},
{"asset/sound/SE/two.wav", 0},
{"asset/sound/SE/three.wav", 0},
{"asset/sound/SE/go.wav", 0},
{"asset/sound/SE/title_pushbutton2.wav", 0},
{"asset/sound/SE/title_noise.wav", 0},
{"asset/sound/SE/slowmo_start.wav", 0},
{"asset/sound/SE/slowmo_end.wav", 0},
{"asset/sound/SE/QTE_fail.wav", 0},
{"asset/sound/SE/QTE_success.wav", 0},
{"asset/sound/SE/QTE_standby.wav", 0},
{"asset/sound/SE/explosion.wav", 0},
{"asset/sound/SE/gate_open.wav", 0},
};
//=============================================================================
// init sound
//=============================================================================
HRESULT InitSound(HWND hWnd)
{
g_DeltaTime = 0;
g_FadeFlag = false;
HRESULT hr;
// enable multithread for sound playback
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// initialize xaudio2
hr = XAudio2Create(&g_pXAudio2, 0);
if(FAILED(hr))
{
MessageBox(hWnd, "Failed to initialize XAudio2!", "Error!", MB_ICONWARNING);
CoUninitialize();
return E_FAIL;
}
// initialize master voice
hr = g_pXAudio2->CreateMasteringVoice(&g_pMasteringVoice);
if(FAILED(hr))
{
MessageBox(hWnd, "Failed to initialize Mastering Voice!", "Error!", MB_ICONWARNING);
if(g_pXAudio2)
{
g_pXAudio2->Release();
g_pXAudio2 = NULL;
}
CoUninitialize();
return E_FAIL;
}
// load sound files
for(int nCntSound = 0; nCntSound < SOUND_LABEL_MAX; nCntSound++)
{
HANDLE hFile;
DWORD dwChunkSize = 0;
DWORD dwChunkPosition = 0;
DWORD dwFiletype;
WAVEFORMATEXTENSIBLE wfx;
XAUDIO2_BUFFER buffer;
memset(&wfx, 0, sizeof(WAVEFORMATEXTENSIBLE));
memset(&buffer, 0, sizeof(XAUDIO2_BUFFER));
// load sound files from given path
hFile = CreateFile(g_aParam[nCntSound].pFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
MessageBox(hWnd, "Invalid Handle Value!", "Error!", MB_ICONWARNING);
return HRESULT_FROM_WIN32(GetLastError());
}
if(SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
{
MessageBox(hWnd, "Invalid Set File Pointer!", "Error!", MB_ICONWARNING);
return HRESULT_FROM_WIN32(GetLastError());
}
hr = CheckChunk(hFile, 'FFIR', &dwChunkSize, &dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "Failed at checking chunk!", "Error!", MB_ICONWARNING);
return S_FALSE;
}
hr = ReadChunkData(hFile, &dwFiletype, sizeof(DWORD), dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "Failed to read chunk data!", "Error!", MB_ICONWARNING);
return S_FALSE;
}
if(dwFiletype != 'EVAW')
{
MessageBox(hWnd, "Invalid file type!", "Error!", MB_ICONWARNING);
return S_FALSE;
}
// �t�H�[�}�b�g�`�F�b�N
hr = CheckChunk(hFile, ' tmf', &dwChunkSize, &dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "�t�H�[�}�b�g�`�F�b�N�Ɏ��s�I(1)", "�x���I", MB_ICONWARNING);
return S_FALSE;
}
hr = ReadChunkData(hFile, &wfx, dwChunkSize, dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "�t�H�[�}�b�g�`�F�b�N�Ɏ��s�I(2)", "�x���I", MB_ICONWARNING);
return S_FALSE;
}
// �I�[�f�B�I�f�[�^�ǂݍ���
hr = CheckChunk(hFile, 'atad', &g_aSizeAudio[nCntSound], &dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "�I�[�f�B�I�f�[�^�ǂݍ��݂Ɏ��s�I(1)", "�x���I", MB_ICONWARNING);
return S_FALSE;
}
g_apDataAudio[nCntSound] = (BYTE*)malloc(g_aSizeAudio[nCntSound]);
hr = ReadChunkData(hFile, g_apDataAudio[nCntSound], g_aSizeAudio[nCntSound], dwChunkPosition);
if(FAILED(hr))
{
MessageBox(hWnd, "�I�[�f�B�I�f�[�^�ǂݍ��݂Ɏ��s�I(2)", "�x���I", MB_ICONWARNING);
return S_FALSE;
}
// create source voice
hr = g_pXAudio2->CreateSourceVoice(&g_apSourceVoice[nCntSound], &(wfx.Format));
if(FAILED(hr))
{
MessageBox(hWnd, "Failed at creating source voice!", "Error!", MB_ICONWARNING);
return S_FALSE;
}
memset(&buffer, 0, sizeof(XAUDIO2_BUFFER));
buffer.AudioBytes = g_aSizeAudio[nCntSound];
buffer.pAudioData = g_apDataAudio[nCntSound];
buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.LoopCount = g_aParam[nCntSound].nCntLoop;
g_apSourceVoice[nCntSound]->SubmitSourceBuffer(&buffer);
}
return S_OK;
}
//=============================================================================
// uninit sound
//=============================================================================
void UninitSound(void)
{
// �ꎞ��~
for(int nCntSound = 0; nCntSound < SOUND_LABEL_MAX; nCntSound++)
{
if(g_apSourceVoice[nCntSound])
{
// �ꎞ��~
g_apSourceVoice[nCntSound]->Stop(0);
// �\�[�X�{�C�X�̔j��
g_apSourceVoice[nCntSound]->DestroyVoice();
g_apSourceVoice[nCntSound] = NULL;
// �I�[�f�B�I�f�[�^�̊J��
free(g_apDataAudio[nCntSound]);
g_apDataAudio[nCntSound] = NULL;
}
}
// �}�X�^�[�{�C�X�̔j��
g_pMasteringVoice->DestroyVoice();
g_pMasteringVoice = NULL;
if(g_pXAudio2)
{
// XAudio2�I�u�W�F�N�g�̊J��
g_pXAudio2->Release();
g_pXAudio2 = NULL;
}
// COM���C�u�����̏I������
CoUninitialize();
}
//=============================================================================
// Update Sound
//=============================================================================
void UpdateSound(void)
{
if (g_FadeFlag)
UpdateFadeSound();
}
//=============================================================================
// Play Sound
//=============================================================================
HRESULT PlaySound(SOUND_LABEL label, float volume)
{
XAUDIO2_VOICE_STATE xa2state;
XAUDIO2_BUFFER buffer;
// init buffer
memset(&buffer, 0, sizeof(XAUDIO2_BUFFER));
buffer.AudioBytes = g_aSizeAudio[label];
buffer.pAudioData = g_apDataAudio[label];
buffer.Flags = XAUDIO2_END_OF_STREAM;
buffer.LoopCount = g_aParam[label].nCntLoop;
g_apSourceVoice[label]->GetState(&xa2state);
if(xa2state.BuffersQueued != 0)
{
g_apSourceVoice[label]->Stop(0);
g_apSourceVoice[label]->FlushSourceBuffers();
}
// submit source buffer
g_apSourceVoice[label]->SubmitSourceBuffer(&buffer);
// play sound
g_apSourceVoice[label]->Start(0);
// set volume
SetVolume(label, volume);
return S_OK;
}
//=============================================================================
// Stop Sound
//=============================================================================
void StopSound(SOUND_LABEL label)
{
XAUDIO2_VOICE_STATE xa2state;
// ��Ԏ擾
g_apSourceVoice[label]->GetState(&xa2state);
if(xa2state.BuffersQueued != 0)
{// ����
// �ꎞ��~
g_apSourceVoice[label]->Stop(0);
// �I�[�f�B�I�o�b�t�@�̍폜
g_apSourceVoice[label]->FlushSourceBuffers();
}
}
//=============================================================================
// Stop all sound
//=============================================================================
void StopSound(void)
{
// �ꎞ��~
for(int nCntSound = 0; nCntSound < SOUND_LABEL_MAX; nCntSound++)
{
if(g_apSourceVoice[nCntSound])
{
// �ꎞ��~
g_apSourceVoice[nCntSound]->Stop(0);
}
}
}
//=============================================================================
// check chunk
//=============================================================================
HRESULT CheckChunk(HANDLE hFile, DWORD format, DWORD *pChunkSize, DWORD *pChunkDataPosition)
{
HRESULT hr = S_OK;
DWORD dwRead;
DWORD dwChunkType;
DWORD dwChunkDataSize;
DWORD dwRIFFDataSize = 0;
DWORD dwFileType;
DWORD dwBytesRead = 0;
DWORD dwOffset = 0;
if(SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
{// �t�@�C���|�C���^��擪�Ɉړ�
return HRESULT_FROM_WIN32(GetLastError());
}
while(hr == S_OK)
{
if(ReadFile(hFile, &dwChunkType, sizeof(DWORD), &dwRead, NULL) == 0)
{// �`�����N�̓ǂݍ���
hr = HRESULT_FROM_WIN32(GetLastError());
}
if(ReadFile(hFile, &dwChunkDataSize, sizeof(DWORD), &dwRead, NULL) == 0)
{// �`�����N�f�[�^�̓ǂݍ���
hr = HRESULT_FROM_WIN32(GetLastError());
}
switch(dwChunkType)
{
case 'FFIR':
dwRIFFDataSize = dwChunkDataSize;
dwChunkDataSize = 4;
if(ReadFile(hFile, &dwFileType, sizeof(DWORD), &dwRead, NULL) == 0)
{// �t�@�C���^�C�v�̓ǂݍ���
hr = HRESULT_FROM_WIN32(GetLastError());
}
break;
default:
if(SetFilePointer(hFile, dwChunkDataSize, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
{// �t�@�C���|�C���^��`�����N�f�[�^���ړ�
return HRESULT_FROM_WIN32(GetLastError());
}
}
dwOffset += sizeof(DWORD) * 2;
if(dwChunkType == format)
{
*pChunkSize = dwChunkDataSize;
*pChunkDataPosition = dwOffset;
return S_OK;
}
dwOffset += dwChunkDataSize;
if(dwBytesRead >= dwRIFFDataSize)
{
return S_FALSE;
}
}
return S_OK;
}
//=============================================================================
// read cunk data
//=============================================================================
HRESULT ReadChunkData(HANDLE hFile, void *pBuffer, DWORD dwBuffersize, DWORD dwBufferoffset)
{
DWORD dwRead;
if(SetFilePointer(hFile, dwBufferoffset, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
{// �t�@�C���|�C���^��w��ʒu�܂ňړ�
return HRESULT_FROM_WIN32(GetLastError());
}
if(ReadFile(hFile, pBuffer, dwBuffersize, &dwRead, NULL) == 0)
{// �f�[�^�̓ǂݍ���
return HRESULT_FROM_WIN32(GetLastError());
}
return S_OK;
}
HRESULT SetVolume(SOUND_LABEL LABEL,float volume,UINT32 OperationSet)
{
return g_apSourceVoice[LABEL]->SetVolume(volume * AUDIO_MASTER, OperationSet);
}
float GetVolume(SOUND_LABEL label)
{
float vol;
g_apSourceVoice[label]->GetVolume(&vol);
return vol;
}
void UpdateFadeSound()
{
if (g_DeltaTime < g_targetTime)
{
SetVolume(g_curFadeSound, g_targetVolume * (g_DeltaTime/ g_targetTime) +
g_curVolume * ((g_targetTime - g_DeltaTime )/ g_targetTime));
g_DeltaTime += (1.0f / 60.0f);
}
else
{
SetVolume(g_curFadeSound, g_targetVolume);
if (g_targetVolume == 0)
{
StopSound(g_curFadeSound);
}
g_DeltaTime = 0;
g_FadeFlag = false;
}
}
void StartFade(SOUND_LABEL label, float targetVolume, float targetTime)
{
// return if a sound is currently fading
if (g_FadeFlag) return;
g_curFadeSound = label;
g_apSourceVoice[label]->GetVolume(&g_curVolume);
g_targetVolume = targetVolume;
g_targetTime = targetTime;
g_FadeFlag = true;
}
void SetPlaybackSpeed(SOUND_LABEL label, float speed)
{
// return if given speed is the same as currently set
float value;
g_apSourceVoice[label]->GetFrequencyRatio(&value);
if (value == speed)
return;
// set playback speed and pitch
g_apSourceVoice[label]->SetFrequencyRatio(speed, 0);
}
| 27.74514
| 114
| 0.553324
|
susajin
|
89af011de156c8e203dc82c575ccc2e901652609
| 1,993
|
hpp
|
C++
|
src/tests/sequential/cusum.hpp
|
ropufu/aftermath
|
ab9364c41672a188879d84ebebb5a23f2d6641ec
|
[
"MIT"
] | null | null | null |
src/tests/sequential/cusum.hpp
|
ropufu/aftermath
|
ab9364c41672a188879d84ebebb5a23f2d6641ec
|
[
"MIT"
] | null | null | null |
src/tests/sequential/cusum.hpp
|
ropufu/aftermath
|
ab9364c41672a188879d84ebebb5a23f2d6641ec
|
[
"MIT"
] | null | null | null |
#ifndef ROPUFU_AFTERMATH_TESTS_SEQUENTIAL_CUSUM_HPP_INCLUDED
#define ROPUFU_AFTERMATH_TESTS_SEQUENTIAL_CUSUM_HPP_INCLUDED
#include <doctest/doctest.h>
#include "../core.hpp"
#include "../../ropufu/random/binomial_sampler.hpp"
#include "../../ropufu/random/normal_sampler_512.hpp"
#include "../../ropufu/random/uniform_int_sampler.hpp"
#include "../../ropufu/sequential/cusum.hpp"
#include <cstddef> // std::size_t
#include <cstdint> // std::int64_t
#include <random> // std::mt19937_64
#include <string> // std::string
#include <vector> // std::vector
#ifdef ROPUFU_TMP_TEST_TYPES
#undef ROPUFU_TMP_TEST_TYPES
#endif
#define ROPUFU_TMP_TEST_TYPES \
ropufu::aftermath::random::binomial_sampler<std::mt19937_64, std::int64_t>, \
ropufu::aftermath::random::normal_sampler_512<std::mt19937_64, double>, \
ropufu::aftermath::random::uniform_int_sampler<std::mt19937_64, std::int64_t> \
#ifndef ROPUFU_NO_JSON
TEST_CASE_TEMPLATE("testing cusum json", sampler_type, ROPUFU_TMP_TEST_TYPES)
{
using value_type = typename sampler_type::value_type;
using cusum_type = ropufu::aftermath::sequential::cusum<value_type>;
cusum_type cusum{};
std::string xxx {};
std::string yyy {};
ropufu::tests::does_json_round_trip(cusum, xxx, yyy);
CHECK_EQ(xxx, yyy);
} // TEST_CASE_TEMPLATE(...)
#endif
TEST_CASE_TEMPLATE("testing cusum accumulation", sampler_type, ROPUFU_TMP_TEST_TYPES)
{
using value_type = typename sampler_type::value_type;
using cusum_type = ropufu::aftermath::sequential::cusum<value_type>;
cusum_type cusum{};
std::vector<value_type> process = {2, 3, -7, 1, 2, 3, 4, 5, 5, -5};
value_type r = 0;
value_type s = 0;
for (value_type x : process)
{
r = s;
s = cusum.observe(x);
} // for (...)
CHECK_EQ(r, 20);
CHECK_EQ(s, 15);
} // TEST_CASE_TEMPLATE(...)
#endif // ROPUFU_AFTERMATH_TESTS_SEQUENTIAL_CUSUM_HPP_INCLUDED
| 31.634921
| 85
| 0.690416
|
ropufu
|
89afea239baecbe7c4dc22b736d7ac16a69051df
| 5,574
|
hpp
|
C++
|
include/dca/math/gaussian_processes/gaussian_fit.hpp
|
PMDee/DCA
|
a8196ec3c88d07944e0499ff00358ea3c830b329
|
[
"BSD-3-Clause"
] | 27
|
2018-08-02T04:28:23.000Z
|
2021-07-08T02:14:20.000Z
|
include/dca/math/gaussian_processes/gaussian_fit.hpp
|
PMDee/DCA
|
a8196ec3c88d07944e0499ff00358ea3c830b329
|
[
"BSD-3-Clause"
] | 200
|
2018-08-02T18:19:03.000Z
|
2022-03-16T21:28:41.000Z
|
include/dca/math/gaussian_processes/gaussian_fit.hpp
|
PMDee/DCA
|
a8196ec3c88d07944e0499ff00358ea3c830b329
|
[
"BSD-3-Clause"
] | 22
|
2018-08-15T15:50:00.000Z
|
2021-09-30T13:41:46.000Z
|
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Author: Peter Staar (taa@zurich.ibm.com)
//
// This class implements a Gaussian fit.
#ifndef DCA_MATH_GAUSSIAN_PROCESSES_GAUSSIAN_FIT_HPP
#define DCA_MATH_GAUSSIAN_PROCESSES_GAUSSIAN_FIT_HPP
#include "dca/linalg/matrix.hpp"
#include "dca/linalg/matrixop.hpp"
namespace dca {
namespace math {
namespace gp {
// dca::math::gp::
template <typename scalar_type, typename K_dmn_t, typename k_dmn_t>
class gaussian_fit {
public:
typedef typename K_dmn_t::parameter_type::element_type K_element_type;
typedef typename k_dmn_t::parameter_type::element_type k_element_type;
typedef linalg::Matrix<scalar_type, linalg::CPU> matrix_type;
gaussian_fit();
matrix_type& get_interpolation_matrix() {
return interpolation_matrix;
}
matrix_type& get_correlation_matrix() {
return correlation_matrix;
}
template <typename covariance_type>
void initialize(covariance_type& covariance, double error);
private:
template <typename covariance_type>
void initialize_interpolation_matrix(covariance_type& covariance, double error);
template <typename covariance_type>
void initialize_correlation_matrix(covariance_type& covariance, double error);
const static int DIMENSION = K_dmn_t::parameter_type::DIMENSION;
std::vector<scalar_type> length_scale;
matrix_type interpolation_matrix;
matrix_type correlation_matrix;
};
template <typename scalar_type, typename K_dmn_t, typename k_dmn_t>
gaussian_fit<scalar_type, K_dmn_t, k_dmn_t>::gaussian_fit()
: length_scale(DIMENSION, 1.),
interpolation_matrix("interpolation_matrix"),
correlation_matrix("correlation_matrix") {}
template <typename scalar_type, typename K_dmn_t, typename k_dmn_t>
template <typename covariance_type>
void gaussian_fit<scalar_type, K_dmn_t, k_dmn_t>::initialize(covariance_type& covariance,
double error) {
initialize_interpolation_matrix(covariance, error);
initialize_correlation_matrix(covariance, error);
}
template <typename scalar_type, typename K_dmn_t, typename k_dmn_t>
template <typename covariance_type>
void gaussian_fit<scalar_type, K_dmn_t, k_dmn_t>::initialize_interpolation_matrix(
covariance_type& covariance, double error) {
int N_r = k_dmn_t::dmn_size();
int N_c = K_dmn_t::dmn_size();
interpolation_matrix.resizeNoCopy(std::pair<int, int>(N_r, N_c));
linalg::Matrix<scalar_type, linalg::CPU> K_K("K_K", std::pair<int, int>(N_c, N_c));
for (int i = 0; i < N_c; i++) {
for (int j = 0; j < N_c; j++) {
K_element_type& x_i = K_dmn_t::get_elements()[i];
K_element_type& x_j = K_dmn_t::get_elements()[j];
std::vector<scalar_type> delta(DIMENSION, 0);
for (int li = 0; li < DIMENSION; li++)
delta[li] = (x_j[li] - x_i[li]);
K_K(i, j) = covariance.execute(delta); // compute_factor(periodic, delta);
}
K_K(i, i) += error * error;
}
linalg::Matrix<scalar_type, linalg::CPU> K_K_inv("K_K_inv", std::pair<int, int>(N_c, N_c));
linalg::matrixop::pseudoInverse(K_K, K_K_inv);
linalg::Matrix<scalar_type, linalg::CPU> interpolation_matrix_tmp("K_K_inv",
std::pair<int, int>(N_r, N_c));
for (int i = 0; i < N_r; i++) {
for (int j = 0; j < N_c; j++) {
k_element_type& x_i = k_dmn_t::get_elements()[i];
K_element_type& x_j = K_dmn_t::get_elements()[j];
std::vector<scalar_type> delta(DIMENSION, 0);
for (int li = 0; li < DIMENSION; li++)
delta[li] = (x_j[li] - x_i[li]);
interpolation_matrix_tmp(i, j) = covariance.execute(delta);
}
interpolation_matrix_tmp(i, i) += error * error;
}
linalg::matrixop::gemm('N', 'N', interpolation_matrix_tmp, K_K_inv, interpolation_matrix);
}
template <typename scalar_type, typename K_dmn_t, typename k_dmn_t>
template <typename covariance_type>
void gaussian_fit<scalar_type, K_dmn_t, k_dmn_t>::initialize_correlation_matrix(
covariance_type& covariance, double error) {
int N_c = K_dmn_t::dmn_size();
int N_r = k_dmn_t::dmn_size();
correlation_matrix.resizeNoCopy(std::pair<int, int>(N_r, N_r));
for (int i = 0; i < N_r; i++) {
for (int j = 0; j < N_r; j++) {
k_element_type& x_i = k_dmn_t::get_elements()[i];
k_element_type& x_j = k_dmn_t::get_elements()[j];
std::vector<scalar_type> delta(DIMENSION, 0);
for (int li = 0; li < DIMENSION; li++)
delta[li] = (x_j[li] - x_i[li]);
correlation_matrix(i, j) = covariance.execute(delta);
}
correlation_matrix(i, i) += error * error;
}
linalg::Matrix<scalar_type, linalg::CPU> k_to_K("k_to_K", std::pair<int, int>(N_c, N_r));
for (int i = 0; i < N_c; i++) {
for (int j = 0; j < N_r; j++) {
K_element_type& x_i = K_dmn_t::get_elements()[i];
k_element_type& x_j = k_dmn_t::get_elements()[j];
std::vector<scalar_type> delta(DIMENSION, 0);
for (int li = 0; li < DIMENSION; li++)
delta[li] = (x_j[li] - x_i[li]);
correlation_matrix(i, j) = covariance.execute(delta);
}
k_to_K(i, i) += error * error;
}
linalg::matrixop::gemm('N', 'N', scalar_type(-1), interpolation_matrix, k_to_K, scalar_type(1),
correlation_matrix);
}
} // gp
} // math
} // dca
#endif // DCA_MATH_GAUSSIAN_PROCESSES_GAUSSIAN_FIT_HPP
| 32.406977
| 99
| 0.679046
|
PMDee
|
89b0a22fac661cc0d7f9419e6fba137712dc3791
| 1,112
|
cpp
|
C++
|
Programacion Competitiva/Contest/HighestValuePalindrome.cpp
|
Angel1612/Computer_Science_UNSA
|
e1696fd2cb7c66f6af9aa14dbd96b4f67c787425
|
[
"MIT"
] | null | null | null |
Programacion Competitiva/Contest/HighestValuePalindrome.cpp
|
Angel1612/Computer_Science_UNSA
|
e1696fd2cb7c66f6af9aa14dbd96b4f67c787425
|
[
"MIT"
] | null | null | null |
Programacion Competitiva/Contest/HighestValuePalindrome.cpp
|
Angel1612/Computer_Science_UNSA
|
e1696fd2cb7c66f6af9aa14dbd96b4f67c787425
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
std::string highest_value_palindrome(std::string s, int k);
int main(){
int n,k;
std::cin >> n >> k;
std::string s;
std::cin >> s;
std::cout << highest_value_palindrome(s, k) << std::endl;
return 0;
}
std::string highest_value_palindrome(std::string s, int k){
std::vector<bool> changed(s.size(), false);
for(int i=0; i<s.size() / 2; ++i){
int j=s.size()-1-i;
if(s[i] > s[j]){
s[j] = s[i];
changed[j] = true;
k--;
}
else if(s[i] < s[j]){
s[i] = s[j];
changed[i] = true;
k--;
}
}
if(k < 0)
return "-1";
if(k == 0)
return s;
for(int i=0; i<s.size() / 2; ++i){
int j=s.size()-1-i;
if(s[i] < '9' && k >= (2 - changed[i] - changed[j])){
s[i] = '9';
s[j] = '9';
k -= (2 - changed[i] - changed[j]);
}
}
if(k > 0 && (s.size() % 2) == 1){
s[(s.size() / 2)] = '9';
}
return s;
}
| 20.592593
| 61
| 0.417266
|
Angel1612
|
89b0dba6edb269ea1581158ed9ad3025e2c63032
| 14,659
|
cpp
|
C++
|
ds/security/gina/snapins/ade/rsoputil.cpp
|
npocmaka/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 17
|
2020-11-13T13:42:52.000Z
|
2021-09-16T09:13:13.000Z
|
ds/security/gina/snapins/ade/rsoputil.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 2
|
2020-10-19T08:02:06.000Z
|
2020-10-19T08:23:18.000Z
|
ds/security/gina/snapins/ade/rsoputil.cpp
|
sancho1952007/Windows-Server-2003
|
5c6fe3db626b63a384230a1aa6b92ac416b0765f
|
[
"Unlicense"
] | 14
|
2020-11-14T09:43:20.000Z
|
2021-08-28T08:59:57.000Z
|
//+--------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1994 - 1997.
//
// File: rsoputil.cpp
//
// Contents: helper functions for working with the RSOP databases
//
// History: 10-18-1999 stevebl Created
//
//---------------------------------------------------------------------------
#include "precomp.hxx"
#include "sddl.h"
//+--------------------------------------------------------------------------
//
// Function: SetParameter
//
// Synopsis: sets a paramter's value in a WMI parameter list
//
// Arguments: [pInst] - instance on which to set the value
// [szParam] - the name of the parameter
// [xData] - the data
//
// History: 10-08-1999 stevebl Created
//
// Notes: There may be several flavors of this procedure, one for
// each data type.
//
//---------------------------------------------------------------------------
HRESULT SetParameter(IWbemClassObject * pInst, TCHAR * szParam, TCHAR * szData)
{
VARIANT var;
HRESULT hr = S_OK;
var.vt = VT_BSTR;
var.bstrVal = SysAllocString(szData);
hr = pInst->Put(szParam, 0, &var, 0);
SysFreeString(var.bstrVal);
return hr;
}
//+--------------------------------------------------------------------------
//
// Function: GetParameter
//
// Synopsis: retrieves a parameter value from a WMI paramter list
//
// Arguments: [pInst] - instance to get the paramter value from
// [szParam] - the name of the paramter
// [xData] - [out] data
//
// History: 10-08-1999 stevebl Created
//
// Notes: There are several flavors of this procedure, one for each
// data type.
//
//---------------------------------------------------------------------------
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, TCHAR * &szData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
if (szData)
{
delete [] szData;
szData = NULL;
}
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
if (var.bstrVal)
{
ULONG ulNoChars = _tcslen(var.bstrVal) + 1;
szData = (TCHAR *) OLEALLOC(sizeof(TCHAR) * ulNoChars);
if (szData)
{
hr = StringCchCopy(szData, ulNoChars, var.bstrVal);
ASSERT(SUCCEEDED(hr));
}
else
{
hr = E_OUTOFMEMORY;
}
}
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, CString &szData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
if (szData)
{
szData = "";
}
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
if (var.bstrVal)
{
szData = var.bstrVal;
}
}
VariantClear(&var);
return hr;
}
HRESULT GetParameterBSTR(IWbemClassObject * pInst, TCHAR * szParam, BSTR &bstrData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
if (bstrData)
{
SysFreeString(bstrData);
}
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
bstrData = SysAllocStringLen(var.bstrVal, SysStringLen(var.bstrVal));
if (NULL == bstrData)
{
hr = E_OUTOFMEMORY;
}
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, BOOL &fData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
fData = var.bVal;
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, HRESULT &hrData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
hrData = (HRESULT) var.lVal;
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, ULONG &ulData)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
ulData = var.ulVal;
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, GUID &guid)
{
TCHAR * sz = NULL;
memset(&guid, 0, sizeof(GUID));
HRESULT hr = GetParameter(pInst, szParam, sz);
if (SUCCEEDED(hr))
{
hr = CLSIDFromString(sz, &guid);
}
if (sz)
{
OLESAFE_DELETE(sz);
}
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, unsigned int &ui)
{
VARIANT var;
HRESULT hr = S_OK;
VariantInit(&var);
ui = 0;
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
ui = (HRESULT) var.uiVal;
}
VariantClear(&var);
return hr;
}
// array variation - gets an array of guids and a count
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR *szParam, UINT &uiCount, GUID * &rgGuid)
{
VARIANT var;
HRESULT hr = S_OK;
uiCount = 0;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt == (VT_ARRAY | VT_BSTR))
{
// build the array
SAFEARRAY * parray = var.parray;
uiCount = parray->rgsabound[0].cElements;
if (uiCount > 0)
{
rgGuid = (GUID *)OLEALLOC(sizeof(GUID) * uiCount);
if (rgGuid)
{
BSTR * rgData = (BSTR *)parray->pvData;
UINT ui = uiCount;
while (ui--)
{
hr = CLSIDFromString(rgData[ui], &rgGuid[ui]);
if (FAILED(hr))
{
return hr;
}
}
}
else
{
uiCount = 0;
hr = E_OUTOFMEMORY;
}
}
}
VariantClear(&var);
return hr;
}
// array variation - gets an array of strings and a count
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR *szParam, UINT &uiCount, TCHAR ** &rgszData)
{
VARIANT var;
HRESULT hr = S_OK;
uiCount = 0;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt == (VT_ARRAY | VT_BSTR))
{
// build the array
SAFEARRAY * parray = var.parray;
uiCount = parray->rgsabound[0].cElements;
if (uiCount > 0)
{
rgszData = (TCHAR **)OLEALLOC(sizeof(TCHAR *) * uiCount);
if (rgszData)
{
BSTR * rgData = (BSTR *)parray->pvData;
UINT ui = uiCount;
while (ui--)
{
OLESAFE_COPYSTRING(rgszData[ui], rgData[ui]);
}
}
else
{
uiCount = 0;
hr = E_OUTOFMEMORY;
}
}
}
VariantClear(&var);
return hr;
}
// array variation - gets an array of CSPLATFORM objects and a count
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, UINT &uiCount, CSPLATFORM * &rgData)
{
VARIANT var;
HRESULT hr = S_OK;
uiCount = 0;
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt == (VT_ARRAY | VT_I4))
{
// build the array
SAFEARRAY * parray = var.parray;
uiCount = parray->rgsabound[0].cElements;
if (uiCount > 0)
{
rgData = (CSPLATFORM *)OLEALLOC(sizeof(CSPLATFORM) * uiCount);
if (rgData)
{
ULONG * rgulData = (ULONG *)parray->pvData;
UINT ui = uiCount;
while (ui--)
{
rgData[ui].dwPlatformId = VER_PLATFORM_WIN32_NT;
rgData[ui].dwVersionHi = 5;
rgData[ui].dwVersionLo = 0;
rgData[ui].dwProcessorArch = rgulData[ui];
}
}
else
{
uiCount = 0;
hr = E_OUTOFMEMORY;
}
}
}
VariantClear(&var);
return hr;
}
HRESULT GetParameter(IWbemClassObject * pInst, TCHAR * szParam, PSECURITY_DESCRIPTOR &psd)
{
VARIANT var;
HRESULT hr = S_OK;
if (psd)
{
LocalFree(psd);
psd = NULL;
}
VariantInit(&var);
hr = pInst->Get(szParam, 0, &var, 0, 0);
if (SUCCEEDED(hr) && var.vt != VT_NULL)
{
psd = (PSECURITY_DESCRIPTOR) LocalAlloc( LPTR, var.parray->rgsabound[0].cElements * sizeof( BYTE ) );
if ( psd )
{
memcpy( psd, var.parray->pvData, var.parray->rgsabound[0].cElements * sizeof( BYTE ) );
if (!IsValidSecurityDescriptor(psd))
{
LocalFree(psd);
psd = NULL;
}
}
else
{
hr = E_OUTOFMEMORY;
}
}
VariantClear(&var);
return hr;
}
HRESULT GetGPOFriendlyName(IWbemServices *pIWbemServices,
LPTSTR lpGPOID, BSTR pLanguage,
LPTSTR *pGPOName)
{
BSTR pQuery = NULL, pName = NULL;
LPTSTR lpQuery = NULL;
IEnumWbemClassObject * pEnum = NULL;
IWbemClassObject *pObjects[2];
HRESULT hr;
ULONG ulRet;
VARIANT varGPOName;
//
// Set the default
//
*pGPOName = NULL;
//
// Build the query
//
ULONG ulQueryNoChars = lstrlen(lpGPOID) + 50;
lpQuery = (LPTSTR) LocalAlloc (LPTR, ulQueryNoChars * sizeof(TCHAR));
if (!lpQuery)
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to allocate memory for unicode query")));
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto Exit;
}
WCHAR szQueryFormat[] = TEXT("SELECT name, id FROM RSOP_GPO where id=\"%s\"");
hr = StringCchPrintf (lpQuery, ulQueryNoChars, szQueryFormat, lpGPOID);
if (FAILED(hr))
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: StringCchPrintf returned error")));
goto Exit;
}
pQuery = SysAllocString (lpQuery);
if (!pQuery)
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to allocate memory for query")));
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto Exit;
}
//
// Allocate BSTRs for the property names we want to retreive
//
pName = SysAllocString (TEXT("name"));
if (!pName)
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to allocate memory for name")));
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto Exit;
}
//
// Execute the query
//
hr = pIWbemServices->ExecQuery (pLanguage, pQuery,
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL, &pEnum);
if (FAILED(hr))
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to query for %s with 0x%x"),
pQuery, hr));
goto Exit;
}
//
// Loop through the results
//
hr = pEnum->Next(WBEM_INFINITE, 1, pObjects, &ulRet);
if (FAILED(hr))
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to get first item in query results for %s with 0x%x"),
pQuery, hr));
goto Exit;
}
//
// Check for the "data not available case"
//
if (ulRet == 0)
{
ULONG ulNoChars = lstrlen(lpGPOID) + 1;
//
// In this case, we cannot find the gpo -- it has most likely been deleted. To give the user some
// useful information, we will fall back to the guid.
//
*pGPOName = (LPTSTR) LocalAlloc (LPTR, ulNoChars * sizeof(TCHAR));
if ( *pGPOName )
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Using GPO guid for friendly name because GPO can't be found")));
hr = StringCchCopy( *pGPOName, ulNoChars, lpGPOID );
ASSERT(SUCCEEDED(hr));
}
else
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to allocate memory for GPO Name in GUID form")));
hr = E_OUTOFMEMORY;
}
goto Exit;
}
//
// Get the name
//
hr = pObjects[0]->Get (pName, 0, &varGPOName, NULL, NULL);
if (FAILED(hr))
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to get gponame in query results for %s with 0x%x"),
pQuery, hr));
goto Exit;
}
//
// Save the name
//
ULONG ulNoChars = lstrlen(varGPOName.bstrVal) + 1;
*pGPOName = (LPTSTR) LocalAlloc (LPTR, ulNoChars * sizeof(TCHAR));
if (!(*pGPOName))
{
DebugMsg((DM_WARNING, TEXT("GetGPOFriendlyName: Failed to allocate memory for GPO Name")));
hr = HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY);
goto Exit;
}
hr = StringCchCopy (*pGPOName, ulNoChars, varGPOName.bstrVal);
ASSERT(SUCCEEDED(hr));
VariantClear (&varGPOName);
hr = S_OK;
Exit:
if (pEnum)
{
pEnum->Release();
}
if (pQuery)
{
SysFreeString (pQuery);
}
if (lpQuery)
{
LocalFree (lpQuery);
}
if (pName)
{
SysFreeString (pName);
}
return hr;
}
HRESULT CStringFromWBEMTime(CString &szOut, BSTR bstrIn, BOOL fShortFormat)
{
HRESULT hr = E_FAIL;
WBEMTime wt(bstrIn);
FILETIME ft;
if (wt.GetFILETIME(&ft))
{
CTime t(ft);
if (fShortFormat)
{
szOut = t.Format(TEXT("%x"));
}
else
{
szOut = t.Format(TEXT("%#c"));
}
hr = S_OK;
}
return hr;
}
| 25.762742
| 125
| 0.497442
|
npocmaka
|
89b2197cab272b06bd62ceea4dbd7ab38ed77dc4
| 1,774
|
cc
|
C++
|
archetype/TestWrappedOutput.cc
|
gitosaurus/archetype
|
849cd50e653adab6e5ca6f23d5350217a8a4d025
|
[
"MIT"
] | 6
|
2015-05-04T17:18:54.000Z
|
2021-01-24T16:23:56.000Z
|
archetype/TestWrappedOutput.cc
|
gitosaurus/archetype
|
849cd50e653adab6e5ca6f23d5350217a8a4d025
|
[
"MIT"
] | null | null | null |
archetype/TestWrappedOutput.cc
|
gitosaurus/archetype
|
849cd50e653adab6e5ca6f23d5350217a8a4d025
|
[
"MIT"
] | null | null | null |
//
// TestWrappedOutput.cpp
// archetype
//
// Created by Derek Jones on 9/21/14.
// Copyright (c) 2014 Derek Jones. All rights reserved.
//
#include <iostream>
#include <string>
#include <sstream>
#include <deque>
#include <iterator>
#include "TestWrappedOutput.hh"
#include "TestRegistry.hh"
#include "StringOutput.hh"
#include "WrappedOutput.hh"
using namespace std;
namespace archetype {
ARCHETYPE_TEST_REGISTER(TestWrappedOutput);
void TestWrappedOutput::testBasicWrap_() {
UserOutput user_soutput{new StringOutput};
StringOutput& strout(*dynamic_cast<StringOutput*>(user_soutput.get()));
UserOutput user_output{new WrappedOutput{user_soutput}};
WrappedOutput& wrout(*dynamic_cast<WrappedOutput*>(user_output.get()));
wrout.setMaxColumns(10);
string utterance = "Now is the time for all good men to come to the aid of their country.";
user_output->put(utterance);
user_output->endLine();
string result = strout.getOutput();
out() << result;
istringstream istr(result);
string line;
deque<string> lines;
while (getline(istr, line)) {
ARCHETYPE_TEST(line.size() <= 10);
lines.push_back(line);
}
ARCHETYPE_TEST(lines.size() > 1);
// Paste it back together and make sure it matches the original
ostringstream back_out;
copy(lines.begin(), lines.end(), ostream_iterator<string>(back_out, " "));
string back_out_s = back_out.str();
back_out_s.resize(back_out_s.size() - 1);
ARCHETYPE_TEST_EQUAL(back_out_s, utterance);
out() << "TestWrappedOutput finished." << endl;
}
void TestWrappedOutput::runTests_() {
testBasicWrap_();
}
}
| 31.122807
| 99
| 0.654453
|
gitosaurus
|
89b5081b750a5e5ac1fcd4fe39900575790b25e8
| 404
|
cpp
|
C++
|
pow_sha1/src/_main.cpp
|
mzk84/phi
|
69c0535eff9f301daaa67e80aa01f39d7ace2b4b
|
[
"Unlicense"
] | null | null | null |
pow_sha1/src/_main.cpp
|
mzk84/phi
|
69c0535eff9f301daaa67e80aa01f39d7ace2b4b
|
[
"Unlicense"
] | null | null | null |
pow_sha1/src/_main.cpp
|
mzk84/phi
|
69c0535eff9f301daaa67e80aa01f39d7ace2b4b
|
[
"Unlicense"
] | null | null | null |
#include "_includes.h"
#include "mzk84_commons.h"
#include "PoW_SHA1.h"
int main() {
std::cout << "\n************************************************************\n";
std::cout << "Proof of Work SHA1 Test\n\n";
size_t prefix_len = 64;
size_t difficulty = 6;
for (auto i = 0; i < 5; i++) {
std::string prefix = mzk84::get_random_string(prefix_len);
PoW_SHA1_Runner(prefix, difficulty, 1);
}
}
| 23.764706
| 81
| 0.554455
|
mzk84
|
89b63e39c6bf70d33d9364c1447d494aaa788823
| 971
|
hpp
|
C++
|
src/LoadInformations.hpp
|
jkalter11/freeshop
|
c7b1858ed713732b8ff9afa116f05a1ed9a4d4c3
|
[
"MIT"
] | 1
|
2021-05-11T10:40:14.000Z
|
2021-05-11T10:40:14.000Z
|
src/LoadInformations.hpp
|
jkalter11/freeshop
|
c7b1858ed713732b8ff9afa116f05a1ed9a4d4c3
|
[
"MIT"
] | null | null | null |
src/LoadInformations.hpp
|
jkalter11/freeshop
|
c7b1858ed713732b8ff9afa116f05a1ed9a4d4c3
|
[
"MIT"
] | 2
|
2021-06-05T15:51:05.000Z
|
2022-02-03T20:44:33.000Z
|
#ifndef FREESHOP_LOADINFORMATIONS_HPP
#define FREESHOP_LOADINFORMATIONS_HPP
#include <cpp3ds/Graphics/Drawable.hpp>
#include <cpp3ds/Graphics/Text.hpp>
#include <cpp3ds/Window/Event.hpp>
#include "TweenObjects.hpp"
#include <TweenEngine/Tween.h>
#include <TweenEngine/TweenManager.h>
namespace FreeShop {
class LoadInformations : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
public:
void update(float delta);
LoadInformations();
~LoadInformations();
static LoadInformations& getInstance();
void updateLoadingPercentage(int newPercentage);
void setStatus(const std::string& message);
void reset();
protected:
virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;
private:
cpp3ds::Text m_textLoadingPercentage;
util3ds::TweenText m_textStatus;
int m_loadingPercentage;
TweenEngine::TweenManager m_tweenManager;
};
} // namespace FreeShop
#endif // FREESHOP_LOADINFORMATIONS_HPP
| 23.119048
| 109
| 0.797116
|
jkalter11
|
89b846212984ab98ac5310f8acd9ec1139074a7c
| 1,978
|
cpp
|
C++
|
src/tt.cpp
|
am1w1zz/CppLearn
|
16db21cb5cc9ca14e488f4f40923b756de18e354
|
[
"MIT"
] | null | null | null |
src/tt.cpp
|
am1w1zz/CppLearn
|
16db21cb5cc9ca14e488f4f40923b756de18e354
|
[
"MIT"
] | null | null | null |
src/tt.cpp
|
am1w1zz/CppLearn
|
16db21cb5cc9ca14e488f4f40923b756de18e354
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include <vector>
#include "tt.h"
struct aa {
void f(int x ,int y) {
std::cout<<"void"<<std::endl;
return ;
}
void f(int x,int y )const {
std::cout<<"int"<<std::endl;
return ;
}
~aa() {
std::cout<<"aa"<<std::endl;
}
};
struct bb : aa {
~bb(){
std::cout<<"bb"<<std::endl;
}
};
struct cc {
int v;
cc(int v) :v(v) {
}
};
void func();
union obj{
union obj* obj;
char _M_client_data[1];
};
struct node {
node* next;
int val;
};
int main() {
// const aa a;
// a.f(1,2);
// bb a;
// std::cout<<sizeof(aa);
// f(1,2);
// f(1,2);
// cc a(1);
// cc b(2);
// cc& c = a;
// std::cout<<c.v<<std::endl;
// c = b;
// std::cout<<c.v<<std::endl;
// std::cout<<a.v<<std::endl;
// std::cout<<b.v<<std::endl;
// func(); //1
// extern int num;
// printf("%d",num); //2
// return 0;
// MyTemplate<int> MyIntTemplate;
// auto i = MyIntTemplate.GetMemebr();
// obj a;
// obj b;
// a.obj = &b;
// b._M_client_data[0] = 'a';
// std::cout<<sizeof(a)<<std::endl;
// std::cout<<sizeof(b)<<std::endl;
// }
int a[] = {0x01020304,2019};
int* b = a;
char* c = (char*)&a[0];
// printf("b+1:%d\n",*(b+1));
// printf("c+1:%d\n",*(c));
// return 0;
std::vector<node*> list_node {new node(),new node(),new node(), new node()};
node* n1 = new node();
list_node[0]->next = n1;
for(auto& i : list_node){
std::cout<<i<<std::endl;
}
// std::cout<<list_node[0]->next<<std::endl;
std::cout<<std::endl;
list_node[0] = list_node[0]->next;
std::cout<<std::endl;
// std::cout<<list_node[0]<<std::endl;
for(auto& i : list_node){
std::cout<<i<<std::endl;
}
aa* a1 = new aa();
bb* b1 = new bb();
a1 = b1;
}
// int num = 3;
// void func(){
// printf("%d\n",num);
// }
| 18.314815
| 80
| 0.455005
|
am1w1zz
|
89b8a472747572f02648ee1674f0857d0aa23f25
| 1,400
|
cpp
|
C++
|
Sudoku/Sudoku_cpp_linux/src/main.cpp
|
SleepyLGod/Miscellaneous
|
1e4e1d5b915de9e2c4a6240f4940e9eeabe7e943
|
[
"Apache-2.0"
] | 1
|
2021-09-06T12:22:59.000Z
|
2021-09-06T12:22:59.000Z
|
Sudoku/Sudoku_cpp_linux/src/main.cpp
|
SleepyLGod/GitRepository_lhd
|
e41db820a2b7f1efc109a9d23002d6ebb7785b10
|
[
"Apache-2.0"
] | null | null | null |
Sudoku/Sudoku_cpp_linux/src/main.cpp
|
SleepyLGod/GitRepository_lhd
|
e41db820a2b7f1efc109a9d23002d6ebb7785b10
|
[
"Apache-2.0"
] | null | null | null |
/**
* main.c
* 基于SAT的数独游戏求解程序
*
* Created by 路昊东 on 2021/9/10
* Copyright ? 2021 路昊东. All rights reserved.
*/
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include "../cnf.h"
#include "../DPLL.h"
#include "../Sudoku.h"
extern ArgueValue *ValueList;
extern Root *r;
int main(int argc, const char * argv[])
{
int op=1;
while (op)
{
system("clear");
printf("\n");
printf("-------------------------WELCOME TO THE WORLD!-------------------------\n");
printf("\t\t\tChoose a progame please.\n");
printf("-----------------------------------------------------------------------\n");
printf(" 1.Sudoku 2.SAT 0.exit\n");
printf("-----------------------------------------------------------------------\n ");
scanf("%d",&op);
switch (op)
{
case 1:
Sudoku();
break;
case 2:
SAT();
break;
case 0:
printf(" logout\n saving session...\n ...copying shared history...\n ...saving history...truncating history files...\n ...completed.\n\n");
break;
default:
printf(" Input error !");
getchar();getchar();
break;
}
}
system("pause");
return 0;
}
| 27.45098
| 160
| 0.39
|
SleepyLGod
|
89bdb539249e2db4bad0da72bebba8cbc08e72fc
| 2,550
|
hpp
|
C++
|
src/solvers/temporal/point_algebra/QualitativeTimePoint.hpp
|
tomcreutz/planning-templ
|
55e35ede362444df9a7def6046f6df06851fe318
|
[
"BSD-3-Clause"
] | 1
|
2022-03-31T12:15:15.000Z
|
2022-03-31T12:15:15.000Z
|
src/solvers/temporal/point_algebra/QualitativeTimePoint.hpp
|
tomcreutz/planning-templ
|
55e35ede362444df9a7def6046f6df06851fe318
|
[
"BSD-3-Clause"
] | null | null | null |
src/solvers/temporal/point_algebra/QualitativeTimePoint.hpp
|
tomcreutz/planning-templ
|
55e35ede362444df9a7def6046f6df06851fe318
|
[
"BSD-3-Clause"
] | 1
|
2021-12-29T10:38:07.000Z
|
2021-12-29T10:38:07.000Z
|
#ifndef TEMPL_SOLVERS_TEMPORAL_POINT_ALGEBRA_QUALITATIVE_TIME_POINT_HPP
#define TEMPL_SOLVERS_TEMPORAL_POINT_ALGEBRA_QUALITATIVE_TIME_POINT_HPP
#include <graph_analysis/VertexRegistration.hpp>
#include "TimePoint.hpp"
namespace templ {
namespace solvers {
namespace temporal {
namespace point_algebra {
/**
* \class QualitativeTimePoint
* \details A QualitativeTimePoint represent a labelled timepoint,
* which allows to formulate qualitative timepoint relationships
*
* A QualitativeTimePoint can have one or more aliases and identical
* aliases identify equal timepoints, which will allow for later
* constraint checking
*
*/
class QualitativeTimePoint : public TimePoint
{
std::vector<TimePoint::Label> mAliases;
static const graph_analysis::VertexRegistration< QualitativeTimePoint > __attribute__((used)) msRegistration;
public:
typedef shared_ptr<QualitativeTimePoint> Ptr;
/**
* Default constructor
* \param label (main) label for this Timepoint
*/
QualitativeTimePoint(const TimePoint::Label& label = "");
/**
* Create instance of QualitativeTimePoint
*/
static QualitativeTimePoint::Ptr getInstance(const TimePoint::Label& label);
/**
* Add an alias for this timepoint
* \param alias Alias
*/
void addAlias(const TimePoint::Label& alias);
/**
* Check if the given label is an alias (or the actual label) of this
* QualitativeTimePoint
* \return True if label is an alias, false otherwise
o*/
bool isAlias(const TimePoint::Label& label) const;
/**
* Check equality of two QualitativeTimePoint instances
* \return True if they are equal, false otherwise
*/
virtual bool operator==(const QualitativeTimePoint& other) const;
/**
* Check if two QualitativeTimePoint instances are distinct
* \return True if they are distinct, false otherwise
*/
bool operator!=(const QualitativeTimePoint& other) const { return ! (*this == other); }
/**
* Get class name
*/
virtual std::string getClassName() const { return "QualitativeTimePoint"; }
/**
* Stringify object
*/
virtual std::string toString(uint32_t indent) const { return std::string(indent,' ') + mLabel; }
private:
virtual Vertex* getClone() const { return new QualitativeTimePoint(*this); }
};
} // end namespace point_algebra
} // end namespace temporal
} // end namespace solvers
} // end namespace templ
#endif // TEMPL_SOLVERS_TEMPORAL_POINT_ALGEBRA_QUALITATIVE_TIME_POINT_HPP
| 29.651163
| 113
| 0.717255
|
tomcreutz
|
89c1670532dfc7e5456bbf05a770a97ea580a086
| 16,394
|
cc
|
C++
|
network/slirp/bootp.cc
|
rahimazizarab/sand-dyn75
|
f5462445ce53b9b769e295928cc1e9203bce78b1
|
[
"BSD-2-Clause"
] | null | null | null |
network/slirp/bootp.cc
|
rahimazizarab/sand-dyn75
|
f5462445ce53b9b769e295928cc1e9203bce78b1
|
[
"BSD-2-Clause"
] | null | null | null |
network/slirp/bootp.cc
|
rahimazizarab/sand-dyn75
|
f5462445ce53b9b769e295928cc1e9203bce78b1
|
[
"BSD-2-Clause"
] | null | null | null |
/////////////////////////////////////////////////////////////////////////
// $Id: bootp.cc 12269 2014-04-02 17:38:09Z vruppert $
/////////////////////////////////////////////////////////////////////////
/*
* BOOTP/DHCP server (ported from Qemu)
* Bochs additions: parameter list and some other options
*
* Copyright (c) 2004 Fabrice Bellard
*
* 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 "slirp.h"
#if BX_NETWORKING && BX_NETMOD_SLIRP
/* XXX: only DHCP is supported */
#define LEASE_TIME (24 * 3600)
typedef struct {
int msg_type;
bx_bool found_srv_id;
struct in_addr req_addr;
uint8_t *params;
uint8_t params_len;
char *hostname;
uint32_t lease_time;
} dhcp_options_t;
static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE };
#ifdef DEBUG
#define DPRINTF(fmt, ...) \
do if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## __VA_ARGS__); fflush(dfd); } while (0)
#else
#define DPRINTF(fmt, ...) do{}while(0)
#endif
static BOOTPClient *get_new_addr(Slirp *slirp, struct in_addr *paddr,
const uint8_t *macaddr)
{
BOOTPClient *bc;
int i;
for(i = 0; i < NB_BOOTP_CLIENTS; i++) {
bc = &slirp->bootp_clients[i];
if (!bc->allocated || !memcmp(macaddr, bc->macaddr, 6))
goto found;
}
return NULL;
found:
bc = &slirp->bootp_clients[i];
bc->allocated = 1;
paddr->s_addr = slirp->vdhcp_startaddr.s_addr + htonl(i);
return bc;
}
static BOOTPClient *request_addr(Slirp *slirp, const struct in_addr *paddr,
const uint8_t *macaddr)
{
uint32_t req_addr = ntohl(paddr->s_addr);
uint32_t dhcp_addr = ntohl(slirp->vdhcp_startaddr.s_addr);
BOOTPClient *bc;
if (req_addr >= dhcp_addr &&
req_addr < (dhcp_addr + NB_BOOTP_CLIENTS)) {
bc = &slirp->bootp_clients[req_addr - dhcp_addr];
if (!bc->allocated || !memcmp(macaddr, bc->macaddr, 6)) {
bc->allocated = 1;
return bc;
}
}
return NULL;
}
static BOOTPClient *find_addr(Slirp *slirp, struct in_addr *paddr,
const uint8_t *macaddr)
{
BOOTPClient *bc;
int i;
for(i = 0; i < NB_BOOTP_CLIENTS; i++) {
if (!memcmp(macaddr, slirp->bootp_clients[i].macaddr, 6))
goto found;
}
return NULL;
found:
bc = &slirp->bootp_clients[i];
bc->allocated = 1;
paddr->s_addr = slirp->vdhcp_startaddr.s_addr + htonl(i);
return bc;
}
static void dhcp_decode(Slirp *slirp, const struct bootp_t *bp, dhcp_options_t *opts)
{
const uint8_t *p, *p_end;
uint16_t defsize, maxsize;
int len, tag;
char msg[80];
memset(opts, 0, sizeof(dhcp_options_t));
p = bp->bp_vend;
p_end = p + DHCP_OPT_LEN;
if (memcmp(p, rfc1533_cookie, 4) != 0)
return;
p += 4;
while (p < p_end) {
tag = p[0];
if (tag == RFC1533_PAD) {
p++;
} else if (tag == RFC1533_END) {
break;
} else {
p++;
if (p >= p_end)
break;
len = *p++;
DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
switch(tag) {
case RFC2132_MSG_TYPE:
if (len >= 1)
opts->msg_type = p[0];
break;
case RFC2132_REQ_ADDR:
if (len >= 4) {
memcpy(&(opts->req_addr.s_addr), p, 4);
}
break;
case RFC2132_SRV_ID:
if (len >= 4) {
if (!memcmp(p, &slirp->vhost_addr, 4)) {
opts->found_srv_id = 1;
}
}
break;
case RFC2132_PARAM_LIST:
if (len >= 1) {
opts->params = (uint8_t*)malloc(len);
memcpy(opts->params, p, len);
opts->params_len = len;
}
break;
case RFC1533_HOSTNAME:
if (len >= 1) {
opts->hostname = (char*)malloc(len + 1);
memcpy(opts->hostname, p, len);
opts->hostname[len] = 0;
}
break;
case RFC2132_LEASE_TIME:
if (len == 4) {
memcpy(&opts->lease_time, p, len);
}
break;
case RFC2132_MAX_SIZE:
if (len == 2) {
memcpy(&maxsize, p, len);
defsize = sizeof(struct bootp_t) - sizeof(struct ip) - sizeof(struct udphdr);
if (ntohs(maxsize) < defsize) {
sprintf(msg, "DHCP server: RFB2132_MAX_SIZE=%u not supported yet", ntohs(maxsize));
slirp_warning(slirp, msg);
}
}
break;
default:
sprintf(msg, "DHCP server: option %d not supported yet", tag);
slirp_warning(slirp, msg);
break;
}
p += len;
}
}
if ((opts->msg_type == DHCPREQUEST) && (opts->req_addr.s_addr == htonl(0L)) &&
bp->bp_ciaddr.s_addr) {
memcpy(&(opts->req_addr.s_addr), &bp->bp_ciaddr, 4);
}
}
static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
{
BOOTPClient *bc = NULL;
struct mbuf *m;
struct bootp_t *rbp;
struct sockaddr_in saddr, daddr;
struct in_addr bcast_addr;
int val;
uint8_t *q, *pp, plen, dhcp_def_params_len;
uint8_t client_ethaddr[ETH_ALEN];
uint8_t dhcp_def_params[8];
bx_bool dhcp_def_params_valid = 0;
dhcp_options_t dhcp_opts;
size_t spaceleft;
char msg[80];
/* extract exact DHCP msg type */
dhcp_decode(slirp, bp, &dhcp_opts);
DPRINTF("bootp packet op=%d msgtype=%d", bp->bp_op, dhcp_opts.msg_type);
if (dhcp_opts.req_addr.s_addr != htonl(0L))
DPRINTF(" req_addr=%08x\n", ntohl(dhcp_opts.req_addr.s_addr));
else
DPRINTF("\n");
if (dhcp_opts.msg_type == 0)
dhcp_opts.msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */
if (dhcp_opts.msg_type != DHCPDISCOVER &&
dhcp_opts.msg_type != DHCPREQUEST)
return;
/* Get client's hardware address from bootp request */
memcpy(client_ethaddr, bp->bp_hwaddr, ETH_ALEN);
m = m_get(slirp);
if (!m) {
return;
}
m->m_data += IF_MAXLINKHDR;
rbp = (struct bootp_t *)m->m_data;
m->m_data += sizeof(struct udpiphdr);
memset(rbp, 0, sizeof(struct bootp_t));
dhcp_def_params_len = 0;
if (dhcp_opts.msg_type == DHCPDISCOVER) {
if (dhcp_opts.req_addr.s_addr != htonl(0L)) {
bc = request_addr(slirp, &dhcp_opts.req_addr, client_ethaddr);
if (bc) {
daddr.sin_addr = dhcp_opts.req_addr;
}
}
if (!bc) {
new_addr:
bc = get_new_addr(slirp, &daddr.sin_addr, client_ethaddr);
if (!bc) {
DPRINTF("no address left\n");
return;
}
}
memcpy(bc->macaddr, client_ethaddr, ETH_ALEN);
dhcp_def_params[0] = RFC2132_LEASE_TIME;
dhcp_def_params[1] = RFC2132_SRV_ID;
dhcp_def_params_len = 2;
if (*slirp->client_hostname || (dhcp_opts.hostname != NULL)) {
dhcp_def_params[dhcp_def_params_len++] = RFC1533_HOSTNAME;
}
dhcp_def_params_valid = 1;
} else if (dhcp_opts.req_addr.s_addr != htonl(0L)) {
bc = request_addr(slirp, &dhcp_opts.req_addr, client_ethaddr);
if (bc) {
daddr.sin_addr = dhcp_opts.req_addr;
memcpy(bc->macaddr, client_ethaddr, ETH_ALEN);
dhcp_def_params[0] = RFC2132_LEASE_TIME;
dhcp_def_params_len = 1;
if (!dhcp_opts.found_srv_id) {
dhcp_def_params[dhcp_def_params_len++] = RFC2132_SRV_ID;
}
dhcp_def_params_valid = 1;
} else {
/* DHCPNAKs should be sent to broadcast */
daddr.sin_addr.s_addr = 0xffffffff;
}
} else {
bc = find_addr(slirp, &daddr.sin_addr, bp->bp_hwaddr);
if (!bc) {
/* if never assigned, behaves as if it was already
assigned (windows fix because it remembers its address) */
goto new_addr;
}
}
/* Update ARP table for this IP address */
arp_table_add(slirp, daddr.sin_addr.s_addr, client_ethaddr);
saddr.sin_addr = slirp->vhost_addr;
saddr.sin_port = htons(BOOTP_SERVER);
daddr.sin_port = htons(BOOTP_CLIENT);
rbp->bp_op = BOOTP_REPLY;
rbp->bp_xid = bp->bp_xid;
rbp->bp_htype = 1;
rbp->bp_hlen = 6;
memcpy(rbp->bp_hwaddr, bp->bp_hwaddr, ETH_ALEN);
rbp->bp_yiaddr = daddr.sin_addr; /* Client IP address */
rbp->bp_siaddr = saddr.sin_addr; /* Server IP address */
q = rbp->bp_vend;
memcpy(q, rfc1533_cookie, 4);
q += 4;
if (bc) {
DPRINTF("%s addr=%08x\n",
(dhcp_opts.msg_type == DHCPDISCOVER) ? "offered" : "ack'ed",
ntohl(daddr.sin_addr.s_addr));
if (dhcp_opts.msg_type == DHCPDISCOVER) {
*q++ = RFC2132_MSG_TYPE;
*q++ = 1;
*q++ = DHCPOFFER;
} else /* DHCPREQUEST */ {
*q++ = RFC2132_MSG_TYPE;
*q++ = 1;
*q++ = DHCPACK;
}
if (slirp->bootp_filename)
snprintf((char *)rbp->bp_file, sizeof(rbp->bp_file), "%s",
slirp->bootp_filename);
strcpy((char *)rbp->bp_sname, "slirp");
pp = dhcp_opts.params;
plen = dhcp_opts.params_len;
while (1) {
while (plen-- > 0) {
spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
if (spaceleft < 6) break;
switch (*pp++) {
case RFC1533_NETMASK:
*q++ = RFC1533_NETMASK;
*q++ = 4;
memcpy(q, &slirp->vnetwork_mask, 4);
q += 4;
break;
case RFC1533_GATEWAY:
if (!slirp->restricted) {
*q++ = RFC1533_GATEWAY;
*q++ = 4;
memcpy(q, &saddr.sin_addr, 4);
q += 4;
}
break;
case RFC1533_DNS:
if (!slirp->restricted) {
*q++ = RFC1533_DNS;
*q++ = 4;
memcpy(q, &slirp->vnameserver_addr, 4);
q += 4;
}
break;
case RFC1533_HOSTNAME:
val = 0;
if (*slirp->client_hostname) {
val = strlen(slirp->client_hostname);
} else if (dhcp_opts.hostname != NULL) {
val = strlen(dhcp_opts.hostname);
}
if ((val > 0) && (spaceleft >= (size_t)(val + 2))) {
*q++ = RFC1533_HOSTNAME;
*q++ = val;
if (*slirp->client_hostname) {
memcpy(q, slirp->client_hostname, val);
} else {
memcpy(q, dhcp_opts.hostname, val);
}
q += val;
}
if (dhcp_opts.hostname != NULL) {
free(dhcp_opts.hostname);
dhcp_opts.hostname = NULL;
}
break;
case RFC1533_INTBROADCAST:
*q++ = RFC1533_INTBROADCAST;
*q++ = 4;
bcast_addr.s_addr = slirp->vhost_addr.s_addr | ~slirp->vnetwork_mask.s_addr;
memcpy(q, &bcast_addr, 4);
q += 4;
break;
case RFC2132_LEASE_TIME:
*q++ = RFC2132_LEASE_TIME;
*q++ = 4;
if ((dhcp_opts.lease_time != 0) &&
(ntohl(dhcp_opts.lease_time) < LEASE_TIME)) {
memcpy(q, &dhcp_opts.lease_time, 4);
} else {
val = htonl(LEASE_TIME);
memcpy(q, &val, 4);
}
q += 4;
dhcp_opts.lease_time = 0;
break;
case RFC2132_SRV_ID:
*q++ = RFC2132_SRV_ID;
*q++ = 4;
memcpy(q, &saddr.sin_addr, 4);
q += 4;
break;
case RFC2132_RENEWAL_TIME:
*q++ = RFC2132_RENEWAL_TIME;
*q++ = 4;
val = htonl(600);
memcpy(q, &val, 4);
q += 4;
break;
case RFC2132_REBIND_TIME:
*q++ = RFC2132_REBIND_TIME;
*q++ = 4;
val = htonl(1800);
memcpy(q, &val, 4);
q += 4;
break;
default:
sprintf(msg, "DHCP server: requested parameter %u not supported yet",
*(pp-1));
slirp_warning(slirp, msg);
}
}
if (!dhcp_def_params_valid) break;
pp = dhcp_def_params;
plen = dhcp_def_params_len;
dhcp_def_params_valid = 0;
}
if (slirp->vdnssearch) {
spaceleft = sizeof(rbp->bp_vend) - (q - rbp->bp_vend);
val = slirp->vdnssearch_len;
if (val + 1 > (int)spaceleft) {
slirp_warning(slirp, "DHCP packet size exceeded, omitting domain-search option.");
} else {
memcpy(q, slirp->vdnssearch, val);
q += val;
}
}
} else {
static const char nak_msg[] = "requested address not available";
DPRINTF("nak'ed addr=%08x\n", ntohl(preq_addr.s_addr));
*q++ = RFC2132_MSG_TYPE;
*q++ = 1;
*q++ = DHCPNAK;
*q++ = RFC2132_MESSAGE;
*q++ = sizeof(nak_msg) - 1;
memcpy(q, nak_msg, sizeof(nak_msg) - 1);
q += sizeof(nak_msg) - 1;
}
*q = RFC1533_END;
daddr.sin_addr.s_addr = 0xffffffffu;
if (dhcp_opts.params != NULL) free(dhcp_opts.params);
m->m_len = sizeof(struct bootp_t) -
sizeof(struct ip) - sizeof(struct udphdr);
udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
}
void bootp_input(struct mbuf *m)
{
struct bootp_t *bp = mtod(m, struct bootp_t *);
if (bp->bp_op == BOOTP_REQUEST) {
bootp_reply(m->slirp, bp);
}
}
#endif
| 34.22547
| 107
| 0.485909
|
rahimazizarab
|
89c340ae80e58b5779e1aa36976412f7276cfd8d
| 3,389
|
cpp
|
C++
|
VC2010Samples/MFC/general/dlgcbr32/Dlgcbar.cpp
|
alonmm/VCSamples
|
6aff0b4902f5027164d593540fcaa6601a0407c3
|
[
"MIT"
] | 300
|
2019-05-09T05:32:33.000Z
|
2022-03-31T20:23:24.000Z
|
VC2010Samples/MFC/general/dlgcbr32/Dlgcbar.cpp
|
JaydenChou/VCSamples
|
9e1d4475555b76a17a3568369867f1d7b6cc6126
|
[
"MIT"
] | 9
|
2016-09-19T18:44:26.000Z
|
2018-10-26T10:20:05.000Z
|
VC2010Samples/MFC/general/dlgcbr32/Dlgcbar.cpp
|
JaydenChou/VCSamples
|
9e1d4475555b76a17a3568369867f1d7b6cc6126
|
[
"MIT"
] | 633
|
2019-05-08T07:34:12.000Z
|
2022-03-30T04:38:28.000Z
|
// Dlgcbar.cpp : Defines the class behaviors for the application.
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "resource.h"
#include "dlgcbar.h"
#include "aboutdlg.h"
#include "wndlist.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTheApp
CTheApp theApp;
BEGIN_MESSAGE_MAP(CTheApp, CWinApp)
//{{AFX_MSG_MAP(CTheApp)
ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTheApp Constructors/Destructors
CTheApp::CTheApp()
{
}
CTheApp::~CTheApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// CTheApp::FirstInstance
// FirstInstance checks for an existing instance of the application.
// If one is found, it is activated.
//
// This function uses a technique similar to that described in KB
// article Q109175 to locate the previous instance of the application.
// However, instead of searching for a matching class name, it searches
// for a matching caption. This allows us to use the normal dialog
// class for our main window. It assumes that the AFX_IDS_APP_TITLE
// string resource matches the caption specified in the dialog template.
BOOL CTheApp::FirstInstance()
{
CString strCaption;
strCaption.LoadString(AFX_IDS_APP_TITLE);
CWnd* pwndFirst = CWnd::FindWindow((LPCTSTR)(DWORD_PTR)WC_DIALOG,
strCaption);
if (pwndFirst)
{
// another instance is already running - activate it
CWnd* pwndPopup = pwndFirst->GetLastActivePopup();
pwndFirst->SetForegroundWindow();
if (pwndFirst->IsIconic())
pwndFirst->ShowWindow(SW_SHOWNORMAL);
if (pwndFirst != pwndPopup)
pwndPopup->SetForegroundWindow();
return FALSE;
}
else
{
// this is the first instance
return TRUE;
}
}
/////////////////////////////////////////////////////////////////////////////
// CTheApp::InitInstance
// InitInstance performs per-instance initialization of the DLGCBAR
// application. If an instance of the application is already running,
// it activates that instance. Otherwise, it creates the modeless
// dialog which serves as the application's interface.
BOOL CTheApp::InitInstance()
{
if (!FirstInstance())
return FALSE;
// Create main window
TRY
{
CWndListDlg* pMainWnd = new CWndListDlg;
m_pMainWnd = pMainWnd;
return pMainWnd->Create();
}
CATCH_ALL(e)
{
TRACE0("Failed to create main dialog\n");
return FALSE;
}
END_CATCH_ALL
}
/////////////////////////////////////////////////////////////////////////////
// CTheApp::OnHelpAbout
// OnHelpAbout displays the application's about box.
void CTheApp::OnHelpAbout()
{
CAboutDlg dlg(m_pMainWnd);
dlg.DoModal();
}
| 27.552846
| 77
| 0.643848
|
alonmm
|
89c67bff10e8091cc9f928b4191649d6f988b318
| 440
|
cpp
|
C++
|
DSA/Notes and examples/comparator.cpp
|
thefool76/hacktoberfest2021
|
237751e17a4fc325ded29fca013fb9f5853cd27c
|
[
"CC0-1.0"
] | 448
|
2021-10-01T04:24:14.000Z
|
2022-03-06T14:34:20.000Z
|
DSA/Notes and examples/comparator.cpp
|
Chanaka-Madushan-Herath/hacktoberfest2021
|
8473df9e058ccb6049720dd372342e0ea60f0e59
|
[
"CC0-1.0"
] | 282
|
2021-10-01T04:29:06.000Z
|
2022-03-07T12:42:57.000Z
|
DSA/Notes and examples/comparator.cpp
|
Chanaka-Madushan-Herath/hacktoberfest2021
|
8473df9e058ccb6049720dd372342e0ea60f0e59
|
[
"CC0-1.0"
] | 1,807
|
2021-10-01T04:24:02.000Z
|
2022-03-28T04:51:25.000Z
|
#include <iostream>
#include<algorithm>
using namespace std;
bool compare(int a,int b)
{
//sorts array in decreasing order
return a>b;
}
int main() {
int a[]={10,2,4,5};
cout<<"given array:"<<endl;
for(int i=0;i<4;i++)
{
cout<<a[i]<<endl;
}
//adding function as parameter
sort(a,a+4,compare);
cout<<"sorted array:"<<endl;
for(int i=0;i<4;i++)
{
cout<<a[i]<<endl;
}
}
| 15.714286
| 37
| 0.536364
|
thefool76
|
89cc12b6fd4de91b2c89b339bf96667e19205a32
| 7,018
|
cpp
|
C++
|
HiveCore/src/Buffer/BufferVolumeData.cpp
|
digirea/HIVE
|
8896b0cc858c1ad0683888b925f71c0f0d71bf9d
|
[
"MIT"
] | null | null | null |
HiveCore/src/Buffer/BufferVolumeData.cpp
|
digirea/HIVE
|
8896b0cc858c1ad0683888b925f71c0f0d71bf9d
|
[
"MIT"
] | null | null | null |
HiveCore/src/Buffer/BufferVolumeData.cpp
|
digirea/HIVE
|
8896b0cc858c1ad0683888b925f71c0f0d71bf9d
|
[
"MIT"
] | null | null | null |
/**
* @file BufferVolumeData.cpp
* BufferVolumeDataクラス
*/
#include "BufferVolumeData.h"
#include "Buffer.h"
#include <vector>
#include <algorithm>
namespace {
inline float remap(float x, const float *table, int n) {
int idx = x * n;
idx = (std::max)((std::min)(n - 1, idx), 0);
return table[idx];
}
} // namespace
/**
* BufferVolumeDataクラス
*/
class BufferVolumeData::Impl
{
private:
int m_dim[3];
int m_comp;
bool m_isNonUniform;
RefPtr<FloatBuffer> m_buffer;
RefPtr<FloatBuffer> m_spacingX;
RefPtr<FloatBuffer> m_spacingY;
RefPtr<FloatBuffer> m_spacingZ;
public:
/// コンストラクタ
Impl()
{
Clear();
}
/// デストラクタ
~Impl()
{
Clear();
}
/// コンストラクタ
Impl(BufferVolumeData* inst)
{
this->m_dim[0] = inst->Width();
this->m_dim[1] = inst->Height();
this->m_dim[2] = inst->Depth();
this->m_comp = inst->Component();
this->m_buffer = inst->Buffer();
this->m_isNonUniform = inst->NonUniform();
this->m_spacingX = inst->SpacingX();
this->m_spacingY = inst->SpacingY();
this->m_spacingZ = inst->SpacingZ();
}
/**
* BufferVolumeDataの作成
* @param w Widthサイズ
* @param h Heightサイズ
* @param d Depthサイズ
* @param component component数
* @param nonUniform flag for non-uniform volume
*/
void Create(int w, int h, int d, int component, bool nonUniform)
{
this->m_dim[0] = w;
this->m_dim[1] = h;
this->m_dim[2] = d;
this->m_comp = component;
FloatBuffer* buf = new FloatBuffer();
FloatBuffer* spacingX = new FloatBuffer();
FloatBuffer* spacingY = new FloatBuffer();
FloatBuffer* spacingZ = new FloatBuffer();
buf->Create(w * h * d * component);
this->m_buffer = buf;
spacingX->Create(w+1);
spacingY->Create(h+1);
spacingZ->Create(d+1);
this->m_spacingX = spacingX;
this->m_spacingY = spacingY;
this->m_spacingZ = spacingZ;
this->m_isNonUniform = nonUniform;
}
/// メンバクリア
void Clear()
{
m_dim[0] = m_dim[1] = m_dim[2] = 0;
m_comp = 0;
m_buffer = new FloatBuffer();
m_isNonUniform = false;
}
/// デバッグ用
void print()
{
}
/**
* Width値取得
* @return Width値
*/
int Width() {
return m_dim[0];
}
/**
* Height値取得
* @return Height値
*/
int Height() {
return m_dim[1];
}
/**
* Depth値取得
* @return Depth値
*/
int Depth() {
return m_dim[2];
}
/**
* Component数取得
* @return Component数
*/
int Component() {
return m_comp;
}
/**
* ボリュームバッファ取得
* @return FloatBufferボリュームバッファへの参照
*/
FloatBuffer *Buffer() {
return m_buffer;
}
const float* Pointer() {
return m_buffer->GetBuffer();
}
/**
* NonUniformフラグ取得
* @return NonUniformフラグ値
*/
bool NonUniform() const {
return m_isNonUniform;
}
/// xスペースバッファを返す
FloatBuffer* SpacingX() {
return m_spacingX;
}
/// yスペースバッファを返す
FloatBuffer* SpacingY() {
return m_spacingY;
}
/// zスペースバッファを返す
FloatBuffer* SpacingZ() {
return m_spacingZ;
}
/**
* サンプリング
* @param ret サンプルされたボリュームバッファ値
* @param x X位置
* @param y Y位置
* @param z Z位置
*/
void Sample(float* ret, float x, float y, float z) {
float xx = x;
float yy = y;
float zz = z;
if (m_isNonUniform) {
// remap coordinate.
if (SpacingX()->GetNum() > 0) {
xx = remap(xx, static_cast<const float*>(SpacingX()->GetBuffer()), SpacingX()->GetNum());
}
if (SpacingX()->GetNum() > 0) {
yy = remap(yy, static_cast<const float*>(SpacingY()->GetBuffer()), SpacingY()->GetNum());
}
if (SpacingX()->GetNum() > 0) {
zz = remap(zz, static_cast<const float*>(SpacingZ()->GetBuffer()), SpacingZ()->GetNum());
}
}
size_t ix = (std::min)((std::max)((size_t)(xx * Width()), (size_t)(Width()-1)), (size_t)0);
size_t iy = (std::min)((std::max)((size_t)(yy * Height()), (size_t)(Height()-1)), (size_t)0);
size_t iz = (std::min)((std::max)((size_t)(zz * Depth()), (size_t)(Depth()-1)), (size_t)0);
size_t idx = Component() * (iz * Width() * Height() + iy * Width() + ix);
const float* buf = static_cast<const float*>(m_buffer->GetBuffer());
for (size_t c = 0; c < Component(); c++) {
ret[c] = buf[idx + c];
}
}
};
/// constructor
BufferVolumeData::BufferVolumeData() : BufferData(TYPE_VOLUME)
{
m_imp = new BufferVolumeData::Impl();
}
/// constructor
BufferVolumeData::BufferVolumeData(BufferVolumeData* inst) : BufferData(TYPE_VOLUME)
{
m_imp = new BufferVolumeData::Impl(inst);
}
/// destructor
BufferVolumeData::~BufferVolumeData()
{
delete m_imp;
}
BufferVolumeData* BufferVolumeData::CreateInstance()
{
return new BufferVolumeData();
}
/**
* BufferVolumeDataの作成
* @param w Widthサイズ
* @param h Heightサイズ
* @param d Depthサイズ
* @param component component数
* @param nonUniform non-uniform flag
*/
void BufferVolumeData::Create(int w, int h, int d, int component, bool nonUniform)
{
m_imp->Create(w, h, d, component, nonUniform);
}
/// メンバクリア
void BufferVolumeData::Clear()
{
m_imp->Clear();
}
/// デバッグ用
void BufferVolumeData::print()
{
m_imp->print();
}
/**
* Width値取得
* @return Width値
*/
int BufferVolumeData::Width() const {
return m_imp->Width();
}
/**
* Height値取得
* @return Height値
*/
int BufferVolumeData::Height() const {
return m_imp->Height();
}
/**
* Depth値取得
* @return Depth値
*/
int BufferVolumeData::Depth() const {
return m_imp->Depth();
}
/**
* Component数取得
* @return Component数
*/
int BufferVolumeData::Component() const {
return m_imp->Component();
}
/**
* ボリュームバッファ取得
* @return FloatBufferボリュームバッファへの参照
*/
FloatBuffer *BufferVolumeData::Buffer() const {
return m_imp->Buffer();
}
/**
* ボリュームバッファ取得
* @return FloatBufferボリュームバッファへの参照
*/
const float* BufferVolumeData::Pointer() const {
return m_imp->Pointer();
}
/**
* NonUniformフラグ取得
* @return NonUniformフラグ値
*/
bool BufferVolumeData::NonUniform() const {
return m_imp->NonUniform();
}
/// xスペースバッファを返す
FloatBuffer* BufferVolumeData::SpacingX() {
return m_imp->SpacingX();
}
/// yスペースバッファを返す
FloatBuffer* BufferVolumeData::SpacingY() {
return m_imp->SpacingY();
}
/// zスペースバッファを返す
FloatBuffer* BufferVolumeData::SpacingZ() {
return m_imp->SpacingZ();
}
/**
* サンプリング
* @param ret サンプルされたボリュームバッファ値
* @param x X位置
* @param y Y位置
* @param z Z位置
*/
void BufferVolumeData::Sample(float* ret, float x, float y, float z) {
m_imp->Sample(ret, x, y, z);
}
| 20.051429
| 105
| 0.568681
|
digirea
|
89ce1eb64b6faa1b0bcb2dc61cd980cfe26ff6b7
| 571,683
|
cc
|
C++
|
ns-allinone-3.27/ns-3.27/build/src/lr-wpan/bindings/ns3module.cc
|
zack-braun/4607_NS
|
43c8fb772e5552fb44bd7cd34173e73e3fb66537
|
[
"MIT"
] | null | null | null |
ns-allinone-3.27/ns-3.27/build/src/lr-wpan/bindings/ns3module.cc
|
zack-braun/4607_NS
|
43c8fb772e5552fb44bd7cd34173e73e3fb66537
|
[
"MIT"
] | null | null | null |
ns-allinone-3.27/ns-3.27/build/src/lr-wpan/bindings/ns3module.cc
|
zack-braun/4607_NS
|
43c8fb772e5552fb44bd7cd34173e73e3fb66537
|
[
"MIT"
] | null | null | null |
#include "ns3module.h"
static PyMethodDef lr_wpan_FatalImpl_functions[] = {
{NULL, NULL, 0, NULL}
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_FatalImpl_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan.FatalImpl",
NULL,
-1,
lr_wpan_FatalImpl_functions,
};
#endif
static PyObject *
initlr_wpan_FatalImpl(void)
{
PyObject *m;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_FatalImpl_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan.FatalImpl", lr_wpan_FatalImpl_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
return m;
}
static PyMethodDef lr_wpan_Hash_Function_functions[] = {
{NULL, NULL, 0, NULL}
};
/* --- classes --- */
PyTypeObject *_PyNs3HashFunctionFnv1a_Type;
PyTypeObject *_PyNs3HashFunctionHash32_Type;
PyTypeObject *_PyNs3HashFunctionHash64_Type;
PyTypeObject *_PyNs3HashFunctionMurmur3_Type;
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_Hash_Function_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan.Hash.Function",
NULL,
-1,
lr_wpan_Hash_Function_functions,
};
#endif
static PyObject *
initlr_wpan_Hash_Function(void)
{
PyObject *m;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_Hash_Function_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan.Hash.Function", lr_wpan_Hash_Function_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
/* Import the 'ns3::Hash::Function::Fnv1a' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return NULL;
}
_PyNs3HashFunctionFnv1a_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Fnv1a");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Hash::Function::Hash32' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return NULL;
}
_PyNs3HashFunctionHash32_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Hash32");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Hash::Function::Hash64' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return NULL;
}
_PyNs3HashFunctionHash64_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Hash64");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Hash::Function::Murmur3' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return NULL;
}
_PyNs3HashFunctionMurmur3_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Murmur3");
if (PyErr_Occurred()) PyErr_Clear();
}
return m;
}
static PyMethodDef lr_wpan_Hash_functions[] = {
{NULL, NULL, 0, NULL}
};
/* --- classes --- */
PyTypeObject *_PyNs3HashImplementation_Type;
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_Hash_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan.Hash",
NULL,
-1,
lr_wpan_Hash_functions,
};
#endif
static PyObject *
initlr_wpan_Hash(void)
{
PyObject *m;
PyObject *submodule;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_Hash_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan.Hash", lr_wpan_Hash_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
/* Import the 'ns3::Hash::Implementation' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return NULL;
}
_PyNs3HashImplementation_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Implementation");
if (PyErr_Occurred()) PyErr_Clear();
}
submodule = initlr_wpan_Hash_Function();
if (submodule == NULL) {
return NULL;
}
Py_INCREF(submodule);
PyModule_AddObject(m, (char *) "Function", submodule);
return m;
}
static PyMethodDef lr_wpan_TracedValueCallback_functions[] = {
{NULL, NULL, 0, NULL}
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_TracedValueCallback_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan.TracedValueCallback",
NULL,
-1,
lr_wpan_TracedValueCallback_functions,
};
#endif
static PyObject *
initlr_wpan_TracedValueCallback(void)
{
PyObject *m;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_TracedValueCallback_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan.TracedValueCallback", lr_wpan_TracedValueCallback_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
return m;
}
static PyMethodDef lr_wpan_internal_functions[] = {
{NULL, NULL, 0, NULL}
};
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_internal_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan.internal",
NULL,
-1,
lr_wpan_internal_functions,
};
#endif
static PyObject *
initlr_wpan_internal(void)
{
PyObject *m;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_internal_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan.internal", lr_wpan_internal_functions, NULL);
#endif
if (m == NULL) {
return NULL;
}
return m;
}
static PyMethodDef lr_wpan_functions[] = {
{NULL, NULL, 0, NULL}
};
/* --- classes --- */
PyTypeObject *_PyNs3Address_Type;
std::map<void*, PyObject*> *_PyNs3Address_wrapper_registry;
PyTypeObject *_PyNs3AsciiTraceHelper_Type;
std::map<void*, PyObject*> *_PyNs3AsciiTraceHelper_wrapper_registry;
PyTypeObject *_PyNs3AsciiTraceHelperForDevice_Type;
std::map<void*, PyObject*> *_PyNs3AsciiTraceHelperForDevice_wrapper_registry;
PyTypeObject *_PyNs3AttributeConstructionList_Type;
std::map<void*, PyObject*> *_PyNs3AttributeConstructionList_wrapper_registry;
PyTypeObject *_PyNs3AttributeConstructionListItem_Type;
std::map<void*, PyObject*> *_PyNs3AttributeConstructionListItem_wrapper_registry;
PyTypeObject *_PyNs3Buffer_Type;
std::map<void*, PyObject*> *_PyNs3Buffer_wrapper_registry;
PyTypeObject *_PyNs3BufferIterator_Type;
std::map<void*, PyObject*> *_PyNs3BufferIterator_wrapper_registry;
PyTypeObject *_PyNs3ByteTagIterator_Type;
std::map<void*, PyObject*> *_PyNs3ByteTagIterator_wrapper_registry;
PyTypeObject *_PyNs3ByteTagIteratorItem_Type;
std::map<void*, PyObject*> *_PyNs3ByteTagIteratorItem_wrapper_registry;
PyTypeObject *_PyNs3ByteTagList_Type;
std::map<void*, PyObject*> *_PyNs3ByteTagList_wrapper_registry;
PyTypeObject *_PyNs3ByteTagListIterator_Type;
std::map<void*, PyObject*> *_PyNs3ByteTagListIterator_wrapper_registry;
PyTypeObject *_PyNs3ByteTagListIteratorItem_Type;
std::map<void*, PyObject*> *_PyNs3ByteTagListIteratorItem_wrapper_registry;
PyTypeObject *_PyNs3CallbackBase_Type;
std::map<void*, PyObject*> *_PyNs3CallbackBase_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3AttributeAccessor_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3AttributeAccessor_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3AttributeChecker_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3AttributeChecker_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3AttributeValue_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3AttributeValue_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3CallbackImplBase_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3CallbackImplBase_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3EventImpl_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3EventImpl_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3HashImplementation_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3HashImplementation_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3NixVector_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3NixVector_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3Packet_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3Packet_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_wrapper_registry;
PyTypeObject *_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_Type;
std::map<void*, PyObject*> *_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_wrapper_registry;
PyTypeObject *_PyNs3EventId_Type;
std::map<void*, PyObject*> *_PyNs3EventId_wrapper_registry;
PyTypeObject *_PyNs3Hasher_Type;
std::map<void*, PyObject*> *_PyNs3Hasher_wrapper_registry;
PyTypeObject *_PyNs3Ipv4Address_Type;
std::map<void*, PyObject*> *_PyNs3Ipv4Address_wrapper_registry;
PyTypeObject *_PyNs3Ipv4Mask_Type;
std::map<void*, PyObject*> *_PyNs3Ipv4Mask_wrapper_registry;
PyTypeObject *_PyNs3Ipv6Address_Type;
std::map<void*, PyObject*> *_PyNs3Ipv6Address_wrapper_registry;
PyTypeObject *_PyNs3Ipv6Prefix_Type;
std::map<void*, PyObject*> *_PyNs3Ipv6Prefix_wrapper_registry;
PyTypeObject *_PyNs3Mac16Address_Type;
std::map<void*, PyObject*> *_PyNs3Mac16Address_wrapper_registry;
PyTypeObject *_PyNs3Mac48Address_Type;
std::map<void*, PyObject*> *_PyNs3Mac48Address_wrapper_registry;
PyTypeObject *_PyNs3Mac64Address_Type;
std::map<void*, PyObject*> *_PyNs3Mac64Address_wrapper_registry;
PyTypeObject *_PyNs3NetDeviceContainer_Type;
std::map<void*, PyObject*> *_PyNs3NetDeviceContainer_wrapper_registry;
PyTypeObject *_PyNs3NodeContainer_Type;
std::map<void*, PyObject*> *_PyNs3NodeContainer_wrapper_registry;
PyTypeObject *_PyNs3ObjectBase_Type;
std::map<void*, PyObject*> *_PyNs3ObjectBase_wrapper_registry;
PyTypeObject *_PyNs3ObjectDeleter_Type;
std::map<void*, PyObject*> *_PyNs3ObjectDeleter_wrapper_registry;
PyTypeObject *_PyNs3ObjectFactory_Type;
std::map<void*, PyObject*> *_PyNs3ObjectFactory_wrapper_registry;
PyTypeObject *_PyNs3PacketMetadata_Type;
std::map<void*, PyObject*> *_PyNs3PacketMetadata_wrapper_registry;
PyTypeObject *_PyNs3PacketMetadataItem_Type;
std::map<void*, PyObject*> *_PyNs3PacketMetadataItem_wrapper_registry;
PyTypeObject *_PyNs3PacketMetadataItemIterator_Type;
std::map<void*, PyObject*> *_PyNs3PacketMetadataItemIterator_wrapper_registry;
PyTypeObject *_PyNs3PacketTagIterator_Type;
std::map<void*, PyObject*> *_PyNs3PacketTagIterator_wrapper_registry;
PyTypeObject *_PyNs3PacketTagIteratorItem_Type;
std::map<void*, PyObject*> *_PyNs3PacketTagIteratorItem_wrapper_registry;
PyTypeObject *_PyNs3PacketTagList_Type;
std::map<void*, PyObject*> *_PyNs3PacketTagList_wrapper_registry;
PyTypeObject *_PyNs3PacketTagListTagData_Type;
std::map<void*, PyObject*> *_PyNs3PacketTagListTagData_wrapper_registry;
PyTypeObject *_PyNs3PcapFile_Type;
std::map<void*, PyObject*> *_PyNs3PcapFile_wrapper_registry;
PyTypeObject *_PyNs3PcapHelper_Type;
std::map<void*, PyObject*> *_PyNs3PcapHelper_wrapper_registry;
PyTypeObject *_PyNs3PcapHelperForDevice_Type;
std::map<void*, PyObject*> *_PyNs3PcapHelperForDevice_wrapper_registry;
PyTypeObject *_PyNs3SequenceNumber8_Type;
std::map<void*, PyObject*> *_PyNs3SequenceNumber8_wrapper_registry;
PyTypeObject *_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map;
PyTypeObject *_PyNs3Simulator_Type;
std::map<void*, PyObject*> *_PyNs3Simulator_wrapper_registry;
PyTypeObject *_PyNs3Tag_Type;
PyTypeObject *_PyNs3TagBuffer_Type;
std::map<void*, PyObject*> *_PyNs3TagBuffer_wrapper_registry;
PyTypeObject *_PyNs3TimeWithUnit_Type;
std::map<void*, PyObject*> *_PyNs3TimeWithUnit_wrapper_registry;
PyTypeObject *_PyNs3TracedValue__Ns3LrWpanMacState_Type;
std::map<void*, PyObject*> *_PyNs3TracedValue__Ns3LrWpanMacState_wrapper_registry;
PyTypeObject *_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_Type;
std::map<void*, PyObject*> *_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_wrapper_registry;
PyTypeObject *_PyNs3TypeId_Type;
std::map<void*, PyObject*> *_PyNs3TypeId_wrapper_registry;
PyTypeObject *_PyNs3TypeIdAttributeInformation_Type;
std::map<void*, PyObject*> *_PyNs3TypeIdAttributeInformation_wrapper_registry;
PyTypeObject *_PyNs3TypeIdTraceSourceInformation_Type;
std::map<void*, PyObject*> *_PyNs3TypeIdTraceSourceInformation_wrapper_registry;
PyTypeObject *_PyNs3Empty_Type;
std::map<void*, PyObject*> *_PyNs3Empty_wrapper_registry;
PyTypeObject *_PyNs3Int64x64_t_Type;
std::map<void*, PyObject*> *_PyNs3Int64x64_t_wrapper_registry;
PyTypeObject *_PyNs3Chunk_Type;
PyTypeObject *_PyNs3Header_Type;
PyTypeObject *_PyNs3Object_Type;
PyTypeObject *_PyNs3ObjectAggregateIterator_Type;
std::map<void*, PyObject*> *_PyNs3ObjectAggregateIterator_wrapper_registry;
PyTypeObject *_PyNs3PcapFileWrapper_Type;
PyTypeObject *_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map;
PyTypeObject *_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt___Type;
pybindgen::TypeMap *_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt____typeid_map;
PyTypeObject *_PyNs3SpectrumPhy_Type;
PyTypeObject *_PyNs3SpectrumSignalParameters_Type;
PyTypeObject *_PyNs3Time_Type;
std::map<void*, PyObject*> *_PyNs3Time_wrapper_registry;
PyTypeObject *_PyNs3TraceSourceAccessor_Type;
PyTypeObject *_PyNs3Trailer_Type;
PyTypeObject *_PyNs3AttributeAccessor_Type;
PyTypeObject *_PyNs3AttributeChecker_Type;
PyTypeObject *_PyNs3AttributeValue_Type;
PyTypeObject *_PyNs3BooleanChecker_Type;
PyTypeObject *_PyNs3BooleanValue_Type;
PyTypeObject *_PyNs3CallbackChecker_Type;
PyTypeObject *_PyNs3CallbackImplBase_Type;
PyTypeObject *_PyNs3CallbackValue_Type;
PyTypeObject *_PyNs3DoubleValue_Type;
PyTypeObject *_PyNs3EmptyAttributeAccessor_Type;
PyTypeObject *_PyNs3EmptyAttributeChecker_Type;
PyTypeObject *_PyNs3EmptyAttributeValue_Type;
PyTypeObject *_PyNs3EnumChecker_Type;
PyTypeObject *_PyNs3EnumValue_Type;
PyTypeObject *_PyNs3EventImpl_Type;
PyTypeObject *_PyNs3IntegerValue_Type;
PyTypeObject *_PyNs3Ipv4AddressChecker_Type;
PyTypeObject *_PyNs3Ipv4AddressValue_Type;
PyTypeObject *_PyNs3Ipv4MaskChecker_Type;
PyTypeObject *_PyNs3Ipv4MaskValue_Type;
PyTypeObject *_PyNs3Ipv6AddressChecker_Type;
PyTypeObject *_PyNs3Ipv6AddressValue_Type;
PyTypeObject *_PyNs3Ipv6PrefixChecker_Type;
PyTypeObject *_PyNs3Ipv6PrefixValue_Type;
PyTypeObject *_PyNs3Mac16AddressChecker_Type;
PyTypeObject *_PyNs3Mac16AddressValue_Type;
PyTypeObject *_PyNs3Mac48AddressChecker_Type;
PyTypeObject *_PyNs3Mac48AddressValue_Type;
PyTypeObject *_PyNs3Mac64AddressChecker_Type;
PyTypeObject *_PyNs3Mac64AddressValue_Type;
PyTypeObject *_PyNs3NetDevice_Type;
PyTypeObject *_PyNs3NixVector_Type;
PyTypeObject *_PyNs3Node_Type;
PyTypeObject *_PyNs3ObjectFactoryChecker_Type;
PyTypeObject *_PyNs3ObjectFactoryValue_Type;
PyTypeObject *_PyNs3OutputStreamWrapper_Type;
PyTypeObject *_PyNs3Packet_Type;
PyTypeObject *_PyNs3TimeValue_Type;
PyTypeObject *_PyNs3TypeIdChecker_Type;
PyTypeObject *_PyNs3TypeIdValue_Type;
PyTypeObject *_PyNs3UintegerValue_Type;
PyTypeObject *_PyNs3AddressChecker_Type;
PyTypeObject *_PyNs3AddressValue_Type;
PyTypeObject *_PyNs3CallbackImpl__Bool_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Ns3ObjectBase___star___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3LrWpanMacState_Ns3LrWpanMacState_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Double_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_char_Unsigned_char_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Const_ns3Address___amp___Ns3NetDevicePacketType_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Time_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
PyTypeObject *_PyNs3CallbackImpl__Void_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type;
std::map<void*, PyObject*> PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry;
static int
_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init__0(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper >();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init__1(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper >(*((PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__copy__(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *self)
{
PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *py_copy;
py_copy = PyObject_New(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper, &PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type);
py_copy->obj = new ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper >(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_dealloc(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry.end()) {
PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper > *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_richcompare (PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *PYBINDGEN_UNUSED(self), PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.DefaultDeleter__Ns3LrWpanInterferenceHelper", /* tp_name */
sizeof(PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"DefaultDeleter__Ns3LrWpanInterferenceHelper(arg0)\nDefaultDeleter__Ns3LrWpanInterferenceHelper()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3LrWpanEdPower_wrapper_registry;
static PyObject* _wrap_PyNs3LrWpanEdPower__get_averagePower(PyNs3LrWpanEdPower *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->averagePower);
return py_retval;
}
static int _wrap_PyNs3LrWpanEdPower__set_averagePower(PyNs3LrWpanEdPower *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->averagePower)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanEdPower__get_lastUpdate(PyNs3LrWpanEdPower *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Time *py_Time;
py_Time = PyObject_New(PyNs3Time, &PyNs3Time_Type);
py_Time->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Time->obj = new ns3::Time(self->obj->lastUpdate);
PyNs3Time_wrapper_registry[(void *) py_Time->obj] = (PyObject *) py_Time;
py_retval = Py_BuildValue((char *) "N", py_Time);
return py_retval;
}
static int _wrap_PyNs3LrWpanEdPower__set_lastUpdate(PyNs3LrWpanEdPower *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Time *tmp_Time;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3Time_Type, &tmp_Time)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->lastUpdate = *tmp_Time->obj;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanEdPower__get_measurementLength(PyNs3LrWpanEdPower *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Time *py_Time;
py_Time = PyObject_New(PyNs3Time, &PyNs3Time_Type);
py_Time->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Time->obj = new ns3::Time(self->obj->measurementLength);
PyNs3Time_wrapper_registry[(void *) py_Time->obj] = (PyObject *) py_Time;
py_retval = Py_BuildValue((char *) "N", py_Time);
return py_retval;
}
static int _wrap_PyNs3LrWpanEdPower__set_measurementLength(PyNs3LrWpanEdPower *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Time *tmp_Time;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3Time_Type, &tmp_Time)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->measurementLength = *tmp_Time->obj;
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3LrWpanEdPower__getsets[] = {
{
(char*) "lastUpdate", /* attribute name */
(getter) _wrap_PyNs3LrWpanEdPower__get_lastUpdate, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanEdPower__set_lastUpdate, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "averagePower", /* attribute name */
(getter) _wrap_PyNs3LrWpanEdPower__get_averagePower, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanEdPower__set_averagePower, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "measurementLength", /* attribute name */
(getter) _wrap_PyNs3LrWpanEdPower__get_measurementLength, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanEdPower__set_measurementLength, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3LrWpanEdPower__tp_init__0(PyNs3LrWpanEdPower *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanEdPower();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanEdPower__tp_init__1(PyNs3LrWpanEdPower *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanEdPower *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanEdPower_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanEdPower(*((PyNs3LrWpanEdPower *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanEdPower__tp_init(PyNs3LrWpanEdPower *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanEdPower__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanEdPower__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3LrWpanEdPower__copy__(PyNs3LrWpanEdPower *self)
{
PyNs3LrWpanEdPower *py_copy;
py_copy = PyObject_New(PyNs3LrWpanEdPower, &PyNs3LrWpanEdPower_Type);
py_copy->obj = new ns3::LrWpanEdPower(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3LrWpanEdPower_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanEdPower_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanEdPower__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanEdPower__tp_dealloc(PyNs3LrWpanEdPower *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3LrWpanEdPower_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3LrWpanEdPower_wrapper_registry.end()) {
PyNs3LrWpanEdPower_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::LrWpanEdPower *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanEdPower__tp_richcompare (PyNs3LrWpanEdPower *PYBINDGEN_UNUSED(self), PyNs3LrWpanEdPower *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanEdPower_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanEdPower_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanEdPower", /* tp_name */
sizeof(PyNs3LrWpanEdPower), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanEdPower__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanEdPower(arg0)\nLrWpanEdPower()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanEdPower__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanEdPower_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3LrWpanEdPower__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanEdPower__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry;
static PyObject* _wrap_PyNs3LrWpanPhyDataAndSymbolRates__get_bitRate(PyNs3LrWpanPhyDataAndSymbolRates *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->bitRate);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyDataAndSymbolRates__set_bitRate(PyNs3LrWpanPhyDataAndSymbolRates *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->bitRate)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyDataAndSymbolRates__get_symbolRate(PyNs3LrWpanPhyDataAndSymbolRates *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->symbolRate);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyDataAndSymbolRates__set_symbolRate(PyNs3LrWpanPhyDataAndSymbolRates *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->symbolRate)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3LrWpanPhyDataAndSymbolRates__getsets[] = {
{
(char*) "symbolRate", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyDataAndSymbolRates__get_symbolRate, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyDataAndSymbolRates__set_symbolRate, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "bitRate", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyDataAndSymbolRates__get_bitRate, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyDataAndSymbolRates__set_bitRate, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init__0(PyNs3LrWpanPhyDataAndSymbolRates *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyDataAndSymbolRates();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init__1(PyNs3LrWpanPhyDataAndSymbolRates *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanPhyDataAndSymbolRates *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanPhyDataAndSymbolRates_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyDataAndSymbolRates(*((PyNs3LrWpanPhyDataAndSymbolRates *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init(PyNs3LrWpanPhyDataAndSymbolRates *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3LrWpanPhyDataAndSymbolRates__copy__(PyNs3LrWpanPhyDataAndSymbolRates *self)
{
PyNs3LrWpanPhyDataAndSymbolRates *py_copy;
py_copy = PyObject_New(PyNs3LrWpanPhyDataAndSymbolRates, &PyNs3LrWpanPhyDataAndSymbolRates_Type);
py_copy->obj = new ns3::LrWpanPhyDataAndSymbolRates(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanPhyDataAndSymbolRates_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanPhyDataAndSymbolRates__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_dealloc(PyNs3LrWpanPhyDataAndSymbolRates *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry.end()) {
PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::LrWpanPhyDataAndSymbolRates *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_richcompare (PyNs3LrWpanPhyDataAndSymbolRates *PYBINDGEN_UNUSED(self), PyNs3LrWpanPhyDataAndSymbolRates *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanPhyDataAndSymbolRates_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanPhyDataAndSymbolRates_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanPhyDataAndSymbolRates", /* tp_name */
sizeof(PyNs3LrWpanPhyDataAndSymbolRates), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanPhyDataAndSymbolRates(arg0)\nLrWpanPhyDataAndSymbolRates()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanPhyDataAndSymbolRates_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3LrWpanPhyDataAndSymbolRates__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanPhyDataAndSymbolRates__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3LrWpanPhyPibAttributes_wrapper_registry;
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCCAMode(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->phyCCAMode);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCCAMode(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->phyCCAMode = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCurrentChannel(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->phyCurrentChannel);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCurrentChannel(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->phyCurrentChannel = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCurrentPage(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(self->obj->phyCurrentPage));
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCurrentPage(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "I", &self->obj->phyCurrentPage)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phyMaxFrameDuration(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(self->obj->phyMaxFrameDuration));
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phyMaxFrameDuration(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "I", &self->obj->phyMaxFrameDuration)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phySHRDuration(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(self->obj->phySHRDuration));
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phySHRDuration(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "I", &self->obj->phySHRDuration)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phySymbolsPerOctet(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->phySymbolsPerOctet);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phySymbolsPerOctet(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->phySymbolsPerOctet)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPibAttributes__get_phyTransmitPower(PyNs3LrWpanPhyPibAttributes *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->phyTransmitPower);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPibAttributes__set_phyTransmitPower(PyNs3LrWpanPhyPibAttributes *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->phyTransmitPower = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3LrWpanPhyPibAttributes__getsets[] = {
{
(char*) "phyCurrentPage", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCurrentPage, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCurrentPage, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phyTransmitPower", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phyTransmitPower, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phyTransmitPower, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phySymbolsPerOctet", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phySymbolsPerOctet, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phySymbolsPerOctet, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phyMaxFrameDuration", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phyMaxFrameDuration, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phyMaxFrameDuration, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phyCurrentChannel", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCurrentChannel, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCurrentChannel, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phyCCAMode", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phyCCAMode, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phyCCAMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phySHRDuration", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPibAttributes__get_phySHRDuration, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPibAttributes__set_phySHRDuration, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3LrWpanPhyPibAttributes__tp_init__0(PyNs3LrWpanPhyPibAttributes *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyPibAttributes();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanPhyPibAttributes__tp_init__1(PyNs3LrWpanPhyPibAttributes *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanPhyPibAttributes *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanPhyPibAttributes_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyPibAttributes(*((PyNs3LrWpanPhyPibAttributes *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanPhyPibAttributes__tp_init(PyNs3LrWpanPhyPibAttributes *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanPhyPibAttributes__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanPhyPibAttributes__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3LrWpanPhyPibAttributes__copy__(PyNs3LrWpanPhyPibAttributes *self)
{
PyNs3LrWpanPhyPibAttributes *py_copy;
py_copy = PyObject_New(PyNs3LrWpanPhyPibAttributes, &PyNs3LrWpanPhyPibAttributes_Type);
py_copy->obj = new ns3::LrWpanPhyPibAttributes(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3LrWpanPhyPibAttributes_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanPhyPibAttributes_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanPhyPibAttributes__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanPhyPibAttributes__tp_dealloc(PyNs3LrWpanPhyPibAttributes *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3LrWpanPhyPibAttributes_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3LrWpanPhyPibAttributes_wrapper_registry.end()) {
PyNs3LrWpanPhyPibAttributes_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::LrWpanPhyPibAttributes *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanPhyPibAttributes__tp_richcompare (PyNs3LrWpanPhyPibAttributes *PYBINDGEN_UNUSED(self), PyNs3LrWpanPhyPibAttributes *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanPhyPibAttributes_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanPhyPibAttributes_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanPhyPibAttributes", /* tp_name */
sizeof(PyNs3LrWpanPhyPibAttributes), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanPhyPibAttributes__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanPhyPibAttributes(arg0)\nLrWpanPhyPibAttributes()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanPhyPibAttributes__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanPhyPibAttributes_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3LrWpanPhyPibAttributes__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanPhyPibAttributes__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry;
static PyObject* _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_phr(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->phr);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_phr(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->phr)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_shrPreamble(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->shrPreamble);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_shrPreamble(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->shrPreamble)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_shrSfd(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "d", self->obj->shrSfd);
return py_retval;
}
static int _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_shrSfd(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "d", &self->obj->shrSfd)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3LrWpanPhyPpduHeaderSymbolNumber__getsets[] = {
{
(char*) "shrSfd", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_shrSfd, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_shrSfd, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "phr", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_phr, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_phr, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "shrPreamble", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__get_shrPreamble, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__set_shrPreamble, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init__0(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyPpduHeaderSymbolNumber();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init__1(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanPhyPpduHeaderSymbolNumber *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanPhyPpduHeaderSymbolNumber(*((PyNs3LrWpanPhyPpduHeaderSymbolNumber *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__copy__(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self)
{
PyNs3LrWpanPhyPpduHeaderSymbolNumber *py_copy;
py_copy = PyObject_New(PyNs3LrWpanPhyPpduHeaderSymbolNumber, &PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type);
py_copy->obj = new ns3::LrWpanPhyPpduHeaderSymbolNumber(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanPhyPpduHeaderSymbolNumber_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_dealloc(PyNs3LrWpanPhyPpduHeaderSymbolNumber *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry.end()) {
PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::LrWpanPhyPpduHeaderSymbolNumber *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_richcompare (PyNs3LrWpanPhyPpduHeaderSymbolNumber *PYBINDGEN_UNUSED(self), PyNs3LrWpanPhyPpduHeaderSymbolNumber *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanPhyPpduHeaderSymbolNumber", /* tp_name */
sizeof(PyNs3LrWpanPhyPpduHeaderSymbolNumber), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanPhyPpduHeaderSymbolNumber(arg0)\nLrWpanPhyPpduHeaderSymbolNumber()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanPhyPpduHeaderSymbolNumber_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3LrWpanPhyPpduHeaderSymbolNumber__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanPhyPpduHeaderSymbolNumber__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3LrWpanSpectrumValueHelper_wrapper_registry;
static int
_wrap_PyNs3LrWpanSpectrumValueHelper__tp_init__0(PyNs3LrWpanSpectrumValueHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanSpectrumValueHelper *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanSpectrumValueHelper_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanSpectrumValueHelper(*((PyNs3LrWpanSpectrumValueHelper *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanSpectrumValueHelper__tp_init__1(PyNs3LrWpanSpectrumValueHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanSpectrumValueHelper();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanSpectrumValueHelper__tp_init(PyNs3LrWpanSpectrumValueHelper *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanSpectrumValueHelper__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanSpectrumValueHelper__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3LrWpanSpectrumValueHelper__copy__(PyNs3LrWpanSpectrumValueHelper *self)
{
PyNs3LrWpanSpectrumValueHelper *py_copy;
py_copy = PyObject_New(PyNs3LrWpanSpectrumValueHelper, &PyNs3LrWpanSpectrumValueHelper_Type);
py_copy->obj = new ns3::LrWpanSpectrumValueHelper(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3LrWpanSpectrumValueHelper_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanSpectrumValueHelper_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanSpectrumValueHelper__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanSpectrumValueHelper__tp_dealloc(PyNs3LrWpanSpectrumValueHelper *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3LrWpanSpectrumValueHelper_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3LrWpanSpectrumValueHelper_wrapper_registry.end()) {
PyNs3LrWpanSpectrumValueHelper_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::LrWpanSpectrumValueHelper *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanSpectrumValueHelper__tp_richcompare (PyNs3LrWpanSpectrumValueHelper *PYBINDGEN_UNUSED(self), PyNs3LrWpanSpectrumValueHelper *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanSpectrumValueHelper_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanSpectrumValueHelper_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanSpectrumValueHelper", /* tp_name */
sizeof(PyNs3LrWpanSpectrumValueHelper), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanSpectrumValueHelper__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanSpectrumValueHelper(arg0)\nLrWpanSpectrumValueHelper()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanSpectrumValueHelper__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanSpectrumValueHelper_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanSpectrumValueHelper__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3McpsDataConfirmParams_wrapper_registry;
static PyObject* _wrap_PyNs3McpsDataConfirmParams__get_m_msduHandle(PyNs3McpsDataConfirmParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_msduHandle);
return py_retval;
}
static int _wrap_PyNs3McpsDataConfirmParams__set_m_msduHandle(PyNs3McpsDataConfirmParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_msduHandle = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataConfirmParams__get_m_status(PyNs3McpsDataConfirmParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_status);
return py_retval;
}
static int _wrap_PyNs3McpsDataConfirmParams__set_m_status(PyNs3McpsDataConfirmParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &self->obj->m_status)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3McpsDataConfirmParams__getsets[] = {
{
(char*) "m_status", /* attribute name */
(getter) _wrap_PyNs3McpsDataConfirmParams__get_m_status, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataConfirmParams__set_m_status, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_msduHandle", /* attribute name */
(getter) _wrap_PyNs3McpsDataConfirmParams__get_m_msduHandle, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataConfirmParams__set_m_msduHandle, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3McpsDataConfirmParams__tp_init__0(PyNs3McpsDataConfirmParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataConfirmParams();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3McpsDataConfirmParams__tp_init__1(PyNs3McpsDataConfirmParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3McpsDataConfirmParams *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3McpsDataConfirmParams_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataConfirmParams(*((PyNs3McpsDataConfirmParams *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3McpsDataConfirmParams__tp_init(PyNs3McpsDataConfirmParams *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3McpsDataConfirmParams__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3McpsDataConfirmParams__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3McpsDataConfirmParams__copy__(PyNs3McpsDataConfirmParams *self)
{
PyNs3McpsDataConfirmParams *py_copy;
py_copy = PyObject_New(PyNs3McpsDataConfirmParams, &PyNs3McpsDataConfirmParams_Type);
py_copy->obj = new ns3::McpsDataConfirmParams(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3McpsDataConfirmParams_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3McpsDataConfirmParams_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3McpsDataConfirmParams__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3McpsDataConfirmParams__tp_dealloc(PyNs3McpsDataConfirmParams *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3McpsDataConfirmParams_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3McpsDataConfirmParams_wrapper_registry.end()) {
PyNs3McpsDataConfirmParams_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::McpsDataConfirmParams *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3McpsDataConfirmParams__tp_richcompare (PyNs3McpsDataConfirmParams *PYBINDGEN_UNUSED(self), PyNs3McpsDataConfirmParams *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3McpsDataConfirmParams_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3McpsDataConfirmParams_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.McpsDataConfirmParams", /* tp_name */
sizeof(PyNs3McpsDataConfirmParams), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3McpsDataConfirmParams__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"McpsDataConfirmParams(arg0)\nMcpsDataConfirmParams()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3McpsDataConfirmParams__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3McpsDataConfirmParams_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3McpsDataConfirmParams__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3McpsDataConfirmParams__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3McpsDataIndicationParams_wrapper_registry;
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_dsn(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_dsn);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_dsn(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dsn = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_dstAddr(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(self->obj->m_dstAddr);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_dstAddr(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *tmp_Mac16Address;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3Mac16Address_Type, &tmp_Mac16Address)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dstAddr = *tmp_Mac16Address->obj;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_dstAddrMode(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_dstAddrMode);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_dstAddrMode(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dstAddrMode = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_dstPanId(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_dstPanId);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_dstPanId(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dstPanId = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_mpduLinkQuality(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_mpduLinkQuality);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_mpduLinkQuality(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_mpduLinkQuality = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_srcAddr(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(self->obj->m_srcAddr);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_srcAddr(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *tmp_Mac16Address;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3Mac16Address_Type, &tmp_Mac16Address)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_srcAddr = *tmp_Mac16Address->obj;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_srcAddrMode(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_srcAddrMode);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_srcAddrMode(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_srcAddrMode = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataIndicationParams__get_m_srcPanId(PyNs3McpsDataIndicationParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_srcPanId);
return py_retval;
}
static int _wrap_PyNs3McpsDataIndicationParams__set_m_srcPanId(PyNs3McpsDataIndicationParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_srcPanId = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3McpsDataIndicationParams__getsets[] = {
{
(char*) "m_srcPanId", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_srcPanId, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_srcPanId, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_srcAddrMode", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_srcAddrMode, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_srcAddrMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_mpduLinkQuality", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_mpduLinkQuality, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_mpduLinkQuality, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstAddrMode", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_dstAddrMode, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_dstAddrMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstAddr", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_dstAddr, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_dstAddr, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dsn", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_dsn, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_dsn, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstPanId", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_dstPanId, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_dstPanId, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_srcAddr", /* attribute name */
(getter) _wrap_PyNs3McpsDataIndicationParams__get_m_srcAddr, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataIndicationParams__set_m_srcAddr, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3McpsDataIndicationParams__tp_init__0(PyNs3McpsDataIndicationParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataIndicationParams();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3McpsDataIndicationParams__tp_init__1(PyNs3McpsDataIndicationParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3McpsDataIndicationParams *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3McpsDataIndicationParams_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataIndicationParams(*((PyNs3McpsDataIndicationParams *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3McpsDataIndicationParams__tp_init(PyNs3McpsDataIndicationParams *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3McpsDataIndicationParams__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3McpsDataIndicationParams__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3McpsDataIndicationParams__copy__(PyNs3McpsDataIndicationParams *self)
{
PyNs3McpsDataIndicationParams *py_copy;
py_copy = PyObject_New(PyNs3McpsDataIndicationParams, &PyNs3McpsDataIndicationParams_Type);
py_copy->obj = new ns3::McpsDataIndicationParams(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3McpsDataIndicationParams_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3McpsDataIndicationParams_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3McpsDataIndicationParams__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3McpsDataIndicationParams__tp_dealloc(PyNs3McpsDataIndicationParams *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3McpsDataIndicationParams_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3McpsDataIndicationParams_wrapper_registry.end()) {
PyNs3McpsDataIndicationParams_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::McpsDataIndicationParams *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3McpsDataIndicationParams__tp_richcompare (PyNs3McpsDataIndicationParams *PYBINDGEN_UNUSED(self), PyNs3McpsDataIndicationParams *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3McpsDataIndicationParams_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3McpsDataIndicationParams_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.McpsDataIndicationParams", /* tp_name */
sizeof(PyNs3McpsDataIndicationParams), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3McpsDataIndicationParams__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"McpsDataIndicationParams(arg0)\nMcpsDataIndicationParams()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3McpsDataIndicationParams__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3McpsDataIndicationParams_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3McpsDataIndicationParams__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3McpsDataIndicationParams__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
std::map<void*, PyObject*> PyNs3McpsDataRequestParams_wrapper_registry;
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_dstAddr(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(self->obj->m_dstAddr);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_dstAddr(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3Mac16Address *tmp_Mac16Address;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3Mac16Address_Type, &tmp_Mac16Address)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dstAddr = *tmp_Mac16Address->obj;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_dstAddrMode(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_dstAddrMode);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_dstAddrMode(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &self->obj->m_dstAddrMode)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_dstPanId(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_dstPanId);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_dstPanId(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_dstPanId = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_msduHandle(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_msduHandle);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_msduHandle(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_msduHandle = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_srcAddrMode(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_srcAddrMode);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_srcAddrMode(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &self->obj->m_srcAddrMode)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3McpsDataRequestParams__get_m_txOptions(PyNs3McpsDataRequestParams *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_txOptions);
return py_retval;
}
static int _wrap_PyNs3McpsDataRequestParams__set_m_txOptions(PyNs3McpsDataRequestParams *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_txOptions = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3McpsDataRequestParams__getsets[] = {
{
(char*) "m_srcAddrMode", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_srcAddrMode, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_srcAddrMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_txOptions", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_txOptions, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_txOptions, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_msduHandle", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_msduHandle, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_msduHandle, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstAddrMode", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_dstAddrMode, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_dstAddrMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstAddr", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_dstAddr, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_dstAddr, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_dstPanId", /* attribute name */
(getter) _wrap_PyNs3McpsDataRequestParams__get_m_dstPanId, /* C function to get the attribute */
(setter) _wrap_PyNs3McpsDataRequestParams__set_m_dstPanId, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static int
_wrap_PyNs3McpsDataRequestParams__tp_init__0(PyNs3McpsDataRequestParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3McpsDataRequestParams *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3McpsDataRequestParams_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataRequestParams(*((PyNs3McpsDataRequestParams *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3McpsDataRequestParams__tp_init__1(PyNs3McpsDataRequestParams *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::McpsDataRequestParams();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3McpsDataRequestParams__tp_init(PyNs3McpsDataRequestParams *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3McpsDataRequestParams__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3McpsDataRequestParams__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3McpsDataRequestParams__copy__(PyNs3McpsDataRequestParams *self)
{
PyNs3McpsDataRequestParams *py_copy;
py_copy = PyObject_New(PyNs3McpsDataRequestParams, &PyNs3McpsDataRequestParams_Type);
py_copy->obj = new ns3::McpsDataRequestParams(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3McpsDataRequestParams_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3McpsDataRequestParams_methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3McpsDataRequestParams__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3McpsDataRequestParams__tp_dealloc(PyNs3McpsDataRequestParams *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3McpsDataRequestParams_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3McpsDataRequestParams_wrapper_registry.end()) {
PyNs3McpsDataRequestParams_wrapper_registry.erase(wrapper_lookup_iter);
}
ns3::McpsDataRequestParams *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3McpsDataRequestParams__tp_richcompare (PyNs3McpsDataRequestParams *PYBINDGEN_UNUSED(self), PyNs3McpsDataRequestParams *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3McpsDataRequestParams_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3McpsDataRequestParams_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.McpsDataRequestParams", /* tp_name */
sizeof(PyNs3McpsDataRequestParams), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3McpsDataRequestParams__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"McpsDataRequestParams(arg0)\nMcpsDataRequestParams()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3McpsDataRequestParams__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3McpsDataRequestParams_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3McpsDataRequestParams__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3McpsDataRequestParams__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
void
PyNs3LrWpanHelper__PythonHelper::EnablePcapInternal(std::string prefix, ns3::Ptr< ns3::NetDevice > nd, bool promiscuous, bool explicitFilename)
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::LrWpanHelper *self_obj_before;
PyObject *py_retval;
const char *prefix_ptr;
Py_ssize_t prefix_len;
PyNs3NetDevice *py_NetDevice;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "EnablePcapInternal"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj;
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = (ns3::LrWpanHelper*) this;
prefix_ptr = (prefix).c_str();
prefix_len = (prefix).size();
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_NetDevice = NULL;
} else {
py_NetDevice = (PyNs3NetDevice *) wrapper_lookup_iter->second;
Py_INCREF(py_NetDevice);
}
if (py_NetDevice == NULL)
{
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid(*const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd))), &PyNs3NetDevice_Type);
py_NetDevice = PyObject_GC_New(PyNs3NetDevice, wrapper_type);
py_NetDevice->inst_dict = NULL;
py_NetDevice->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd))->Ref();
py_NetDevice->obj = const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd));
PyNs3ObjectBase_wrapper_registry[(void *) py_NetDevice->obj] = (PyObject *) py_NetDevice;
}
py_retval = PyObject_CallMethod(m_pyself, (char *) "EnablePcapInternal", (char *) "s#NNN", prefix_ptr, prefix_len, py_NetDevice, PyBool_FromLong(promiscuous), PyBool_FromLong(explicitFilename));
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
void
PyNs3LrWpanHelper__PythonHelper::EnableAsciiInternal(ns3::Ptr< ns3::OutputStreamWrapper > stream, std::string prefix, ns3::Ptr< ns3::NetDevice > nd, bool explicitFilename)
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::LrWpanHelper *self_obj_before;
PyObject *py_retval;
PyNs3OutputStreamWrapper *py_OutputStreamWrapper;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
const char *prefix_ptr;
Py_ssize_t prefix_len;
PyNs3NetDevice *py_NetDevice;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter2;
PyTypeObject *wrapper_type2 = 0;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "EnableAsciiInternal"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj;
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = (ns3::LrWpanHelper*) this;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) const_cast<ns3::OutputStreamWrapper *> (ns3::PeekPointer (stream)));
if (wrapper_lookup_iter == PyNs3Empty_wrapper_registry.end()) {
py_OutputStreamWrapper = NULL;
} else {
py_OutputStreamWrapper = (PyNs3OutputStreamWrapper *) wrapper_lookup_iter->second;
Py_INCREF(py_OutputStreamWrapper);
}
if (py_OutputStreamWrapper == NULL)
{
wrapper_type = PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt____typeid_map.lookup_wrapper(typeid(*const_cast<ns3::OutputStreamWrapper *> (ns3::PeekPointer (stream))), &PyNs3OutputStreamWrapper_Type);
py_OutputStreamWrapper = PyObject_New(PyNs3OutputStreamWrapper, wrapper_type);
py_OutputStreamWrapper->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::OutputStreamWrapper *> (ns3::PeekPointer (stream))->Ref();
py_OutputStreamWrapper->obj = const_cast<ns3::OutputStreamWrapper *> (ns3::PeekPointer (stream));
PyNs3Empty_wrapper_registry[(void *) py_OutputStreamWrapper->obj] = (PyObject *) py_OutputStreamWrapper;
}
prefix_ptr = (prefix).c_str();
prefix_len = (prefix).size();
wrapper_lookup_iter2 = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd)));
if (wrapper_lookup_iter2 == PyNs3ObjectBase_wrapper_registry.end()) {
py_NetDevice = NULL;
} else {
py_NetDevice = (PyNs3NetDevice *) wrapper_lookup_iter2->second;
Py_INCREF(py_NetDevice);
}
if (py_NetDevice == NULL)
{
wrapper_type2 = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid(*const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd))), &PyNs3NetDevice_Type);
py_NetDevice = PyObject_GC_New(PyNs3NetDevice, wrapper_type2);
py_NetDevice->inst_dict = NULL;
py_NetDevice->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd))->Ref();
py_NetDevice->obj = const_cast<ns3::NetDevice *> (ns3::PeekPointer (nd));
PyNs3ObjectBase_wrapper_registry[(void *) py_NetDevice->obj] = (PyObject *) py_NetDevice;
}
py_retval = PyObject_CallMethod(m_pyself, (char *) "EnableAsciiInternal", (char *) "Ns#NN", py_OutputStreamWrapper, prefix_ptr, prefix_len, py_NetDevice, PyBool_FromLong(explicitFilename));
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanHelper* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
static int
_wrap_PyNs3LrWpanHelper__tp_init__0(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
if (Py_TYPE(self) != &PyNs3LrWpanHelper_Type)
{
self->obj = new PyNs3LrWpanHelper__PythonHelper();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
((PyNs3LrWpanHelper__PythonHelper*) self->obj)->set_pyobj((PyObject *)self);
} else {
// visibility: 'public'
self->obj = new ns3::LrWpanHelper();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
}
return 0;
}
static int
_wrap_PyNs3LrWpanHelper__tp_init__1(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
bool useMultiModelSpectrumChannel;
PyObject *py_useMultiModelSpectrumChannel;
const char *keywords[] = {"useMultiModelSpectrumChannel", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &py_useMultiModelSpectrumChannel)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
useMultiModelSpectrumChannel = (bool) PyObject_IsTrue(py_useMultiModelSpectrumChannel);
if (Py_TYPE(self) != &PyNs3LrWpanHelper_Type)
{
self->obj = new PyNs3LrWpanHelper__PythonHelper(useMultiModelSpectrumChannel);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
((PyNs3LrWpanHelper__PythonHelper*) self->obj)->set_pyobj((PyObject *)self);
} else {
// visibility: 'public'
self->obj = new ns3::LrWpanHelper(useMultiModelSpectrumChannel);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
}
return 0;
}
int _wrap_PyNs3LrWpanHelper__tp_init(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanHelper__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanHelper__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanHelper_AssignStreams(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int64_t retval;
PyNs3NetDeviceContainer *c;
int64_t stream;
const char *keywords[] = {"c", "stream", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!L", (char **) keywords, &PyNs3NetDeviceContainer_Type, &c, &stream)) {
return NULL;
}
retval = self->obj->AssignStreams(*((PyNs3NetDeviceContainer *) c)->obj, stream);
py_retval = Py_BuildValue((char *) "L", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_AssociateToPan(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3NetDeviceContainer *c;
int panId;
const char *keywords[] = {"c", "panId", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!i", (char **) keywords, &PyNs3NetDeviceContainer_Type, &c, &panId)) {
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->AssociateToPan(*((PyNs3NetDeviceContainer *) c)->obj, panId);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableLogComponents(PyNs3LrWpanHelper *self)
{
PyObject *py_retval;
self->obj->EnableLogComponents();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_LrWpanPhyEnumerationPrinter(PyNs3LrWpanHelper *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
std::string retval;
ns3::LrWpanPhyEnumeration e;
const char *keywords[] = {"e", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &e)) {
return NULL;
}
retval = ns3::LrWpanHelper::LrWpanPhyEnumerationPrinter(e);
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_SetChannel(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
const char *channelName;
Py_ssize_t channelName_len;
const char *keywords[] = {"channelName", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#", (char **) keywords, &channelName, &channelName_len)) {
return NULL;
}
self->obj->SetChannel(std::string(channelName, channelName_len));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_Install(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3NodeContainer *c;
const char *keywords[] = {"c", NULL};
PyNs3NetDeviceContainer *py_NetDeviceContainer;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3NodeContainer_Type, &c)) {
return NULL;
}
ns3::NetDeviceContainer retval = self->obj->Install(*((PyNs3NodeContainer *) c)->obj);
py_NetDeviceContainer = PyObject_New(PyNs3NetDeviceContainer, &PyNs3NetDeviceContainer_Type);
py_NetDeviceContainer->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_NetDeviceContainer->obj = new ns3::NetDeviceContainer(retval);
PyNs3NetDeviceContainer_wrapper_registry[(void *) py_NetDeviceContainer->obj] = (PyObject *) py_NetDeviceContainer;
py_retval = Py_BuildValue((char *) "N", py_NetDeviceContainer);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_LrWpanMacStatePrinter(PyNs3LrWpanHelper *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
std::string retval;
ns3::LrWpanMacState e;
const char *keywords[] = {"e", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &e)) {
return NULL;
}
retval = ns3::LrWpanHelper::LrWpanMacStatePrinter(e);
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAsciiAll__0(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
const char *keywords[] = {"prefix", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#", (char **) keywords, &prefix, &prefix_len)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->EnableAsciiAll(std::string(prefix, prefix_len));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAsciiAll__1(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
const char *keywords[] = {"stream", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
self->obj->EnableAsciiAll(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanHelper_EnableAsciiAll(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanHelper_EnableAsciiAll__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAsciiAll__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcap__0(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NetDevice *nd;
ns3::NetDevice *nd_ptr;
bool promiscuous;
PyObject *py_promiscuous = NULL;
bool explicitFilename;
PyObject *py_explicitFilename = NULL;
const char *keywords[] = {"prefix", "nd", "promiscuous", "explicitFilename", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!|OO", (char **) keywords, &prefix, &prefix_len, &PyNs3NetDevice_Type, &nd, &py_promiscuous, &py_explicitFilename)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
nd_ptr = (nd ? nd->obj : NULL);
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
explicitFilename = py_explicitFilename? (bool) PyObject_IsTrue(py_explicitFilename) : false;
self->obj->EnablePcap(std::string(prefix, prefix_len), ns3::Ptr< ns3::NetDevice > (nd_ptr), promiscuous, explicitFilename);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcap__1(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
const char *ndName;
Py_ssize_t ndName_len;
bool promiscuous;
PyObject *py_promiscuous = NULL;
bool explicitFilename;
PyObject *py_explicitFilename = NULL;
const char *keywords[] = {"prefix", "ndName", "promiscuous", "explicitFilename", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#s#|OO", (char **) keywords, &prefix, &prefix_len, &ndName, &ndName_len, &py_promiscuous, &py_explicitFilename)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
explicitFilename = py_explicitFilename? (bool) PyObject_IsTrue(py_explicitFilename) : false;
self->obj->EnablePcap(std::string(prefix, prefix_len), std::string(ndName, ndName_len), promiscuous, explicitFilename);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcap__2(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NetDeviceContainer *d;
bool promiscuous;
PyObject *py_promiscuous = NULL;
const char *keywords[] = {"prefix", "d", "promiscuous", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!|O", (char **) keywords, &prefix, &prefix_len, &PyNs3NetDeviceContainer_Type, &d, &py_promiscuous)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
self->obj->EnablePcap(std::string(prefix, prefix_len), *((PyNs3NetDeviceContainer *) d)->obj, promiscuous);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcap__3(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NodeContainer *n;
bool promiscuous;
PyObject *py_promiscuous = NULL;
const char *keywords[] = {"prefix", "n", "promiscuous", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!|O", (char **) keywords, &prefix, &prefix_len, &PyNs3NodeContainer_Type, &n, &py_promiscuous)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
self->obj->EnablePcap(std::string(prefix, prefix_len), *((PyNs3NodeContainer *) n)->obj, promiscuous);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcap__4(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
unsigned int nodeid;
unsigned int deviceid;
bool promiscuous;
PyObject *py_promiscuous = NULL;
const char *keywords[] = {"prefix", "nodeid", "deviceid", "promiscuous", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#II|O", (char **) keywords, &prefix, &prefix_len, &nodeid, &deviceid, &py_promiscuous)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
self->obj->EnablePcap(std::string(prefix, prefix_len), nodeid, deviceid, promiscuous);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanHelper_EnablePcap(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[5] = {0,};
retval = _wrap_PyNs3LrWpanHelper_EnablePcap__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnablePcap__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnablePcap__2(self, args, kwargs, &exceptions[2]);
if (!exceptions[2]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnablePcap__3(self, args, kwargs, &exceptions[3]);
if (!exceptions[3]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnablePcap__4(self, args, kwargs, &exceptions[4]);
if (!exceptions[4]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
return retval;
}
error_list = PyList_New(5);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyList_SET_ITEM(error_list, 2, PyObject_Str(exceptions[2]));
Py_DECREF(exceptions[2]);
PyList_SET_ITEM(error_list, 3, PyObject_Str(exceptions[3]));
Py_DECREF(exceptions[3]);
PyList_SET_ITEM(error_list, 4, PyObject_Str(exceptions[4]));
Py_DECREF(exceptions[4]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__0(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NetDevice *nd;
ns3::NetDevice *nd_ptr;
bool explicitFilename;
PyObject *py_explicitFilename = NULL;
const char *keywords[] = {"prefix", "nd", "explicitFilename", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!|O", (char **) keywords, &prefix, &prefix_len, &PyNs3NetDevice_Type, &nd, &py_explicitFilename)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
nd_ptr = (nd ? nd->obj : NULL);
explicitFilename = py_explicitFilename? (bool) PyObject_IsTrue(py_explicitFilename) : false;
self->obj->EnableAscii(std::string(prefix, prefix_len), ns3::Ptr< ns3::NetDevice > (nd_ptr), explicitFilename);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__1(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
PyNs3NetDevice *nd;
ns3::NetDevice *nd_ptr;
const char *keywords[] = {"stream", "nd", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream, &PyNs3NetDevice_Type, &nd)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
nd_ptr = (nd ? nd->obj : NULL);
self->obj->EnableAscii(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr), ns3::Ptr< ns3::NetDevice > (nd_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__2(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
const char *ndName;
Py_ssize_t ndName_len;
bool explicitFilename;
PyObject *py_explicitFilename = NULL;
const char *keywords[] = {"prefix", "ndName", "explicitFilename", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#s#|O", (char **) keywords, &prefix, &prefix_len, &ndName, &ndName_len, &py_explicitFilename)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
explicitFilename = py_explicitFilename? (bool) PyObject_IsTrue(py_explicitFilename) : false;
self->obj->EnableAscii(std::string(prefix, prefix_len), std::string(ndName, ndName_len), explicitFilename);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__3(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
const char *ndName;
Py_ssize_t ndName_len;
const char *keywords[] = {"stream", "ndName", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!s#", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream, &ndName, &ndName_len)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
self->obj->EnableAscii(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr), std::string(ndName, ndName_len));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__4(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NetDeviceContainer *d;
const char *keywords[] = {"prefix", "d", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!", (char **) keywords, &prefix, &prefix_len, &PyNs3NetDeviceContainer_Type, &d)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->EnableAscii(std::string(prefix, prefix_len), *((PyNs3NetDeviceContainer *) d)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__5(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
PyNs3NetDeviceContainer *d;
const char *keywords[] = {"stream", "d", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream, &PyNs3NetDeviceContainer_Type, &d)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
self->obj->EnableAscii(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr), *((PyNs3NetDeviceContainer *) d)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__6(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
PyNs3NodeContainer *n;
const char *keywords[] = {"prefix", "n", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#O!", (char **) keywords, &prefix, &prefix_len, &PyNs3NodeContainer_Type, &n)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->EnableAscii(std::string(prefix, prefix_len), *((PyNs3NodeContainer *) n)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__7(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
PyNs3NodeContainer *n;
const char *keywords[] = {"stream", "n", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream, &PyNs3NodeContainer_Type, &n)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
self->obj->EnableAscii(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr), *((PyNs3NodeContainer *) n)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__8(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
unsigned int nodeid;
unsigned int deviceid;
bool explicitFilename;
PyObject *py_explicitFilename;
const char *keywords[] = {"prefix", "nodeid", "deviceid", "explicitFilename", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#IIO", (char **) keywords, &prefix, &prefix_len, &nodeid, &deviceid, &py_explicitFilename)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
explicitFilename = (bool) PyObject_IsTrue(py_explicitFilename);
self->obj->EnableAscii(std::string(prefix, prefix_len), nodeid, deviceid, explicitFilename);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnableAscii__9(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3OutputStreamWrapper *stream;
ns3::OutputStreamWrapper *stream_ptr;
unsigned int nodeid;
unsigned int deviceid;
const char *keywords[] = {"stream", "nodeid", "deviceid", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!II", (char **) keywords, &PyNs3OutputStreamWrapper_Type, &stream, &nodeid, &deviceid)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
stream_ptr = (stream ? stream->obj : NULL);
self->obj->EnableAscii(ns3::Ptr< ns3::OutputStreamWrapper > (stream_ptr), nodeid, deviceid);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanHelper_EnableAscii(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[10] = {0,};
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__2(self, args, kwargs, &exceptions[2]);
if (!exceptions[2]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__3(self, args, kwargs, &exceptions[3]);
if (!exceptions[3]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__4(self, args, kwargs, &exceptions[4]);
if (!exceptions[4]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__5(self, args, kwargs, &exceptions[5]);
if (!exceptions[5]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
Py_DECREF(exceptions[4]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__6(self, args, kwargs, &exceptions[6]);
if (!exceptions[6]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
Py_DECREF(exceptions[4]);
Py_DECREF(exceptions[5]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__7(self, args, kwargs, &exceptions[7]);
if (!exceptions[7]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
Py_DECREF(exceptions[4]);
Py_DECREF(exceptions[5]);
Py_DECREF(exceptions[6]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__8(self, args, kwargs, &exceptions[8]);
if (!exceptions[8]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
Py_DECREF(exceptions[4]);
Py_DECREF(exceptions[5]);
Py_DECREF(exceptions[6]);
Py_DECREF(exceptions[7]);
return retval;
}
retval = _wrap_PyNs3LrWpanHelper_EnableAscii__9(self, args, kwargs, &exceptions[9]);
if (!exceptions[9]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
Py_DECREF(exceptions[2]);
Py_DECREF(exceptions[3]);
Py_DECREF(exceptions[4]);
Py_DECREF(exceptions[5]);
Py_DECREF(exceptions[6]);
Py_DECREF(exceptions[7]);
Py_DECREF(exceptions[8]);
return retval;
}
error_list = PyList_New(10);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyList_SET_ITEM(error_list, 2, PyObject_Str(exceptions[2]));
Py_DECREF(exceptions[2]);
PyList_SET_ITEM(error_list, 3, PyObject_Str(exceptions[3]));
Py_DECREF(exceptions[3]);
PyList_SET_ITEM(error_list, 4, PyObject_Str(exceptions[4]));
Py_DECREF(exceptions[4]);
PyList_SET_ITEM(error_list, 5, PyObject_Str(exceptions[5]));
Py_DECREF(exceptions[5]);
PyList_SET_ITEM(error_list, 6, PyObject_Str(exceptions[6]));
Py_DECREF(exceptions[6]);
PyList_SET_ITEM(error_list, 7, PyObject_Str(exceptions[7]));
Py_DECREF(exceptions[7]);
PyList_SET_ITEM(error_list, 8, PyObject_Str(exceptions[8]));
Py_DECREF(exceptions[8]);
PyList_SET_ITEM(error_list, 9, PyObject_Str(exceptions[9]));
Py_DECREF(exceptions[9]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanHelper_EnablePcapAll(PyNs3LrWpanHelper *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
const char *prefix;
Py_ssize_t prefix_len;
bool promiscuous;
PyObject *py_promiscuous = NULL;
const char *keywords[] = {"prefix", "promiscuous", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#|O", (char **) keywords, &prefix, &prefix_len, &py_promiscuous)) {
return NULL;
}
promiscuous = py_promiscuous? (bool) PyObject_IsTrue(py_promiscuous) : false;
self->obj->EnablePcapAll(std::string(prefix, prefix_len), promiscuous);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyMethodDef PyNs3LrWpanHelper_methods[] = {
{(char *) "AssignStreams", (PyCFunction) _wrap_PyNs3LrWpanHelper_AssignStreams, METH_KEYWORDS|METH_VARARGS, "AssignStreams(c, stream)\n\ntype: c: ns3::NetDeviceContainer\ntype: stream: int64_t" },
{(char *) "AssociateToPan", (PyCFunction) _wrap_PyNs3LrWpanHelper_AssociateToPan, METH_KEYWORDS|METH_VARARGS, "AssociateToPan(c, panId)\n\ntype: c: ns3::NetDeviceContainer\ntype: panId: uint16_t" },
{(char *) "EnableLogComponents", (PyCFunction) _wrap_PyNs3LrWpanHelper_EnableLogComponents, METH_NOARGS, "EnableLogComponents()\n\n" },
{(char *) "LrWpanPhyEnumerationPrinter", (PyCFunction) _wrap_PyNs3LrWpanHelper_LrWpanPhyEnumerationPrinter, METH_KEYWORDS|METH_VARARGS|METH_STATIC, "LrWpanPhyEnumerationPrinter(e)\n\ntype: e: ns3::LrWpanPhyEnumeration" },
{(char *) "SetChannel", (PyCFunction) _wrap_PyNs3LrWpanHelper_SetChannel, METH_KEYWORDS|METH_VARARGS, "SetChannel(channelName)\n\ntype: channelName: std::string" },
{(char *) "Install", (PyCFunction) _wrap_PyNs3LrWpanHelper_Install, METH_KEYWORDS|METH_VARARGS, "Install(c)\n\ntype: c: ns3::NodeContainer" },
{(char *) "LrWpanMacStatePrinter", (PyCFunction) _wrap_PyNs3LrWpanHelper_LrWpanMacStatePrinter, METH_KEYWORDS|METH_VARARGS|METH_STATIC, "LrWpanMacStatePrinter(e)\n\ntype: e: ns3::LrWpanMacState" },
{(char *) "EnableAsciiAll", (PyCFunction) _wrap_PyNs3LrWpanHelper_EnableAsciiAll, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "EnablePcap", (PyCFunction) _wrap_PyNs3LrWpanHelper_EnablePcap, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "EnableAscii", (PyCFunction) _wrap_PyNs3LrWpanHelper_EnableAscii, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "EnablePcapAll", (PyCFunction) _wrap_PyNs3LrWpanHelper_EnablePcapAll, METH_KEYWORDS|METH_VARARGS, "EnablePcapAll(prefix, promiscuous)\n\ntype: prefix: std::string\ntype: promiscuous: bool" },
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanHelper__tp_clear(PyNs3LrWpanHelper *self)
{
Py_CLEAR(self->inst_dict);
ns3::LrWpanHelper *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
}
static int
PyNs3LrWpanHelper__tp_traverse(PyNs3LrWpanHelper *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
if (self->obj && typeid(*self->obj).name() == typeid(PyNs3LrWpanHelper__PythonHelper).name() )
Py_VISIT((PyObject *) self);
return 0;
}
static void
_wrap_PyNs3LrWpanHelper__tp_dealloc(PyNs3LrWpanHelper *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3PcapHelperForDevice_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3PcapHelperForDevice_wrapper_registry.end()) {
PyNs3PcapHelperForDevice_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanHelper__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanHelper__tp_richcompare (PyNs3LrWpanHelper *PYBINDGEN_UNUSED(self), PyNs3LrWpanHelper *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanHelper_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanHelper_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanHelper", /* tp_name */
sizeof(PyNs3LrWpanHelper), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanHelper__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanHelper(useMultiModelSpectrumChannel)\nLrWpanHelper()", /* Documentation string */
(traverseproc)PyNs3LrWpanHelper__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanHelper__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanHelper__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanHelper_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanHelper, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanHelper__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanLqiTag__tp_init__0(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanLqiTag *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanLqiTag_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanLqiTag(*((PyNs3LrWpanLqiTag *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanLqiTag__tp_init__1(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanLqiTag();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanLqiTag__tp_init__2(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
int lqi;
const char *keywords[] = {"lqi", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &lqi)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
if (lqi > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanLqiTag(lqi);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanLqiTag__tp_init(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[3] = {0,};
retval = _wrap_PyNs3LrWpanLqiTag__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanLqiTag__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
retval = _wrap_PyNs3LrWpanLqiTag__tp_init__2(self, args, kwargs, &exceptions[2]);
if (!exceptions[2]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
return retval;
}
error_list = PyList_New(3);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyList_SET_ITEM(error_list, 2, PyObject_Str(exceptions[2]));
Py_DECREF(exceptions[2]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_Set(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int lqi;
const char *keywords[] = {"lqi", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &lqi)) {
return NULL;
}
if (lqi > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->Set(lqi);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_Deserialize(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3TagBuffer *i;
const char *keywords[] = {"i", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3TagBuffer_Type, &i)) {
return NULL;
}
self->obj->Deserialize(*((PyNs3TagBuffer *) i)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_Get(PyNs3LrWpanLqiTag *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->Get();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanLqiTag::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_Serialize(PyNs3LrWpanLqiTag *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3TagBuffer *i;
const char *keywords[] = {"i", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3TagBuffer_Type, &i)) {
return NULL;
}
self->obj->Serialize(*((PyNs3TagBuffer *) i)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_GetInstanceTypeId(PyNs3LrWpanLqiTag *self)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = self->obj->GetInstanceTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanLqiTag_GetSerializedSize(PyNs3LrWpanLqiTag *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetSerializedSize();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanLqiTag__copy__(PyNs3LrWpanLqiTag *self)
{
PyNs3LrWpanLqiTag *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanLqiTag, &PyNs3LrWpanLqiTag_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanLqiTag(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanLqiTag_methods[] = {
{(char *) "Set", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_Set, METH_KEYWORDS|METH_VARARGS, "Set(lqi)\n\ntype: lqi: uint8_t" },
{(char *) "Deserialize", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_Deserialize, METH_KEYWORDS|METH_VARARGS, "Deserialize(i)\n\ntype: i: ns3::TagBuffer" },
{(char *) "Get", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_Get, METH_NOARGS, "Get()\n\n" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "Serialize", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_Serialize, METH_KEYWORDS|METH_VARARGS, "Serialize(i)\n\ntype: i: ns3::TagBuffer" },
{(char *) "GetInstanceTypeId", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_GetInstanceTypeId, METH_NOARGS, "GetInstanceTypeId()\n\n" },
{(char *) "GetSerializedSize", (PyCFunction) _wrap_PyNs3LrWpanLqiTag_GetSerializedSize, METH_NOARGS, "GetSerializedSize()\n\n" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanLqiTag__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanLqiTag__tp_clear(PyNs3LrWpanLqiTag *self)
{
Py_CLEAR(self->inst_dict);
ns3::LrWpanLqiTag *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
}
static int
PyNs3LrWpanLqiTag__tp_traverse(PyNs3LrWpanLqiTag *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanLqiTag__tp_dealloc(PyNs3LrWpanLqiTag *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanLqiTag__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanLqiTag__tp_richcompare (PyNs3LrWpanLqiTag *PYBINDGEN_UNUSED(self), PyNs3LrWpanLqiTag *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanLqiTag_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanLqiTag_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanLqiTag", /* tp_name */
sizeof(PyNs3LrWpanLqiTag), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanLqiTag__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanLqiTag(arg0)\nLrWpanLqiTag(lqi)\nLrWpanLqiTag()", /* Documentation string */
(traverseproc)PyNs3LrWpanLqiTag__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanLqiTag__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanLqiTag__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanLqiTag_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanLqiTag, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanLqiTag__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanMacHeader__tp_init__0(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanMacHeader *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanMacHeader_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanMacHeader(*((PyNs3LrWpanMacHeader *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanMacHeader__tp_init__1(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanMacHeader();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanMacHeader__tp_init__2(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
ns3::LrWpanMacHeader::LrWpanMacType wpanMacType;
int seqNum;
const char *keywords[] = {"wpanMacType", "seqNum", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ii", (char **) keywords, &wpanMacType, &seqNum)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
if (seqNum > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanMacHeader(wpanMacType, seqNum);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanMacHeader__tp_init(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[3] = {0,};
retval = _wrap_PyNs3LrWpanMacHeader__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader__tp_init__2(self, args, kwargs, &exceptions[2]);
if (!exceptions[2]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
return retval;
}
error_list = PyList_New(3);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyList_SET_ITEM(error_list, 2, PyObject_Str(exceptions[2]));
Py_DECREF(exceptions[2]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSecCtrlReserved(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int res;
const char *keywords[] = {"res", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &res)) {
return NULL;
}
if (res > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetSecCtrlReserved(res);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsAcknowledgment(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsAcknowledgment();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetFrmPend(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetFrmPend();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsData(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsData();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsSecEnable(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsSecEnable();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanMacHeader::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetDstAddrMode(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetDstAddrMode();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetNoFrmPend(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetNoFrmPend();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetKeyId__0(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
int keyIndex;
const char *keywords[] = {"keyIndex", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &keyIndex)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (keyIndex > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetKeyId(keyIndex);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetKeyId__1(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
unsigned int keySrc;
int keyIndex;
const char *keywords[] = {"keySrc", "keyIndex", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Ii", (char **) keywords, &keySrc, &keyIndex)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (keyIndex > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetKeyId(keySrc, keyIndex);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetKeyId__2(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
uint64_t keySrc;
int keyIndex;
const char *keywords[] = {"keySrc", "keyIndex", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Ki", (char **) keywords, &keySrc, &keyIndex)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (keyIndex > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetKeyId(keySrc, keyIndex);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanMacHeader_SetKeyId(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[3] = {0,};
retval = _wrap_PyNs3LrWpanMacHeader_SetKeyId__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader_SetKeyId__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader_SetKeyId__2(self, args, kwargs, &exceptions[2]);
if (!exceptions[2]) {
Py_DECREF(exceptions[0]);
Py_DECREF(exceptions[1]);
return retval;
}
error_list = PyList_New(3);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyList_SET_ITEM(error_list, 2, PyObject_Str(exceptions[2]));
Py_DECREF(exceptions[2]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_Serialize(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3BufferIterator *start;
const char *keywords[] = {"start", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3BufferIterator_Type, &start)) {
return NULL;
}
self->obj->Serialize(*((PyNs3BufferIterator *) start)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetDstAddrFields__0(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
int panId;
PyNs3Mac16Address *addr;
const char *keywords[] = {"panId", "addr", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "iO!", (char **) keywords, &panId, &PyNs3Mac16Address_Type, &addr)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetDstAddrFields(panId, *((PyNs3Mac16Address *) addr)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetDstAddrFields__1(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
int panId;
PyNs3Mac64Address *addr;
const char *keywords[] = {"panId", "addr", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "iO!", (char **) keywords, &panId, &PyNs3Mac64Address_Type, &addr)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetDstAddrFields(panId, *((PyNs3Mac64Address *) addr)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanMacHeader_SetDstAddrFields(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanMacHeader_SetDstAddrFields__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader_SetDstAddrFields__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSecDisable(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetSecDisable();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetNoAckReq(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetNoAckReq();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetFrmCounter(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetFrmCounter();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetKeyIdIndex(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetKeyIdIndex();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields__0(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
int panId;
PyNs3Mac16Address *addr;
const char *keywords[] = {"panId", "addr", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "iO!", (char **) keywords, &panId, &PyNs3Mac16Address_Type, &addr)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetSrcAddrFields(panId, *((PyNs3Mac16Address *) addr)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields__1(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
int panId;
PyNs3Mac64Address *addr;
const char *keywords[] = {"panId", "addr", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "iO!", (char **) keywords, &panId, &PyNs3Mac64Address_Type, &addr)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
self->obj->SetSrcAddrFields(panId, *((PyNs3Mac64Address *) addr)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSeqNum(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int seqNum;
const char *keywords[] = {"seqNum", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &seqNum)) {
return NULL;
}
if (seqNum > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetSeqNum(seqNum);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSecEnable(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetSecEnable();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSecControl(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int secLevel;
const char *keywords[] = {"secLevel", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &secLevel)) {
return NULL;
}
if (secLevel > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetSecControl(secLevel);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetDstAddrMode(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int addrMode;
const char *keywords[] = {"addrMode", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &addrMode)) {
return NULL;
}
if (addrMode > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetDstAddrMode(addrMode);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSecLevel(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetSecLevel();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetFrameControl(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetFrameControl();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetPanIdComp(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetPanIdComp();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetType(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanMacHeader::LrWpanMacType wpanMacType;
const char *keywords[] = {"wpanMacType", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &wpanMacType)) {
return NULL;
}
self->obj->SetType(wpanMacType);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetKeyIdMode(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int keyIdMode;
const char *keywords[] = {"keyIdMode", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &keyIdMode)) {
return NULL;
}
if (keyIdMode > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetKeyIdMode(keyIdMode);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsPanIdComp(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsPanIdComp();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetExtSrcAddr(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
PyNs3Mac64Address *py_Mac64Address;
ns3::Mac64Address retval = self->obj->GetExtSrcAddr();
py_Mac64Address = PyObject_New(PyNs3Mac64Address, &PyNs3Mac64Address_Type);
py_Mac64Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac64Address->obj = new ns3::Mac64Address(retval);
PyNs3Mac64Address_wrapper_registry[(void *) py_Mac64Address->obj] = (PyObject *) py_Mac64Address;
py_retval = Py_BuildValue((char *) "N", py_Mac64Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetFrameVer(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int ver;
const char *keywords[] = {"ver", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &ver)) {
return NULL;
}
if (ver > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetFrameVer(ver);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_Deserialize(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
uint32_t retval;
PyNs3BufferIterator *start;
const char *keywords[] = {"start", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3BufferIterator_Type, &start)) {
return NULL;
}
retval = self->obj->Deserialize(*((PyNs3BufferIterator *) start)->obj);
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetKeyIdSrc64(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint64_t retval;
retval = self->obj->GetKeyIdSrc64();
py_retval = Py_BuildValue((char *) "K", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSrcAddrMode(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int addrMode;
const char *keywords[] = {"addrMode", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &addrMode)) {
return NULL;
}
if (addrMode > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetSrcAddrMode(addrMode);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetDstPanId(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetDstPanId();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsCommand(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsCommand();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetNoPanIdComp(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetNoPanIdComp();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsFrmPend(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsFrmPend();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetFrameVer(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetFrameVer();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetExtDstAddr(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
PyNs3Mac64Address *py_Mac64Address;
ns3::Mac64Address retval = self->obj->GetExtDstAddr();
py_Mac64Address = PyObject_New(PyNs3Mac64Address, &PyNs3Mac64Address_Type);
py_Mac64Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac64Address->obj = new ns3::Mac64Address(retval);
PyNs3Mac64Address_wrapper_registry[(void *) py_Mac64Address->obj] = (PyObject *) py_Mac64Address;
py_retval = Py_BuildValue((char *) "N", py_Mac64Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetKeyIdMode(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetKeyIdMode();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetShortDstAddr(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
ns3::Mac16Address retval = self->obj->GetShortDstAddr();
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(retval);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetInstanceTypeId(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = self->obj->GetInstanceTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSerializedSize(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetSerializedSize();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSrcAddrMode(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetSrcAddrMode();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetFrameControl(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int frameControl;
const char *keywords[] = {"frameControl", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &frameControl)) {
return NULL;
}
if (frameControl > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetFrameControl(frameControl);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetFrmCounter(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
unsigned int frmCntr;
const char *keywords[] = {"frmCntr", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "I", (char **) keywords, &frmCntr)) {
return NULL;
}
self->obj->SetFrmCounter(frmCntr);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetSecLevel(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int secLevel;
const char *keywords[] = {"secLevel", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &secLevel)) {
return NULL;
}
if (secLevel > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetSecLevel(secLevel);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetFrmCtrlRes(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetFrmCtrlRes();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetShortSrcAddr(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
ns3::Mac16Address retval = self->obj->GetShortSrcAddr();
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(retval);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetType(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
ns3::LrWpanMacHeader::LrWpanMacType retval;
retval = self->obj->GetType();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetAckReq(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
self->obj->SetAckReq();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSrcPanId(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetSrcPanId();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetKeyIdSrc32(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetKeyIdSrc32();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsBeacon(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsBeacon();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_IsAckReq(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsAckReq();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSecControl(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetSecControl();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSeqNum(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetSeqNum();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_GetSecCtrlReserved(PyNs3LrWpanMacHeader *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetSecCtrlReserved();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacHeader_SetFrmCtrlRes(PyNs3LrWpanMacHeader *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int res;
const char *keywords[] = {"res", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &res)) {
return NULL;
}
if (res > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetFrmCtrlRes(res);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanMacHeader__copy__(PyNs3LrWpanMacHeader *self)
{
PyNs3LrWpanMacHeader *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanMacHeader, &PyNs3LrWpanMacHeader_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanMacHeader(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanMacHeader_methods[] = {
{(char *) "SetSecCtrlReserved", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSecCtrlReserved, METH_KEYWORDS|METH_VARARGS, "SetSecCtrlReserved(res)\n\ntype: res: uint8_t" },
{(char *) "IsAcknowledgment", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsAcknowledgment, METH_NOARGS, "IsAcknowledgment()\n\n" },
{(char *) "SetFrmPend", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetFrmPend, METH_NOARGS, "SetFrmPend()\n\n" },
{(char *) "IsData", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsData, METH_NOARGS, "IsData()\n\n" },
{(char *) "IsSecEnable", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsSecEnable, METH_NOARGS, "IsSecEnable()\n\n" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "GetDstAddrMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetDstAddrMode, METH_NOARGS, "GetDstAddrMode()\n\n" },
{(char *) "SetNoFrmPend", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetNoFrmPend, METH_NOARGS, "SetNoFrmPend()\n\n" },
{(char *) "SetKeyId", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetKeyId, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "Serialize", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_Serialize, METH_KEYWORDS|METH_VARARGS, "Serialize(start)\n\ntype: start: ns3::Buffer::Iterator" },
{(char *) "SetDstAddrFields", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetDstAddrFields, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "SetSecDisable", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSecDisable, METH_NOARGS, "SetSecDisable()\n\n" },
{(char *) "SetNoAckReq", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetNoAckReq, METH_NOARGS, "SetNoAckReq()\n\n" },
{(char *) "GetFrmCounter", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetFrmCounter, METH_NOARGS, "GetFrmCounter()\n\n" },
{(char *) "GetKeyIdIndex", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetKeyIdIndex, METH_NOARGS, "GetKeyIdIndex()\n\n" },
{(char *) "SetSrcAddrFields", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSrcAddrFields, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "SetSeqNum", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSeqNum, METH_KEYWORDS|METH_VARARGS, "SetSeqNum(seqNum)\n\ntype: seqNum: uint8_t" },
{(char *) "SetSecEnable", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSecEnable, METH_NOARGS, "SetSecEnable()\n\n" },
{(char *) "SetSecControl", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSecControl, METH_KEYWORDS|METH_VARARGS, "SetSecControl(secLevel)\n\ntype: secLevel: uint8_t" },
{(char *) "SetDstAddrMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetDstAddrMode, METH_KEYWORDS|METH_VARARGS, "SetDstAddrMode(addrMode)\n\ntype: addrMode: uint8_t" },
{(char *) "GetSecLevel", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSecLevel, METH_NOARGS, "GetSecLevel()\n\n" },
{(char *) "GetFrameControl", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetFrameControl, METH_NOARGS, "GetFrameControl()\n\n" },
{(char *) "SetPanIdComp", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetPanIdComp, METH_NOARGS, "SetPanIdComp()\n\n" },
{(char *) "SetType", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetType, METH_KEYWORDS|METH_VARARGS, "SetType(wpanMacType)\n\ntype: wpanMacType: ns3::LrWpanMacHeader::LrWpanMacType" },
{(char *) "SetKeyIdMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetKeyIdMode, METH_KEYWORDS|METH_VARARGS, "SetKeyIdMode(keyIdMode)\n\ntype: keyIdMode: uint8_t" },
{(char *) "IsPanIdComp", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsPanIdComp, METH_NOARGS, "IsPanIdComp()\n\n" },
{(char *) "GetExtSrcAddr", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetExtSrcAddr, METH_NOARGS, "GetExtSrcAddr()\n\n" },
{(char *) "SetFrameVer", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetFrameVer, METH_KEYWORDS|METH_VARARGS, "SetFrameVer(ver)\n\ntype: ver: uint8_t" },
{(char *) "Deserialize", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_Deserialize, METH_KEYWORDS|METH_VARARGS, "Deserialize(start)\n\ntype: start: ns3::Buffer::Iterator" },
{(char *) "GetKeyIdSrc64", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetKeyIdSrc64, METH_NOARGS, "GetKeyIdSrc64()\n\n" },
{(char *) "SetSrcAddrMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSrcAddrMode, METH_KEYWORDS|METH_VARARGS, "SetSrcAddrMode(addrMode)\n\ntype: addrMode: uint8_t" },
{(char *) "GetDstPanId", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetDstPanId, METH_NOARGS, "GetDstPanId()\n\n" },
{(char *) "IsCommand", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsCommand, METH_NOARGS, "IsCommand()\n\n" },
{(char *) "SetNoPanIdComp", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetNoPanIdComp, METH_NOARGS, "SetNoPanIdComp()\n\n" },
{(char *) "IsFrmPend", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsFrmPend, METH_NOARGS, "IsFrmPend()\n\n" },
{(char *) "GetFrameVer", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetFrameVer, METH_NOARGS, "GetFrameVer()\n\n" },
{(char *) "GetExtDstAddr", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetExtDstAddr, METH_NOARGS, "GetExtDstAddr()\n\n" },
{(char *) "GetKeyIdMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetKeyIdMode, METH_NOARGS, "GetKeyIdMode()\n\n" },
{(char *) "GetShortDstAddr", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetShortDstAddr, METH_NOARGS, "GetShortDstAddr()\n\n" },
{(char *) "GetInstanceTypeId", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetInstanceTypeId, METH_NOARGS, "GetInstanceTypeId()\n\n" },
{(char *) "GetSerializedSize", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSerializedSize, METH_NOARGS, "GetSerializedSize()\n\n" },
{(char *) "GetSrcAddrMode", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSrcAddrMode, METH_NOARGS, "GetSrcAddrMode()\n\n" },
{(char *) "SetFrameControl", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetFrameControl, METH_KEYWORDS|METH_VARARGS, "SetFrameControl(frameControl)\n\ntype: frameControl: uint16_t" },
{(char *) "SetFrmCounter", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetFrmCounter, METH_KEYWORDS|METH_VARARGS, "SetFrmCounter(frmCntr)\n\ntype: frmCntr: uint32_t" },
{(char *) "SetSecLevel", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetSecLevel, METH_KEYWORDS|METH_VARARGS, "SetSecLevel(secLevel)\n\ntype: secLevel: uint8_t" },
{(char *) "GetFrmCtrlRes", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetFrmCtrlRes, METH_NOARGS, "GetFrmCtrlRes()\n\n" },
{(char *) "GetShortSrcAddr", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetShortSrcAddr, METH_NOARGS, "GetShortSrcAddr()\n\n" },
{(char *) "GetType", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetType, METH_NOARGS, "GetType()\n\n" },
{(char *) "SetAckReq", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetAckReq, METH_NOARGS, "SetAckReq()\n\n" },
{(char *) "GetSrcPanId", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSrcPanId, METH_NOARGS, "GetSrcPanId()\n\n" },
{(char *) "GetKeyIdSrc32", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetKeyIdSrc32, METH_NOARGS, "GetKeyIdSrc32()\n\n" },
{(char *) "IsBeacon", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsBeacon, METH_NOARGS, "IsBeacon()\n\n" },
{(char *) "IsAckReq", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_IsAckReq, METH_NOARGS, "IsAckReq()\n\n" },
{(char *) "GetSecControl", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSecControl, METH_NOARGS, "GetSecControl()\n\n" },
{(char *) "GetSeqNum", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSeqNum, METH_NOARGS, "GetSeqNum()\n\n" },
{(char *) "GetSecCtrlReserved", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_GetSecCtrlReserved, METH_NOARGS, "GetSecCtrlReserved()\n\n" },
{(char *) "SetFrmCtrlRes", (PyCFunction) _wrap_PyNs3LrWpanMacHeader_SetFrmCtrlRes, METH_KEYWORDS|METH_VARARGS, "SetFrmCtrlRes(res)\n\ntype: res: uint8_t" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanMacHeader__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanMacHeader__tp_clear(PyNs3LrWpanMacHeader *self)
{
Py_CLEAR(self->inst_dict);
ns3::LrWpanMacHeader *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
}
static int
PyNs3LrWpanMacHeader__tp_traverse(PyNs3LrWpanMacHeader *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanMacHeader__tp_dealloc(PyNs3LrWpanMacHeader *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanMacHeader__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanMacHeader__tp_richcompare (PyNs3LrWpanMacHeader *PYBINDGEN_UNUSED(self), PyNs3LrWpanMacHeader *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanMacHeader_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanMacHeader_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanMacHeader", /* tp_name */
sizeof(PyNs3LrWpanMacHeader), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanMacHeader__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanMacHeader(wpanMacType, seqNum)\nLrWpanMacHeader(arg0)\nLrWpanMacHeader()", /* Documentation string */
(traverseproc)PyNs3LrWpanMacHeader__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanMacHeader__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanMacHeader__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanMacHeader_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanMacHeader, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanMacHeader__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
pybindgen::TypeMap PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____typeid_map;
static int
_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init__0(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init__1(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *o;
const char *keywords[] = {"o", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type, &o)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >(*((PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *) o)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
static PyObject*
_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____copy__(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *self)
{
PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *py_copy;
py_copy = PyObject_New(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__, &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type);
py_copy->obj = new ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3Empty_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___methods[] = {
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_dealloc(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3Empty_wrapper_registry.end()) {
PyNs3Empty_wrapper_registry.erase(wrapper_lookup_iter);
}
if (self->obj) {
ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> > *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_richcompare (PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *PYBINDGEN_UNUSED(self), PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__ *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__", /* tp_name */
sizeof(PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__(o)\nSimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
PyObject *
PyNs3LrWpanCsmaCa__PythonHelper::_wrap_NotifyConstructionCompleted(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
PyNs3LrWpanCsmaCa__PythonHelper *helper = dynamic_cast< PyNs3LrWpanCsmaCa__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method NotifyConstructionCompleted of class ObjectBase is protected and can only be called by a subclass");
return NULL;
}
helper->NotifyConstructionCompleted__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
PyNs3LrWpanCsmaCa__PythonHelper::_wrap_DoInitialize(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
PyNs3LrWpanCsmaCa__PythonHelper *helper = dynamic_cast< PyNs3LrWpanCsmaCa__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method DoInitialize of class Object is protected and can only be called by a subclass");
return NULL;
}
helper->DoInitialize__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
PyNs3LrWpanCsmaCa__PythonHelper::_wrap_NotifyNewAggregate(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
PyNs3LrWpanCsmaCa__PythonHelper *helper = dynamic_cast< PyNs3LrWpanCsmaCa__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method NotifyNewAggregate of class Object is protected and can only be called by a subclass");
return NULL;
}
helper->NotifyNewAggregate__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
void
PyNs3LrWpanCsmaCa__PythonHelper::DoDispose()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::LrWpanCsmaCa *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "DoDispose"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3LrWpanCsmaCa* >(m_pyself)->obj;
reinterpret_cast< PyNs3LrWpanCsmaCa* >(m_pyself)->obj = (ns3::LrWpanCsmaCa*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "DoDispose", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3LrWpanCsmaCa* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanCsmaCa* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanCsmaCa* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
ns3::TypeId
PyNs3LrWpanCsmaCa__PythonHelper::GetInstanceTypeId() const
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::Object *self_obj_before;
PyObject *py_retval;
PyNs3TypeId *tmp_TypeId;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "GetInstanceTypeId"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
self_obj_before = reinterpret_cast< PyNs3Object* >(m_pyself)->obj;
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = const_cast< ns3::Object* >((const ns3::Object*) this);
py_retval = PyObject_CallMethod(m_pyself, (char *) "GetInstanceTypeId", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
py_retval = Py_BuildValue((char*) "(N)", py_retval);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3TypeId_Type, &tmp_TypeId)) {
PyErr_Print();
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
ns3::TypeId retval = *tmp_TypeId->obj;
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return retval;
}
void
PyNs3LrWpanCsmaCa__PythonHelper::DoInitialize()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::Object *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "DoInitialize"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::Object::DoInitialize();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3Object* >(m_pyself)->obj;
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = (ns3::Object*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "DoInitialize", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
void
PyNs3LrWpanCsmaCa__PythonHelper::NotifyNewAggregate()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::Object *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "NotifyNewAggregate"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::Object::NotifyNewAggregate();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3Object* >(m_pyself)->obj;
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = (ns3::Object*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "NotifyNewAggregate", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
void
PyNs3LrWpanCsmaCa__PythonHelper::NotifyConstructionCompleted()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::ObjectBase *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "NotifyConstructionCompleted"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::ObjectBase::NotifyConstructionCompleted();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj;
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = (ns3::ObjectBase*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "NotifyConstructionCompleted", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
static int
_wrap_PyNs3LrWpanCsmaCa__tp_init(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
return -1;
}
if (Py_TYPE(self) != &PyNs3LrWpanCsmaCa_Type)
{
self->obj = new PyNs3LrWpanCsmaCa__PythonHelper();
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
((PyNs3LrWpanCsmaCa__PythonHelper*) self->obj)->set_pyobj((PyObject *)self);
ns3::CompleteConstruct(self->obj);
} else {
// visibility: 'public'
self->obj = new ns3::LrWpanCsmaCa();
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
ns3::CompleteConstruct(self->obj);
}
return 0;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetUnitBackoffPeriod(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
uint64_t unitBackoffPeriod;
const char *keywords[] = {"unitBackoffPeriod", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "K", (char **) keywords, &unitBackoffPeriod)) {
return NULL;
}
self->obj->SetUnitBackoffPeriod(unitBackoffPeriod);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_PlmeCcaConfirm(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
const char *keywords[] = {"status", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &status)) {
return NULL;
}
self->obj->PlmeCcaConfirm(status);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanCsmaCa::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetMacMaxCSMABackoffs(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int macMaxCSMABackoffs;
const char *keywords[] = {"macMaxCSMABackoffs", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &macMaxCSMABackoffs)) {
return NULL;
}
if (macMaxCSMABackoffs > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetMacMaxCSMABackoffs(macMaxCSMABackoffs);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_Start(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->Start();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_CanProceed(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->CanProceed();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_RandomBackoffDelay(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->RandomBackoffDelay();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetLrWpanMacStateCallback(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *macState;
ns3::Ptr<PythonCallbackImpl15> macState_cb_impl;
const char *keywords[] = {"macState", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &macState)) {
return NULL;
}
if (!PyCallable_Check(macState)) {
PyErr_SetString(PyExc_TypeError, "parameter 'macState' must be callbale");
return NULL;
}
macState_cb_impl = ns3::Create<PythonCallbackImpl15> (macState);
self->obj->SetLrWpanMacStateCallback(ns3::Callback<void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (macState_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetNB(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetNB();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetMac(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanMac > retval;
PyNs3LrWpanMac *py_LrWpanMac;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetMac();
if (!(const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
if (typeid((*const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))).name() == typeid(PyNs3LrWpanMac__PythonHelper).name())
{
py_LrWpanMac = reinterpret_cast< PyNs3LrWpanMac* >(reinterpret_cast< PyNs3LrWpanMac__PythonHelper* >(const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))->m_pyself);
py_LrWpanMac->obj = const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval));
Py_INCREF(py_LrWpanMac);
} else {
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanMac = NULL;
} else {
py_LrWpanMac = (PyNs3LrWpanMac *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanMac);
}
if (py_LrWpanMac == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanMac_Type);
py_LrWpanMac = PyObject_GC_New(PyNs3LrWpanMac, wrapper_type);
py_LrWpanMac->inst_dict = NULL;
py_LrWpanMac->inst_dict = NULL;
py_LrWpanMac->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanMac->obj = const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanMac->obj] = (PyObject *) py_LrWpanMac;
}
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanMac);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_RequestCCA(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->RequestCCA();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetMacMaxBE(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int macMaxBE;
const char *keywords[] = {"macMaxBE", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &macMaxBE)) {
return NULL;
}
if (macMaxBE > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetMacMaxBE(macMaxBE);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_IsUnSlottedCsmaCa(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsUnSlottedCsmaCa();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetUnSlottedCsmaCa(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->SetUnSlottedCsmaCa();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetMacMaxBE(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetMacMaxBE();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetSlottedCsmaCa(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->SetSlottedCsmaCa();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetMac(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanMac *mac;
ns3::LrWpanMac *mac_ptr;
const char *keywords[] = {"mac", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanMac_Type, &mac)) {
return NULL;
}
mac_ptr = (mac ? mac->obj : NULL);
self->obj->SetMac(ns3::Ptr< ns3::LrWpanMac > (mac_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetMacMaxCSMABackoffs(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetMacMaxCSMABackoffs();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_SetMacMinBE(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int macMinBE;
const char *keywords[] = {"macMinBE", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &macMinBE)) {
return NULL;
}
if (macMinBE > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetMacMinBE(macMinBE);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetTimeToNextSlot(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
PyNs3Time *py_Time;
ns3::Time retval = self->obj->GetTimeToNextSlot();
py_Time = PyObject_New(PyNs3Time, &PyNs3Time_Type);
py_Time->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Time->obj = new ns3::Time(retval);
PyNs3Time_wrapper_registry[(void *) py_Time->obj] = (PyObject *) py_Time;
py_retval = Py_BuildValue((char *) "N", py_Time);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_IsSlottedCsmaCa(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsSlottedCsmaCa();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetMacMinBE(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetMacMinBE();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_GetUnitBackoffPeriod(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
uint64_t retval;
retval = self->obj->GetUnitBackoffPeriod();
py_retval = Py_BuildValue((char *) "K", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_AssignStreams(PyNs3LrWpanCsmaCa *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int64_t retval;
int64_t stream;
const char *keywords[] = {"stream", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &stream)) {
return NULL;
}
retval = self->obj->AssignStreams(stream);
py_retval = Py_BuildValue((char *) "L", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanCsmaCa_Cancel(PyNs3LrWpanCsmaCa *self)
{
PyObject *py_retval;
self->obj->Cancel();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyMethodDef PyNs3LrWpanCsmaCa_methods[] = {
{(char *) "SetUnitBackoffPeriod", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetUnitBackoffPeriod, METH_KEYWORDS|METH_VARARGS, "SetUnitBackoffPeriod(unitBackoffPeriod)\n\ntype: unitBackoffPeriod: uint64_t" },
{(char *) "PlmeCcaConfirm", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_PlmeCcaConfirm, METH_KEYWORDS|METH_VARARGS, "PlmeCcaConfirm(status)\n\ntype: status: ns3::LrWpanPhyEnumeration" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "SetMacMaxCSMABackoffs", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetMacMaxCSMABackoffs, METH_KEYWORDS|METH_VARARGS, "SetMacMaxCSMABackoffs(macMaxCSMABackoffs)\n\ntype: macMaxCSMABackoffs: uint8_t" },
{(char *) "Start", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_Start, METH_NOARGS, "Start()\n\n" },
{(char *) "CanProceed", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_CanProceed, METH_NOARGS, "CanProceed()\n\n" },
{(char *) "RandomBackoffDelay", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_RandomBackoffDelay, METH_NOARGS, "RandomBackoffDelay()\n\n" },
{(char *) "SetLrWpanMacStateCallback", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetLrWpanMacStateCallback, METH_KEYWORDS|METH_VARARGS, "SetLrWpanMacStateCallback(macState)\n\ntype: macState: ns3::Callback< void, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "GetNB", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetNB, METH_NOARGS, "GetNB()\n\n" },
{(char *) "GetMac", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetMac, METH_NOARGS, "GetMac()\n\n" },
{(char *) "RequestCCA", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_RequestCCA, METH_NOARGS, "RequestCCA()\n\n" },
{(char *) "SetMacMaxBE", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetMacMaxBE, METH_KEYWORDS|METH_VARARGS, "SetMacMaxBE(macMaxBE)\n\ntype: macMaxBE: uint8_t" },
{(char *) "IsUnSlottedCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_IsUnSlottedCsmaCa, METH_NOARGS, "IsUnSlottedCsmaCa()\n\n" },
{(char *) "SetUnSlottedCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetUnSlottedCsmaCa, METH_NOARGS, "SetUnSlottedCsmaCa()\n\n" },
{(char *) "GetMacMaxBE", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetMacMaxBE, METH_NOARGS, "GetMacMaxBE()\n\n" },
{(char *) "SetSlottedCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetSlottedCsmaCa, METH_NOARGS, "SetSlottedCsmaCa()\n\n" },
{(char *) "SetMac", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetMac, METH_KEYWORDS|METH_VARARGS, "SetMac(mac)\n\ntype: mac: ns3::Ptr< ns3::LrWpanMac >" },
{(char *) "GetMacMaxCSMABackoffs", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetMacMaxCSMABackoffs, METH_NOARGS, "GetMacMaxCSMABackoffs()\n\n" },
{(char *) "SetMacMinBE", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_SetMacMinBE, METH_KEYWORDS|METH_VARARGS, "SetMacMinBE(macMinBE)\n\ntype: macMinBE: uint8_t" },
{(char *) "GetTimeToNextSlot", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetTimeToNextSlot, METH_NOARGS, "GetTimeToNextSlot()\n\n" },
{(char *) "IsSlottedCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_IsSlottedCsmaCa, METH_NOARGS, "IsSlottedCsmaCa()\n\n" },
{(char *) "GetMacMinBE", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetMacMinBE, METH_NOARGS, "GetMacMinBE()\n\n" },
{(char *) "GetUnitBackoffPeriod", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_GetUnitBackoffPeriod, METH_NOARGS, "GetUnitBackoffPeriod()\n\n" },
{(char *) "AssignStreams", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_AssignStreams, METH_KEYWORDS|METH_VARARGS, "AssignStreams(stream)\n\ntype: stream: int64_t" },
{(char *) "Cancel", (PyCFunction) _wrap_PyNs3LrWpanCsmaCa_Cancel, METH_NOARGS, "Cancel()\n\n" },
{(char *) "NotifyConstructionCompleted", (PyCFunction) PyNs3LrWpanCsmaCa__PythonHelper::_wrap_NotifyConstructionCompleted, METH_NOARGS, NULL },
{(char *) "DoInitialize", (PyCFunction) PyNs3LrWpanCsmaCa__PythonHelper::_wrap_DoInitialize, METH_NOARGS, NULL },
{(char *) "NotifyNewAggregate", (PyCFunction) PyNs3LrWpanCsmaCa__PythonHelper::_wrap_NotifyNewAggregate, METH_NOARGS, NULL },
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanCsmaCa__tp_clear(PyNs3LrWpanCsmaCa *self)
{
Py_CLEAR(self->inst_dict);
if (self->obj) {
ns3::LrWpanCsmaCa *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
}
static int
PyNs3LrWpanCsmaCa__tp_traverse(PyNs3LrWpanCsmaCa *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
if (self->obj && typeid(*self->obj).name() == typeid(PyNs3LrWpanCsmaCa__PythonHelper).name() && self->obj->GetReferenceCount() == 1)
Py_VISIT((PyObject *) self);
return 0;
}
static void
_wrap_PyNs3LrWpanCsmaCa__tp_dealloc(PyNs3LrWpanCsmaCa *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanCsmaCa__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanCsmaCa__tp_richcompare (PyNs3LrWpanCsmaCa *PYBINDGEN_UNUSED(self), PyNs3LrWpanCsmaCa *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanCsmaCa_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanCsmaCa_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanCsmaCa", /* tp_name */
sizeof(PyNs3LrWpanCsmaCa), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanCsmaCa__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanCsmaCa()", /* Documentation string */
(traverseproc)PyNs3LrWpanCsmaCa__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanCsmaCa__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanCsmaCa__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanCsmaCa_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanCsmaCa, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanCsmaCa__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanErrorModel__tp_init__0(PyNs3LrWpanErrorModel *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanErrorModel *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanErrorModel_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanErrorModel(*((PyNs3LrWpanErrorModel *) arg0)->obj);
self->obj->Ref ();
ns3::CompleteConstruct(self->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanErrorModel__tp_init__1(PyNs3LrWpanErrorModel *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanErrorModel();
self->obj->Ref ();
ns3::CompleteConstruct(self->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanErrorModel__tp_init(PyNs3LrWpanErrorModel *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanErrorModel__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanErrorModel__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanErrorModel_GetChunkSuccessRate(PyNs3LrWpanErrorModel *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
double retval;
double snr;
unsigned int nbits;
const char *keywords[] = {"snr", "nbits", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "dI", (char **) keywords, &snr, &nbits)) {
return NULL;
}
retval = self->obj->GetChunkSuccessRate(snr, nbits);
py_retval = Py_BuildValue((char *) "d", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanErrorModel_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanErrorModel::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanErrorModel__copy__(PyNs3LrWpanErrorModel *self)
{
PyNs3LrWpanErrorModel *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanErrorModel, &PyNs3LrWpanErrorModel_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanErrorModel(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanErrorModel_methods[] = {
{(char *) "GetChunkSuccessRate", (PyCFunction) _wrap_PyNs3LrWpanErrorModel_GetChunkSuccessRate, METH_KEYWORDS|METH_VARARGS, "GetChunkSuccessRate(snr, nbits)\n\ntype: snr: double\ntype: nbits: uint32_t" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanErrorModel_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanErrorModel__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanErrorModel__tp_clear(PyNs3LrWpanErrorModel *self)
{
Py_CLEAR(self->inst_dict);
if (self->obj) {
ns3::LrWpanErrorModel *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
}
static int
PyNs3LrWpanErrorModel__tp_traverse(PyNs3LrWpanErrorModel *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanErrorModel__tp_dealloc(PyNs3LrWpanErrorModel *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanErrorModel__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanErrorModel__tp_richcompare (PyNs3LrWpanErrorModel *PYBINDGEN_UNUSED(self), PyNs3LrWpanErrorModel *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanErrorModel_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanErrorModel_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanErrorModel", /* tp_name */
sizeof(PyNs3LrWpanErrorModel), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanErrorModel__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanErrorModel(arg0)\nLrWpanErrorModel()", /* Documentation string */
(traverseproc)PyNs3LrWpanErrorModel__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanErrorModel__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanErrorModel__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanErrorModel_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanErrorModel, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanErrorModel__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanInterferenceHelper__tp_init(void)
{
PyErr_SetString(PyExc_TypeError, "class 'LrWpanInterferenceHelper' cannot be constructed ()");
return -1;
}
PyObject *
_wrap_PyNs3LrWpanInterferenceHelper_ClearSignals(PyNs3LrWpanInterferenceHelper *self)
{
PyObject *py_retval;
self->obj->ClearSignals();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyMethodDef PyNs3LrWpanInterferenceHelper_methods[] = {
{(char *) "ClearSignals", (PyCFunction) _wrap_PyNs3LrWpanInterferenceHelper_ClearSignals, METH_NOARGS, "ClearSignals()\n\n" },
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanInterferenceHelper__tp_dealloc(PyNs3LrWpanInterferenceHelper *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3Empty_wrapper_registry.end()) {
PyNs3Empty_wrapper_registry.erase(wrapper_lookup_iter);
}
if (self->obj) {
ns3::LrWpanInterferenceHelper *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanInterferenceHelper__tp_richcompare (PyNs3LrWpanInterferenceHelper *PYBINDGEN_UNUSED(self), PyNs3LrWpanInterferenceHelper *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanInterferenceHelper_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanInterferenceHelper_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanInterferenceHelper", /* tp_name */
sizeof(PyNs3LrWpanInterferenceHelper), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanInterferenceHelper__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanInterferenceHelper__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanInterferenceHelper_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanInterferenceHelper__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
PyObject *
PyNs3LrWpanMac__PythonHelper::_wrap_NotifyConstructionCompleted(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3LrWpanMac__PythonHelper *helper = dynamic_cast< PyNs3LrWpanMac__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method NotifyConstructionCompleted of class ObjectBase is protected and can only be called by a subclass");
return NULL;
}
helper->NotifyConstructionCompleted__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
PyNs3LrWpanMac__PythonHelper::_wrap_DoInitialize(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3LrWpanMac__PythonHelper *helper = dynamic_cast< PyNs3LrWpanMac__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method DoInitialize of class LrWpanMac is protected and can only be called by a subclass");
return NULL;
}
helper->DoInitialize__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
PyNs3LrWpanMac__PythonHelper::_wrap_NotifyNewAggregate(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3LrWpanMac__PythonHelper *helper = dynamic_cast< PyNs3LrWpanMac__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method NotifyNewAggregate of class Object is protected and can only be called by a subclass");
return NULL;
}
helper->NotifyNewAggregate__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
PyNs3LrWpanMac__PythonHelper::_wrap_DoDispose(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3LrWpanMac__PythonHelper *helper = dynamic_cast< PyNs3LrWpanMac__PythonHelper* >(self->obj);
if (helper == NULL) {
PyErr_SetString(PyExc_TypeError, "Method DoDispose of class LrWpanMac is protected and can only be called by a subclass");
return NULL;
}
helper->DoDispose__parent_caller();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
void
PyNs3LrWpanMac__PythonHelper::DoDispose()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::LrWpanMac *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "DoDispose"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::LrWpanMac::DoDispose();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj;
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = (ns3::LrWpanMac*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "DoDispose", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
void
PyNs3LrWpanMac__PythonHelper::DoInitialize()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::LrWpanMac *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "DoInitialize"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::LrWpanMac::DoInitialize();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj;
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = (ns3::LrWpanMac*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "DoInitialize", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3LrWpanMac* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
ns3::TypeId
PyNs3LrWpanMac__PythonHelper::GetInstanceTypeId() const
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::Object *self_obj_before;
PyObject *py_retval;
PyNs3TypeId *tmp_TypeId;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "GetInstanceTypeId"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
self_obj_before = reinterpret_cast< PyNs3Object* >(m_pyself)->obj;
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = const_cast< ns3::Object* >((const ns3::Object*) this);
py_retval = PyObject_CallMethod(m_pyself, (char *) "GetInstanceTypeId", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
py_retval = Py_BuildValue((char*) "(N)", py_retval);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3TypeId_Type, &tmp_TypeId)) {
PyErr_Print();
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return ns3::Object::GetInstanceTypeId();
}
ns3::TypeId retval = *tmp_TypeId->obj;
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return retval;
}
void
PyNs3LrWpanMac__PythonHelper::NotifyNewAggregate()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::Object *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "NotifyNewAggregate"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::Object::NotifyNewAggregate();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3Object* >(m_pyself)->obj;
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = (ns3::Object*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "NotifyNewAggregate", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3Object* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
void
PyNs3LrWpanMac__PythonHelper::NotifyConstructionCompleted()
{
PyGILState_STATE __py_gil_state;
PyObject *py_method;
ns3::ObjectBase *self_obj_before;
PyObject *py_retval;
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0);
py_method = PyObject_GetAttrString(m_pyself, (char *) "NotifyConstructionCompleted"); PyErr_Clear();
if (py_method == NULL || Py_TYPE(py_method) == &PyCFunction_Type) {
ns3::ObjectBase::NotifyConstructionCompleted();
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
self_obj_before = reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj;
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = (ns3::ObjectBase*) this;
py_retval = PyObject_CallMethod(m_pyself, (char *) "NotifyConstructionCompleted", (char *) "");
if (py_retval == NULL) {
PyErr_Print();
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
if (py_retval != Py_None) {
PyErr_SetString(PyExc_TypeError, "function/method should return None");
Py_DECREF(py_retval);
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
Py_DECREF(py_retval);
reinterpret_cast< PyNs3ObjectBase* >(m_pyself)->obj = self_obj_before;
Py_XDECREF(py_method);
if (PyEval_ThreadsInitialized())
PyGILState_Release(__py_gil_state);
return;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_aBaseSlotDuration(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_aBaseSlotDuration);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_aBaseSlotDuration(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_aBaseSlotDuration)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_aBaseSuperframeDuration(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_aBaseSuperframeDuration);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_aBaseSuperframeDuration(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_aBaseSuperframeDuration)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_aNumSuperframeSlots(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_aNumSuperframeSlots);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_aNumSuperframeSlots(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_aNumSuperframeSlots)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macBeaconOrder(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_macBeaconOrder);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macBeaconOrder(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_macBeaconOrder)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macBeaconTxTime(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_macBeaconTxTime);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macBeaconTxTime(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_macBeaconTxTime)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macDsn(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3SequenceNumber8 *py_SequenceNumber8;
py_SequenceNumber8 = PyObject_New(PyNs3SequenceNumber8, &PyNs3SequenceNumber8_Type);
py_SequenceNumber8->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_SequenceNumber8->obj = new ns3::SequenceNumber8(self->obj->m_macDsn);
PyNs3SequenceNumber8_wrapper_registry[(void *) py_SequenceNumber8->obj] = (PyObject *) py_SequenceNumber8;
py_retval = Py_BuildValue((char *) "N", py_SequenceNumber8);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macDsn(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyNs3SequenceNumber8 *tmp_SequenceNumber8;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O!", &PyNs3SequenceNumber8_Type, &tmp_SequenceNumber8)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_macDsn = *tmp_SequenceNumber8->obj;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macMaxFrameRetries(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", (int)self->obj->m_macMaxFrameRetries);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macMaxFrameRetries(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_macMaxFrameRetries = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macPanId(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", self->obj->m_macPanId);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macPanId(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
int tmp;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "i", &tmp)) {
Py_DECREF(py_retval);
return -1;
}
if (tmp > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
Py_DECREF(py_retval);
return -1;
}
self->obj->m_macPanId = tmp;
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macPromiscuousMode(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(self->obj->m_macPromiscuousMode));
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macPromiscuousMode(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyObject *py_boolretval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O", &py_boolretval)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_macPromiscuousMode = PyObject_IsTrue(py_boolretval);
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macRxOnWhenIdle(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(self->obj->m_macRxOnWhenIdle));
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macRxOnWhenIdle(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
PyObject *py_boolretval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "O", &py_boolretval)) {
Py_DECREF(py_retval);
return -1;
}
self->obj->m_macRxOnWhenIdle = PyObject_IsTrue(py_boolretval);
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macSuperframeOrder(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_macSuperframeOrder);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macSuperframeOrder(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_macSuperframeOrder)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyObject* _wrap_PyNs3LrWpanMac__get_m_macSyncSymbolOffset(PyNs3LrWpanMac *self, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "K", self->obj->m_macSyncSymbolOffset);
return py_retval;
}
static int _wrap_PyNs3LrWpanMac__set_m_macSyncSymbolOffset(PyNs3LrWpanMac *self, PyObject *value, void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "(O)", value);
if (!PyArg_ParseTuple(py_retval, (char *) "K", &self->obj->m_macSyncSymbolOffset)) {
Py_DECREF(py_retval);
return -1;
}
Py_DECREF(py_retval);
return 0;
}
static PyGetSetDef PyNs3LrWpanMac__getsets[] = {
{
(char*) "m_macRxOnWhenIdle", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macRxOnWhenIdle, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macRxOnWhenIdle, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macPromiscuousMode", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macPromiscuousMode, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macPromiscuousMode, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macPanId", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macPanId, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macPanId, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macBeaconTxTime", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macBeaconTxTime, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macBeaconTxTime, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macSuperframeOrder", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macSuperframeOrder, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macSuperframeOrder, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_aBaseSlotDuration", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_aBaseSlotDuration, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_aBaseSlotDuration, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macMaxFrameRetries", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macMaxFrameRetries, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macMaxFrameRetries, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macBeaconOrder", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macBeaconOrder, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macBeaconOrder, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macDsn", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macDsn, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macDsn, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_aNumSuperframeSlots", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_aNumSuperframeSlots, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_aNumSuperframeSlots, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_macSyncSymbolOffset", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_macSyncSymbolOffset, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_macSyncSymbolOffset, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "m_aBaseSuperframeDuration", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_m_aBaseSuperframeDuration, /* C function to get the attribute */
(setter) _wrap_PyNs3LrWpanMac__set_m_aBaseSuperframeDuration, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
static PyObject* _wrap_PyNs3LrWpanMac__get_aMinMPDUOverhead(PyObject * PYBINDGEN_UNUSED(obj), void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(ns3::LrWpanMac::aMinMPDUOverhead));
return py_retval;
}
static PyGetSetDef Ns3LrWpanMacMeta__getsets[] = {
{
(char*) "aMinMPDUOverhead", /* attribute name */
(getter) _wrap_PyNs3LrWpanMac__get_aMinMPDUOverhead, /* C function to get the attribute */
(setter) NULL, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
PyTypeObject PyNs3LrWpanMacMeta_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "Ns3LrWpanMacMeta", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
Ns3LrWpanMacMeta__getsets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
0 /* tp_del */
};
static int
_wrap_PyNs3LrWpanMac__tp_init__0(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanMac *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanMac_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
if (Py_TYPE(self) != &PyNs3LrWpanMac_Type)
{
self->obj = new PyNs3LrWpanMac__PythonHelper(*((PyNs3LrWpanMac *) arg0)->obj);
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
((PyNs3LrWpanMac__PythonHelper*) self->obj)->set_pyobj((PyObject *)self);
ns3::CompleteConstruct(self->obj);
} else {
// visibility: 'public'
self->obj = new ns3::LrWpanMac(*((PyNs3LrWpanMac *) arg0)->obj);
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
ns3::CompleteConstruct(self->obj);
}
return 0;
}
static int
_wrap_PyNs3LrWpanMac__tp_init__1(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
if (Py_TYPE(self) != &PyNs3LrWpanMac_Type)
{
self->obj = new PyNs3LrWpanMac__PythonHelper();
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
((PyNs3LrWpanMac__PythonHelper*) self->obj)->set_pyobj((PyObject *)self);
ns3::CompleteConstruct(self->obj);
} else {
// visibility: 'public'
self->obj = new ns3::LrWpanMac();
self->obj->Ref ();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
ns3::CompleteConstruct(self->obj);
}
return 0;
}
int _wrap_PyNs3LrWpanMac__tp_init(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanMac__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMac__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetShortAddress(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3Mac16Address *address;
const char *keywords[] = {"address", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Mac16Address_Type, &address)) {
return NULL;
}
self->obj->SetShortAddress(*((PyNs3Mac16Address *) address)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetPanId(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetPanId();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PlmeSetAttributeConfirm(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
ns3::LrWpanPibAttributeIdentifier id;
const char *keywords[] = {"status", "id", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ii", (char **) keywords, &status, &id)) {
return NULL;
}
self->obj->PlmeSetAttributeConfirm(status, id);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PlmeSetTRXStateConfirm(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
const char *keywords[] = {"status", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &status)) {
return NULL;
}
self->obj->PlmeSetTRXStateConfirm(status);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanMac::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetPhy(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanPhy *phy;
ns3::LrWpanPhy *phy_ptr;
const char *keywords[] = {"phy", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanPhy_Type, &phy)) {
return NULL;
}
phy_ptr = (phy ? phy->obj : NULL);
self->obj->SetPhy(ns3::Ptr< ns3::LrWpanPhy > (phy_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PlmeEdConfirm(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
int energyLevel;
const char *keywords[] = {"status", "energyLevel", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ii", (char **) keywords, &status, &energyLevel)) {
return NULL;
}
if (energyLevel > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->PlmeEdConfirm(status, energyLevel);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetMcpsDataConfirmCallback(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl11> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl11> (c);
self->obj->SetMcpsDataConfirmCallback(ns3::Callback<void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetMacMaxFrameRetries(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int retries;
const char *keywords[] = {"retries", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &retries)) {
return NULL;
}
if (retries > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetMacMaxFrameRetries(retries);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetExtendedAddress(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3Mac64Address *address;
const char *keywords[] = {"address", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Mac64Address_Type, &address)) {
return NULL;
}
self->obj->SetExtendedAddress(*((PyNs3Mac64Address *) address)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PdDataConfirm(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
const char *keywords[] = {"status", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &status)) {
return NULL;
}
self->obj->PdDataConfirm(status);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetRxOnWhenIdle(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool rxOnWhenIdle;
PyObject *py_rxOnWhenIdle;
const char *keywords[] = {"rxOnWhenIdle", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &py_rxOnWhenIdle)) {
return NULL;
}
rxOnWhenIdle = (bool) PyObject_IsTrue(py_rxOnWhenIdle);
self->obj->SetRxOnWhenIdle(rxOnWhenIdle);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PlmeCcaConfirm(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration status;
const char *keywords[] = {"status", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &status)) {
return NULL;
}
self->obj->PlmeCcaConfirm(status);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_PdDataIndication(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
unsigned int psduLength;
PyNs3Packet *p;
ns3::Packet *p_ptr;
int lqi;
const char *keywords[] = {"psduLength", "p", "lqi", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "IO!i", (char **) keywords, &psduLength, &PyNs3Packet_Type, &p, &lqi)) {
return NULL;
}
p_ptr = (p ? p->obj : NULL);
if (lqi > 0xff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->PdDataIndication(psduLength, ns3::Ptr< ns3::Packet > (p_ptr), lqi);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetAssociationStatus(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
ns3::LrWpanAssociationStatus retval;
retval = self->obj->GetAssociationStatus();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_McpsDataRequest(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3McpsDataRequestParams *params;
PyNs3Packet *p;
ns3::Packet *p_ptr;
const char *keywords[] = {"params", "p", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3McpsDataRequestParams_Type, ¶ms, &PyNs3Packet_Type, &p)) {
return NULL;
}
p_ptr = (p ? p->obj : NULL);
self->obj->McpsDataRequest(*((PyNs3McpsDataRequestParams *) params)->obj, ns3::Ptr< ns3::Packet > (p_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetExtendedAddress(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3Mac64Address *py_Mac64Address;
ns3::Mac64Address retval = self->obj->GetExtendedAddress();
py_Mac64Address = PyObject_New(PyNs3Mac64Address, &PyNs3Mac64Address_Type);
py_Mac64Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac64Address->obj = new ns3::Mac64Address(retval);
PyNs3Mac64Address_wrapper_registry[(void *) py_Mac64Address->obj] = (PyObject *) py_Mac64Address;
py_retval = Py_BuildValue((char *) "N", py_Mac64Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetPanId(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int panId;
const char *keywords[] = {"panId", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &panId)) {
return NULL;
}
if (panId > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
self->obj->SetPanId(panId);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetLrWpanMacState(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanMacState macState;
const char *keywords[] = {"macState", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &macState)) {
return NULL;
}
self->obj->SetLrWpanMacState(macState);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetMcpsDataIndicationCallback(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl12> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl12> (c);
self->obj->SetMcpsDataIndicationCallback(ns3::Callback<void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetRxOnWhenIdle(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->GetRxOnWhenIdle();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetMacAckWaitDuration(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
uint64_t retval;
retval = self->obj->GetMacAckWaitDuration();
py_retval = Py_BuildValue((char *) "K", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetAssociationStatus(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanAssociationStatus status;
const char *keywords[] = {"status", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &status)) {
return NULL;
}
self->obj->SetAssociationStatus(status);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetPhy(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanPhy > retval;
PyNs3LrWpanPhy *py_LrWpanPhy;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetPhy();
if (!(const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanPhy = NULL;
} else {
py_LrWpanPhy = (PyNs3LrWpanPhy *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanPhy);
}
if (py_LrWpanPhy == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanPhy_Type);
py_LrWpanPhy = PyObject_GC_New(PyNs3LrWpanPhy, wrapper_type);
py_LrWpanPhy->inst_dict = NULL;
py_LrWpanPhy->inst_dict = NULL;
py_LrWpanPhy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanPhy->obj = const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanPhy->obj] = (PyObject *) py_LrWpanPhy;
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanPhy);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetMacMaxFrameRetries(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
uint8_t retval;
retval = self->obj->GetMacMaxFrameRetries();
py_retval = Py_BuildValue((char *) "i", (int)retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_GetShortAddress(PyNs3LrWpanMac *self)
{
PyObject *py_retval;
PyNs3Mac16Address *py_Mac16Address;
ns3::Mac16Address retval = self->obj->GetShortAddress();
py_Mac16Address = PyObject_New(PyNs3Mac16Address, &PyNs3Mac16Address_Type);
py_Mac16Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Mac16Address->obj = new ns3::Mac16Address(retval);
PyNs3Mac16Address_wrapper_registry[(void *) py_Mac16Address->obj] = (PyObject *) py_Mac16Address;
py_retval = Py_BuildValue((char *) "N", py_Mac16Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMac_SetCsmaCa(PyNs3LrWpanMac *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanCsmaCa *csmaCa;
ns3::LrWpanCsmaCa *csmaCa_ptr;
const char *keywords[] = {"csmaCa", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanCsmaCa_Type, &csmaCa)) {
return NULL;
}
csmaCa_ptr = (csmaCa ? csmaCa->obj : NULL);
self->obj->SetCsmaCa(ns3::Ptr< ns3::LrWpanCsmaCa > (csmaCa_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanMac__copy__(PyNs3LrWpanMac *self)
{
PyNs3LrWpanMac *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanMac, &PyNs3LrWpanMac_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanMac(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanMac_methods[] = {
{(char *) "SetShortAddress", (PyCFunction) _wrap_PyNs3LrWpanMac_SetShortAddress, METH_KEYWORDS|METH_VARARGS, "SetShortAddress(address)\n\ntype: address: ns3::Mac16Address" },
{(char *) "GetPanId", (PyCFunction) _wrap_PyNs3LrWpanMac_GetPanId, METH_NOARGS, "GetPanId()\n\n" },
{(char *) "PlmeSetAttributeConfirm", (PyCFunction) _wrap_PyNs3LrWpanMac_PlmeSetAttributeConfirm, METH_KEYWORDS|METH_VARARGS, "PlmeSetAttributeConfirm(status, id)\n\ntype: status: ns3::LrWpanPhyEnumeration\ntype: id: ns3::LrWpanPibAttributeIdentifier" },
{(char *) "PlmeSetTRXStateConfirm", (PyCFunction) _wrap_PyNs3LrWpanMac_PlmeSetTRXStateConfirm, METH_KEYWORDS|METH_VARARGS, "PlmeSetTRXStateConfirm(status)\n\ntype: status: ns3::LrWpanPhyEnumeration" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanMac_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "SetPhy", (PyCFunction) _wrap_PyNs3LrWpanMac_SetPhy, METH_KEYWORDS|METH_VARARGS, "SetPhy(phy)\n\ntype: phy: ns3::Ptr< ns3::LrWpanPhy >" },
{(char *) "PlmeEdConfirm", (PyCFunction) _wrap_PyNs3LrWpanMac_PlmeEdConfirm, METH_KEYWORDS|METH_VARARGS, "PlmeEdConfirm(status, energyLevel)\n\ntype: status: ns3::LrWpanPhyEnumeration\ntype: energyLevel: uint8_t" },
{(char *) "SetMcpsDataConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanMac_SetMcpsDataConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetMcpsDataConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "SetMacMaxFrameRetries", (PyCFunction) _wrap_PyNs3LrWpanMac_SetMacMaxFrameRetries, METH_KEYWORDS|METH_VARARGS, "SetMacMaxFrameRetries(retries)\n\ntype: retries: uint8_t" },
{(char *) "SetExtendedAddress", (PyCFunction) _wrap_PyNs3LrWpanMac_SetExtendedAddress, METH_KEYWORDS|METH_VARARGS, "SetExtendedAddress(address)\n\ntype: address: ns3::Mac64Address" },
{(char *) "PdDataConfirm", (PyCFunction) _wrap_PyNs3LrWpanMac_PdDataConfirm, METH_KEYWORDS|METH_VARARGS, "PdDataConfirm(status)\n\ntype: status: ns3::LrWpanPhyEnumeration" },
{(char *) "SetRxOnWhenIdle", (PyCFunction) _wrap_PyNs3LrWpanMac_SetRxOnWhenIdle, METH_KEYWORDS|METH_VARARGS, "SetRxOnWhenIdle(rxOnWhenIdle)\n\ntype: rxOnWhenIdle: bool" },
{(char *) "PlmeCcaConfirm", (PyCFunction) _wrap_PyNs3LrWpanMac_PlmeCcaConfirm, METH_KEYWORDS|METH_VARARGS, "PlmeCcaConfirm(status)\n\ntype: status: ns3::LrWpanPhyEnumeration" },
{(char *) "PdDataIndication", (PyCFunction) _wrap_PyNs3LrWpanMac_PdDataIndication, METH_KEYWORDS|METH_VARARGS, "PdDataIndication(psduLength, p, lqi)\n\ntype: psduLength: uint32_t\ntype: p: ns3::Ptr< ns3::Packet >\ntype: lqi: uint8_t" },
{(char *) "GetAssociationStatus", (PyCFunction) _wrap_PyNs3LrWpanMac_GetAssociationStatus, METH_NOARGS, "GetAssociationStatus()\n\n" },
{(char *) "McpsDataRequest", (PyCFunction) _wrap_PyNs3LrWpanMac_McpsDataRequest, METH_KEYWORDS|METH_VARARGS, "McpsDataRequest(params, p)\n\ntype: params: ns3::McpsDataRequestParams\ntype: p: ns3::Ptr< ns3::Packet >" },
{(char *) "GetExtendedAddress", (PyCFunction) _wrap_PyNs3LrWpanMac_GetExtendedAddress, METH_NOARGS, "GetExtendedAddress()\n\n" },
{(char *) "SetPanId", (PyCFunction) _wrap_PyNs3LrWpanMac_SetPanId, METH_KEYWORDS|METH_VARARGS, "SetPanId(panId)\n\ntype: panId: uint16_t" },
{(char *) "SetLrWpanMacState", (PyCFunction) _wrap_PyNs3LrWpanMac_SetLrWpanMacState, METH_KEYWORDS|METH_VARARGS, "SetLrWpanMacState(macState)\n\ntype: macState: ns3::LrWpanMacState" },
{(char *) "SetMcpsDataIndicationCallback", (PyCFunction) _wrap_PyNs3LrWpanMac_SetMcpsDataIndicationCallback, METH_KEYWORDS|METH_VARARGS, "SetMcpsDataIndicationCallback(c)\n\ntype: c: ns3::Callback< void, ns3::McpsDataIndicationParams, ns3::Ptr< ns3::Packet >, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "GetRxOnWhenIdle", (PyCFunction) _wrap_PyNs3LrWpanMac_GetRxOnWhenIdle, METH_NOARGS, "GetRxOnWhenIdle()\n\n" },
{(char *) "GetMacAckWaitDuration", (PyCFunction) _wrap_PyNs3LrWpanMac_GetMacAckWaitDuration, METH_NOARGS, "GetMacAckWaitDuration()\n\n" },
{(char *) "SetAssociationStatus", (PyCFunction) _wrap_PyNs3LrWpanMac_SetAssociationStatus, METH_KEYWORDS|METH_VARARGS, "SetAssociationStatus(status)\n\ntype: status: ns3::LrWpanAssociationStatus" },
{(char *) "GetPhy", (PyCFunction) _wrap_PyNs3LrWpanMac_GetPhy, METH_NOARGS, "GetPhy()\n\n" },
{(char *) "GetMacMaxFrameRetries", (PyCFunction) _wrap_PyNs3LrWpanMac_GetMacMaxFrameRetries, METH_NOARGS, "GetMacMaxFrameRetries()\n\n" },
{(char *) "GetShortAddress", (PyCFunction) _wrap_PyNs3LrWpanMac_GetShortAddress, METH_NOARGS, "GetShortAddress()\n\n" },
{(char *) "SetCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanMac_SetCsmaCa, METH_KEYWORDS|METH_VARARGS, "SetCsmaCa(csmaCa)\n\ntype: csmaCa: ns3::Ptr< ns3::LrWpanCsmaCa >" },
{(char *) "NotifyConstructionCompleted", (PyCFunction) PyNs3LrWpanMac__PythonHelper::_wrap_NotifyConstructionCompleted, METH_NOARGS, NULL },
{(char *) "DoInitialize", (PyCFunction) PyNs3LrWpanMac__PythonHelper::_wrap_DoInitialize, METH_NOARGS, NULL },
{(char *) "NotifyNewAggregate", (PyCFunction) PyNs3LrWpanMac__PythonHelper::_wrap_NotifyNewAggregate, METH_NOARGS, NULL },
{(char *) "DoDispose", (PyCFunction) PyNs3LrWpanMac__PythonHelper::_wrap_DoDispose, METH_NOARGS, NULL },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanMac__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanMac__tp_clear(PyNs3LrWpanMac *self)
{
Py_CLEAR(self->inst_dict);
if (self->obj) {
ns3::LrWpanMac *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
}
static int
PyNs3LrWpanMac__tp_traverse(PyNs3LrWpanMac *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
if (self->obj && typeid(*self->obj).name() == typeid(PyNs3LrWpanMac__PythonHelper).name() && self->obj->GetReferenceCount() == 1)
Py_VISIT((PyObject *) self);
return 0;
}
static void
_wrap_PyNs3LrWpanMac__tp_dealloc(PyNs3LrWpanMac *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanMac__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanMac__tp_richcompare (PyNs3LrWpanMac *PYBINDGEN_UNUSED(self), PyNs3LrWpanMac *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanMac_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanMac_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanMac", /* tp_name */
sizeof(PyNs3LrWpanMac), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanMac__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanMac(arg0)\nLrWpanMac()", /* Documentation string */
(traverseproc)PyNs3LrWpanMac__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanMac__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanMac__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanMac_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
PyNs3LrWpanMac__getsets, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanMac, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanMac__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static PyObject* _wrap_PyNs3LrWpanMacTrailer__get_LR_WPAN_MAC_FCS_LENGTH(PyObject * PYBINDGEN_UNUSED(obj), void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "i", ns3::LrWpanMacTrailer::LR_WPAN_MAC_FCS_LENGTH);
return py_retval;
}
static PyGetSetDef Ns3LrWpanMacTrailerMeta__getsets[] = {
{
(char*) "LR_WPAN_MAC_FCS_LENGTH", /* attribute name */
(getter) _wrap_PyNs3LrWpanMacTrailer__get_LR_WPAN_MAC_FCS_LENGTH, /* C function to get the attribute */
(setter) NULL, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
PyTypeObject PyNs3LrWpanMacTrailerMeta_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "Ns3LrWpanMacTrailerMeta", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
Ns3LrWpanMacTrailerMeta__getsets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
0 /* tp_del */
};
static int
_wrap_PyNs3LrWpanMacTrailer__tp_init__0(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanMacTrailer *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanMacTrailer_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanMacTrailer(*((PyNs3LrWpanMacTrailer *) arg0)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanMacTrailer__tp_init__1(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanMacTrailer();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanMacTrailer__tp_init(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanMacTrailer__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanMacTrailer__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_CheckFcs(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool retval;
PyNs3Packet *p;
ns3::Packet *p_ptr;
const char *keywords[] = {"p", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Packet_Type, &p)) {
return NULL;
}
p_ptr = (p ? p->obj : NULL);
retval = self->obj->CheckFcs(ns3::Ptr< ns3::Packet > (p_ptr));
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_GetFcs(PyNs3LrWpanMacTrailer *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetFcs();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_SetFcs(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3Packet *p;
ns3::Packet *p_ptr;
const char *keywords[] = {"p", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Packet_Type, &p)) {
return NULL;
}
p_ptr = (p ? p->obj : NULL);
self->obj->SetFcs(ns3::Ptr< ns3::Packet > (p_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_Deserialize(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
uint32_t retval;
PyNs3BufferIterator *start;
const char *keywords[] = {"start", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3BufferIterator_Type, &start)) {
return NULL;
}
retval = self->obj->Deserialize(*((PyNs3BufferIterator *) start)->obj);
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanMacTrailer::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_Serialize(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3BufferIterator *start;
const char *keywords[] = {"start", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3BufferIterator_Type, &start)) {
return NULL;
}
self->obj->Serialize(*((PyNs3BufferIterator *) start)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_EnableFcs(PyNs3LrWpanMacTrailer *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool enable;
PyObject *py_enable;
const char *keywords[] = {"enable", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &py_enable)) {
return NULL;
}
enable = (bool) PyObject_IsTrue(py_enable);
self->obj->EnableFcs(enable);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_GetInstanceTypeId(PyNs3LrWpanMacTrailer *self)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = self->obj->GetInstanceTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_GetSerializedSize(PyNs3LrWpanMacTrailer *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetSerializedSize();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanMacTrailer_IsFcsEnabled(PyNs3LrWpanMacTrailer *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsFcsEnabled();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanMacTrailer__copy__(PyNs3LrWpanMacTrailer *self)
{
PyNs3LrWpanMacTrailer *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanMacTrailer, &PyNs3LrWpanMacTrailer_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanMacTrailer(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanMacTrailer_methods[] = {
{(char *) "CheckFcs", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_CheckFcs, METH_KEYWORDS|METH_VARARGS, "CheckFcs(p)\n\ntype: p: ns3::Ptr< ns3::Packet const >" },
{(char *) "GetFcs", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_GetFcs, METH_NOARGS, "GetFcs()\n\n" },
{(char *) "SetFcs", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_SetFcs, METH_KEYWORDS|METH_VARARGS, "SetFcs(p)\n\ntype: p: ns3::Ptr< ns3::Packet const >" },
{(char *) "Deserialize", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_Deserialize, METH_KEYWORDS|METH_VARARGS, "Deserialize(start)\n\ntype: start: ns3::Buffer::Iterator" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "Serialize", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_Serialize, METH_KEYWORDS|METH_VARARGS, "Serialize(start)\n\ntype: start: ns3::Buffer::Iterator" },
{(char *) "EnableFcs", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_EnableFcs, METH_KEYWORDS|METH_VARARGS, "EnableFcs(enable)\n\ntype: enable: bool" },
{(char *) "GetInstanceTypeId", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_GetInstanceTypeId, METH_NOARGS, "GetInstanceTypeId()\n\n" },
{(char *) "GetSerializedSize", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_GetSerializedSize, METH_NOARGS, "GetSerializedSize()\n\n" },
{(char *) "IsFcsEnabled", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer_IsFcsEnabled, METH_NOARGS, "IsFcsEnabled()\n\n" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanMacTrailer__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanMacTrailer__tp_clear(PyNs3LrWpanMacTrailer *self)
{
Py_CLEAR(self->inst_dict);
ns3::LrWpanMacTrailer *tmp = self->obj;
self->obj = NULL;
if (!(self->flags&PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED)) {
delete tmp;
}
}
static int
PyNs3LrWpanMacTrailer__tp_traverse(PyNs3LrWpanMacTrailer *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanMacTrailer__tp_dealloc(PyNs3LrWpanMacTrailer *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanMacTrailer__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanMacTrailer__tp_richcompare (PyNs3LrWpanMacTrailer *PYBINDGEN_UNUSED(self), PyNs3LrWpanMacTrailer *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanMacTrailer_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanMacTrailer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanMacTrailer", /* tp_name */
sizeof(PyNs3LrWpanMacTrailer), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanMacTrailer__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanMacTrailer(arg0)\nLrWpanMacTrailer()", /* Documentation string */
(traverseproc)PyNs3LrWpanMacTrailer__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanMacTrailer__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanMacTrailer__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanMacTrailer_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanMacTrailer, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanMacTrailer__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static PyObject* _wrap_PyNs3LrWpanPhy__get_aMaxPhyPacketSize(PyObject * PYBINDGEN_UNUSED(obj), void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(ns3::LrWpanPhy::aMaxPhyPacketSize));
return py_retval;
}
static PyObject* _wrap_PyNs3LrWpanPhy__get_aTurnaroundTime(PyObject * PYBINDGEN_UNUSED(obj), void * PYBINDGEN_UNUSED(closure))
{
PyObject *py_retval;
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(ns3::LrWpanPhy::aTurnaroundTime));
return py_retval;
}
static PyGetSetDef Ns3LrWpanPhyMeta__getsets[] = {
{
(char*) "aMaxPhyPacketSize", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhy__get_aMaxPhyPacketSize, /* C function to get the attribute */
(setter) NULL, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{
(char*) "aTurnaroundTime", /* attribute name */
(getter) _wrap_PyNs3LrWpanPhy__get_aTurnaroundTime, /* C function to get the attribute */
(setter) NULL, /* C function to set the attribute */
NULL, /* optional doc string */
NULL /* optional additional data for getter and setter */
},
{ NULL, NULL, NULL, NULL, NULL }
};
PyTypeObject PyNs3LrWpanPhyMeta_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "Ns3LrWpanPhyMeta", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
Ns3LrWpanPhyMeta__getsets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_subclasses */
0, /* tp_weaklist */
0 /* tp_del */
};
static int
_wrap_PyNs3LrWpanPhy__tp_init(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
return -1;
}
self->obj = new ns3::LrWpanPhy();
self->obj->Ref ();
ns3::CompleteConstruct(self->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPdDataConfirmCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl2> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl2> (c);
self->obj->SetPdDataConfirmCallback(ns3::Callback<void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPlmeSetTRXStateConfirmCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl2> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl2> (c);
self->obj->SetPlmeSetTRXStateConfirmCallback(ns3::Callback<void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanPhy::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPlmeSetAttributeConfirmCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl5> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl5> (c);
self->obj->SetPlmeSetAttributeConfirmCallback(ns3::Callback<void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_PlmeGetAttributeRequest(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPibAttributeIdentifier id;
const char *keywords[] = {"id", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &id)) {
return NULL;
}
self->obj->PlmeGetAttributeRequest(id);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetPhySHRDuration(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
uint64_t retval;
retval = self->obj->GetPhySHRDuration();
py_retval = Py_BuildValue((char *) "K", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetDataOrSymbolRate(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
double retval;
bool isData;
PyObject *py_isData;
const char *keywords[] = {"isData", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &py_isData)) {
return NULL;
}
isData = (bool) PyObject_IsTrue(py_isData);
retval = self->obj->GetDataOrSymbolRate(isData);
py_retval = Py_BuildValue((char *) "d", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetPhySymbolsPerOctet(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
double retval;
retval = self->obj->GetPhySymbolsPerOctet();
py_retval = Py_BuildValue((char *) "d", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetErrorModel(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanErrorModel *e;
ns3::LrWpanErrorModel *e_ptr;
const char *keywords[] = {"e", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanErrorModel_Type, &e)) {
return NULL;
}
e_ptr = (e ? e->obj : NULL);
self->obj->SetErrorModel(ns3::Ptr< ns3::LrWpanErrorModel > (e_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_PlmeSetTRXStateRequest(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
ns3::LrWpanPhyEnumeration state;
const char *keywords[] = {"state", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &state)) {
return NULL;
}
self->obj->PlmeSetTRXStateRequest(state);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPlmeEdConfirmCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl3> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl3> (c);
self->obj->SetPlmeEdConfirmCallback(ns3::Callback<void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPdDataIndicationCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl1> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl1> (c);
self->obj->SetPdDataIndicationCallback(ns3::Callback<void, unsigned int, ns3::Ptr<ns3::Packet>, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_PlmeCcaRequest(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
self->obj->PlmeCcaRequest();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetErrorModel(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanErrorModel > retval;
PyNs3LrWpanErrorModel *py_LrWpanErrorModel;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetErrorModel();
if (!(const_cast<ns3::LrWpanErrorModel *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanErrorModel *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanErrorModel = NULL;
} else {
py_LrWpanErrorModel = (PyNs3LrWpanErrorModel *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanErrorModel);
}
if (py_LrWpanErrorModel == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanErrorModel *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanErrorModel_Type);
py_LrWpanErrorModel = PyObject_GC_New(PyNs3LrWpanErrorModel, wrapper_type);
py_LrWpanErrorModel->inst_dict = NULL;
py_LrWpanErrorModel->inst_dict = NULL;
py_LrWpanErrorModel->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanErrorModel *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanErrorModel->obj = const_cast<ns3::LrWpanErrorModel *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanErrorModel->obj] = (PyObject *) py_LrWpanErrorModel;
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanErrorModel);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_PlmeEdRequest(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
self->obj->PlmeEdRequest();
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_StartRx(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3SpectrumSignalParameters *params;
ns3::SpectrumSignalParameters *params_ptr;
const char *keywords[] = {"params", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3SpectrumSignalParameters_Type, ¶ms)) {
return NULL;
}
params_ptr = (params ? params->obj : NULL);
self->obj->StartRx(ns3::Ptr< ns3::SpectrumSignalParameters > (params_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetDevice(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3NetDevice *d;
ns3::NetDevice *d_ptr;
const char *keywords[] = {"d", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3NetDevice_Type, &d)) {
return NULL;
}
d_ptr = (d ? d->obj : NULL);
self->obj->SetDevice(ns3::Ptr< ns3::NetDevice > (d_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_GetDevice(PyNs3LrWpanPhy *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::NetDevice > retval;
PyNs3NetDevice *py_NetDevice;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetDevice();
if (!(const_cast<ns3::NetDevice *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::NetDevice *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_NetDevice = NULL;
} else {
py_NetDevice = (PyNs3NetDevice *) wrapper_lookup_iter->second;
Py_INCREF(py_NetDevice);
}
if (py_NetDevice == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::NetDevice *> (ns3::PeekPointer (retval)))), &PyNs3NetDevice_Type);
py_NetDevice = PyObject_GC_New(PyNs3NetDevice, wrapper_type);
py_NetDevice->inst_dict = NULL;
py_NetDevice->inst_dict = NULL;
py_NetDevice->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::NetDevice *> (ns3::PeekPointer (retval))->Ref();
py_NetDevice->obj = const_cast<ns3::NetDevice *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_NetDevice->obj] = (PyObject *) py_NetDevice;
}
py_retval = Py_BuildValue((char *) "N", py_NetDevice);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_SetPlmeCcaConfirmCallback(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *c;
ns3::Ptr<PythonCallbackImpl2> c_cb_impl;
const char *keywords[] = {"c", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &c)) {
return NULL;
}
if (!PyCallable_Check(c)) {
PyErr_SetString(PyExc_TypeError, "parameter 'c' must be callbale");
return NULL;
}
c_cb_impl = ns3::Create<PythonCallbackImpl2> (c);
self->obj->SetPlmeCcaConfirmCallback(ns3::Callback<void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (c_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_PdDataRequest(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
unsigned int psduLength;
PyNs3Packet *p;
ns3::Packet *p_ptr;
const char *keywords[] = {"psduLength", "p", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "IO!", (char **) keywords, &psduLength, &PyNs3Packet_Type, &p)) {
return NULL;
}
p_ptr = (p ? p->obj : NULL);
self->obj->PdDataRequest(psduLength, ns3::Ptr< ns3::Packet > (p_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanPhy_AssignStreams(PyNs3LrWpanPhy *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int64_t retval;
int64_t stream;
const char *keywords[] = {"stream", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &stream)) {
return NULL;
}
retval = self->obj->AssignStreams(stream);
py_retval = Py_BuildValue((char *) "L", retval);
return py_retval;
}
static PyMethodDef PyNs3LrWpanPhy_methods[] = {
{(char *) "SetPdDataConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPdDataConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetPdDataConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "SetPlmeSetTRXStateConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPlmeSetTRXStateConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetPlmeSetTRXStateConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "SetPlmeSetAttributeConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPlmeSetAttributeConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetPlmeSetAttributeConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPibAttributeIdentifier, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "PlmeGetAttributeRequest", (PyCFunction) _wrap_PyNs3LrWpanPhy_PlmeGetAttributeRequest, METH_KEYWORDS|METH_VARARGS, "PlmeGetAttributeRequest(id)\n\ntype: id: ns3::LrWpanPibAttributeIdentifier" },
{(char *) "GetPhySHRDuration", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetPhySHRDuration, METH_NOARGS, "GetPhySHRDuration()\n\n" },
{(char *) "GetDataOrSymbolRate", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetDataOrSymbolRate, METH_KEYWORDS|METH_VARARGS, "GetDataOrSymbolRate(isData)\n\ntype: isData: bool" },
{(char *) "GetPhySymbolsPerOctet", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetPhySymbolsPerOctet, METH_NOARGS, "GetPhySymbolsPerOctet()\n\n" },
{(char *) "SetErrorModel", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetErrorModel, METH_KEYWORDS|METH_VARARGS, "SetErrorModel(e)\n\ntype: e: ns3::Ptr< ns3::LrWpanErrorModel >" },
{(char *) "PlmeSetTRXStateRequest", (PyCFunction) _wrap_PyNs3LrWpanPhy_PlmeSetTRXStateRequest, METH_KEYWORDS|METH_VARARGS, "PlmeSetTRXStateRequest(state)\n\ntype: state: ns3::LrWpanPhyEnumeration" },
{(char *) "SetPlmeEdConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPlmeEdConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetPlmeEdConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::LrWpanPhyEnumeration, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "SetPdDataIndicationCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPdDataIndicationCallback, METH_KEYWORDS|METH_VARARGS, "SetPdDataIndicationCallback(c)\n\ntype: c: ns3::Callback< void, unsigned int, ns3::Ptr< ns3::Packet >, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "PlmeCcaRequest", (PyCFunction) _wrap_PyNs3LrWpanPhy_PlmeCcaRequest, METH_NOARGS, "PlmeCcaRequest()\n\n" },
{(char *) "GetErrorModel", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetErrorModel, METH_NOARGS, "GetErrorModel()\n\n" },
{(char *) "PlmeEdRequest", (PyCFunction) _wrap_PyNs3LrWpanPhy_PlmeEdRequest, METH_NOARGS, "PlmeEdRequest()\n\n" },
{(char *) "StartRx", (PyCFunction) _wrap_PyNs3LrWpanPhy_StartRx, METH_KEYWORDS|METH_VARARGS, "StartRx(params)\n\ntype: params: ns3::Ptr< ns3::SpectrumSignalParameters >" },
{(char *) "SetDevice", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetDevice, METH_KEYWORDS|METH_VARARGS, "SetDevice(d)\n\ntype: d: ns3::Ptr< ns3::NetDevice >" },
{(char *) "GetDevice", (PyCFunction) _wrap_PyNs3LrWpanPhy_GetDevice, METH_NOARGS, "GetDevice()\n\n" },
{(char *) "SetPlmeCcaConfirmCallback", (PyCFunction) _wrap_PyNs3LrWpanPhy_SetPlmeCcaConfirmCallback, METH_KEYWORDS|METH_VARARGS, "SetPlmeCcaConfirmCallback(c)\n\ntype: c: ns3::Callback< void, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "PdDataRequest", (PyCFunction) _wrap_PyNs3LrWpanPhy_PdDataRequest, METH_KEYWORDS|METH_VARARGS, "PdDataRequest(psduLength, p)\n\ntype: psduLength: uint32_t const\ntype: p: ns3::Ptr< ns3::Packet >" },
{(char *) "AssignStreams", (PyCFunction) _wrap_PyNs3LrWpanPhy_AssignStreams, METH_KEYWORDS|METH_VARARGS, "AssignStreams(stream)\n\ntype: stream: int64_t" },
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanPhy__tp_clear(PyNs3LrWpanPhy *self)
{
Py_CLEAR(self->inst_dict);
if (self->obj) {
ns3::LrWpanPhy *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
}
static int
PyNs3LrWpanPhy__tp_traverse(PyNs3LrWpanPhy *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanPhy__tp_dealloc(PyNs3LrWpanPhy *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanPhy__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanPhy__tp_richcompare (PyNs3LrWpanPhy *PYBINDGEN_UNUSED(self), PyNs3LrWpanPhy *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanPhy_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanPhy_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanPhy", /* tp_name */
sizeof(PyNs3LrWpanPhy), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanPhy__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanPhy()", /* Documentation string */
(traverseproc)PyNs3LrWpanPhy__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanPhy__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanPhy__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanPhy_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanPhy, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanPhy__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init__0(PyNs3LrWpanSpectrumSignalParameters *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanSpectrumSignalParameters();
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init__1(PyNs3LrWpanSpectrumSignalParameters *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanSpectrumSignalParameters *p;
const char *keywords[] = {"p", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanSpectrumSignalParameters_Type, &p)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanSpectrumSignalParameters(*((PyNs3LrWpanSpectrumSignalParameters *) p)->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init(PyNs3LrWpanSpectrumSignalParameters *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanSpectrumSignalParameters_Copy(PyNs3LrWpanSpectrumSignalParameters *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::SpectrumSignalParameters > retval;
PyNs3SpectrumSignalParameters *py_SpectrumSignalParameters;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->Copy();
if (!(const_cast<ns3::SpectrumSignalParameters *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) const_cast<ns3::SpectrumSignalParameters *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3Empty_wrapper_registry.end()) {
py_SpectrumSignalParameters = NULL;
} else {
py_SpectrumSignalParameters = (PyNs3SpectrumSignalParameters *) wrapper_lookup_iter->second;
Py_INCREF(py_SpectrumSignalParameters);
}
if (py_SpectrumSignalParameters == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map.lookup_wrapper(typeid((*const_cast<ns3::SpectrumSignalParameters *> (ns3::PeekPointer (retval)))), &PyNs3SpectrumSignalParameters_Type);
py_SpectrumSignalParameters = PyObject_New(PyNs3SpectrumSignalParameters, wrapper_type);
py_SpectrumSignalParameters->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::SpectrumSignalParameters *> (ns3::PeekPointer (retval))->Ref();
py_SpectrumSignalParameters->obj = const_cast<ns3::SpectrumSignalParameters *> (ns3::PeekPointer (retval));
PyNs3Empty_wrapper_registry[(void *) py_SpectrumSignalParameters->obj] = (PyObject *) py_SpectrumSignalParameters;
}
py_retval = Py_BuildValue((char *) "N", py_SpectrumSignalParameters);
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanSpectrumSignalParameters__copy__(PyNs3LrWpanSpectrumSignalParameters *self)
{
PyNs3LrWpanSpectrumSignalParameters *py_copy;
py_copy = PyObject_New(PyNs3LrWpanSpectrumSignalParameters, &PyNs3LrWpanSpectrumSignalParameters_Type);
py_copy->obj = new ns3::LrWpanSpectrumSignalParameters(*self->obj);
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3Empty_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanSpectrumSignalParameters_methods[] = {
{(char *) "Copy", (PyCFunction) _wrap_PyNs3LrWpanSpectrumSignalParameters_Copy, METH_NOARGS, "Copy()\n\n" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanSpectrumSignalParameters__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_dealloc(PyNs3LrWpanSpectrumSignalParameters *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3Empty_wrapper_registry.end()) {
PyNs3Empty_wrapper_registry.erase(wrapper_lookup_iter);
}
if (self->obj) {
ns3::LrWpanSpectrumSignalParameters *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_richcompare (PyNs3LrWpanSpectrumSignalParameters *PYBINDGEN_UNUSED(self), PyNs3LrWpanSpectrumSignalParameters *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanSpectrumSignalParameters_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanSpectrumSignalParameters_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanSpectrumSignalParameters", /* tp_name */
sizeof(PyNs3LrWpanSpectrumSignalParameters), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"LrWpanSpectrumSignalParameters(p)\nLrWpanSpectrumSignalParameters()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanSpectrumSignalParameters_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanSpectrumSignalParameters__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_init(void)
{
PyErr_SetString(PyExc_TypeError, "class 'CallbackImpl' cannot be constructed (have pure virtual methods but no helper class)");
return -1;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty___call__(PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3McpsDataConfirmParams *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3McpsDataConfirmParams_Type, &arg0)) {
return NULL;
}
self->obj->operator()(*((PyNs3McpsDataConfirmParams *) arg0)->obj);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_DoGetTypeid(void)
{
PyObject *py_retval;
std::string retval;
retval = ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >::DoGetTypeid();
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_GetTypeid(PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self)
{
PyObject *py_retval;
std::string retval;
retval = self->obj->GetTypeid();
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
static PyMethodDef PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods[] = {
{(char *) "DoGetTypeid", (PyCFunction) _wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_DoGetTypeid, METH_NOARGS|METH_STATIC, "DoGetTypeid()\n\n" },
{(char *) "GetTypeid", (PyCFunction) _wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_GetTypeid, METH_NOARGS, "GetTypeid()\n\n" },
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_dealloc(PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3Empty_wrapper_registry.end()) {
PyNs3Empty_wrapper_registry.erase(wrapper_lookup_iter);
}
if (self->obj) {
ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_richcompare (PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *PYBINDGEN_UNUSED(self), PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty", /* tp_name */
sizeof(PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty___call__, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty(arg0)\nCallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_init(void)
{
PyErr_SetString(PyExc_TypeError, "class 'CallbackImpl' cannot be constructed (have pure virtual methods but no helper class)");
return -1;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty___call__(PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3McpsDataIndicationParams *arg0;
PyNs3Packet *arg1;
ns3::Packet *arg1_ptr;
const char *keywords[] = {"arg0", "arg1", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3McpsDataIndicationParams_Type, &arg0, &PyNs3Packet_Type, &arg1)) {
return NULL;
}
arg1_ptr = (arg1 ? arg1->obj : NULL);
self->obj->operator()(*((PyNs3McpsDataIndicationParams *) arg0)->obj, ns3::Ptr< ns3::Packet > (arg1_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_DoGetTypeid(void)
{
PyObject *py_retval;
std::string retval;
retval = ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >::DoGetTypeid();
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
PyObject *
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_GetTypeid(PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self)
{
PyObject *py_retval;
std::string retval;
retval = self->obj->GetTypeid();
py_retval = Py_BuildValue((char *) "s#", (retval).c_str(), (retval).size());
return py_retval;
}
static PyMethodDef PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods[] = {
{(char *) "DoGetTypeid", (PyCFunction) _wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_DoGetTypeid, METH_NOARGS|METH_STATIC, "DoGetTypeid()\n\n" },
{(char *) "GetTypeid", (PyCFunction) _wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_GetTypeid, METH_NOARGS, "GetTypeid()\n\n" },
{NULL, NULL, 0, NULL}
};
static void
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_dealloc(PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3Empty_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3Empty_wrapper_registry.end()) {
PyNs3Empty_wrapper_registry.erase(wrapper_lookup_iter);
}
if (self->obj) {
ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty > *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_richcompare (PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *PYBINDGEN_UNUSED(self), PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty", /* tp_name */
sizeof(PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty___call__, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty(arg0)\nCallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty()", /* Documentation string */
(traverseproc)NULL, /* tp_traverse */
(inquiry)NULL, /* tp_clear */
(richcmpfunc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)_wrap_PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
static int
_wrap_PyNs3LrWpanNetDevice__tp_init__0(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyNs3LrWpanNetDevice *arg0;
const char *keywords[] = {"arg0", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanNetDevice_Type, &arg0)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanNetDevice(*((PyNs3LrWpanNetDevice *) arg0)->obj);
self->obj->Ref ();
ns3::CompleteConstruct(self->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
static int
_wrap_PyNs3LrWpanNetDevice__tp_init__1(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
const char *keywords[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "", (char **) keywords)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return -1;
}
self->obj = new ns3::LrWpanNetDevice();
self->obj->Ref ();
ns3::CompleteConstruct(self->obj);
self->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
return 0;
}
int _wrap_PyNs3LrWpanNetDevice__tp_init(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
int retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanNetDevice__tp_init__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanNetDevice__tp_init__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return -1;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetMulticast__0(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3Ipv4Address *multicastGroup;
const char *keywords[] = {"multicastGroup", NULL};
PyNs3Address *py_Address;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Ipv4Address_Type, &multicastGroup)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
ns3::Address retval = self->obj->GetMulticast(*((PyNs3Ipv4Address *) multicastGroup)->obj);
py_Address = PyObject_New(PyNs3Address, &PyNs3Address_Type);
py_Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Address->obj = new ns3::Address(retval);
PyNs3Address_wrapper_registry[(void *) py_Address->obj] = (PyObject *) py_Address;
py_retval = Py_BuildValue((char *) "N", py_Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetMulticast__1(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs, PyObject **return_exception)
{
PyObject *py_retval;
PyNs3Ipv6Address *addr;
const char *keywords[] = {"addr", NULL};
PyNs3Address *py_Address;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Ipv6Address_Type, &addr)) {
{
PyObject *exc_type, *traceback;
PyErr_Fetch(&exc_type, return_exception, &traceback);
Py_XDECREF(exc_type);
Py_XDECREF(traceback);
}
return NULL;
}
ns3::Address retval = self->obj->GetMulticast(*((PyNs3Ipv6Address *) addr)->obj);
py_Address = PyObject_New(PyNs3Address, &PyNs3Address_Type);
py_Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Address->obj = new ns3::Address(retval);
PyNs3Address_wrapper_registry[(void *) py_Address->obj] = (PyObject *) py_Address;
py_retval = Py_BuildValue((char *) "N", py_Address);
return py_retval;
}
PyObject * _wrap_PyNs3LrWpanNetDevice_GetMulticast(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject * retval;
PyObject *error_list;
PyObject *exceptions[2] = {0,};
retval = _wrap_PyNs3LrWpanNetDevice_GetMulticast__0(self, args, kwargs, &exceptions[0]);
if (!exceptions[0]) {
return retval;
}
retval = _wrap_PyNs3LrWpanNetDevice_GetMulticast__1(self, args, kwargs, &exceptions[1]);
if (!exceptions[1]) {
Py_DECREF(exceptions[0]);
return retval;
}
error_list = PyList_New(2);
PyList_SET_ITEM(error_list, 0, PyObject_Str(exceptions[0]));
Py_DECREF(exceptions[0]);
PyList_SET_ITEM(error_list, 1, PyObject_Str(exceptions[1]));
Py_DECREF(exceptions[1]);
PyErr_SetObject(PyExc_TypeError, error_list);
Py_DECREF(error_list);
return NULL;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_IsPointToPoint(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsPointToPoint();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetTypeId(void)
{
PyObject *py_retval;
PyNs3TypeId *py_TypeId;
ns3::TypeId retval = ns3::LrWpanNetDevice::GetTypeId();
py_TypeId = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type);
py_TypeId->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_TypeId->obj = new ns3::TypeId(retval);
PyNs3TypeId_wrapper_registry[(void *) py_TypeId->obj] = (PyObject *) py_TypeId;
py_retval = Py_BuildValue((char *) "N", py_TypeId);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetPhy(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanPhy *phy;
ns3::LrWpanPhy *phy_ptr;
const char *keywords[] = {"phy", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanPhy_Type, &phy)) {
return NULL;
}
phy_ptr = (phy ? phy->obj : NULL);
self->obj->SetPhy(ns3::Ptr< ns3::LrWpanPhy > (phy_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_Send(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool retval;
PyNs3Packet *packet;
ns3::Packet *packet_ptr;
PyObject *dest;
ns3::Address dest2;
int protocolNumber;
const char *keywords[] = {"packet", "dest", "protocolNumber", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!Oi", (char **) keywords, &PyNs3Packet_Type, &packet, &dest, &protocolNumber)) {
return NULL;
}
packet_ptr = (packet ? packet->obj : NULL);
if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Address_Type)) {
dest2 = *((PyNs3Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Ipv4Address_Type)) {
dest2 = *((PyNs3Ipv4Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Ipv6Address_Type)) {
dest2 = *((PyNs3Ipv6Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac16Address_Type)) {
dest2 = *((PyNs3Mac16Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac48Address_Type)) {
dest2 = *((PyNs3Mac48Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac64Address_Type)) {
dest2 = *((PyNs3Mac64Address *) dest)->obj;
} else {
PyErr_Format(PyExc_TypeError, "parameter must an instance of one of the types (Address, Ipv4Address, Ipv6Address, Mac16Address, Mac48Address, Mac64Address), not %s", Py_TYPE(dest)->tp_name);
return NULL;
}
if (protocolNumber > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
retval = self->obj->Send(ns3::Ptr< ns3::Packet > (packet_ptr), dest2, protocolNumber);
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetIfIndex(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
uint32_t retval;
retval = self->obj->GetIfIndex();
py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_NeedsArp(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->NeedsArp();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetNode(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::Node > retval;
PyNs3Node *py_Node;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetNode();
if (!(const_cast<ns3::Node *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
if (typeid((*const_cast<ns3::Node *> (ns3::PeekPointer (retval)))).name() == typeid(PyNs3Node__PythonHelper).name())
{
py_Node = reinterpret_cast< PyNs3Node* >(reinterpret_cast< PyNs3Node__PythonHelper* >(const_cast<ns3::Node *> (ns3::PeekPointer (retval)))->m_pyself);
py_Node->obj = const_cast<ns3::Node *> (ns3::PeekPointer (retval));
Py_INCREF(py_Node);
} else {
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::Node *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_Node = NULL;
} else {
py_Node = (PyNs3Node *) wrapper_lookup_iter->second;
Py_INCREF(py_Node);
}
if (py_Node == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::Node *> (ns3::PeekPointer (retval)))), &PyNs3Node_Type);
py_Node = PyObject_GC_New(PyNs3Node, wrapper_type);
py_Node->inst_dict = NULL;
py_Node->inst_dict = NULL;
py_Node->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::Node *> (ns3::PeekPointer (retval))->Ref();
py_Node->obj = const_cast<ns3::Node *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_Node->obj] = (PyObject *) py_Node;
}
}
py_retval = Py_BuildValue((char *) "N", py_Node);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetMac(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanMac > retval;
PyNs3LrWpanMac *py_LrWpanMac;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetMac();
if (!(const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
if (typeid((*const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))).name() == typeid(PyNs3LrWpanMac__PythonHelper).name())
{
py_LrWpanMac = reinterpret_cast< PyNs3LrWpanMac* >(reinterpret_cast< PyNs3LrWpanMac__PythonHelper* >(const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))->m_pyself);
py_LrWpanMac->obj = const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval));
Py_INCREF(py_LrWpanMac);
} else {
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanMac = NULL;
} else {
py_LrWpanMac = (PyNs3LrWpanMac *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanMac);
}
if (py_LrWpanMac == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanMac_Type);
py_LrWpanMac = PyObject_GC_New(PyNs3LrWpanMac, wrapper_type);
py_LrWpanMac->inst_dict = NULL;
py_LrWpanMac->inst_dict = NULL;
py_LrWpanMac->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanMac->obj = const_cast<ns3::LrWpanMac *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanMac->obj] = (PyObject *) py_LrWpanMac;
}
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanMac);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetCsmaCa(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanCsmaCa > retval;
PyNs3LrWpanCsmaCa *py_LrWpanCsmaCa;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetCsmaCa();
if (!(const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
if (typeid((*const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval)))).name() == typeid(PyNs3LrWpanCsmaCa__PythonHelper).name())
{
py_LrWpanCsmaCa = reinterpret_cast< PyNs3LrWpanCsmaCa* >(reinterpret_cast< PyNs3LrWpanCsmaCa__PythonHelper* >(const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval)))->m_pyself);
py_LrWpanCsmaCa->obj = const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval));
Py_INCREF(py_LrWpanCsmaCa);
} else {
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanCsmaCa = NULL;
} else {
py_LrWpanCsmaCa = (PyNs3LrWpanCsmaCa *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanCsmaCa);
}
if (py_LrWpanCsmaCa == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanCsmaCa_Type);
py_LrWpanCsmaCa = PyObject_GC_New(PyNs3LrWpanCsmaCa, wrapper_type);
py_LrWpanCsmaCa->inst_dict = NULL;
py_LrWpanCsmaCa->inst_dict = NULL;
py_LrWpanCsmaCa->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanCsmaCa->obj = const_cast<ns3::LrWpanCsmaCa *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanCsmaCa->obj] = (PyObject *) py_LrWpanCsmaCa;
}
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanCsmaCa);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SendFrom(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool retval;
PyNs3Packet *packet;
ns3::Packet *packet_ptr;
PyObject *source;
ns3::Address source2;
PyObject *dest;
ns3::Address dest2;
int protocolNumber;
const char *keywords[] = {"packet", "source", "dest", "protocolNumber", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!OOi", (char **) keywords, &PyNs3Packet_Type, &packet, &source, &dest, &protocolNumber)) {
return NULL;
}
packet_ptr = (packet ? packet->obj : NULL);
if (PyObject_IsInstance(source, (PyObject*) &PyNs3Address_Type)) {
source2 = *((PyNs3Address *) source)->obj;
} else if (PyObject_IsInstance(source, (PyObject*) &PyNs3Ipv4Address_Type)) {
source2 = *((PyNs3Ipv4Address *) source)->obj;
} else if (PyObject_IsInstance(source, (PyObject*) &PyNs3Ipv6Address_Type)) {
source2 = *((PyNs3Ipv6Address *) source)->obj;
} else if (PyObject_IsInstance(source, (PyObject*) &PyNs3Mac16Address_Type)) {
source2 = *((PyNs3Mac16Address *) source)->obj;
} else if (PyObject_IsInstance(source, (PyObject*) &PyNs3Mac48Address_Type)) {
source2 = *((PyNs3Mac48Address *) source)->obj;
} else if (PyObject_IsInstance(source, (PyObject*) &PyNs3Mac64Address_Type)) {
source2 = *((PyNs3Mac64Address *) source)->obj;
} else {
PyErr_Format(PyExc_TypeError, "parameter must an instance of one of the types (Address, Ipv4Address, Ipv6Address, Mac16Address, Mac48Address, Mac64Address), not %s", Py_TYPE(source)->tp_name);
return NULL;
}
if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Address_Type)) {
dest2 = *((PyNs3Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Ipv4Address_Type)) {
dest2 = *((PyNs3Ipv4Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Ipv6Address_Type)) {
dest2 = *((PyNs3Ipv6Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac16Address_Type)) {
dest2 = *((PyNs3Mac16Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac48Address_Type)) {
dest2 = *((PyNs3Mac48Address *) dest)->obj;
} else if (PyObject_IsInstance(dest, (PyObject*) &PyNs3Mac64Address_Type)) {
dest2 = *((PyNs3Mac64Address *) dest)->obj;
} else {
PyErr_Format(PyExc_TypeError, "parameter must an instance of one of the types (Address, Ipv4Address, Ipv6Address, Mac16Address, Mac48Address, Mac64Address), not %s", Py_TYPE(dest)->tp_name);
return NULL;
}
if (protocolNumber > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
retval = self->obj->SendFrom(ns3::Ptr< ns3::Packet > (packet_ptr), source2, dest2, protocolNumber);
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_IsBroadcast(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsBroadcast();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetMtu(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
uint16_t retval;
retval = self->obj->GetMtu();
py_retval = Py_BuildValue((char *) "i", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_IsBridge(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsBridge();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetNode(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3Node *node;
ns3::Node *node_ptr;
const char *keywords[] = {"node", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3Node_Type, &node)) {
return NULL;
}
node_ptr = (node ? node->obj : NULL);
self->obj->SetNode(ns3::Ptr< ns3::Node > (node_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetAddress(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
PyNs3Address *py_Address;
ns3::Address retval = self->obj->GetAddress();
py_Address = PyObject_New(PyNs3Address, &PyNs3Address_Type);
py_Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Address->obj = new ns3::Address(retval);
PyNs3Address_wrapper_registry[(void *) py_Address->obj] = (PyObject *) py_Address;
py_retval = Py_BuildValue((char *) "N", py_Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_IsLinkUp(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsLinkUp();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetIfIndex(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
unsigned int index;
const char *keywords[] = {"index", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "I", (char **) keywords, &index)) {
return NULL;
}
self->obj->SetIfIndex(index);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetMac(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanMac *mac;
ns3::LrWpanMac *mac_ptr;
const char *keywords[] = {"mac", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanMac_Type, &mac)) {
return NULL;
}
mac_ptr = (mac ? mac->obj : NULL);
self->obj->SetMac(ns3::Ptr< ns3::LrWpanMac > (mac_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetAddress(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *address;
ns3::Address address2;
const char *keywords[] = {"address", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &address)) {
return NULL;
}
if (PyObject_IsInstance(address, (PyObject*) &PyNs3Address_Type)) {
address2 = *((PyNs3Address *) address)->obj;
} else if (PyObject_IsInstance(address, (PyObject*) &PyNs3Ipv4Address_Type)) {
address2 = *((PyNs3Ipv4Address *) address)->obj;
} else if (PyObject_IsInstance(address, (PyObject*) &PyNs3Ipv6Address_Type)) {
address2 = *((PyNs3Ipv6Address *) address)->obj;
} else if (PyObject_IsInstance(address, (PyObject*) &PyNs3Mac16Address_Type)) {
address2 = *((PyNs3Mac16Address *) address)->obj;
} else if (PyObject_IsInstance(address, (PyObject*) &PyNs3Mac48Address_Type)) {
address2 = *((PyNs3Mac48Address *) address)->obj;
} else if (PyObject_IsInstance(address, (PyObject*) &PyNs3Mac64Address_Type)) {
address2 = *((PyNs3Mac64Address *) address)->obj;
} else {
PyErr_Format(PyExc_TypeError, "parameter must an instance of one of the types (Address, Ipv4Address, Ipv6Address, Mac16Address, Mac48Address, Mac64Address), not %s", Py_TYPE(address)->tp_name);
return NULL;
}
self->obj->SetAddress(address2);
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetBroadcast(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
PyNs3Address *py_Address;
ns3::Address retval = self->obj->GetBroadcast();
py_Address = PyObject_New(PyNs3Address, &PyNs3Address_Type);
py_Address->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
py_Address->obj = new ns3::Address(retval);
PyNs3Address_wrapper_registry[(void *) py_Address->obj] = (PyObject *) py_Address;
py_retval = Py_BuildValue((char *) "N", py_Address);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_AddLinkChangeCallback(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *callback;
ns3::Ptr<PythonCallbackImpl10> callback_cb_impl;
const char *keywords[] = {"callback", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &callback)) {
return NULL;
}
if (!PyCallable_Check(callback)) {
PyErr_SetString(PyExc_TypeError, "parameter 'callback' must be callbale");
return NULL;
}
callback_cb_impl = ns3::Create<PythonCallbackImpl10> (callback);
self->obj->AddLinkChangeCallback(ns3::Callback<void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (callback_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetReceiveCallback(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyObject *cb;
ns3::Ptr<PythonCallbackImpl16> cb_cb_impl;
const char *keywords[] = {"cb", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O", (char **) keywords, &cb)) {
return NULL;
}
if (!PyCallable_Check(cb)) {
PyErr_SetString(PyExc_TypeError, "parameter 'cb' must be callbale");
return NULL;
}
cb_cb_impl = ns3::Create<PythonCallbackImpl16> (cb);
self->obj->SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty> (cb_cb_impl));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_IsMulticast(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->IsMulticast();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetMtu(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
bool retval;
int mtu;
const char *keywords[] = {"mtu", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "i", (char **) keywords, &mtu)) {
return NULL;
}
if (mtu > 0xffff) {
PyErr_SetString(PyExc_ValueError, "Out of range");
return NULL;
}
retval = self->obj->SetMtu(mtu);
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_GetPhy(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
ns3::Ptr< ns3::LrWpanPhy > retval;
PyNs3LrWpanPhy *py_LrWpanPhy;
std::map<void*, PyObject*>::const_iterator wrapper_lookup_iter;
PyTypeObject *wrapper_type = 0;
retval = self->obj->GetPhy();
if (!(const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)))) {
Py_INCREF(Py_None);
return Py_None;
}
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)));
if (wrapper_lookup_iter == PyNs3ObjectBase_wrapper_registry.end()) {
py_LrWpanPhy = NULL;
} else {
py_LrWpanPhy = (PyNs3LrWpanPhy *) wrapper_lookup_iter->second;
Py_INCREF(py_LrWpanPhy);
}
if (py_LrWpanPhy == NULL) {
wrapper_type = PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.lookup_wrapper(typeid((*const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval)))), &PyNs3LrWpanPhy_Type);
py_LrWpanPhy = PyObject_GC_New(PyNs3LrWpanPhy, wrapper_type);
py_LrWpanPhy->inst_dict = NULL;
py_LrWpanPhy->inst_dict = NULL;
py_LrWpanPhy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval))->Ref();
py_LrWpanPhy->obj = const_cast<ns3::LrWpanPhy *> (ns3::PeekPointer (retval));
PyNs3ObjectBase_wrapper_registry[(void *) py_LrWpanPhy->obj] = (PyObject *) py_LrWpanPhy;
}
py_retval = Py_BuildValue((char *) "N", py_LrWpanPhy);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SupportsSendFrom(PyNs3LrWpanNetDevice *self)
{
PyObject *py_retval;
bool retval;
retval = self->obj->SupportsSendFrom();
py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval));
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_McpsDataIndication(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3McpsDataIndicationParams *params;
PyNs3Packet *pkt;
ns3::Packet *pkt_ptr;
const char *keywords[] = {"params", "pkt", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!O!", (char **) keywords, &PyNs3McpsDataIndicationParams_Type, ¶ms, &PyNs3Packet_Type, &pkt)) {
return NULL;
}
pkt_ptr = (pkt ? pkt->obj : NULL);
self->obj->McpsDataIndication(*((PyNs3McpsDataIndicationParams *) params)->obj, ns3::Ptr< ns3::Packet > (pkt_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_AssignStreams(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
int64_t retval;
int64_t stream;
const char *keywords[] = {"stream", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &stream)) {
return NULL;
}
retval = self->obj->AssignStreams(stream);
py_retval = Py_BuildValue((char *) "L", retval);
return py_retval;
}
PyObject *
_wrap_PyNs3LrWpanNetDevice_SetCsmaCa(PyNs3LrWpanNetDevice *self, PyObject *args, PyObject *kwargs)
{
PyObject *py_retval;
PyNs3LrWpanCsmaCa *csmaca;
ns3::LrWpanCsmaCa *csmaca_ptr;
const char *keywords[] = {"csmaca", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "O!", (char **) keywords, &PyNs3LrWpanCsmaCa_Type, &csmaca)) {
return NULL;
}
csmaca_ptr = (csmaca ? csmaca->obj : NULL);
self->obj->SetCsmaCa(ns3::Ptr< ns3::LrWpanCsmaCa > (csmaca_ptr));
Py_INCREF(Py_None);
py_retval = Py_None;
return py_retval;
}
static PyObject*
_wrap_PyNs3LrWpanNetDevice__copy__(PyNs3LrWpanNetDevice *self)
{
PyNs3LrWpanNetDevice *py_copy;
py_copy = PyObject_GC_New(PyNs3LrWpanNetDevice, &PyNs3LrWpanNetDevice_Type);
py_copy->inst_dict = NULL;
py_copy->obj = new ns3::LrWpanNetDevice(*self->obj);
py_copy->inst_dict = NULL;
py_copy->flags = PYBINDGEN_WRAPPER_FLAG_NONE;
PyNs3ObjectBase_wrapper_registry[(void *) py_copy->obj] = (PyObject *) py_copy;
return (PyObject*) py_copy;
}
static PyMethodDef PyNs3LrWpanNetDevice_methods[] = {
{(char *) "GetMulticast", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetMulticast, METH_KEYWORDS|METH_VARARGS, NULL },
{(char *) "IsPointToPoint", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_IsPointToPoint, METH_NOARGS, "IsPointToPoint()\n\n" },
{(char *) "GetTypeId", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetTypeId, METH_NOARGS|METH_STATIC, "GetTypeId()\n\n" },
{(char *) "SetPhy", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetPhy, METH_KEYWORDS|METH_VARARGS, "SetPhy(phy)\n\ntype: phy: ns3::Ptr< ns3::LrWpanPhy >" },
{(char *) "Send", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_Send, METH_KEYWORDS|METH_VARARGS, "Send(packet, dest, protocolNumber)\n\ntype: packet: ns3::Ptr< ns3::Packet >\ntype: dest: ns3::Address const &\ntype: protocolNumber: uint16_t" },
{(char *) "GetIfIndex", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetIfIndex, METH_NOARGS, "GetIfIndex()\n\n" },
{(char *) "NeedsArp", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_NeedsArp, METH_NOARGS, "NeedsArp()\n\n" },
{(char *) "GetNode", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetNode, METH_NOARGS, "GetNode()\n\n" },
{(char *) "GetMac", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetMac, METH_NOARGS, "GetMac()\n\n" },
{(char *) "GetCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetCsmaCa, METH_NOARGS, "GetCsmaCa()\n\n" },
{(char *) "SendFrom", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SendFrom, METH_KEYWORDS|METH_VARARGS, "SendFrom(packet, source, dest, protocolNumber)\n\ntype: packet: ns3::Ptr< ns3::Packet >\ntype: source: ns3::Address const &\ntype: dest: ns3::Address const &\ntype: protocolNumber: uint16_t" },
{(char *) "IsBroadcast", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_IsBroadcast, METH_NOARGS, "IsBroadcast()\n\n" },
{(char *) "GetMtu", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetMtu, METH_NOARGS, "GetMtu()\n\n" },
{(char *) "IsBridge", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_IsBridge, METH_NOARGS, "IsBridge()\n\n" },
{(char *) "SetNode", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetNode, METH_KEYWORDS|METH_VARARGS, "SetNode(node)\n\ntype: node: ns3::Ptr< ns3::Node >" },
{(char *) "GetAddress", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetAddress, METH_NOARGS, "GetAddress()\n\n" },
{(char *) "IsLinkUp", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_IsLinkUp, METH_NOARGS, "IsLinkUp()\n\n" },
{(char *) "SetIfIndex", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetIfIndex, METH_KEYWORDS|METH_VARARGS, "SetIfIndex(index)\n\ntype: index: uint32_t const" },
{(char *) "SetMac", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetMac, METH_KEYWORDS|METH_VARARGS, "SetMac(mac)\n\ntype: mac: ns3::Ptr< ns3::LrWpanMac >" },
{(char *) "SetAddress", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetAddress, METH_KEYWORDS|METH_VARARGS, "SetAddress(address)\n\ntype: address: ns3::Address" },
{(char *) "GetBroadcast", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetBroadcast, METH_NOARGS, "GetBroadcast()\n\n" },
{(char *) "AddLinkChangeCallback", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_AddLinkChangeCallback, METH_KEYWORDS|METH_VARARGS, "AddLinkChangeCallback(callback)\n\ntype: callback: ns3::Callback< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "SetReceiveCallback", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetReceiveCallback, METH_KEYWORDS|METH_VARARGS, "SetReceiveCallback(cb)\n\ntype: cb: ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet const >, unsigned short, ns3::Address const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >" },
{(char *) "IsMulticast", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_IsMulticast, METH_NOARGS, "IsMulticast()\n\n" },
{(char *) "SetMtu", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetMtu, METH_KEYWORDS|METH_VARARGS, "SetMtu(mtu)\n\ntype: mtu: uint16_t const" },
{(char *) "GetPhy", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_GetPhy, METH_NOARGS, "GetPhy()\n\n" },
{(char *) "SupportsSendFrom", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SupportsSendFrom, METH_NOARGS, "SupportsSendFrom()\n\n" },
{(char *) "McpsDataIndication", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_McpsDataIndication, METH_KEYWORDS|METH_VARARGS, "McpsDataIndication(params, pkt)\n\ntype: params: ns3::McpsDataIndicationParams\ntype: pkt: ns3::Ptr< ns3::Packet >" },
{(char *) "AssignStreams", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_AssignStreams, METH_KEYWORDS|METH_VARARGS, "AssignStreams(stream)\n\ntype: stream: int64_t" },
{(char *) "SetCsmaCa", (PyCFunction) _wrap_PyNs3LrWpanNetDevice_SetCsmaCa, METH_KEYWORDS|METH_VARARGS, "SetCsmaCa(csmaca)\n\ntype: csmaca: ns3::Ptr< ns3::LrWpanCsmaCa >" },
{(char *) "__copy__", (PyCFunction) _wrap_PyNs3LrWpanNetDevice__copy__, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL}
};
static void
PyNs3LrWpanNetDevice__tp_clear(PyNs3LrWpanNetDevice *self)
{
Py_CLEAR(self->inst_dict);
if (self->obj) {
ns3::LrWpanNetDevice *tmp = self->obj;
self->obj = NULL;
tmp->Unref();
}
}
static int
PyNs3LrWpanNetDevice__tp_traverse(PyNs3LrWpanNetDevice *self, visitproc visit, void *arg)
{
Py_VISIT(self->inst_dict);
return 0;
}
static void
_wrap_PyNs3LrWpanNetDevice__tp_dealloc(PyNs3LrWpanNetDevice *self)
{
std::map<void*, PyObject*>::iterator wrapper_lookup_iter;
wrapper_lookup_iter = PyNs3ObjectBase_wrapper_registry.find((void *) self->obj);
if (wrapper_lookup_iter != PyNs3ObjectBase_wrapper_registry.end()) {
PyNs3ObjectBase_wrapper_registry.erase(wrapper_lookup_iter);
}
PyNs3LrWpanNetDevice__tp_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
_wrap_PyNs3LrWpanNetDevice__tp_richcompare (PyNs3LrWpanNetDevice *PYBINDGEN_UNUSED(self), PyNs3LrWpanNetDevice *other, int opid)
{
if (!PyObject_IsInstance((PyObject*) other, (PyObject*) &PyNs3LrWpanNetDevice_Type)) {
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
switch (opid)
{
case Py_LT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_LE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_EQ:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_NE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GE:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
case Py_GT:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
} /* closes switch (opid) */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
PyTypeObject PyNs3LrWpanNetDevice_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
(char *) "lr_wpan.LrWpanNetDevice", /* tp_name */
sizeof(PyNs3LrWpanNetDevice), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)_wrap_PyNs3LrWpanNetDevice__tp_dealloc, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)NULL, /* tp_getattr */
(setattrfunc)NULL, /* tp_setattr */
#if PY_MAJOR_VERSION >= 3
NULL,
#else
(cmpfunc)NULL, /* tp_compare */
#endif
(reprfunc)NULL, /* tp_repr */
(PyNumberMethods*)NULL, /* tp_as_number */
(PySequenceMethods*)NULL, /* tp_as_sequence */
(PyMappingMethods*)NULL, /* tp_as_mapping */
(hashfunc)NULL, /* tp_hash */
(ternaryfunc)NULL, /* tp_call */
(reprfunc)NULL, /* tp_str */
(getattrofunc)NULL, /* tp_getattro */
(setattrofunc)NULL, /* tp_setattro */
(PyBufferProcs*)NULL, /* tp_as_buffer */
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC, /* tp_flags */
"LrWpanNetDevice(arg0)\nLrWpanNetDevice()", /* Documentation string */
(traverseproc)PyNs3LrWpanNetDevice__tp_traverse, /* tp_traverse */
(inquiry)PyNs3LrWpanNetDevice__tp_clear, /* tp_clear */
(richcmpfunc)_wrap_PyNs3LrWpanNetDevice__tp_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)NULL, /* tp_iter */
(iternextfunc)NULL, /* tp_iternext */
(struct PyMethodDef*)PyNs3LrWpanNetDevice_methods, /* tp_methods */
(struct PyMemberDef*)0, /* tp_members */
0, /* tp_getset */
NULL, /* tp_base */
NULL, /* tp_dict */
(descrgetfunc)NULL, /* tp_descr_get */
(descrsetfunc)NULL, /* tp_descr_set */
offsetof(PyNs3LrWpanNetDevice, inst_dict), /* tp_dictoffset */
(initproc)_wrap_PyNs3LrWpanNetDevice__tp_init, /* tp_init */
(allocfunc)PyType_GenericAlloc, /* tp_alloc */
(newfunc)PyType_GenericNew, /* tp_new */
(freefunc)0, /* tp_free */
(inquiry)NULL, /* tp_is_gc */
NULL, /* tp_bases */
NULL, /* tp_mro */
NULL, /* tp_cache */
NULL, /* tp_subclasses */
NULL, /* tp_weaklist */
(destructor) NULL /* tp_del */
};
/* --- enumerations --- */
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef lr_wpan_moduledef = {
PyModuleDef_HEAD_INIT,
"lr_wpan",
NULL,
-1,
lr_wpan_functions,
};
#endif
#if PY_VERSION_HEX >= 0x03000000
#define MOD_ERROR NULL
#define MOD_INIT(name) PyObject* PyInit_##name(void)
#define MOD_RETURN(val) val
#else
#define MOD_ERROR
#define MOD_INIT(name) void init##name(void)
#define MOD_RETURN(val)
#endif
#if defined(__cplusplus)
extern "C"
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
__attribute__ ((visibility("default")))
#endif
MOD_INIT(lr_wpan)
{
PyObject *m;
PyObject *submodule;
#if PY_VERSION_HEX >= 0x03000000
m = PyModule_Create(&lr_wpan_moduledef);
#else
m = Py_InitModule3((char *) "lr_wpan", lr_wpan_functions, NULL);
#endif
if (m == NULL) {
return MOD_ERROR;
}
PyModule_AddIntConstant(m, (char *) "STD_IOS_IN", std::ios::in);
PyModule_AddIntConstant(m, (char *) "STD_IOS_OUT", std::ios::out);
PyModule_AddIntConstant(m, (char *) "STD_IOS_ATE", std::ios::ate);
PyModule_AddIntConstant(m, (char *) "STD_IOS_APP", std::ios::app);
PyModule_AddIntConstant(m, (char *) "STD_IOS_TRUNC", std::ios::trunc);
PyModule_AddIntConstant(m, (char *) "STD_IOS_BINARY", std::ios::binary);
/* Import the 'ns3::Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::AsciiTraceHelper' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AsciiTraceHelper_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AsciiTraceHelper");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3AsciiTraceHelper_wrapper_registry");
if (_cobj == NULL) {
_PyNs3AsciiTraceHelper_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3AsciiTraceHelper_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::AsciiTraceHelperForDevice' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AsciiTraceHelperForDevice_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AsciiTraceHelperForDevice");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3AsciiTraceHelperForDevice_wrapper_registry");
if (_cobj == NULL) {
_PyNs3AsciiTraceHelperForDevice_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3AsciiTraceHelperForDevice_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::AttributeConstructionList' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AttributeConstructionList_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AttributeConstructionList");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3AttributeConstructionList_wrapper_registry");
if (_cobj == NULL) {
_PyNs3AttributeConstructionList_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3AttributeConstructionList_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::AttributeConstructionList::Item' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AttributeConstructionListItem_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Item");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3AttributeConstructionListItem_wrapper_registry");
if (_cobj == NULL) {
_PyNs3AttributeConstructionListItem_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3AttributeConstructionListItem_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Buffer' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Buffer_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Buffer");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Buffer_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Buffer_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Buffer_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Buffer::Iterator' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3BufferIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Iterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3BufferIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3BufferIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3BufferIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ByteTagIterator' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ByteTagIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ByteTagIterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ByteTagIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ByteTagIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ByteTagIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ByteTagIterator::Item' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ByteTagIteratorItem_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Item");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ByteTagIteratorItem_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ByteTagIteratorItem_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ByteTagIteratorItem_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ByteTagList' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ByteTagList_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ByteTagList");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ByteTagList_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ByteTagList_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ByteTagList_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ByteTagList::Iterator' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ByteTagListIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Iterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ByteTagListIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ByteTagListIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ByteTagListIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ByteTagList::Iterator::Item' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ByteTagListIteratorItem_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Item");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ByteTagListIteratorItem_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ByteTagListIteratorItem_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ByteTagListIteratorItem_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::CallbackBase' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackBase_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackBase");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3CallbackBase_wrapper_registry");
if (_cobj == NULL) {
_PyNs3CallbackBase_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3CallbackBase_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::AttributeAccessor >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3AttributeAccessor_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3AttributeAccessor");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3AttributeAccessor_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3AttributeAccessor_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3AttributeAccessor_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::AttributeChecker >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3AttributeChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3AttributeChecker");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3AttributeChecker_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3AttributeChecker_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3AttributeChecker_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::AttributeValue >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3AttributeValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3AttributeValue");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3AttributeValue_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3AttributeValue_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3AttributeValue_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::CallbackImplBase >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3CallbackImplBase_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3CallbackImplBase");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3CallbackImplBase_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3CallbackImplBase_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3CallbackImplBase_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::EventImpl >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3EventImpl_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3EventImpl");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3EventImpl_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3EventImpl_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3EventImpl_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::Hash::Implementation >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3HashImplementation_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3HashImplementation");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3HashImplementation_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3HashImplementation_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3HashImplementation_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::NixVector >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3NixVector_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3NixVector");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3NixVector_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3NixVector_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3NixVector_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::OutputStreamWrapper >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3OutputStreamWrapper");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3OutputStreamWrapper_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::Packet >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3Packet_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3Packet");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3Packet_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3Packet_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3Packet_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::SpectrumSignalParameters >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3SpectrumSignalParameters");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3SpectrumSignalParameters_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::DefaultDeleter< ns3::TraceSourceAccessor >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DefaultDeleter__Ns3TraceSourceAccessor");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_wrapper_registry");
if (_cobj == NULL) {
_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3DefaultDeleter__Ns3TraceSourceAccessor_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::EventId' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EventId_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EventId");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3EventId_wrapper_registry");
if (_cobj == NULL) {
_PyNs3EventId_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3EventId_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Hasher' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Hasher_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Hasher");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Hasher_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Hasher_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Hasher_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Ipv4Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Ipv4Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Ipv4Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Ipv4Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Ipv4Mask' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4Mask_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4Mask");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Ipv4Mask_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Ipv4Mask_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Ipv4Mask_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Ipv6Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Ipv6Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Ipv6Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Ipv6Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Ipv6Prefix' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6Prefix_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6Prefix");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Ipv6Prefix_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Ipv6Prefix_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Ipv6Prefix_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Mac16Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac16Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac16Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Mac16Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Mac16Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Mac16Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Mac48Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac48Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac48Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Mac48Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Mac48Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Mac48Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Mac64Address' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac64Address_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac64Address");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Mac64Address_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Mac64Address_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Mac64Address_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::NetDeviceContainer' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3NetDeviceContainer_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "NetDeviceContainer");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3NetDeviceContainer_wrapper_registry");
if (_cobj == NULL) {
_PyNs3NetDeviceContainer_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3NetDeviceContainer_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::NodeContainer' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3NodeContainer_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "NodeContainer");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3NodeContainer_wrapper_registry");
if (_cobj == NULL) {
_PyNs3NodeContainer_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3NodeContainer_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ObjectBase' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectBase_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ObjectBase");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ObjectBase_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ObjectBase_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ObjectBase_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ObjectDeleter' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectDeleter_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ObjectDeleter");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ObjectDeleter_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ObjectDeleter_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ObjectDeleter_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::ObjectFactory' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectFactory_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ObjectFactory");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ObjectFactory_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ObjectFactory_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ObjectFactory_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketMetadata' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketMetadata_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PacketMetadata");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketMetadata_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketMetadata_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketMetadata_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketMetadata::Item' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketMetadataItem_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Item");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketMetadataItem_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketMetadataItem_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketMetadataItem_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketMetadata::ItemIterator' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketMetadataItemIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ItemIterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketMetadataItemIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketMetadataItemIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketMetadataItemIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketTagIterator' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketTagIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PacketTagIterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketTagIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketTagIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketTagIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketTagIterator::Item' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketTagIteratorItem_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Item");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketTagIteratorItem_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketTagIteratorItem_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketTagIteratorItem_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketTagList' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketTagList_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PacketTagList");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketTagList_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketTagList_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketTagList_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PacketTagList::TagData' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PacketTagListTagData_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TagData");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PacketTagListTagData_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PacketTagListTagData_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PacketTagListTagData_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PcapFile' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PcapFile_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PcapFile");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PcapFile_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PcapFile_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PcapFile_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PcapHelper' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PcapHelper_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PcapHelper");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PcapHelper_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PcapHelper_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PcapHelper_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PcapHelperForDevice' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PcapHelperForDevice_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PcapHelperForDevice");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3PcapHelperForDevice_wrapper_registry");
if (_cobj == NULL) {
_PyNs3PcapHelperForDevice_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3PcapHelperForDevice_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SequenceNumber8' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SequenceNumber8_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SequenceNumber8");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SequenceNumber8_wrapper_registry");
if (_cobj == NULL) {
_PyNs3SequenceNumber8_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3SequenceNumber8_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::Object, ns3::ObjectBase, ns3::ObjectDeleter >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Simulator' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Simulator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Simulator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Simulator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Simulator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Simulator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Tag' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Tag_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Tag");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::TagBuffer' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TagBuffer_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TagBuffer");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TagBuffer_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TagBuffer_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TagBuffer_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TimeWithUnit' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TimeWithUnit_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TimeWithUnit");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TimeWithUnit_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TimeWithUnit_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TimeWithUnit_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TracedValue< ns3::LrWpanMacState >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TracedValue__Ns3LrWpanMacState_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TracedValue__Ns3LrWpanMacState");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TracedValue__Ns3LrWpanMacState_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TracedValue__Ns3LrWpanMacState_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TracedValue__Ns3LrWpanMacState_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TracedValue< ns3::LrWpanPhyEnumeration >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TracedValue__Ns3LrWpanPhyEnumeration");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TracedValue__Ns3LrWpanPhyEnumeration_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TypeId' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TypeId_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TypeId");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TypeId_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TypeId_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TypeId_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TypeId::AttributeInformation' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TypeIdAttributeInformation_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AttributeInformation");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TypeIdAttributeInformation_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TypeIdAttributeInformation_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TypeIdAttributeInformation_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TypeId::TraceSourceInformation' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TypeIdTraceSourceInformation_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TraceSourceInformation");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3TypeIdTraceSourceInformation_wrapper_registry");
if (_cobj == NULL) {
_PyNs3TypeIdTraceSourceInformation_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3TypeIdTraceSourceInformation_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::empty' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "empty");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Empty_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Empty_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Empty_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::int64x64_t' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Int64x64_t_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "int64x64_t");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Int64x64_t_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Int64x64_t_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Int64x64_t_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::Chunk' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Chunk_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Chunk");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Header' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Header_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Header");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Object' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Object_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Object");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Object::AggregateIterator' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectAggregateIterator_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AggregateIterator");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3ObjectAggregateIterator_wrapper_registry");
if (_cobj == NULL) {
_PyNs3ObjectAggregateIterator_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3ObjectAggregateIterator_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::PcapFileWrapper' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3PcapFileWrapper_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "PcapFileWrapper");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::AttributeAccessor, ns3::empty, ns3::DefaultDeleter<ns3::AttributeAccessor> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3AttributeAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeAccessor__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::AttributeChecker, ns3::empty, ns3::DefaultDeleter<ns3::AttributeChecker> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3AttributeChecker_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeChecker__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::AttributeValue, ns3::empty, ns3::DefaultDeleter<ns3::AttributeValue> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3AttributeValue_Ns3Empty_Ns3DefaultDeleter__lt__ns3AttributeValue__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::CallbackImplBase, ns3::empty, ns3::DefaultDeleter<ns3::CallbackImplBase> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::EventImpl, ns3::empty, ns3::DefaultDeleter<ns3::EventImpl> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3EventImpl_Ns3Empty_Ns3DefaultDeleter__lt__ns3EventImpl__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::Hash::Implementation, ns3::empty, ns3::DefaultDeleter<ns3::Hash::Implementation> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3HashImplementation_Ns3Empty_Ns3DefaultDeleter__lt__ns3HashImplementation__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::NixVector, ns3::empty, ns3::DefaultDeleter<ns3::NixVector> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3NixVector_Ns3Empty_Ns3DefaultDeleter__lt__ns3NixVector__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::OutputStreamWrapper, ns3::empty, ns3::DefaultDeleter<ns3::OutputStreamWrapper> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3OutputStreamWrapper_Ns3Empty_Ns3DefaultDeleter__lt__ns3OutputStreamWrapper__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::Packet, ns3::empty, ns3::DefaultDeleter<ns3::Packet> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3Packet_Ns3Empty_Ns3DefaultDeleter__lt__ns3Packet__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::SpectrumSignalParameters, ns3::empty, ns3::DefaultDeleter<ns3::SpectrumSignalParameters> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt___Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt__");
if (PyErr_Occurred()) PyErr_Clear();
/* Import the 'ns3::SimpleRefCount< ns3::TraceSourceAccessor, ns3::empty, ns3::DefaultDeleter<ns3::TraceSourceAccessor> >' class type map from module 'ns.core' */
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt____typeid_map");
if (_cobj == NULL) {
_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt____typeid_map = new pybindgen::TypeMap;
PyErr_Clear();
} else {
_PyNs3SimpleRefCount__Ns3TraceSourceAccessor_Ns3Empty_Ns3DefaultDeleter__lt__ns3TraceSourceAccessor__gt____typeid_map = reinterpret_cast<pybindgen::TypeMap*> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::SpectrumPhy' class from module 'ns.spectrum' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.spectrum");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SpectrumPhy_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SpectrumPhy");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::SpectrumSignalParameters' class from module 'ns.spectrum' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.spectrum");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3SpectrumSignalParameters_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "SpectrumSignalParameters");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Time' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Time_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Time");
if (PyErr_Occurred()) PyErr_Clear();
PyObject *_cobj = PyObject_GetAttrString(module, (char*) "_PyNs3Time_wrapper_registry");
if (_cobj == NULL) {
_PyNs3Time_wrapper_registry = NULL;
PyErr_Clear();
} else {
_PyNs3Time_wrapper_registry = reinterpret_cast< std::map<void*, PyObject*> *> (PyCObject_AsVoidPtr (_cobj));
Py_DECREF(_cobj);
}
}
/* Import the 'ns3::TraceSourceAccessor' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TraceSourceAccessor_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TraceSourceAccessor");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Trailer' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Trailer_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Trailer");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::AttributeAccessor' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AttributeAccessor_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AttributeAccessor");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::AttributeChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AttributeChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AttributeChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::AttributeValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AttributeValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AttributeValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::BooleanChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3BooleanChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "BooleanChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::BooleanValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3BooleanValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "BooleanValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImplBase' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImplBase_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImplBase");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::DoubleValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3DoubleValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "DoubleValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EmptyAttributeAccessor' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EmptyAttributeAccessor_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EmptyAttributeAccessor");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EmptyAttributeChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EmptyAttributeChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EmptyAttributeChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EmptyAttributeValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EmptyAttributeValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EmptyAttributeValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EnumChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EnumChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EnumChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EnumValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EnumValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EnumValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::EventImpl' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3EventImpl_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "EventImpl");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::IntegerValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3IntegerValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "IntegerValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv4AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv4AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv4MaskChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4MaskChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4MaskChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv4MaskValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv4MaskValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv4MaskValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv6AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv6AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv6PrefixChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6PrefixChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6PrefixChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Ipv6PrefixValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Ipv6PrefixValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Ipv6PrefixValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac16AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac16AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac16AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac16AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac16AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac16AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac48AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac48AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac48AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac48AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac48AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac48AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac64AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac64AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac64AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Mac64AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Mac64AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Mac64AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::NetDevice' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3NetDevice_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "NetDevice");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::NixVector' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3NixVector_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "NixVector");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Node' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Node_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Node");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::ObjectFactoryChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectFactoryChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ObjectFactoryChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::ObjectFactoryValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3ObjectFactoryValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "ObjectFactoryValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::OutputStreamWrapper' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3OutputStreamWrapper_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "OutputStreamWrapper");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::Packet' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3Packet_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "Packet");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::TimeValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TimeValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TimeValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::TypeIdChecker' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TypeIdChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TypeIdChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::TypeIdValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3TypeIdValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "TypeIdValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::UintegerValue' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3UintegerValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "UintegerValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::AddressChecker' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AddressChecker_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AddressChecker");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::AddressValue' class from module 'ns.network' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.network");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3AddressValue_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "AddressValue");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Bool_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Bool_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< ns3::ObjectBase *, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Ns3ObjectBase___star___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Ns3ObjectBase___star___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::LrWpanMacState, ns3::LrWpanMacState, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3LrWpanMacState_Ns3LrWpanMacState_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3LrWpanMacState_Ns3LrWpanMacState_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, double, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Double_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Double_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Ptr<const ns3::Packet>, unsigned char, unsigned char, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_char_Unsigned_char_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_char_Unsigned_char_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<const ns3::Packet>, unsigned short, const ns3::Address &, const ns3::Address &, ns3::NetDevice::PacketType, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Const_ns3Address___amp___Ns3NetDevicePacketType_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Ptr__lt__const_ns3Packet__gt___Unsigned_short_Const_ns3Address___amp___Const_ns3Address___amp___Ns3NetDevicePacketType_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Ptr<ns3::NetDevice>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Ptr__lt__ns3NetDevice__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::Time, ns3::LrWpanPhyEnumeration, ns3::LrWpanPhyEnumeration, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Time_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Time_Ns3LrWpanPhyEnumeration_Ns3LrWpanPhyEnumeration_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
/* Import the 'ns3::CallbackImpl< void, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class from module 'ns.core' */
{
PyObject *module = PyImport_ImportModule((char*) "ns.core");
if (module == NULL) {
return MOD_ERROR;
}
_PyNs3CallbackImpl__Void_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type = (PyTypeObject*) PyObject_GetAttrString(module, (char*) "CallbackImpl__Void_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty");
if (PyErr_Occurred()) PyErr_Clear();
}
PyModule_AddObject(m, (char *) "_PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_wrapper_registry, NULL));
/* Register the 'ns3::DefaultDeleter< ns3::LrWpanInterferenceHelper >' class */
if (PyType_Ready(&PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "DefaultDeleter__Ns3LrWpanInterferenceHelper", (PyObject *) &PyNs3DefaultDeleter__Ns3LrWpanInterferenceHelper_Type);
PyModule_AddObject(m, (char *) "_PyNs3LrWpanEdPower_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3LrWpanEdPower_wrapper_registry, NULL));
/* Register the 'ns3::LrWpanEdPower' class */
if (PyType_Ready(&PyNs3LrWpanEdPower_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanEdPower", (PyObject *) &PyNs3LrWpanEdPower_Type);
PyModule_AddObject(m, (char *) "_PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3LrWpanPhyDataAndSymbolRates_wrapper_registry, NULL));
/* Register the 'ns3::LrWpanPhyDataAndSymbolRates' class */
if (PyType_Ready(&PyNs3LrWpanPhyDataAndSymbolRates_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanPhyDataAndSymbolRates", (PyObject *) &PyNs3LrWpanPhyDataAndSymbolRates_Type);
PyModule_AddObject(m, (char *) "_PyNs3LrWpanPhyPibAttributes_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3LrWpanPhyPibAttributes_wrapper_registry, NULL));
/* Register the 'ns3::LrWpanPhyPibAttributes' class */
if (PyType_Ready(&PyNs3LrWpanPhyPibAttributes_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanPhyPibAttributes", (PyObject *) &PyNs3LrWpanPhyPibAttributes_Type);
PyModule_AddObject(m, (char *) "_PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3LrWpanPhyPpduHeaderSymbolNumber_wrapper_registry, NULL));
/* Register the 'ns3::LrWpanPhyPpduHeaderSymbolNumber' class */
if (PyType_Ready(&PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanPhyPpduHeaderSymbolNumber", (PyObject *) &PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type);
PyModule_AddObject(m, (char *) "_PyNs3LrWpanSpectrumValueHelper_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3LrWpanSpectrumValueHelper_wrapper_registry, NULL));
/* Register the 'ns3::LrWpanSpectrumValueHelper' class */
if (PyType_Ready(&PyNs3LrWpanSpectrumValueHelper_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanSpectrumValueHelper", (PyObject *) &PyNs3LrWpanSpectrumValueHelper_Type);
PyModule_AddObject(m, (char *) "_PyNs3McpsDataConfirmParams_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3McpsDataConfirmParams_wrapper_registry, NULL));
/* Register the 'ns3::McpsDataConfirmParams' class */
if (PyType_Ready(&PyNs3McpsDataConfirmParams_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "McpsDataConfirmParams", (PyObject *) &PyNs3McpsDataConfirmParams_Type);
PyModule_AddObject(m, (char *) "_PyNs3McpsDataIndicationParams_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3McpsDataIndicationParams_wrapper_registry, NULL));
/* Register the 'ns3::McpsDataIndicationParams' class */
if (PyType_Ready(&PyNs3McpsDataIndicationParams_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "McpsDataIndicationParams", (PyObject *) &PyNs3McpsDataIndicationParams_Type);
PyModule_AddObject(m, (char *) "_PyNs3McpsDataRequestParams_wrapper_registry", PyCObject_FromVoidPtr(&PyNs3McpsDataRequestParams_wrapper_registry, NULL));
/* Register the 'ns3::McpsDataRequestParams' class */
if (PyType_Ready(&PyNs3McpsDataRequestParams_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "McpsDataRequestParams", (PyObject *) &PyNs3McpsDataRequestParams_Type);
/* Register the 'ns3::LrWpanHelper' class */
PyNs3LrWpanHelper_Type.tp_base = &PyNs3PcapHelperForDevice_Type;
PyNs3LrWpanHelper_Type.tp_bases = PyTuple_New(2);
Py_INCREF((PyObject *) &PyNs3PcapHelperForDevice_Type);
PyTuple_SET_ITEM(PyNs3LrWpanHelper_Type.tp_bases, 0, (PyObject *) &PyNs3PcapHelperForDevice_Type);
Py_INCREF((PyObject *) &PyNs3AsciiTraceHelperForDevice_Type);
PyTuple_SET_ITEM(PyNs3LrWpanHelper_Type.tp_bases, 1, (PyObject *) &PyNs3AsciiTraceHelperForDevice_Type);
if (PyType_Ready(&PyNs3LrWpanHelper_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanHelper", (PyObject *) &PyNs3LrWpanHelper_Type);
/* Register the 'ns3::LrWpanLqiTag' class */
PyNs3LrWpanLqiTag_Type.tp_base = &PyNs3Tag_Type;
if (PyType_Ready(&PyNs3LrWpanLqiTag_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanLqiTag", (PyObject *) &PyNs3LrWpanLqiTag_Type);
/* Register the 'ns3::LrWpanMacHeader' class */
PyNs3LrWpanMacHeader_Type.tp_base = &PyNs3Header_Type;
if (PyType_Ready(&PyNs3LrWpanMacHeader_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanMacHeader", (PyObject *) &PyNs3LrWpanMacHeader_Type);
PyModule_AddObject(m, (char *) "_PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____typeid_map", PyCObject_FromVoidPtr(&PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____typeid_map, NULL));
PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____typeid_map.register_wrapper(typeid(ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >), &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type);
/* Register the 'ns3::SimpleRefCount< ns3::LrWpanInterferenceHelper, ns3::empty, ns3::DefaultDeleter<ns3::LrWpanInterferenceHelper> >' class */
PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type.tp_base = &PyNs3Empty_Type;
if (PyType_Ready(&PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt__", (PyObject *) &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type);
PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.register_wrapper(typeid(ns3::LrWpanCsmaCa), &PyNs3LrWpanCsmaCa_Type);
/* Register the 'ns3::LrWpanCsmaCa' class */
PyNs3LrWpanCsmaCa_Type.tp_base = &PyNs3Object_Type;
if (PyType_Ready(&PyNs3LrWpanCsmaCa_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanCsmaCa", (PyObject *) &PyNs3LrWpanCsmaCa_Type);
PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.register_wrapper(typeid(ns3::LrWpanErrorModel), &PyNs3LrWpanErrorModel_Type);
/* Register the 'ns3::LrWpanErrorModel' class */
PyNs3LrWpanErrorModel_Type.tp_base = &PyNs3Object_Type;
if (PyType_Ready(&PyNs3LrWpanErrorModel_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanErrorModel", (PyObject *) &PyNs3LrWpanErrorModel_Type);
PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt____typeid_map.register_wrapper(typeid(ns3::LrWpanInterferenceHelper), &PyNs3LrWpanInterferenceHelper_Type);
/* Register the 'ns3::LrWpanInterferenceHelper' class */
PyNs3LrWpanInterferenceHelper_Type.tp_base = &PyNs3SimpleRefCount__Ns3LrWpanInterferenceHelper_Ns3Empty_Ns3DefaultDeleter__lt__ns3LrWpanInterferenceHelper__gt___Type;
if (PyType_Ready(&PyNs3LrWpanInterferenceHelper_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanInterferenceHelper", (PyObject *) &PyNs3LrWpanInterferenceHelper_Type);
PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.register_wrapper(typeid(ns3::LrWpanMac), &PyNs3LrWpanMac_Type);
/* Register the 'ns3::LrWpanMac' class */
PyNs3LrWpanMacMeta_Type.tp_base = Py_TYPE(&PyNs3Object_Type);
/* Some fields need to be manually inheritted from the parent metaclass */
PyNs3LrWpanMacMeta_Type.tp_traverse = Py_TYPE(&PyNs3Object_Type)->tp_traverse;
PyNs3LrWpanMacMeta_Type.tp_clear = Py_TYPE(&PyNs3Object_Type)->tp_clear;
PyNs3LrWpanMacMeta_Type.tp_is_gc = Py_TYPE(&PyNs3Object_Type)->tp_is_gc;
/* PyType tp_setattro is too restrictive */
PyNs3LrWpanMacMeta_Type.tp_setattro = PyObject_GenericSetAttr;
PyType_Ready(&PyNs3LrWpanMacMeta_Type);
PyNs3LrWpanMac_Type.tp_base = &PyNs3Object_Type;
Py_TYPE(&PyNs3LrWpanMac_Type) = &PyNs3LrWpanMacMeta_Type;
if (PyType_Ready(&PyNs3LrWpanMac_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanMac", (PyObject *) &PyNs3LrWpanMac_Type);
/* Register the 'ns3::LrWpanMacTrailer' class */
PyNs3LrWpanMacTrailerMeta_Type.tp_base = Py_TYPE(&PyNs3Trailer_Type);
/* Some fields need to be manually inheritted from the parent metaclass */
PyNs3LrWpanMacTrailerMeta_Type.tp_traverse = Py_TYPE(&PyNs3Trailer_Type)->tp_traverse;
PyNs3LrWpanMacTrailerMeta_Type.tp_clear = Py_TYPE(&PyNs3Trailer_Type)->tp_clear;
PyNs3LrWpanMacTrailerMeta_Type.tp_is_gc = Py_TYPE(&PyNs3Trailer_Type)->tp_is_gc;
/* PyType tp_setattro is too restrictive */
PyNs3LrWpanMacTrailerMeta_Type.tp_setattro = PyObject_GenericSetAttr;
PyType_Ready(&PyNs3LrWpanMacTrailerMeta_Type);
PyNs3LrWpanMacTrailer_Type.tp_base = &PyNs3Trailer_Type;
Py_TYPE(&PyNs3LrWpanMacTrailer_Type) = &PyNs3LrWpanMacTrailerMeta_Type;
if (PyType_Ready(&PyNs3LrWpanMacTrailer_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanMacTrailer", (PyObject *) &PyNs3LrWpanMacTrailer_Type);
PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.register_wrapper(typeid(ns3::LrWpanPhy), &PyNs3LrWpanPhy_Type);
/* Register the 'ns3::LrWpanPhy' class */
PyNs3LrWpanPhyMeta_Type.tp_base = Py_TYPE(&PyNs3SpectrumPhy_Type);
/* Some fields need to be manually inheritted from the parent metaclass */
PyNs3LrWpanPhyMeta_Type.tp_traverse = Py_TYPE(&PyNs3SpectrumPhy_Type)->tp_traverse;
PyNs3LrWpanPhyMeta_Type.tp_clear = Py_TYPE(&PyNs3SpectrumPhy_Type)->tp_clear;
PyNs3LrWpanPhyMeta_Type.tp_is_gc = Py_TYPE(&PyNs3SpectrumPhy_Type)->tp_is_gc;
/* PyType tp_setattro is too restrictive */
PyNs3LrWpanPhyMeta_Type.tp_setattro = PyObject_GenericSetAttr;
PyType_Ready(&PyNs3LrWpanPhyMeta_Type);
PyNs3LrWpanPhy_Type.tp_base = &PyNs3SpectrumPhy_Type;
Py_TYPE(&PyNs3LrWpanPhy_Type) = &PyNs3LrWpanPhyMeta_Type;
if (PyType_Ready(&PyNs3LrWpanPhy_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanPhy", (PyObject *) &PyNs3LrWpanPhy_Type);
PyNs3SimpleRefCount__Ns3SpectrumSignalParameters_Ns3Empty_Ns3DefaultDeleter__lt__ns3SpectrumSignalParameters__gt____typeid_map.register_wrapper(typeid(ns3::LrWpanSpectrumSignalParameters), &PyNs3LrWpanSpectrumSignalParameters_Type);
/* Register the 'ns3::LrWpanSpectrumSignalParameters' class */
PyNs3LrWpanSpectrumSignalParameters_Type.tp_base = &PyNs3SpectrumSignalParameters_Type;
if (PyType_Ready(&PyNs3LrWpanSpectrumSignalParameters_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanSpectrumSignalParameters", (PyObject *) &PyNs3LrWpanSpectrumSignalParameters_Type);
PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map.register_wrapper(typeid(ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >), &PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type);
/* Register the 'ns3::CallbackImpl< void, ns3::McpsDataConfirmParams, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class */
PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type.tp_base = &PyNs3CallbackImplBase_Type;
if (PyType_Ready(&PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty", (PyObject *) &PyNs3CallbackImpl__Void_Ns3McpsDataConfirmParams_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type);
PyNs3SimpleRefCount__Ns3CallbackImplBase_Ns3Empty_Ns3DefaultDeleter__lt__ns3CallbackImplBase__gt____typeid_map.register_wrapper(typeid(ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >), &PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type);
/* Register the 'ns3::CallbackImpl< void, ns3::McpsDataIndicationParams, ns3::Ptr<ns3::Packet>, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >' class */
PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type.tp_base = &PyNs3CallbackImplBase_Type;
if (PyType_Ready(&PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty", (PyObject *) &PyNs3CallbackImpl__Void_Ns3McpsDataIndicationParams_Ns3Ptr__lt__ns3Packet__gt___Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Ns3Empty_Type);
PyNs3SimpleRefCount__Ns3Object_Ns3ObjectBase_Ns3ObjectDeleter__typeid_map.register_wrapper(typeid(ns3::LrWpanNetDevice), &PyNs3LrWpanNetDevice_Type);
/* Register the 'ns3::LrWpanNetDevice' class */
PyNs3LrWpanNetDevice_Type.tp_base = &PyNs3NetDevice_Type;
if (PyType_Ready(&PyNs3LrWpanNetDevice_Type)) {
return MOD_ERROR;
}
PyModule_AddObject(m, (char *) "LrWpanNetDevice", (PyObject *) &PyNs3LrWpanNetDevice_Type);
PyModule_AddObject(m, (char *) "LrWpanEdPower", (PyObject *) &PyNs3LrWpanEdPower_Type);
PyModule_AddObject(m, (char *) "LrWpanPhyDataAndSymbolRates", (PyObject *) &PyNs3LrWpanPhyDataAndSymbolRates_Type);
PyModule_AddObject(m, (char *) "LrWpanPhyPpduHeaderSymbolNumber", (PyObject *) &PyNs3LrWpanPhyPpduHeaderSymbolNumber_Type);
PyModule_AddObject(m, (char *) "LrWpanPhyPibAttributes", (PyObject *) &PyNs3LrWpanPhyPibAttributes_Type);
PyModule_AddIntConstant(m, (char *) "TX_OPTION_NONE", ns3::TX_OPTION_NONE);
PyModule_AddIntConstant(m, (char *) "TX_OPTION_ACK", ns3::TX_OPTION_ACK);
PyModule_AddIntConstant(m, (char *) "TX_OPTION_GTS", ns3::TX_OPTION_GTS);
PyModule_AddIntConstant(m, (char *) "TX_OPTION_INDIRECT", ns3::TX_OPTION_INDIRECT);
PyModule_AddIntConstant(m, (char *) "MAC_IDLE", ns3::MAC_IDLE);
PyModule_AddIntConstant(m, (char *) "MAC_CSMA", ns3::MAC_CSMA);
PyModule_AddIntConstant(m, (char *) "MAC_SENDING", ns3::MAC_SENDING);
PyModule_AddIntConstant(m, (char *) "MAC_ACK_PENDING", ns3::MAC_ACK_PENDING);
PyModule_AddIntConstant(m, (char *) "CHANNEL_ACCESS_FAILURE", ns3::CHANNEL_ACCESS_FAILURE);
PyModule_AddIntConstant(m, (char *) "CHANNEL_IDLE", ns3::CHANNEL_IDLE);
PyModule_AddIntConstant(m, (char *) "SET_PHY_TX_ON", ns3::SET_PHY_TX_ON);
PyModule_AddIntConstant(m, (char *) "NO_PANID_ADDR", ns3::NO_PANID_ADDR);
PyModule_AddIntConstant(m, (char *) "ADDR_MODE_RESERVED", ns3::ADDR_MODE_RESERVED);
PyModule_AddIntConstant(m, (char *) "SHORT_ADDR", ns3::SHORT_ADDR);
PyModule_AddIntConstant(m, (char *) "EXT_ADDR", ns3::EXT_ADDR);
PyModule_AddIntConstant(m, (char *) "ASSOCIATED", ns3::ASSOCIATED);
PyModule_AddIntConstant(m, (char *) "PAN_AT_CAPACITY", ns3::PAN_AT_CAPACITY);
PyModule_AddIntConstant(m, (char *) "PAN_ACCESS_DENIED", ns3::PAN_ACCESS_DENIED);
PyModule_AddIntConstant(m, (char *) "ASSOCIATED_WITHOUT_ADDRESS", ns3::ASSOCIATED_WITHOUT_ADDRESS);
PyModule_AddIntConstant(m, (char *) "DISASSOCIATED", ns3::DISASSOCIATED);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_SUCCESS", ns3::IEEE_802_15_4_SUCCESS);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_TRANSACTION_OVERFLOW", ns3::IEEE_802_15_4_TRANSACTION_OVERFLOW);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_TRANSACTION_EXPIRED", ns3::IEEE_802_15_4_TRANSACTION_EXPIRED);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_CHANNEL_ACCESS_FAILURE", ns3::IEEE_802_15_4_CHANNEL_ACCESS_FAILURE);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_INVALID_ADDRESS", ns3::IEEE_802_15_4_INVALID_ADDRESS);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_INVALID_GTS", ns3::IEEE_802_15_4_INVALID_GTS);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_NO_ACK", ns3::IEEE_802_15_4_NO_ACK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_COUNTER_ERROR", ns3::IEEE_802_15_4_COUNTER_ERROR);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_FRAME_TOO_LONG", ns3::IEEE_802_15_4_FRAME_TOO_LONG);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_UNAVAILABLE_KEY", ns3::IEEE_802_15_4_UNAVAILABLE_KEY);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_UNSUPPORTED_SECURITY", ns3::IEEE_802_15_4_UNSUPPORTED_SECURITY);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_INVALID_PARAMETER", ns3::IEEE_802_15_4_INVALID_PARAMETER);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_868MHZ_BPSK", ns3::IEEE_802_15_4_868MHZ_BPSK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_915MHZ_BPSK", ns3::IEEE_802_15_4_915MHZ_BPSK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_868MHZ_ASK", ns3::IEEE_802_15_4_868MHZ_ASK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_915MHZ_ASK", ns3::IEEE_802_15_4_915MHZ_ASK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_868MHZ_OQPSK", ns3::IEEE_802_15_4_868MHZ_OQPSK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_915MHZ_OQPSK", ns3::IEEE_802_15_4_915MHZ_OQPSK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_2_4GHZ_OQPSK", ns3::IEEE_802_15_4_2_4GHZ_OQPSK);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_INVALID_PHY_OPTION", ns3::IEEE_802_15_4_INVALID_PHY_OPTION);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_BUSY", ns3::IEEE_802_15_4_PHY_BUSY);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_BUSY_RX", ns3::IEEE_802_15_4_PHY_BUSY_RX);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_BUSY_TX", ns3::IEEE_802_15_4_PHY_BUSY_TX);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_FORCE_TRX_OFF", ns3::IEEE_802_15_4_PHY_FORCE_TRX_OFF);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_IDLE", ns3::IEEE_802_15_4_PHY_IDLE);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_INVALID_PARAMETER", ns3::IEEE_802_15_4_PHY_INVALID_PARAMETER);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_RX_ON", ns3::IEEE_802_15_4_PHY_RX_ON);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_SUCCESS", ns3::IEEE_802_15_4_PHY_SUCCESS);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_TRX_OFF", ns3::IEEE_802_15_4_PHY_TRX_OFF);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_TX_ON", ns3::IEEE_802_15_4_PHY_TX_ON);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE", ns3::IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_READ_ONLY", ns3::IEEE_802_15_4_PHY_READ_ONLY);
PyModule_AddIntConstant(m, (char *) "IEEE_802_15_4_PHY_UNSPECIFIED", ns3::IEEE_802_15_4_PHY_UNSPECIFIED);
PyModule_AddIntConstant(m, (char *) "phyCurrentChannel", ns3::phyCurrentChannel);
PyModule_AddIntConstant(m, (char *) "phyChannelsSupported", ns3::phyChannelsSupported);
PyModule_AddIntConstant(m, (char *) "phyTransmitPower", ns3::phyTransmitPower);
PyModule_AddIntConstant(m, (char *) "phyCCAMode", ns3::phyCCAMode);
PyModule_AddIntConstant(m, (char *) "phyCurrentPage", ns3::phyCurrentPage);
PyModule_AddIntConstant(m, (char *) "phyMaxFrameDuration", ns3::phyMaxFrameDuration);
PyModule_AddIntConstant(m, (char *) "phySHRDuration", ns3::phySHRDuration);
PyModule_AddIntConstant(m, (char *) "phySymbolsPerOctet", ns3::phySymbolsPerOctet);
{
PyObject *tmp_value;
// ns3::LrWpanMacHeader::LRWPAN_MAC_BEACON
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LRWPAN_MAC_BEACON);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LRWPAN_MAC_BEACON", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::LRWPAN_MAC_DATA
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LRWPAN_MAC_DATA);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LRWPAN_MAC_DATA", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::LRWPAN_MAC_ACKNOWLEDGMENT
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LRWPAN_MAC_ACKNOWLEDGMENT);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LRWPAN_MAC_ACKNOWLEDGMENT", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::LRWPAN_MAC_COMMAND
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LRWPAN_MAC_COMMAND);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LRWPAN_MAC_COMMAND", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::LRWPAN_MAC_RESERVED
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LRWPAN_MAC_RESERVED);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LRWPAN_MAC_RESERVED", tmp_value);
Py_DECREF(tmp_value);
}
{
PyObject *tmp_value;
// ns3::LrWpanMacHeader::NOADDR
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::NOADDR);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "NOADDR", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::RESADDR
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::RESADDR);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "RESADDR", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::SHORTADDR
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::SHORTADDR);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "SHORTADDR", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::EXTADDR
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::EXTADDR);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "EXTADDR", tmp_value);
Py_DECREF(tmp_value);
}
{
PyObject *tmp_value;
// ns3::LrWpanMacHeader::IMPLICIT
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::IMPLICIT);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "IMPLICIT", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::NOKEYSOURCE
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::NOKEYSOURCE);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "NOKEYSOURCE", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::SHORTKEYSOURCE
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::SHORTKEYSOURCE);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "SHORTKEYSOURCE", tmp_value);
Py_DECREF(tmp_value);
// ns3::LrWpanMacHeader::LONGKEYSOURCE
tmp_value = PyLong_FromLong(ns3::LrWpanMacHeader::LONGKEYSOURCE);
PyDict_SetItemString((PyObject*) PyNs3LrWpanMacHeader_Type.tp_dict, "LONGKEYSOURCE", tmp_value);
Py_DECREF(tmp_value);
}
submodule = initlr_wpan_FatalImpl();
if (submodule == NULL) {
return MOD_ERROR;
}
Py_INCREF(submodule);
PyModule_AddObject(m, (char *) "FatalImpl", submodule);
submodule = initlr_wpan_Hash();
if (submodule == NULL) {
return MOD_ERROR;
}
Py_INCREF(submodule);
PyModule_AddObject(m, (char *) "Hash", submodule);
submodule = initlr_wpan_TracedValueCallback();
if (submodule == NULL) {
return MOD_ERROR;
}
Py_INCREF(submodule);
PyModule_AddObject(m, (char *) "TracedValueCallback", submodule);
submodule = initlr_wpan_internal();
if (submodule == NULL) {
return MOD_ERROR;
}
Py_INCREF(submodule);
PyModule_AddObject(m, (char *) "internal", submodule);
return MOD_RETURN(m);
}
| 40.160379
| 494
| 0.676347
|
zack-braun
|
89cf563a8a467269e12fc835a7fbd6f2d9a44a7f
| 6,914
|
hh
|
C++
|
RAVL2/Math/Indexing/VectorIndexIterN.hh
|
isuhao/ravl2
|
317e0ae1cb51e320b877c3bad6a362447b5e52ec
|
[
"BSD-Source-Code"
] | null | null | null |
RAVL2/Math/Indexing/VectorIndexIterN.hh
|
isuhao/ravl2
|
317e0ae1cb51e320b877c3bad6a362447b5e52ec
|
[
"BSD-Source-Code"
] | null | null | null |
RAVL2/Math/Indexing/VectorIndexIterN.hh
|
isuhao/ravl2
|
317e0ae1cb51e320b877c3bad6a362447b5e52ec
|
[
"BSD-Source-Code"
] | null | null | null |
// This file is part of RAVL, Recognition And Vision Library
// Copyright (C) 2004, University of Surrey
// This code may be redistributed under the terms of the GNU Lesser
// General Public License (LGPL). See the lgpl.licence file for details or
// see http://www.gnu.org/copyleft/lesser.html
// file-header-ends-here
#ifndef RAVL_VECTORINDEXITERN_HEADER
#define RAVL_VECTORINDEXITERN_HEADER 1
///////////////////////////////////////////////
//! rcsid="$Id: VectorIndexIterN.hh 4130 2004-03-20 15:08:03Z craftit $"
//! file="Ravl/Math/Indexing/VectorIndexIterN.hh"
//! lib=RavlMath
//! userlevel=Normal
//! author="Charles Galambos"
//! date="04/10/2000"
//! docentry="Ravl.Math.Vector Index"
#include "Ravl/VectorIndex.hh"
#include "Ravl/PriQueueL.hh"
#include "Ravl/PriQueue.hh"
#include "Ravl/Index2d.hh"
#include "Ravl/HSet.hh"
#include "Ravl/StdMath.hh"
#include "Ravl/Assert.hh"
#define DODEBUG 0
#if DODEBUG
#define ONDEBUG(x) x
#else
#define ONDEBUG(x)
#endif
namespace RavlN {
//! userlevel=Normal
//: Iterate through the N closest points in a VectorIndex.
template<class LabelT>
class VectorIndexIterNC {
public:
typedef Tuple2C<VectorC, LabelT> DataT;
inline VectorIndexIterNC(VectorIndexC<LabelT> & thedata,
const VectorC & thepoint);
//: Constructor.
inline void First();
//: Get ready to return closest point.
inline bool IsElm() const
{ return ordered.IsElm(); }
//: Any points yet to be returned?
inline operator bool() const
{ return IsElm(); }
//: At a valid point ?
inline void Next();
//: Goto next point.
inline void operator++(int)
{ Next(); }
//: Goto next point
inline LabelT &Data() { return ordered.Top().Data2(); }
//: Access label of current closest point.
inline const LabelT &Data() const { return ordered.Top().Data2(); }
//: Access label of current closest point.
inline DataT &RawData() { return ordered.Top(); }
//: Access label of current closest point.
inline const VectorC &VectorData() const
{return ordered.Top().Data1(); }
//: Access label and coordinates of current closest point.
// Once this data is returned it cannot be accessed again
protected:
bool QueueNextData();
//: Queue up next lot of data.
inline void AddBin(const VectorC &bin );
VectorIndexC<LabelT> &data;
VectorC centre;
RealT maxDist; // Maximum distance we can trust.
RealT maxSearchDistance;
IntT dim;
RealT min[8],max[8];
IntT square_size;
PriQueueC<RealT, DataT > ordered;
};
///////////////////////////////////////////////////
template<class LabelT>
inline
VectorIndexIterNC<LabelT>::VectorIndexIterNC(VectorIndexC<LabelT> &thedata,
const VectorC& thepoint)
: data(thedata),
centre(thepoint),
maxDist(0),
dim(thedata.dim),
square_size(1),
ordered(128)
{
maxSearchDistance = data.maxSearchDistance;
RavlAssert(dim < 8);
//cerr << "Centre:" << centre << "\n";
First();
}
///////////////////////////////////////////////////
template<class LabelT>
inline
void VectorIndexIterNC<LabelT>::AddBin(const VectorC &abin) {
DListC<DataT> *point_list = data.bins.GetBin(abin);
ONDEBUG(cerr << "Search " << abin << " Bin=" << ((void *) point_list) << "\n");
if(point_list == 0)
return;
DLIterC<DataT> point_it(*point_list);
for(;point_it;point_it++)
ordered.Insert(data.dist(point_it.Data().Data1(), centre), point_it.Data());
}
//: Queue up next lot of data.
template<class LabelT>
inline
bool VectorIndexIterNC<LabelT>::QueueNextData() {
ONDEBUG(cerr << "VectorIndexIterNC<LabelT>::QueueNextData(), Called for " << maxDist << "\n");
RealT hbin_size = data.bins.BinSize()[0]/2;
RealT bin_size = data.bins.BinSize()[0];
for(;maxDist < maxSearchDistance;) {
// Find closest limit.
RealT closest = maxSearchDistance * 2;
int dir = 0;
bool incmax = false;
for(int d = 0;d < dim;d++) {
RealT ndist1 = centre[d] - min[d];
RealT ndist2 = max[d] - centre[d];
if(ndist2 < ndist1) {
if(closest > ndist2) {
closest = ndist2;
dir = d;
incmax = true;
}
} else {
if(closest > ndist1) {
closest = ndist1;
dir = d;
incmax = false;
}
}
}
ONDEBUG(cerr << "VectorIndexIterNC<LabelT>::QueueNextData(), Direction: " << dir << " Max:" << ((int) incmax) << " MaxDist :" << maxDist << "\n");
// Add a plane along that direction.
RealT addAt;
if(incmax) {
max[dir] += data.bins.BinSize()[dir];
addAt = max[dir] - hbin_size;
} else {
min[dir] -= data.bins.BinSize()[dir];
addAt = min[dir] + hbin_size;
}
VectorC ind(dim);
int i;
for(i = 0;i < dim;i++)
ind[i] = min[i];
ind[dir] = addAt;
for(i = dim-1;i >= 0;) {
if(i==(dim-1)) {
//...Inner;
if(i == dir) {
AddBin(ind);
i--;
continue;
}
// Do the inner loop quickly.
for(;ind[i] < max[i];ind[i] += bin_size)
AddBin(ind);
i--;
continue;
}
if(i == dir) {
i--;
continue;
}
ind[i] += data.bins.BinSize()[i];
if(ind[i] > max[i]) {
ind[i] = min[i];
i--;
continue;
}
i = dim-1;
}
closest = maxSearchDistance * 2;
for(int d = 0;d < dim;d++) {
RealT ndist1 = centre[d] - min[d];
RealT ndist2 = max[d] - centre[d];
if(ndist2 < closest)
closest = ndist2;
if(ndist1 < closest)
closest = ndist1;
}
maxDist = closest;
if(ordered.IsElm())
if(ordered.TopKey() < maxDist)
break; // Got some new valid points.
}
ONDEBUG(cerr << "VectorIndexIterNC<LabelT>::QueueNextData(), Max dist now: " << maxDist << "\n");
return true;
}
template<class LabelT>
inline void VectorIndexIterNC<LabelT>::First()
{
// Get the list of the bin in which point falls
VectorC binCent = data.bins.BinCentre(centre);
RealT hbin_size = data.bins.BinSize()[0]/2;
// Calculate minimum distance.
VectorC centDist = centre - binCent;
maxDist = Min(hbin_size - Abs(centDist[0]),hbin_size - Abs(centDist[1]));
AddBin(centre);
for(int d = 0;d < dim;d++) {
min[d] = binCent[d] - hbin_size;
max[d] = binCent[d] + hbin_size;
}
ONDEBUG(cerr << "VectorIndexIterNC<LabelT>::First(), MaxDist " << maxDist <<" Proj:" << centre << " \n");
if(ordered.IsElm())
if(ordered.TopKey() < maxDist)
return ; // Done.
QueueNextData();
}
///////////////////////////////////////////////////
template<class LabelT>
inline void VectorIndexIterNC<LabelT>::Next() {
RavlAssert(ordered.IsElm());
ordered.DelTop();
if(ordered.IsElm())
if(ordered.Top().Data1() < maxDist)
return ;
QueueNextData();
}
}
#undef ONDEBUG
#undef DODEBUG
#endif
| 26.189394
| 153
| 0.59083
|
isuhao
|
89d1b96a977fae6664c2cb09355c1dd481fa1b41
| 336
|
hpp
|
C++
|
inode.hpp
|
macdice/ds9fs
|
d6676d7996a2f3b5722b7d37f3aa58233a397aa5
|
[
"BSD-2-Clause"
] | 3
|
2021-05-18T18:45:47.000Z
|
2021-05-24T14:31:21.000Z
|
inode.hpp
|
macdice/dsfs
|
d6676d7996a2f3b5722b7d37f3aa58233a397aa5
|
[
"BSD-2-Clause"
] | null | null | null |
inode.hpp
|
macdice/dsfs
|
d6676d7996a2f3b5722b7d37f3aa58233a397aa5
|
[
"BSD-2-Clause"
] | null | null | null |
#ifndef INODE_HPP
#define INODE_HPP
#include <cstddef>
#include <sys/types.h>
struct inode {
virtual ~inode() {}
virtual void write(int fd, const char *data, std::size_t size, off_t offset) = 0;
virtual void truncate(int fd, std::size_t size) = 0;
virtual void synchronize(int fd) = 0;
virtual void lose_power() = 0;
};
#endif
| 19.764706
| 82
| 0.699405
|
macdice
|
89d4a4127f21642f4525fc464e4f8db5a0456a86
| 6,216
|
cpp
|
C++
|
11_CPP/02_CPP02/ex03/main.cpp
|
tderwedu/42cursus
|
2f56b87ce87227175e7a297d850aa16031acb0a8
|
[
"Unlicense"
] | null | null | null |
11_CPP/02_CPP02/ex03/main.cpp
|
tderwedu/42cursus
|
2f56b87ce87227175e7a297d850aa16031acb0a8
|
[
"Unlicense"
] | null | null | null |
11_CPP/02_CPP02/ex03/main.cpp
|
tderwedu/42cursus
|
2f56b87ce87227175e7a297d850aa16031acb0a8
|
[
"Unlicense"
] | null | null | null |
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tderwedu <tderwedu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/30 14:24:51 by tderwedu #+# #+# */
/* Updated: 2021/10/14 15:46:35 by tderwedu ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include <string>
#include "Fixed.hpp"
#include "Point.hpp"
# define BOLD "\e[1;37m"
# define CLEAR "\e[0m" << std::endl
bool bsp(Point const a, Point const b, Point const c, Point const point);
int main(void)
{
Point a = Point(-1.0f, 0.0f);
Point b = Point( 0.0f, 1.0f);
Point c = Point( 1.0f, 0.0f);
std::cout << BOLD << "Triangle Vertices:" << CLEAR;
std::cout << "a : " << a << std::endl;
std::cout << "b : " << b << std::endl;
std::cout << "c : " << c << std::endl << std::endl;
std::cout << BOLD << "Triangle Midpoints:" << CLEAR;
std::cout << "ab : (-0.5, 0.5)" << std::endl;
std::cout << "bc : ( 0.5, 0.5)" << std::endl;
std::cout << "ca : ( 0.0, 0.0)" << std::endl << std::endl;
std::cout << BOLD << "\t [ Permutations ]" << CLEAR;
std::cout << " Point INSIDE: (0.0, 0.5)" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, Point(0.0f, 0.05f)) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(0.0f, 0.05f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(0.0f, 0.05f)) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.0f, 0.05f)) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, Point(0.0f, 0.05f)) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, Point(0.0f, 0.05f)) << std::endl;
std::cout << " Point OUTSIDE: (0.0, 2.0)" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, Point(0.0f, 2.0f)) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(0.0f, 2.0f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(0.0f, 2.0f)) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.0f, 2.0f)) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, Point(0.0f, 2.0f)) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, Point(0.0f, 2.0f)) << std::endl;
std::cout << BOLD << "\t [ Point on Edge ]" << CLEAR;
std::cout << " Point on Edge ab" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, Point(-0.5f, 0.5f)) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(-0.5f, 0.5f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(-0.5f, 0.5f)) << std::endl;
std::cout << " Point on Edge bc" << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.5f, 0.5f)) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, Point(0.5f, 0.5f)) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, Point(0.5f, 0.5f)) << std::endl;
std::cout << " Point on Edge ca" << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(0.0f, 0.0f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(0.0f, 0.0f)) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.0f, 0.0f)) << std::endl;
std::cout << BOLD << "\t [ Point on Vertex ]" << CLEAR;
std::cout << " Point == a" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, a) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, a) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, a) << std::endl;
std::cout << " Point == b" << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, b) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, b) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, b) << std::endl;
std::cout << " Point == c" << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, c) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, c) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, c) << std::endl;
std::cout << BOLD << "\t [ Point INSIDE but close to Edge ]" << CLEAR;
std::cout << " Point close to Edge ab" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, Point(-0.49f, 0.49f)) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(-0.49f, 0.49f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(-0.49f, 0.49f)) << std::endl;
std::cout << " Point close to Edge bc" << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.49f, 0.49f)) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, Point(0.49f, 0.49f)) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, Point(0.49f, 0.49f)) << std::endl;
std::cout << " Point close to Edge ca" << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(0.0f, 0.01f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(0.0f, 0.01f)) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.0f, 0.01f)) << std::endl;
std::cout << BOLD << "\t [ Point OUTSIDE but close to Edge ]" << CLEAR;
std::cout << " Point close to Edge ab" << std::endl;
std::cout << "a, b, c : " << bsp(a, b, c, Point(-0.51f, 0.51f)) << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(-0.51f, 0.51f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(-0.51f, 0.51f)) << std::endl;
std::cout << " Point close to Edge bc" << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.51f, 0.51f)) << std::endl;
std::cout << "c, b, a : " << bsp(c, b, a, Point(0.51f, 0.51f)) << std::endl;
std::cout << "b, a, c : " << bsp(b, a, c, Point(0.51f, 0.51f)) << std::endl;
std::cout << " Point close to Edge ca" << std::endl;
std::cout << "b, c, a : " << bsp(b, c, a, Point(0.0f, -0.01f)) << std::endl;
std::cout << "c, a, b : " << bsp(c, a, b, Point(0.0f, -0.01f)) << std::endl;
std::cout << "a, c, b : " << bsp(a, c, b, Point(0.0f, -0.01f)) << std::endl;
}
| 56.509091
| 80
| 0.42471
|
tderwedu
|
89d8899149f99a2917ad76d922e6428c5e7a10cd
| 5,161
|
cpp
|
C++
|
Akel/src/Renderer/Buffers/vk_buffer.cpp
|
NurissGames/Akel
|
9580f7eb1d4a0dbe20459bd83a5e681a040c29de
|
[
"MIT"
] | 3
|
2021-12-01T17:59:30.000Z
|
2022-01-22T20:29:08.000Z
|
Akel/src/Renderer/Buffers/vk_buffer.cpp
|
NurissGames/Akel
|
9580f7eb1d4a0dbe20459bd83a5e681a040c29de
|
[
"MIT"
] | null | null | null |
Akel/src/Renderer/Buffers/vk_buffer.cpp
|
NurissGames/Akel
|
9580f7eb1d4a0dbe20459bd83a5e681a040c29de
|
[
"MIT"
] | 1
|
2021-12-01T17:59:32.000Z
|
2021-12-01T17:59:32.000Z
|
// This file is a part of Akel
// Authors : @kbz_8
// Created : 10/04/2022
// Updated : 08/05/2022
#include "vk_buffer.h"
namespace Ak
{
void Buffer::create(Buffer::kind type, VkDeviceSize size, VkBufferUsageFlags usage, const void* data)
{
if(type == Buffer::kind::constant)
{
if(data == nullptr)
{
Core::log::report(ERROR, "Vulkan : trying to create constant buffer without data (constant buffers cannot be modified after creation)");
return;
}
_usage = usage | VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
else
{
_usage = usage;
_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
}
_mem_chunck.size = size;
createBuffer(_usage, _flags);
if(type == Buffer::kind::constant)
{
void* mapped = nullptr;
mapMem(mapped);
std::memcpy(mapped, data, _mem_chunck.size);
unmapMem();
pushToGPU();
}
}
void Buffer::destroy() noexcept
{
Ak_assert(_buffer != VK_NULL_HANDLE, "trying to destroy an uninit video buffer");
vkDestroyBuffer(Render_Core::get().getDevice().get(), _buffer, nullptr);
Render_Core::get().freeChunk(_mem_chunck);
}
void Buffer::createBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlags properties)
{
VkBufferCreateInfo bufferInfo{};
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = _mem_chunck.size;
bufferInfo.usage = usage;
bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
auto device = Render_Core::get().getDevice().get();
if(vkCreateBuffer(device, &bufferInfo, nullptr, &_buffer) != VK_SUCCESS)
Core::log::report(FATAL_ERROR, "Vulkan : failed to create buffer");
VkMemoryRequirements memRequirements;
vkGetBufferMemoryRequirements(device, _buffer, &memRequirements);
VkMemoryAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = memRequirements.size;
allocInfo.memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits);
_mem_chunck = Render_Core::get().allocChunk(memRequirements, properties);
vkBindBufferMemory(device, _buffer, _mem_chunck.memory, _mem_chunck.offset);
}
void Buffer::pushToGPU() noexcept
{
Buffer newBuffer;
newBuffer._mem_chunck.size = this->_mem_chunck.size;
newBuffer._usage = (this->_usage & VK_BUFFER_USAGE_TRANSFER_SRC_BIT) | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
newBuffer._flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
newBuffer.createBuffer(newBuffer._usage, newBuffer._flags);
auto cmdpool = Render_Core::get().getCmdPool().get();
auto device = Render_Core::get().getDevice().get();
VkCommandBufferAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandPool = cmdpool;
allocInfo.commandBufferCount = 1;
VkCommandBuffer commandBuffer;
vkAllocateCommandBuffers(device, &allocInfo, &commandBuffer);
VkCommandBufferBeginInfo beginInfo{};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
vkBeginCommandBuffer(commandBuffer, &beginInfo);
VkBufferCopy copyRegion{};
copyRegion.size = this->_mem_chunck.size;
vkCmdCopyBuffer(commandBuffer, _buffer, newBuffer._buffer, 1, ©Region);
vkEndCommandBuffer(commandBuffer);
VkSubmitInfo submitInfo{};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &commandBuffer;
auto graphicsQueue = Render_Core::get().getQueue().getGraphic();
vkQueueSubmit(graphicsQueue, 1, &submitInfo, VK_NULL_HANDLE);
vkQueueWaitIdle(graphicsQueue);
vkFreeCommandBuffers(device, cmdpool, 1, &commandBuffer);
this->swap(newBuffer);
newBuffer.destroy();
}
void Buffer::swap(Buffer& buffer)
{
VkBuffer temp_b = _buffer;
_buffer = buffer._buffer;
buffer._buffer = temp_b;
GPU_Mem_Chunk temp_c = _mem_chunck;
_mem_chunck = buffer._mem_chunck;
buffer._mem_chunck = temp_c;
VkBufferUsageFlags temp_u = _usage;
_usage = buffer._usage;
buffer._usage = temp_u;
VkMemoryPropertyFlags temp_f = _flags;
_flags = buffer._flags;
buffer._flags = temp_f;
}
void Buffer::flush(VkDeviceSize size, VkDeviceSize offset)
{
VkMappedMemoryRange mappedRange{};
mappedRange.memory = _mem_chunck.memory;
mappedRange.offset = offset;
mappedRange.size = size;
vkFlushMappedMemoryRanges(Render_Core::get().getDevice().get(), 1, &mappedRange);
}
uint32_t Buffer::findMemoryType(uint32_t typeFilter)
{
VkPhysicalDeviceMemoryProperties memProperties;
vkGetPhysicalDeviceMemoryProperties(Render_Core::get().getDevice().getPhysicalDevice(), &memProperties);
for(uint32_t i = 0; i < memProperties.memoryTypeCount; i++)
{
if((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & _flags) == _flags)
return i;
}
Core::log::report(FATAL_ERROR, "Vulkan : failed to find suitable memory type");
return 0; // Not necessary due to the FATAL_ERROR parameter for logs but that removes a warning
}
}
| 30.720238
| 140
| 0.757605
|
NurissGames
|
89dac5024f306b7fca25809226bb3c32db59760f
| 1,637
|
cpp
|
C++
|
pen/class2.cpp
|
harveywangdao/earth
|
665660120a00834f0963ad9163bf4f6a97d11c35
|
[
"Apache-2.0"
] | null | null | null |
pen/class2.cpp
|
harveywangdao/earth
|
665660120a00834f0963ad9163bf4f6a97d11c35
|
[
"Apache-2.0"
] | null | null | null |
pen/class2.cpp
|
harveywangdao/earth
|
665660120a00834f0963ad9163bf4f6a97d11c35
|
[
"Apache-2.0"
] | null | null | null |
#include <cstring>
#include <string>
#include <cstdio>
#include <iostream>
#include <unistd.h>
using namespace std;
class People1
{
public:
int age1;
People1()
{
cout << "People1 object is being created" << endl;
}
virtual int getAge()
{
cout << "People1 getAge" << endl;
return age1;
}
virtual void setAge(int a)
{
cout << "People1 setAge" << endl;
age1 = a;
}
virtual ~People1()
{
cout << "People1 object is being deleted " << age1 << endl;
}
};
class People2
{
public:
int age2;
People2()
{
cout << "People2 object is being created" << endl;
}
virtual int getAge()
{
cout << "People2 getAge" << endl;
return age2;
}
virtual void setAge(int a)
{
cout << "People2 setAge" << endl;
age2 = a;
}
virtual ~People2()
{
cout << "People2 object is being deleted " << age2 << endl;
}
};
class Student: public People1, public People2
{
public:
int no;
int age;
Student(int a, int n)
{
age = a;
no = n;
cout << "Student object is being created" << endl;
}
virtual void setNo(int n)
{
no = n;
}
virtual int getNo()
{
return no;
}
virtual int getAge()
{
cout << "Student getAge" << endl;
return age;
}
virtual void setAge(int a)
{
cout << "Student setAge" << endl;
age = a;
}
virtual ~Student()
{
cout << "Student object is being deleted " << age << endl;
}
};
int main(int argc, char const *argv[])
{
Student *s1 = new Student(10, 111);
cout<< s1->getAge() << endl;
s1->setAge(20);
cout<< s1->getAge() << endl;
delete s1;
return 0;
}
| 14.234783
| 63
| 0.564447
|
harveywangdao
|
89dfb0507644feeb4104cdbfdf7c99a4f47ca371
| 54,289
|
cpp
|
C++
|
qtensor/qtensor.cpp
|
ClarkResearchGroup/tensor-tools
|
25fe4553991d2680b43301aef1960e4c20f1e146
|
[
"Apache-2.0"
] | 8
|
2020-07-14T01:55:51.000Z
|
2022-02-12T14:06:59.000Z
|
qtensor/qtensor.cpp
|
ClarkResearchGroup/tensor-tools
|
25fe4553991d2680b43301aef1960e4c20f1e146
|
[
"Apache-2.0"
] | 1
|
2020-07-31T02:43:25.000Z
|
2020-08-08T16:18:36.000Z
|
qtensor/qtensor.cpp
|
ClarkResearchGroup/tensor-tools
|
25fe4553991d2680b43301aef1960e4c20f1e146
|
[
"Apache-2.0"
] | 1
|
2020-12-01T03:40:26.000Z
|
2020-12-01T03:40:26.000Z
|
/*
* Copyright 2020 Ryan Levy, Xiongjie Yu, and Bryan K. Clark
*
* 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 QUANTUM_NUMBERED_TENSOR_CLASS
#define QUANTUM_NUMBERED_TENSOR_CLASS
#include "qtensor.h"
string indToStr(vector<qtensor_index> &indices,unordered_map<string,char> &charMap)
{
assert(charMap.size() >= indices.size());
string myString="";
for (auto i: indices){
const string thisTag = i.tagNoArrow();
myString+=charMap[thisTag];
}
return myString;
}
string indicesToChar(vector<qtensor_index> &indices,unordered_map<string,char> &charMap)
{
char ch='a';
for (auto i : charMap) //find highest char
if (i.second > ch)
ch=i.second;
if(ch!='a') ++ch; //increment from latest
for (auto i: indices){
auto thisTag = i.tagNoArrow();
auto it= charMap.find(thisTag);
if (it==charMap.end()){ //new tag, add it to map
charMap[thisTag]=ch;
++ch;
}
}
return indToStr(indices,charMap);
}
string indToStrNP(vector<qtensor_index> &indices,unordered_map<string,char> &charMap)
{
string myString="";
for (auto i: indices){
const string thisTag = noPrime(i).tagNoArrow();
myString+=charMap[thisTag];
}
return myString;
}
string indicesToCharNP(vector<qtensor_index> &indices, unordered_map<string,char> &charMap)
{
char ch='a';
for (auto i : charMap) //find highest char
if (i.second > ch)
ch=i.second;
if(ch!='a') ++ch; //increment from latest
for (auto i : indices){
auto thisTag = noPrime(i).tagNoArrow();
auto it= charMap.find(thisTag);
if (it==charMap.end()){ //new tag, add it to map
charMap[thisTag]=ch;
++ch;
}
}
return indToStrNP(indices,charMap);
}
//-----------------------------------------------------------------------------
// Constructors
template <typename T>
qtensor<T>::qtensor(){
rank = 0;
_initted = false;
}
template qtensor<double>::qtensor();
template qtensor< std::complex<double> >::qtensor();
template <typename T>
qtensor<T>::qtensor(arr_list arrows){
rank = 0;
for(auto a :arrows){
idx_set.emplace_back(a);
++rank;
}
_initted = false;
}
template qtensor<double>::qtensor(arr_list arrows);
template qtensor< std::complex<double> >::qtensor(arr_list arrows);
template <typename T>
qtensor<T>::qtensor(arr_vec& arrows){
rank = 0;
for(auto a :arrows){
idx_set.emplace_back(a);
++rank;
}
_initted = false;
}
template qtensor<double>::qtensor(arr_vec& arrows);
template qtensor< std::complex<double> >::qtensor(arr_vec& arrows);
template <typename T>
qtensor<T>::qtensor(arr_list arrows, str_list names){
rank = 0;
arr_vec arrows_vec;
str_vec names_vec;
for(auto a :arrows){
arrows_vec.push_back(a);
++rank;
}
for(auto n :names){
names_vec.push_back(n);
}
for (size_t i = 0; i < arrows_vec.size(); i++) {
idx_set.emplace_back(arrows_vec[i], names_vec[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_list arrows, str_list names);
template qtensor< std::complex<double> >::qtensor(arr_list arrows, str_list names);
template <typename T>
qtensor<T>::qtensor(arr_vec& arrows, str_vec& names){
rank = arrows.size();
for (size_t i = 0; i < arrows.size(); i++) {
idx_set.emplace_back(arrows[i], names[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_vec& arrows, str_vec& names);
template qtensor< std::complex<double> >::qtensor(arr_vec& arrows, str_vec& names);
template <typename T>
qtensor<T>::qtensor(arr_list arrows, str_list names, typ_list types){
rank = 0;
arr_vec arrows_vec;
str_vec names_vec;
typ_vec types_vec;
for(auto a :arrows){
arrows_vec.push_back(a);
++rank;
}
for(auto n :names){
names_vec.push_back(n);
}
for(auto t :types){
types_vec.push_back(t);
}
for (size_t i = 0; i < arrows_vec.size(); i++) {
idx_set.emplace_back(arrows_vec[i], names_vec[i], types_vec[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_list arrows, str_list names, typ_list types);
template qtensor< std::complex<double> >::qtensor(arr_list arrows, str_list names, typ_list types);
template <typename T>
qtensor<T>::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types){
rank = arrows.size();
for (size_t i = 0; i < arrows.size(); i++) {
idx_set.emplace_back(arrows[i], names[i], types[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types);
template qtensor< std::complex<double> >::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types);
template <typename T>
qtensor<T>::qtensor(arr_list arrows, str_list names, typ_list types, uint_list levels){
rank = 0;
arr_vec arrows_vec;
str_vec names_vec;
typ_vec types_vec;
uint_vec levels_vec;
for(auto a :arrows){
arrows_vec.push_back(a);
++rank;
}
for(auto n :names){
names_vec.push_back(n);
}
for(auto t :types){
types_vec.push_back(t);
}
for(auto l :levels){
levels_vec.push_back(l);
}
for (size_t i = 0; i < rank; i++) {
idx_set.emplace_back(arrows_vec[i], names_vec[i], types_vec[i], levels_vec[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_list arrows, str_list names, typ_list types, uint_list levels);
template qtensor< std::complex<double> >::qtensor(arr_list arrows, str_list names, typ_list types, uint_list levels);
template <typename T>
qtensor<T>::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types, uint_vec& levels){
rank = arrows.size();
for (size_t i = 0; i < arrows.size(); i++) {
idx_set.emplace_back(arrows[i], names[i], types[i], levels[i]);
}
_initted = false;
}
template qtensor<double>::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types, uint_vec& levels);
template qtensor< std::complex<double> >::qtensor(arr_vec& arrows, str_vec& names, typ_vec& types, uint_vec& levels);
template <typename T>
qtensor<T>::qtensor(vector<qtensor_index>& qidx_vec){
rank = qidx_vec.size();
idx_set = qidx_vec;
_initted = false;
}
template qtensor<double>::qtensor(vector<qtensor_index>& idx_vec);
template qtensor< std::complex<double> >::qtensor(vector<qtensor_index>& idx_vec);
template <typename T>
qtensor<T>::qtensor(vector<qtensor_index>&& qidx_vec){
idx_set = std::move(qidx_vec);
rank = idx_set.size();
_initted = false;
}
template qtensor<double>::qtensor(vector<qtensor_index>&& idx_vec);
template qtensor< std::complex<double> >::qtensor(vector<qtensor_index>&& idx_vec);
template <typename T>
qtensor<T>::qtensor(initializer_list<qtensor_index> qidx_list){
rank = 0;
for(auto i : qidx_list){
idx_set.push_back(i);
++rank;
}
_initted = false;
}
template qtensor<double>::qtensor(initializer_list<qtensor_index> qidx_list);
template qtensor< std::complex<double> >::qtensor(initializer_list<qtensor_index> qidx_list);
template <typename T>
qtensor<T>::qtensor(const qtensor<T>& other){
rank = other.rank;
idx_set = other.idx_set;
_block = other._block;
block_index_qn = other.block_index_qn;
block_index_qd = other.block_index_qd;
block_index_qi = other.block_index_qi;
block_id_by_qn_str = other.block_id_by_qn_str;
_initted = other._initted;
}
template qtensor<double>::qtensor(const qtensor<double>& other);
template qtensor< std::complex<double> >::qtensor(const qtensor< std::complex<double> >& other);
template <typename T>
qtensor<T>::qtensor(qtensor<T>&& other){
rank = other.rank;
idx_set = std::move(other.idx_set);
_block = std::move(other._block);
block_index_qn = std::move(other.block_index_qn);
block_index_qd = std::move(other.block_index_qd);
block_index_qi = std::move(other.block_index_qi);
block_id_by_qn_str = std::move(other.block_id_by_qn_str);
_initted = other._initted;
}
template qtensor<double>::qtensor(qtensor<double>&& other);
template qtensor< std::complex<double> >::qtensor(qtensor< std::complex<double> >&& other);
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------
// set up quantum number information (qn, qdim) for selected qtensor_index
template <typename T>
void qtensor<T>::addQNtoIndex(unsigned idx, quantum_number qn){
assert(idx<rank);
idx_set[idx].addQN(qn);
}
template void qtensor<double>::addQNtoIndex(unsigned idx, quantum_number qn);
template void qtensor< std::complex<double> >::addQNtoIndex(unsigned idx, quantum_number qn);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Initialize legal block
template <typename T>
void qtensor<T>::initBlock(){
if(rank>0 && !_initted){
// get strides
uint_vec stride;
stride.push_back(1);
for (size_t i = 0; i < rank; i++) {
stride.push_back(idx_set[i].size() * stride[i]);
}
unsigned n = stride.back();
// iterate over all combinations of qns
for (size_t i = 0; i < n; i++) {
uint_vec pos(rank);
int_vec qds(rank);
vector<QN_t> qns(rank);
unsigned size = 1;
QN_t totalQN = 0;
for (size_t j = 0; j < rank; j++) {
pos[j] = unsigned(i/stride[j])%idx_set[j].size();
qns[j] = idx_set[j].qn(pos[j]);
qds[j] = idx_set[j].qdim(pos[j]);
size *= qds[j];
if(idx_set[j].arrow()==Inward){
totalQN += qns[j];
}else{
totalQN -= qns[j];
}
}
// legal combination
if(totalQN==0){
string qn_str;
for (size_t j = 0; j < rank; j++) {
qn_str += (to_string(qns[j])+" ");
}
_block.emplace_back(rank,qds.data());
//block.emplace_back(size);
block_index_qn.push_back(std::move(qns));
block_index_qd.push_back(std::move(qds));
block_index_qi.push_back(std::move(pos));
block_id_by_qn_str[qn_str] = _block.size()-1;
}
}
}
_initted = true;
}
template void qtensor<double>::initBlock();
template void qtensor< std::complex<double> >::initBlock();
template <typename T>
void qtensor<T>::clearBlock(){
rank = idx_set.size();
//block.clear();
_block.clear();
block_index_qn.clear();
block_index_qd.clear();
block_index_qi.clear();
block_id_by_qn_str.clear();
_initted = false;
}
template void qtensor<double>::clearBlock();
template void qtensor< std::complex<double> >::clearBlock();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Reset
template <typename T>
void qtensor<T>::reset(vector<qtensor_index>& idx_vec){
clearBlock();
idx_set = idx_vec;
rank = idx_set.size();
}
template void qtensor<double>::reset(vector<qtensor_index>& idx_vec);
template void qtensor< std::complex<double> >::reset(vector<qtensor_index>& idx_vec);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Set values
template <typename T>
void qtensor<T>::setRandom(){
assert(_initted);
for (size_t i = 0; i < _block.size(); i++) {
//random_array(block[i].data(), block[i].size());
_block[i].fill_random(0,1);
}
}
template void qtensor<double>::setRandom();
template void qtensor< std::complex<double> >::setRandom();
template <typename T>
void qtensor<T>::setZero(){
assert(_initted);
for (size_t i = 0; i < _block.size(); i++) {
_block[i].set_zero();
}
}
template void qtensor<double>::setZero();
template void qtensor< std::complex<double> >::setZero();
template <typename T>
void qtensor<T>::setOne(){
assert(_initted);
string ind = getIndices();
for (size_t i = 0; i < _block.size(); i++) {
_block[i][ind.c_str()] = 1.;
}
}
template void qtensor<double>::setOne();
template void qtensor< std::complex<double> >::setOne();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Permute
template <typename T>
void qtensor<T>::permute(uint_vec& perm){
assert(_initted);
bool perm_needed = false;
for (size_t i = 0; i < perm.size(); i++) {
if(i!=perm[i]){
perm_needed = true;
break;
}
}
if (perm_needed){
#ifndef NDEBUG
perr<<"permute"<<endl;
#endif
qtensor<T> A(*this);
for (size_t i = 0; i < rank; i++) {
A.idx_set[i] = idx_set[perm[i]];
}
A.block_id_by_qn_str.clear();
T alpha = 1;
T beta = 0;
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
unordered_map<string,char> charMap;
string indOld = getIndices(charMap);
string indNew = A.getIndices(charMap);
omp_set_num_threads(numThreads);
for (size_t i = 0; i < _block.size(); i++) {
string A_qn_str;
int_vec idx_sizes(rank);
for (size_t j = 0; j < rank; j++) {
A.block_index_qn[i][j] = block_index_qn[i][perm[j]];
A.block_index_qd[i][j] = block_index_qd[i][perm[j]];
A.block_index_qi[i][j] = block_index_qi[i][perm[j]];
A_qn_str += (to_string(A.block_index_qn[i][j])+" ");
idx_sizes[j] =A.block_index_qd[i][j];
}
A.block_id_by_qn_str[A_qn_str] = i;
//permute by "hand"
CTF::Tensor<> B(A.rank,idx_sizes.data());
B[indNew.c_str()] = _block[i][indOld.c_str()];
A._block[i] = std::move(B);
}
*this = A;
}
}
template void qtensor<double>::permute(uint_vec& perm);
template void qtensor< std::complex<double> >::permute(uint_vec& perm);
template <typename T>
void qtensor<T>::permute(uint_list perm){
uint_vec perm_vec;
for(auto s : perm){
perm_vec.push_back(s);
}
permute(perm_vec);
}
template void qtensor<double>::permute(uint_list perm);
template void qtensor< std::complex<double> >::permute(uint_list perm);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Operator overloading
template <typename T>
qtensor<T>& qtensor<T>::operator=(const qtensor<T>& other){
if(this!=&other){
clearBlock();
rank = other.rank;
idx_set = other.idx_set;
_block = other._block;
block_index_qn = other.block_index_qn;
block_index_qd = other.block_index_qd;
block_index_qi = other.block_index_qi;
block_id_by_qn_str = other.block_id_by_qn_str;
_initted = other._initted;
}
return *this;
}
template qtensor<double>& qtensor<double>::operator=(const qtensor<double> &other);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator=(const qtensor< std::complex<double> > &other);
template <typename T>
qtensor<T>& qtensor<T>::operator=(qtensor<T>&& other){
if(this!=&other){
clearBlock();
rank = other.rank;
idx_set = std::move(other.idx_set);
_block = std::move(other._block);
block_index_qn = std::move(other.block_index_qn);
block_index_qd = std::move(other.block_index_qd);
block_index_qi = std::move(other.block_index_qi);
block_id_by_qn_str = std::move(other.block_id_by_qn_str);
_initted = other._initted;
}
return *this;
}
template qtensor<double>& qtensor<double>::operator=(qtensor<double>&& other);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator=(qtensor< std::complex<double> >&& other);
template <typename T>
qtensor<T> qtensor<T>::operator * (qtensor<T>& other){
assert(_initted || other._initted);
if( _initted && !other._initted ){
qtensor<T> res(*this);
return res;
}
if( other._initted && !_initted ){
qtensor<T> res(other);
return res;
}
//copy
//qtensor<T> A(*this);
//qtensor<T> B(other);
vector<qtensor_index> A_idx_set = idx_set;
vector<qtensor_index> B_idx_set = other.idx_set;
// mark repeated indices
unordered_map<string,int> index_marker;
vector< pair<unsigned,unsigned> > idx_pair;
for (size_t i = 0; i < rank; i++) {
index_marker[A_idx_set[i].tag()] = i;
}
for (size_t i = 0; i < other.rank; i++) {
qtensor_index tp = B_idx_set[i];
tp.dag();
if(index_marker.find(tp.tag()) == index_marker.end()){
index_marker[B_idx_set[i].tag()] = i;
}else{
idx_pair.push_back( std::make_pair(unsigned(index_marker[tp.tag()]), i) );
index_marker[tp.tag()] = -1;
index_marker[B_idx_set[i].tag()] = -1;
}
}
// permute
uint_vec A_perm;
uint_vec B_perm;
for (size_t i = 0; i < rank; i++) {
if (index_marker[A_idx_set[i].tag()] != -1){
A_perm.push_back(i);
}
}
for (size_t i = 0; i < idx_pair.size(); i++) {
A_perm.push_back(idx_pair[i].first);
B_perm.push_back(idx_pair[i].second);
}
for (size_t i = 0; i < other.rank; i++) {
if (index_marker[B_idx_set[i].tag()] != -1){
B_perm.push_back(i);
}
}
//A.permute(A_perm);
//B.permute(B_perm);
//permute by hand
for (size_t i = 0; i < rank; i++) {
A_idx_set[i] = idx_set[A_perm[i]];
}
for (size_t i = 0; i < other.rank; i++) {
B_idx_set[i] = other.idx_set[B_perm[i]];
}
unordered_map< string, unsigned > A_block_id_by_qn_str;
unordered_map< string, unsigned > B_block_id_by_qn_str;
for(size_t i=0;i<_block.size();i++){
string A_qn_str;
for (size_t j = 0; j < rank; j++) {
A_qn_str += (to_string(block_index_qn[i][A_perm[j]])+" ");
}
A_block_id_by_qn_str[A_qn_str] = i;
}
for(size_t i=0;i<other._block.size();i++){
string B_qn_str;
for (size_t j = 0; j < other.rank; j++) {
B_qn_str += (to_string(other.block_index_qn[i][B_perm[j]])+" ");
}
B_block_id_by_qn_str[B_qn_str] = i;
}
// number of repeated indices
unsigned num_rep = idx_pair.size();
// set up new qtensor_index
vector<qtensor_index> res_index_set;
for (size_t i = 0; i < rank-num_rep; i++) {
res_index_set.push_back(A_idx_set[i]);
}
for (size_t i = num_rep; i < other.rank; i++) {
res_index_set.push_back(B_idx_set[i]);
}
qtensor<T> res(res_index_set);
res._initted = true;
// get blocks info
set<QN_t> mid_QN_set;
unordered_map< QN_t, set<uint_vec> > left_index_qi;
unordered_map< QN_t, set<uint_vec> > mid_index_qi;
unordered_map< QN_t, set<uint_vec> > right_index_qi;
for (size_t i = 0; i < _block.size(); i++) {
QN_t mid_QN = 0;
uint_vec left_qi;
for (size_t j = 0; j < rank-num_rep; j++) {
left_qi.push_back(block_index_qi[i][A_perm[j]]);
if(A_idx_set[j].arrow()==Inward){
mid_QN += block_index_qn[i][A_perm[j]];
}else{
mid_QN -= block_index_qn[i][A_perm[j]];
}
}
mid_QN_set.insert(mid_QN);
left_index_qi[mid_QN].insert(left_qi);
}
for (size_t i = 0; i < other._block.size(); i++) {
QN_t mid_QN = 0;
uint_vec right_qi;
for (size_t j = num_rep; j < other.rank; j++) {
right_qi.push_back(other.block_index_qi[i][B_perm[j]]);
if(B_idx_set[j].arrow()==Inward){
mid_QN -= other.block_index_qn[i][B_perm[j]];
}else{
mid_QN += other.block_index_qn[i][B_perm[j]];
}
}
uint_vec mid_qi;
for (size_t j = 0; j < num_rep; j++) {
mid_qi.push_back(other.block_index_qi[i][B_perm[j]]);
}
right_index_qi[mid_QN].insert(right_qi);
mid_index_qi[mid_QN].insert(mid_qi);
}
unordered_map<string,char> charMap;
string indA_L = getIndices(charMap);
string indB_R = other.getIndices(charMap);
string indC = res.getIndices(charMap);
// merge blocks
for (auto i1 = mid_QN_set.begin(); i1 != mid_QN_set.end(); ++i1){
auto q = *i1;
const set<uint_vec>& left_qi_set = left_index_qi[q];
const set<uint_vec>& right_qi_set = right_index_qi[q];
const set<uint_vec>& mid_qi_set = mid_index_qi[q];
for (auto i2 = right_qi_set.begin(); i2 != right_qi_set.end(); ++i2){
const uint_vec& right_qi = *i2;
for (auto i3 = left_qi_set.begin(); i3 != left_qi_set.end(); ++i3){
const uint_vec& left_qi = *i3;
uint_vec res_block_index_qi;
int_vec res_block_index_qd;
qn_vec res_block_index_qn;
unsigned res_block_size = 1;
string res_qn_str;
qn_vec A_block_qn(rank);
qn_vec B_block_qn(other.rank);
int M=1,N=1;
for (size_t i = 0; i < left_qi.size(); i++) {
res_block_index_qi.push_back(left_qi[i]);
res_block_index_qd.push_back(A_idx_set[i].qdim(left_qi[i]));
res_block_index_qn.push_back(A_idx_set[i].qn(left_qi[i]));
res_block_size *= res_block_index_qd.back();
res_qn_str += (to_string(res_block_index_qn.back())+" ");
A_block_qn[i] = res_block_index_qn.back();
M *= res_block_index_qd.back();
}
for (size_t i = 0; i < right_qi.size(); i++) {
res_block_index_qi.push_back(right_qi[i]);
res_block_index_qd.push_back(B_idx_set[num_rep+i].qdim(right_qi[i]));
res_block_index_qn.push_back(B_idx_set[num_rep+i].qn(right_qi[i]));
res_block_size *= res_block_index_qd.back();
res_qn_str += (to_string(res_block_index_qn.back())+" ");
B_block_qn[num_rep+i] = res_block_index_qn.back();
N *= res_block_index_qd.back();
}
// std::cout << "\n" << '\n';
//res.block.emplace_back(res_block_size);
res._block.emplace_back(res_index_set.size(),res_block_index_qd.data());
res.block_index_qn.push_back(res_block_index_qn);
res.block_index_qd.push_back(res_block_index_qd);
res.block_index_qi.push_back(res_block_index_qi);
res.block_id_by_qn_str[res_qn_str] = res._block.size()-1;
// sum over all blocks
for (auto i4 = mid_qi_set.begin(); i4 != mid_qi_set.end(); ++i4){
const auto& mid_qi = *i4;
qn_vec A_block_qn_complete(A_block_qn);
qn_vec B_block_qn_complete(B_block_qn);
string A_qn_str, B_qn_str;
int K=1;
for (size_t i = 0; i < num_rep; i++) {
A_block_qn_complete[i+rank-num_rep] = A_idx_set[i+rank-num_rep].qn(mid_qi[i]);
B_block_qn_complete[i] = B_idx_set[i].qn(mid_qi[i]);
K *= B_idx_set[i].qdim(mid_qi[i]);
}
for (size_t i = 0; i < rank; i++) {
A_qn_str += (to_string(A_block_qn_complete[i])+" ");
}
for (size_t i = 0; i < other.rank; i++) {
B_qn_str += (to_string(B_block_qn_complete[i])+" ");
}
auto Ait = A_block_id_by_qn_str.find(A_qn_str);
auto Bit = B_block_id_by_qn_str.find(B_qn_str);
if(Ait!=A_block_id_by_qn_str.end() && Bit!=B_block_id_by_qn_str.end()){
//Do C = A_L*B_R
auto& C = res._block.back();
auto A_L = _block[Ait->second][indA_L.c_str()];
auto B_R = other._block[Bit->second][indB_R.c_str()];
C[indC.c_str()] += A_L*B_R;
}
}
}
}
}
for(size_t ii=0;ii<res._block.size();ii++){
for(unsigned l=0;l<res.rank;l++){
assert(res._block[ii].lens[l]==res.block_index_qd[ii][l]);
}
}
return res;
}
template qtensor<double> qtensor<double>::operator * (qtensor<double>& other);
template qtensor< std::complex<double> > qtensor< std::complex<double> >::operator * (qtensor< std::complex<double> >& other);
#if !defined(USE_HPTT)
template <typename T>
qtensor<T> qtensor<T>::operator + (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// copy
qtensor<T> res = A;
// permute
uint_vec perm;
find_index_permutation(res.idx_set, idx_set, perm);
res.permute(perm);
// add
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
#pragma omp parallel for default(shared)
for (size_t i = 0; i < block.size(); i++) {
string res_qn_str;
for (size_t j = 0; j < rank; j++) {
res_qn_str += (to_string(res.block_index_qn[i][j])+" ");
}
unsigned idx = res.block_id_by_qn_str[res_qn_str];
// iterate over all elements
for (size_t k = 0; k < block[i].size(); k++) {
res.block[idx][k] += block[i][k];
}
}
return res;
}
#else
template <typename T>
qtensor<T> qtensor<T>::operator + (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// copy
qtensor<T> res(*this);
// find permutation
uint_vec perm;
find_index_permutation(A.idx_set, res.idx_set, perm);
// add
T alpha = 1;
T beta = 1;
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
for (size_t i = 0; i < A.block.size(); i++) {
string res_qn_str;
int_vec idx_sizes(rank);
for (size_t j = 0; j < rank; j++) {
res_qn_str += (to_string(A.block_index_qn[i][perm[j]])+" ");
idx_sizes[j] = A.block_index_qd[i][j];
}
unsigned res_idx = res.block_id_by_qn_str[res_qn_str];
/*auto plan = hptt::create_plan(
(int *)perm.data(), rank,
alpha, A.block[i].data(), idx_sizes.data(), NULL,
beta, res.block[res_idx].data(), NULL,
hptt::ESTIMATE,numThreads);
plan->execute();*/
}
return res;
}
#endif
template qtensor<double> qtensor<double>::operator + (qtensor<double>& A);
template qtensor< std::complex<double> > qtensor< std::complex<double> >::operator + (qtensor< std::complex<double> >& A);
#if !defined(USE_HPTT)
template <typename T>
qtensor<T> qtensor<T>::operator - (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// copy
qtensor<T> res = A;
// permute
uint_vec perm;
find_index_permutation(res.idx_set, idx_set, perm);
res.permute(perm);
// add
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
#pragma omp parallel for default(shared)
for (size_t i = 0; i < block.size(); i++) {
string res_qn_str;
for (size_t j = 0; j < rank; j++) {
res_qn_str += (to_string(res.block_index_qn[i][j])+" ");
}
unsigned idx = res.block_id_by_qn_str[res_qn_str];
// iterate over all elements
for (size_t k = 0; k < block[i].size(); k++) {
res.block[idx][k] = block[i][k] - res.block[idx][k];
}
}
return res;
}
#else
template <typename T>
qtensor<T> qtensor<T>::operator - (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// copy
qtensor<T> res(*this);
// find permutation
uint_vec perm;
find_index_permutation(A.idx_set, res.idx_set, perm);
// add
T alpha = -1;
T beta = 1;
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
for (size_t i = 0; i < A.block.size(); i++) {
string res_qn_str;
int_vec idx_sizes(rank);
for (size_t j = 0; j < rank; j++) {
res_qn_str += (to_string(A.block_index_qn[i][perm[j]])+" ");
idx_sizes[j] = A.block_index_qd[i][j];
}
unsigned res_idx = res.block_id_by_qn_str[res_qn_str];
/*auto plan = hptt::create_plan(
(int *)perm.data(), rank,
alpha, A.block[i].data(), idx_sizes.data(), NULL,
beta, res.block[res_idx].data(), NULL,
hptt::ESTIMATE,numThreads);
plan->execute();*/
}
return res;
}
#endif
template qtensor<double> qtensor<double>::operator - (qtensor<double>& A);
template qtensor< std::complex<double> > qtensor< std::complex<double> >::operator - (qtensor< std::complex<double> >& A);
#if !defined(USE_HPTT)
template <typename T>
qtensor<T>& qtensor<T>::operator += (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// permute
uint_vec perm;
find_index_permutation(A.idx_set, idx_set, perm);
A.permute(perm);
// add
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
#pragma omp parallel for default(shared)
for (size_t i = 0; i < block.size(); i++) {
string A_qn_str;
for (size_t j = 0; j < rank; j++) {
A_qn_str += (to_string(A.block_index_qn[i][j])+" ");
}
unsigned idx = A.block_id_by_qn_str[A_qn_str];
// iterate over all elements
for (size_t k = 0; k < block[i].size(); k++) {
block[i][k] += A.block[idx][k];
}
}
return *this;
}
#else
template <typename T>
qtensor<T>& qtensor<T>::operator += (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// find permutation
uint_vec perm;
find_index_permutation(A.idx_set, idx_set, perm);
// add
T alpha = 1;
T beta = 1;
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
for (size_t i = 0; i < A.block.size(); i++) {
string qn_str;
int_vec idx_sizes(rank);
for (size_t j = 0; j < rank; j++) {
qn_str += (to_string(A.block_index_qn[i][perm[j]])+" ");
idx_sizes[j] = A.block_index_qd[i][j];
}
unsigned idx = block_id_by_qn_str[qn_str];
/*auto plan = hptt::create_plan(
(int *)perm.data(), rank,
alpha, A.block[i].data(), idx_sizes.data(), NULL,
beta, block[idx].data(), NULL,
hptt::ESTIMATE,numThreads);
plan->execute();*/
}
return *this;
}
#endif
template qtensor<double>& qtensor<double>::operator += (qtensor<double>& A);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator += (qtensor< std::complex<double> >& A);
#if !defined(USE_HPTT)
template <typename T>
qtensor<T>& qtensor<T>::operator -= (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// permute
uint_vec perm;
find_index_permutation(A.idx_set, idx_set, perm);
A.permute(perm);
// add
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
#pragma omp parallel for default(shared)
for (size_t i = 0; i < block.size(); i++) {
string A_qn_str;
for (size_t j = 0; j < rank; j++) {
A_qn_str += (to_string(A.block_index_qn[i][j])+" ");
}
unsigned idx = A.block_id_by_qn_str[A_qn_str];
// iterate over all elements
for (size_t k = 0; k < block[i].size(); k++) {
block[i][k] -= A.block[idx][k];
}
}
return *this;
}
#else
template <typename T>
qtensor<T>& qtensor<T>::operator -= (qtensor<T>& A){
assert(1==2);
assert(_initted && A._initted);
assert(rank==A.rank);
// find permutation
uint_vec perm;
find_index_permutation(A.idx_set, idx_set, perm);
// add
T alpha = -1;
T beta = 1;
char* p = std::getenv("OMP_NUM_THREADS");
int numThreads = 1;
if(p){
numThreads = atoi(p);
}
omp_set_num_threads(numThreads);
for (size_t i = 0; i < A.block.size(); i++) {
string qn_str;
int_vec idx_sizes(rank);
for (size_t j = 0; j < rank; j++) {
qn_str += (to_string(A.block_index_qn[i][perm[j]])+" ");
idx_sizes[j] = A.block_index_qd[i][j];
}
unsigned idx = block_id_by_qn_str[qn_str];
/*auto plan = hptt::create_plan(
(int *)perm.data(), rank,
alpha, A.block[i].data(), idx_sizes.data(), NULL,
beta, block[idx].data(), NULL,
hptt::ESTIMATE,numThreads);
plan->execute();*/
}
return *this;
}
#endif
template qtensor<double>& qtensor<double>::operator -= (qtensor<double>& A);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator -= (qtensor< std::complex<double> >& A);
template <typename T>
qtensor<T>& qtensor<T>::operator *= (const T c){
assert(_initted);
CTF::Scalar<T> cs(c);
auto ind = getIndices();
for (size_t i = 0; i < _block.size(); i++) {
_block[i][ind.c_str()]*=cs[""];
}
return *this;
}
template qtensor<double>& qtensor<double>::operator*=(const double c);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator*=(const std::complex<double> c);
template <typename T>
qtensor<T>& qtensor<T>::operator /= (const T c){
assert(_initted);
auto invC = 1./c;
CTF::Scalar<T> cs(invC);
string indA = getIndices();
for (size_t i = 0; i < _block.size(); i++) {
_block[i][indA.c_str()]*=cs[""];
}
return *this;
}
template qtensor<double>& qtensor<double>::operator/=(const double c);
template qtensor< std::complex<double> >& qtensor< std::complex<double> >::operator/=(const std::complex<double> c);
template <typename T>
qtensor<T> qtensor<T>::operator*(const T c){
assert(1==2);
assert(_initted);
qtensor A(*this);
for (size_t i = 0; i < A.block.size(); i++) {
for (size_t j = 0; j < A.block[i].size(); j++) {
A.block[i][j] *= c;
}
}
return A;
}
template qtensor<double> qtensor<double>::operator*(const double c);
template qtensor< std::complex<double> > qtensor< std::complex<double> >::operator*(const std::complex<double> c);
template <typename T>
qtensor<T> qtensor<T>::operator/(const T c){
assert(1==2);
assert(_initted);
qtensor A(*this);
for (size_t i = 0; i < A.block.size(); i++) {
for (size_t j = 0; j < A.block[i].size(); j++) {
A.block[i][j] *= c;
}
}
return A;
}
template qtensor<double> qtensor<double>::operator/(const double c);
template qtensor< std::complex<double> > qtensor< std::complex<double> >::operator/(const std::complex<double> c);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Contract to scalar
template <typename T>
T qtensor<T>::contract(qtensor<T>& A){
assert(_initted && A._initted);
assert(rank>0 && A.rank>0);
uint_vec perm;
//qtensor<T> B(A); B.dag();
vector<qtensor_index> A_idx_set = A.idx_set;
for(unsigned i=0;i<A.rank;i++) A_idx_set[i].dag();
//find_index_permutation(A.idx_set, idx_set, perm);
//B.permute(perm);
T res = 0;
unordered_map<string,char> charMap;
string ind = getIndices(charMap);
string indA = indicesToChar(A_idx_set,charMap);//B.getIndices(charMap);
for(auto it = block_id_by_qn_str.begin(); it != block_id_by_qn_str.end(); ++it){
string qn_str = it->first;
unsigned this_idx = it->second;
auto A_it = A.block_id_by_qn_str.find(qn_str);
if(A_it == A.block_id_by_qn_str.end()) continue;
unsigned A_idx = A_it->second;
res += _block[this_idx][ind.c_str()]*A._block[A_idx][indA.c_str()];
}
return res;
}
template double qtensor<double>::contract(qtensor<double>& A);
template std::complex<double> qtensor< std::complex<double> >::contract(qtensor< std::complex<double> >& A);
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------
// special arithmetic operations with another tensor in the format/pattern
template <typename T>
void qtensor<T>::add(qtensor<T>& A, T c){
assert(A._initted && _initted);
assert(A.rank == rank);
unordered_map<string,char> charMap;
auto ind = getIndices(charMap);
auto indA = A.getIndices(charMap);
CTF::Scalar<T> cs(c);
for (auto i = A.block_id_by_qn_str.begin(); i != A.block_id_by_qn_str.end(); ++i){
string qn_str = i->first;
unsigned A_id = i->second;
auto it = block_id_by_qn_str.find(qn_str);
if(it!=block_id_by_qn_str.end()){
unsigned t_id = it->second;
assert(A._block[A_id].get_tot_size(false) == _block[t_id].get_tot_size(false));
assert(A._block[A_id].order == _block[t_id].order);
_block[t_id][ind.c_str()] += cs[""]*A._block[A_id][indA.c_str()];
}
else{
block_index_qn.push_back(A.block_index_qn[A_id]);
block_index_qd.push_back(A.block_index_qd[A_id]);
block_index_qi.push_back(A.block_index_qi[A_id]);
CTF::Tensor<T> aBlock(rank,A.block_index_qd[A_id].data());
aBlock[ind.c_str()] = cs[""]*A._block[A_id][indA.c_str()];
_block.push_back(std::move(aBlock));
block_id_by_qn_str[qn_str] = _block.size()-1;
}
}
}
template void qtensor<double>::add(qtensor<double>& A, double c);
template void qtensor< std::complex<double> >::add(qtensor< std::complex<double> >& A, std::complex<double> c);
template <typename T>
T qtensor<T>::inner_product(qtensor<T>& A){
assert(A._initted && _initted);
assert(A.rank == rank);
unordered_map<string,char> charMap;
auto ind = getIndices(charMap);
auto indA = A.getIndices(charMap);
T res = 0;
for (auto i = block_id_by_qn_str.begin(); i != block_id_by_qn_str.end(); ++i){
string qn_str = i->first;
unsigned t_id = i->second;
if(A.block_id_by_qn_str.find(qn_str)!=A.block_id_by_qn_str.end()){
unsigned A_id = A.block_id_by_qn_str.at(qn_str);
assert(A._block[A_id].get_tot_size(false) == _block[t_id].get_tot_size(false));
res += CTF::Function<double,T,T>([](T l, T r){ return std::real(cconj(l)*r);})(_block[t_id][ind.c_str()],A._block[A_id][indA.c_str()]);
}
}
return res;
}
template double qtensor<double>::inner_product(qtensor<double>& A);
template std::complex<double> qtensor< std::complex<double> >::inner_product(qtensor< std::complex<double> >& A);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Get diagonal subtensor
// e.g. For a qtensor with index (i1, i1p, i2, i2p), assume
// (i1, i1p) cancel each other's quantum number, and
// (i2, i2p) cancel each other's quantum number.
// Then the diagonal is then made by only two index (i1, i2).
// But this only makes sense if i1 is able to cancel i2 as well.
// So not every qtensor with paired indices can have a sensible
// diagonal subtensor.
template <typename T>
qtensor<T> qtensor<T>::diagonal(){
assert(_initted && rank>1);
assert(rank%2==0);
vector<qtensor_index> new_idx_set;
vector< std::pair<int,int> > idx_pair;
uint_vec left_index;
uint_vec right_index;
for (size_t i = 0; i < rank; i++) {
for (size_t j = i+1; j < rank; j++) {
if(idx_set[i].similar(idx_set[j])){
if(idx_set[i].level() < idx_set[j].level()){
new_idx_set.push_back(idx_set[i]);
left_index.push_back(i);
right_index.push_back(j);
idx_pair.push_back(std::make_pair(i,j));
}else{
new_idx_set.push_back(idx_set[j]);
left_index.push_back(j);
right_index.push_back(i);
idx_pair.push_back(std::make_pair(j,i));
}
break;
}
}
}
assert(2*new_idx_set.size()==rank);
// Set up new qtensor
qtensor<T> res(new_idx_set);
res._initted = true;
unordered_map<string,char> charMap;
auto indNew = indicesToCharNP(new_idx_set,charMap);
auto indOrig = indicesToCharNP(idx_set,charMap);
// extract diagonal blocks
for (size_t i = 0; i < _block.size(); i++) {
uint_vec t_stride;
t_stride.push_back(1);
for (size_t j = 0; j < rank; j++) {
t_stride.push_back(block_index_qd[i][j] * t_stride[j]);
}
uint_vec left_qi;
bool is_diag_block = true;
for (size_t j = 0; j < left_index.size(); j++) {
if(block_index_qi[i][left_index[j]] != block_index_qi[i][right_index[j]]){
is_diag_block = false;
break;
}else{
left_qi.push_back(block_index_qi[i][left_index[j]]);
}
}
if(is_diag_block){
const uint_vec& res_block_index_qi = left_qi;
int_vec res_block_index_qd;
qn_vec res_block_index_qn;
unsigned res_block_size = 1;
string res_qn_str;
for (size_t j = 0; j < left_index.size(); j++) {
res_block_index_qn.push_back(block_index_qn[i][left_index[j]]);
res_block_index_qd.push_back(block_index_qd[i][left_index[j]]);
res_block_size *= res_block_index_qd.back();
res_qn_str += (to_string(res_block_index_qn.back())+" ");
}
res._block.emplace_back(res_block_index_qd.size(),res_block_index_qd.data());
res.block_index_qn.push_back(res_block_index_qn);
res.block_index_qd.push_back(res_block_index_qd);
res.block_index_qi.push_back(res_block_index_qi);
res.block_id_by_qn_str[res_qn_str] = res._block.size()-1;
// copy values
uint_vec stride;
stride.push_back(1);
for (size_t j = 0; j < res.rank; j++) {
stride.push_back(res_block_index_qd[j] * stride[j]);
}
res._block.back()[indNew.c_str()] = _block[i][indOrig.c_str()];
}
}
return res;
}
template qtensor<double> qtensor<double>::diagonal();
template qtensor< std::complex<double> > qtensor< std::complex<double> >::diagonal();
//---------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Print Info
template <typename T>
void qtensor<T>::print(unsigned print_level){
pout<<"-------------------------------------"<<'\n';
pout<<"(1) Tensor's rank = "<<rank<<'\n';
pout<<"(2) Tensor's index (arrow, name, type, prime level), {(qn, qdim)}"<<'\n';
for (size_t i = 0; i < rank; i++) {
pout << " ";
if(idx_set[i].arrow()==Inward){
pout<<"(Inward"<<", ";
}else{
pout<<"(Outward"<<", ";
}
pout<<idx_set[i].name()<<", ";
if(idx_set[i].type()==Link){
pout<<"Link"<<", ";
}else{
pout<<"Site"<<", ";
}
pout<<idx_set[i].level()<<")"<<", {";
for (size_t j = 0; j < idx_set[i].size(); j++) {
pout << "(" << idx_set[i].qn(j) << ", " << idx_set[i].qdim(j) << ") ";
}
pout << "}" << '\n';
}
if (print_level>0) {
pout<<"(3) Number of legal QN block = "<<_block.size()<<'\n';
pout<<"(4) QN block"<<'\n';
for (size_t i = 0; i < _block.size(); i++){
uint_vec v = block_index_qi[i];
pout<<"Block "<<i<<" indices: ";
for (size_t j = 0; j < rank; j++) {
pout<<"(";
if(idx_set[j].arrow()==Inward){
pout<<"Inward"<<", qn=";
}else{
pout<<"Outward"<<", qn=";
}
pout<<block_index_qn[i][j]<<", qdim="<<block_index_qd[i][j]<<")"<<" ";
}
pout << "size = " << _block[i].get_tot_size(false) << '\n';
if(print_level>1){
/*for (size_t j = 0; j < block[i].size(); j++) {
pout<<block[i][j]<<" ";
}*/
_block[i].print();
pout<<'\n';
}
}
}
pout << "-------------------------------------" << '\n';
}
template void qtensor<double>::print(unsigned print_level);
template void qtensor< std::complex<double> >::print(unsigned print_level);
//-----------------------------------------------------------------------------
// Save/Load
template <typename T>
void qtensor<T>::save(string fn){
assert(1==2);
assert(_initted);
uint_vec idx_arrows;
str_vec idx_names;
uint_vec idx_types;
uint_vec idx_levels;
vector<qn_vec> idx_qn(rank);
vector<int_vec> idx_qdim(rank);
for (size_t i = 0; i < rank; i++) {
idx_arrows.push_back(idx_set[i].arrow());
idx_names.push_back(idx_set[i].name());
idx_types.push_back(idx_set[i].type());
idx_levels.push_back(idx_set[i].level());
for (size_t j = 0; j < idx_set[i].size(); j++) {
idx_qn[i].push_back(idx_set[i].qn(j));
idx_qdim[i].push_back(idx_set[i].qdim(j));
}
}
ezh5::File fh5W (fn, H5F_ACC_TRUNC);
fh5W["num_blocks"] = block.size();
fh5W["rank"] = rank;
fh5W["idx_arrows"] = idx_arrows;
fh5W["idx_types"] = idx_types;
fh5W["idx_levels"] = idx_levels;
for (size_t i = 0; i < rank; i++) {
fh5W["idx_qn_"+to_string(i)] = idx_qn[i];
fh5W["idx_qdim_"+to_string(i)] = idx_qdim[i];
}
for (size_t i = 0; i < rank; i++) {
std::vector<char> vec(idx_names[i].begin(),idx_names[i].end());
fh5W["idx_name_"+std::to_string(i)] = vec;
}
for (size_t i = 0; i < block.size(); i++) {
fh5W["block_"+to_string(i)] = block[i];
fh5W["block_"+to_string(i)+"_qi"] = block_index_qi[i];
}
}
template void qtensor<double>::save(string fn);
template void qtensor< std::complex<double> >::save(string fn);
template <typename T>
void qtensor<T>::save(ezh5::Node& fh5W){
assert(_initted);
uint_vec idx_arrows;
str_vec idx_names;
uint_vec idx_types;
uint_vec idx_levels;
vector<qn_vec> idx_qn(rank);
vector<int_vec> idx_qdim(rank);
for (size_t i = 0; i < rank; i++) {
idx_arrows.push_back(idx_set[i].arrow());
idx_names.push_back(idx_set[i].name());
idx_types.push_back(idx_set[i].type());
idx_levels.push_back(idx_set[i].level());
for (size_t j = 0; j < idx_set[i].size(); j++) {
idx_qn[i].push_back(idx_set[i].qn(j));
idx_qdim[i].push_back(idx_set[i].qdim(j));
}
}
fh5W["num_blocks"] = _block.size();
fh5W["rank"] = rank;
fh5W["idx_arrows"] = idx_arrows;
fh5W["idx_types"] = idx_types;
fh5W["idx_levels"] = idx_levels;
for (size_t i = 0; i < rank; i++) {
fh5W["idx_qn_"+to_string(i)] = idx_qn[i];
fh5W["idx_qdim_"+to_string(i)] = idx_qdim[i];
}
for (size_t i = 0; i < rank; i++) {
std::vector<char> vec(idx_names[i].begin(),idx_names[i].end());
fh5W["idx_name_"+std::to_string(i)] = vec;
}
for (size_t i = 0; i < _block.size(); i++) {
fh5W["block_"+to_string(i)+"_qi"] = block_index_qi[i];
}
//save blocks externally
}
template void qtensor<double>::save(ezh5::Node& fW);
template void qtensor< std::complex<double> >::save(ezh5::Node& fW);
template <typename T>
void qtensor<T>::load(string fn){
assert(1==2);
uint_vec idx_arrows_int;
arr_vec idx_arrows;
str_vec idx_names;
uint_vec idx_types_int;
typ_vec idx_types;
uint_vec idx_levels;
unsigned num_blocks;
ezh5::File fh5R (fn, H5F_ACC_RDONLY);
fh5R["num_blocks"] >> num_blocks;
fh5R["rank"] >> rank;
fh5R["idx_arrows"] >> idx_arrows_int;
fh5R["idx_types"] >> idx_types_int;
fh5R["idx_levels"] >> idx_levels;
idx_set.clear();
for (size_t i = 0; i < rank; i++) {
std::vector<char> vec;
fh5R["idx_name_"+to_string(i)] >> vec;
string s = string(vec.begin(),vec.end());
idx_names.push_back(s);
idx_arrows.push_back(arrow_type(idx_arrows_int[i]));
idx_types.push_back(index_type(idx_types_int[i]));
idx_set.push_back(qtensor_index(idx_arrows[i],idx_names[i],idx_types[i],idx_levels[i]));
qn_vec idx_qn;
uint_vec idx_qdim;
fh5R["idx_qn_"+to_string(i)] >> idx_qn;
fh5R["idx_qdim_"+to_string(i)] >> idx_qdim;
idx_set[i].addQN(idx_qn, idx_qdim);
}
qtensor<T> A(idx_set);
A._initted = true;
for (size_t i = 0; i < num_blocks; i++) {
uint_vec qi_vec;
int_vec qd_vec;
qn_vec vec_qn;
string qn_str;
fh5R["block_"+to_string(i)+"_qi"] >> qi_vec;
for (size_t j = 0; j < rank; j++) {
vec_qn.push_back(idx_set[j].qn(qi_vec[j]));
qd_vec.push_back(idx_set[j].qdim(qi_vec[j]));
qn_str += (to_string(vec_qn.back())+" ");
}
A.block.push_back(vector<T>(1));
A.block_index_qi.push_back(qi_vec);
A.block_index_qd.push_back(qd_vec);
A.block_index_qn.push_back(vec_qn);
A.block_id_by_qn_str[qn_str] = i;
fh5R["block_"+to_string(i)] >> A.block.back();
}
(*this) = A;
}
template void qtensor<double>::load(string fn);
template void qtensor< std::complex<double> >::load(string fn);
template <typename T>
void qtensor<T>::load(ezh5::Node& fh5R){
uint_vec idx_arrows_int;
arr_vec idx_arrows;
str_vec idx_names;
uint_vec idx_types_int;
typ_vec idx_types;
uint_vec idx_levels;
unsigned num_blocks;
fh5R["num_blocks"] >> num_blocks;
fh5R["rank"] >> rank;
fh5R["idx_arrows"] >> idx_arrows_int;
fh5R["idx_types"] >> idx_types_int;
fh5R["idx_levels"] >> idx_levels;
idx_set.clear();
for (size_t i = 0; i < rank; i++) {
std::vector<char> vec;
fh5R["idx_name_"+to_string(i)] >> vec;
string s = string(vec.begin(),vec.end());
idx_names.push_back(s);
idx_arrows.push_back(arrow_type(idx_arrows_int[i]));
idx_types.push_back(index_type(idx_types_int[i]));
idx_set.push_back(qtensor_index(idx_arrows[i],idx_names[i],idx_types[i],idx_levels[i]));
qn_vec idx_qn;
uint_vec idx_qdim;
fh5R["idx_qn_"+to_string(i)] >> idx_qn;
fh5R["idx_qdim_"+to_string(i)] >> idx_qdim;
idx_set[i].addQN(idx_qn, idx_qdim);
}
qtensor<T> A(idx_set);
A._initted = true;
for (size_t i = 0; i < num_blocks; i++) {
uint_vec qi_vec;
int_vec qd_vec;
qn_vec vec_qn;
string qn_str;
fh5R["block_"+to_string(i)+"_qi"] >> qi_vec;
for (size_t j = 0; j < rank; j++) {
vec_qn.push_back(idx_set[j].qn(qi_vec[j]));
qd_vec.push_back(idx_set[j].qdim(qi_vec[j]));
qn_str += (to_string(vec_qn.back())+" ");
}
//A.block.push_back(vector<T>(1));
A._block.emplace_back(rank,qd_vec.data());
A.block_index_qi.push_back(qi_vec);
A.block_index_qd.push_back(qd_vec);
A.block_index_qn.push_back(vec_qn);
A.block_id_by_qn_str[qn_str] = i;
//fh5R["block_"+to_string(i)] >> A.block.back();
}
(*this) = A;
}
template void qtensor<double>::load(ezh5::Node& fR);
template void qtensor< std::complex<double> >::load(ezh5::Node& fR);
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Prime level manipulation
template <typename T>
void qtensor<T>::prime(int inc){
for (size_t i = 0; i < rank; i++) {
idx_set[i].prime(inc);
}
}
template void qtensor<double>::prime(int inc);
template void qtensor< std::complex<double> >::prime(int inc);
template <typename T>
void qtensor<T>::primeLink(int inc){
for (size_t i = 0; i < rank; i++) {
idx_set[i].primeLink(inc);
}
}
template void qtensor<double>::primeLink(int inc);
template void qtensor< std::complex<double> >::primeLink(int inc);
template <typename T>
void qtensor<T>::primeSite(int inc){
for (size_t i = 0; i < rank; i++) {
idx_set[i].primeSite(inc);
}
}
template void qtensor<double>::primeSite(int inc);
template void qtensor< std::complex<double> >::primeSite(int inc);
template <typename T>
void qtensor<T>::mapPrime(unsigned from, unsigned to){
for (size_t i = 0; i < rank; i++) {
idx_set[i].mapPrime(from, to);
}
}
template void qtensor<double>::mapPrime(unsigned from, unsigned to);
template void qtensor< std::complex<double> >::mapPrime(unsigned from, unsigned to);
template <typename T>
void qtensor<T>::mapPrime(unsigned from, unsigned to, index_type type){
for (size_t i = 0; i < rank; i++) {
idx_set[i].mapPrime(from, to, type);
}
}
template void qtensor<double>::mapPrime(unsigned from, unsigned to, index_type type);
template void qtensor< std::complex<double> >::mapPrime(unsigned from, unsigned to, index_type type);
template <typename T>
void qtensor<T>::dag(){
for (size_t i = 0; i < rank; i++) {
idx_set[i].dag();
}
}
template void qtensor<double>::dag();
template void qtensor< std::complex<double> >::dag();
template <>
void qtensor<double>::conj(){}
template <>
void qtensor<std::complex<double> >::conj(){
auto ind = getIndices();
using cmplx = std::complex<double>;
for (size_t i = 0; i < _block.size(); i++) {
CTF::Transform<cmplx>([ind](cmplx & d){ d= std::conj(d); })(_block[i][ind.c_str()]);
}
}
//---------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Norm
template<> double qtensor<double>::norm(){
assert(_initted);
double res = 0.0;
for (size_t i = 0; i < _block.size(); i++) {
/*for (size_t j = 0; j < block[i].size(); j++) {
res += std::real(block[i][j]*std::conj(block[i][j]));
}*/
res += _block[i].reduce(CTF::OP_SUMSQ);
}
return std::sqrt(res);
}
//template double qtensor<double>::norm();
//template double qtensor< std::complex<double> >::norm();
template<> double qtensor<std::complex<double> >::norm(){
assert(_initted);
double res = 0.0;
string indthis = getIndices();
for (size_t i = 0; i < _block.size(); i++) {
/*for (size_t j = 0; j < block[i].size(); j++) {
res += std::real(block[i][j]*std::conj(block[i][j]));
}*/
using cmplx = std::complex<double>;
CTF::Scalar<double> tot;
auto A = _block[i][indthis.c_str()];
tot[""] += CTF::Function<double,cmplx,cmplx>([](cmplx l, cmplx r){ return std::real(cconj(l)*r);})(A,A);
res+= tot;
}
return std::sqrt(res);
}
template <typename T>
double qtensor<T>::normalize(){
assert(_initted);
double res = norm();
auto ind = getIndices();
for (size_t i = 0; i < _block.size(); i++) {
_block[i][ind.c_str()]*=(1./res);
}
return res;
}
template double qtensor<double>::normalize();
template double qtensor< std::complex<double> >::normalize();
//-----------------------------------------------------------------------------
// Index help
template <typename T>
string qtensor<T>::getIndices(){
char ch='a';
_indices = string(ch,rank);
for (unsigned i=0;i<rank;i++){ _indices[i]=ch++; }
return _indices;
}
template string qtensor<double>::getIndices();
template string qtensor<std::complex<double> >::getIndices();
template <typename T>
string qtensor<T>::getIndices(unordered_map<string,char> &charMap){
_indices = indicesToChar(idx_set,charMap);
return _indices;
}
template string qtensor<double>::getIndices(unordered_map<string,char> &charMap);
template string qtensor<std::complex<double> >::getIndices(unordered_map<string,char> &charMap);
//-----------------------------------------------------------------------------
#endif
| 32.45009
| 141
| 0.607895
|
ClarkResearchGroup
|
89e1274278a0bff99a3783c7779dbe8b65955b92
| 339
|
cpp
|
C++
|
src/Interface/Handling/JsonAPIResourceBuilder.cpp
|
korenandr/poco_restful_webservice
|
864b02fb0cd500c9c74fb2f6931c44ecd6f4d019
|
[
"Apache-2.0"
] | 1
|
2021-07-01T18:45:35.000Z
|
2021-07-01T18:45:35.000Z
|
src/Interface/Handling/JsonAPIResourceBuilder.cpp
|
korenandr/poco_restful_webservice
|
864b02fb0cd500c9c74fb2f6931c44ecd6f4d019
|
[
"Apache-2.0"
] | null | null | null |
src/Interface/Handling/JsonAPIResourceBuilder.cpp
|
korenandr/poco_restful_webservice
|
864b02fb0cd500c9c74fb2f6931c44ecd6f4d019
|
[
"Apache-2.0"
] | null | null | null |
#include "Interface/Handling/JsonAPIResourceBuilder.h"
namespace Interface::Handling {
JsonAPIResourceBuilder::JsonAPIResourceBuilder()
: JsonAPIAbstractRootResourceBuilder("")
{ }
JsonAPIResourceBuilder::JsonAPIResourceBuilder(const std::string & url)
: JsonAPIAbstractRootResourceBuilder(url)
{ }
}
| 21.1875
| 75
| 0.734513
|
korenandr
|
89e394cf4d0768c3326a5aa7ca1bf8345abddfc5
| 1,494
|
cpp
|
C++
|
src/client/sdl/drawables/drawable_text_entry_button.cpp
|
Santoi/quantum-chess
|
a2f5a0f322c6aa51488c52c8ebacbe0ad75ca9f9
|
[
"MIT"
] | 9
|
2021-12-22T02:10:34.000Z
|
2021-12-30T17:14:25.000Z
|
src/client/sdl/drawables/drawable_text_entry_button.cpp
|
Santoi/quantum-chess
|
a2f5a0f322c6aa51488c52c8ebacbe0ad75ca9f9
|
[
"MIT"
] | null | null | null |
src/client/sdl/drawables/drawable_text_entry_button.cpp
|
Santoi/quantum-chess
|
a2f5a0f322c6aa51488c52c8ebacbe0ad75ca9f9
|
[
"MIT"
] | null | null | null |
#include "drawable_text_entry_button.h"
#include <utility>
#include <string>
DrawableTextEntryButton::DrawableTextEntryButton(
TextSpriteRepository &text_repository,
ButtonSpriteRepository &button_repository,
std::string default_text) :
text_repository(text_repository),
button_repository(button_repository),
button_name(std::move(default_text)),
text_box(button_repository, text_repository, "text", ""),
text(text_repository, ""), is_pressed(false),
x(0), y(0), width(0),
height(0) {}
void DrawableTextEntryButton::setAreaAndPosition(int x_, int y_, int width_,
int height_) {
x = x_;
y = y_;
width = width_;
height = height_;
}
bool DrawableTextEntryButton::isPixelOnTextEntry(
const PixelCoordinate &pixel) {
is_pressed = (pixel.x() > x && pixel.x() < x + width &&
pixel.y() > y && pixel.y() < y + height);
return is_pressed;
}
void DrawableTextEntryButton::render(const std::string ¤t_text) {
is_pressed ? text_box.enablePressedStatus() : text_box.disablePressedStatus();
text_box.setAreaAndPosition(x, y, width, height);
text_box.render();
if (current_text.empty()) {
text.setColor('d');
text.setText(button_name);
} else {
text.setColor('w');
text.setText(current_text);
}
int text_x = x + width / 2 - text.getDrawableWidth() / 2;
int text_y = y + height / 2 - text.getDrawableHeight() / 2;
text.render(text_x, text_y);
}
| 31.125
| 80
| 0.668675
|
Santoi
|
89e7a7d2a32ad560b594975537a29bb715877bda
| 5,001
|
cpp
|
C++
|
srcdll/cdc.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
srcdll/cdc.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
srcdll/cdc.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
// 232usb Copyright (c) 03-04 Zoroyoshi, Japan
// See source.txt for detail
#include <windows.h>
#include "usbdi.h"
#include "common.h"
#include "file.h"
#include "device.h"
#include "cdc.h"
int cdc_extension::
classissue()
{
if(classut) return -1; //issued
int pkt= classendp->Descriptor.wMaxPacketSize&0x7ff;
classut= uf->lpIssueInterruptTransfer(classpipe, notifyevent, serialevent
, USB_IN_TRANSFER|USB_SHORT_TRANSFER_OK, pkt, classbuf, 0);
//zmesg(ZM_USB,L" classissue=x%x\n", classut);
if(classut==0) { //?error
zmesg(ZM_ERROR,L" classissue err=%d\n", GetLastError());
return 0;
};
return 1;
};
int cdc_extension::
classwait()
{
if(classut==0) return 0; //nothing queued
DWORD rc= ~0;
DWORD len= 0;
int rt= uf->lpIsTransferComplete(classut);
if(uf->lpGetTransferStatus(classut, &len, &rc)) {
if(rt==0) return 0; //waiting
uf->lpCloseTransfer(classut);
};
zmesg(ZM_USB,L" classwait=x%x len=%d\n", classut, len);
classut= 0;
if(rc!=0) { //?error
zmesg(ZM_ERROR,L" classwait=x%x rc=%d\n", classut, rc);
};
if(len==10&&classbuf[0]==0xa1&&classbuf[1]==0x20) { //SERIAL_STATE notify
DWORD state= classbuf[8]|classbuf[9]<<8;
DWORD err;
err= 0;
if(state&0x10) err|= CE_FRAME;
if(state&0x20) err|= CE_RXPARITY;
if(state&0x40) err|= CE_OVERRUN;
if(state&4) err|= CE_BREAK;
DWORD in;
in= state>>3&MS_CTS_ON|state<<4&MS_DSR_ON|state<<3&MS_RING_ON|state<<7&MS_RLSD_ON|state>>2&1;
if(!(usbmode&MODE_2303)) in|= MS_CTS_ON;
linestatein(in, err);
} else { //other ignored
};
return 1;
};
int cdc_extension::
dispatchdo()
{
int rt;
rt= device_extension::dispatchdo();
classwait();
classissue();
if(rt==0&&classut==0) return 0;
return 1;
};
BOOL cdc_extension::
init()
{
zmesg(ZM_DRIVER,L"cdc::init\n");
if(classendp==0||recvendp==0||sendendp==0) return FALSE;
if(device_extension::init()==0) return FALSE;
lineout= 0;
classut= 0;
classpipe= uf->lpOpenPipe(uh, &classendp->Descriptor);
USB_TRANSFER ut;
ut= uf->lpClearFeature(uh, 0, 0
, USB_SEND_TO_ENDPOINT, USB_FEATURE_ENDPOINT_STALL, classendp->Descriptor.bEndpointAddress);
if(ut) uf->lpCloseTransfer(ut);
USB_DEVICE_REQUEST req;
WORD abs;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_CLASS|USB_REQUEST_FOR_INTERFACE;
req.bRequest= 0x2; //SET_COMM_FEATURE
req.wValue= 1; req.wIndex= classif; req.wLength= sizeof(abs);
abs= 2; //enable multiplexing
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_INTERFACE|USB_OUT_TRANSFER
, &req, (BYTE*)&abs, 0);
if(ut) uf->lpCloseTransfer(ut);
return TRUE;
};
BOOL cdc_extension::
deinit()
{
uf->lpClosePipe(classpipe); classpipe= 0;
device_extension::deinit();
return TRUE;
};
USB_TRANSFER cdc_extension::
issuebreak(int code)
{
USB_TRANSFER ut;
USB_DEVICE_REQUEST req;
int duration= 0;
if(code) duration=0xffff;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_CLASS|USB_REQUEST_FOR_INTERFACE;
req.bRequest= 0x23; //SEND_BREAK;
req.wValue= duration; req.wIndex= classif; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_INTERFACE|USB_OUT_TRANSFER
, &req, 0, 0);
zmesg(ZM_USB,L" BREAK(x%x) ut=x%x\n", duration, ut);
if(ut) uf->lpCloseTransfer(ut);
return(0); //dummy
};
USB_TRANSFER cdc_extension::
issuelinestate(int nandcode, int orcode, HANDLE event)
{
USB_TRANSFER ut;
USB_DEVICE_REQUEST req;
HANDLE ev= event;
if(event==0) {
ev= CreateEvent(0, 0, 0, 0);
EnterCriticalSection(&flowcs);
};
lineout= lineout&~nandcode|orcode;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_CLASS|USB_REQUEST_FOR_INTERFACE;
req.bRequest= 0x22; //SET_CONTROL_LINE_STATE
req.wValue= (WORD)lineout; req.wIndex= classif; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, notifyevent, ev
, USB_SEND_TO_INTERFACE|USB_OUT_TRANSFER
, &req, 0, 0);
if(event==0) {
LeaveCriticalSection(&flowcs);
if(ut) {
WaitForSingleObject(ev, INFINITE);
uf->lpCloseTransfer(ut);
ut= 0;
};
CloseHandle(ev);
};
zmesg(ZM_USB,L" LINE_STATE(x%x) ut=x%x\n", lineout, ut);
return(ut);
};
BOOL cdc_extension::
applydcb()
{
device_extension::applydcb();
if(usbmode&MODE_NOBAUD) return TRUE;
USB_TRANSFER ut;
USB_DEVICE_REQUEST req;
BYTE buf[7];
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_CLASS|USB_REQUEST_FOR_INTERFACE;
req.bRequest= 0x20; //SET_LINE_CODING
req.wValue= 0; req.wIndex= classif; req.wLength= 7;
*(DWORD*)buf= dcb.BaudRate;
buf[4]= dcb.StopBits;
buf[5]= dcb.Parity;
buf[6]= dcb.ByteSize;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_INTERFACE|USB_OUT_TRANSFER
, &req, buf, 0);
zmesg(ZM_USB,L" APPLYDCB ut=x%x\n", ut);
if(ut) uf->lpCloseTransfer(ut);
return TRUE;
};
| 27.327869
| 98
| 0.667666
|
HPC-Factor
|
89e8aa346df247c24ff451f5559150e4d972bc32
| 8,291
|
hpp
|
C++
|
rgcmidcpp/src/binutils.hpp
|
mdsitton/rhythmChartFormat
|
1e53aaff34603bee258582293d11d29e0bf53bde
|
[
"BSD-2-Clause"
] | 8
|
2017-09-20T20:24:29.000Z
|
2019-08-10T22:55:13.000Z
|
rgcmidcpp/src/binutils.hpp
|
mdsitton/rhythmChartFormat
|
1e53aaff34603bee258582293d11d29e0bf53bde
|
[
"BSD-2-Clause"
] | null | null | null |
rgcmidcpp/src/binutils.hpp
|
mdsitton/rhythmChartFormat
|
1e53aaff34603bee258582293d11d29e0bf53bde
|
[
"BSD-2-Clause"
] | 1
|
2018-08-28T19:28:20.000Z
|
2018-08-28T19:28:20.000Z
|
// Copyright (c) 2015-2017 Matthew Sitton <matthewsitton@gmail.com>
// See LICENSE in the RhythmGameChart root for license information.
#pragma once
#include <cstdint>
#include <istream>
#include <ostream>
#include <vector>
#include <stdexcept>
#include <algorithm>
#include <string>
#include <string_view>
// This is an older version of the code used in openrhythm with backported
// bugfixes because it's a bit simpler to extend/understand. Way slower than
// my code in openrhythm.
// Read and write strings
// The data format here is <vlv length> <string data>
std::string read_string(std::istream &stream);
void write_string(std::ostream &stream, std::string_view str);
// Templates to read from a file different length values
template<typename T, bool swapEndian = true>
T read_type(std::istream &file)
{
T output;
constexpr auto size = sizeof(T);
int offset;
char readContainer[size];
file.read(&readContainer[0], size);
char* outPtr = reinterpret_cast<char*>(&output);
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = (size-1) - i; // endianness lol ?
}
else
{
offset = i;
}
*(outPtr+offset) = readContainer[i];
}
return output;
}
template<typename T, bool swapEndian = true>
T read_type(std::istream &file, size_t size)
{
T output = 0;
if (sizeof(output) < size)
{
throw std::runtime_error("Size greater than container type");
}
else
{
int offset;
char readContainer[size];
file.read(&readContainer[0], size);
char *outPtr = reinterpret_cast<char*>(&output);
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = (size-1) - i; // endianness lol ?
}
else
{
offset = i;
}
*(outPtr+offset) = readContainer[i];
}
}
return output;
}
template<typename T, bool swapEndian = true>
void read_type(std::istream &file, T *output, size_t length)
{
auto size = sizeof(T);
int offset;
for (size_t j = 0; j < length; j++)
{
char *outPtr = reinterpret_cast<char*>(output);
char readContainer[size];
file.read(&readContainer[0], size);
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = ((size-1) - i) + (size * j); // endianness lol ?
}
else
{
offset = i + (size * j);
}
*(outPtr+offset) = readContainer[i];
}
}
}
// We implement peek with read_type above to reduce code duplication.
template<typename T, bool swapEndian = true>
T peek_type(std::istream &file)
{
// We need to emulate a peek because we need several bytes of data.
std::streampos startingPos = file.tellg();
T output = read_type<T, swapEndian>(file);
file.seekg(startingPos);
return output;
}
template<typename T, bool swapEndian = true>
T peek_type(std::istream &file, size_t size)
{
// We need to emulate a peek because we need several bytes of data.
std::streampos startingPos = file.tellg();
T output = read_type<T, swapEndian>(file, size);
file.seekg(startingPos);
return output;
}
template<typename T, bool swapEndian = true>
void peek_type(std::istream &file, T *output, size_t length)
{
// We need to emulate a peek because we need several bytes of data.
std::streampos startingPos = file.tellg();
read_type<T, swapEndian>(file, output, length);
file.seekg(startingPos);
}
// write `source` to `file` in big endian
template<typename T, bool swapEndian = true>
void write_type(std::ostream &file, T source)
{
auto size = sizeof(T);
int offset;
T output;
char* sourcePtr = reinterpret_cast<char*>(&source);
char* outPtr = reinterpret_cast<char*>(&output);
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = (size-1) - i; // endianness lol ?
}
else
{
offset = i;
}
*(outPtr+i) = *(sourcePtr+offset);
}
file.write(outPtr, size);
}
// write only `size` bytes from `source` to `file` in big endian
template<typename T, bool swapEndian = true>
void write_type(std::ostream &file, T source, size_t size)
{
if (size > sizeof(T))
{
throw std::runtime_error("Size greater than container type");
}
else
{
int offset;
T output;
char* sourcePtr = reinterpret_cast<char*>(&source);
char* outPtr = reinterpret_cast<char*>(&output);
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = (size-1) - i; // endianness lol ?
}
else
{
offset = i;
}
*(outPtr+i) = *(sourcePtr+offset);
}
file.write(outPtr, size);
}
}
// Write `length` number of `T` from `source` in big endian
// Primarally used for writing strings.
template<typename T, bool swapEndian = true>
void write_type(std::ostream &file, const T *source, size_t length)
{
auto size = sizeof(T);
int offset;
T output;
char* sourcePtr = const_cast<char*>(source);
char* outPtr = reinterpret_cast<char*>(&output);
for (size_t j = 0; j < length; j++)
{
for (size_t i = 0; i < size; i++)
{
if (swapEndian)
{
offset = ((size-1) - i) + (size * j); // endianness lol ?
}
else
{
offset = i + (size * j);
}
*(outPtr+i) = *(sourcePtr+offset);
}
file.write(outPtr, size);
}
}
// Convert string to bytes for creation of things like BOM's
template<typename T, bool swapEndian = false>
T str_to_bin(std::string_view str)
{
T output = 0;
int offset = 0;
size_t size = sizeof(T);
if (size < str.length())
{
throw std::runtime_error("Size greater than container type");
}
for (size_t i = 0; i < str.length(); i++)
{
if (swapEndian)
{
offset = static_cast<int>((size-1) - i); // endianness lol ?
}
else
{
offset = i;
}
output |= str[offset] << ((size-1-i)*8);
}
return output;
}
// Read and write to VariableLengthValues
// This is an earlier varient of my varlen reading code I wrote for openrhythm w/ bugfixes.
// It is slower but supports reading and writing, and i'm lazy so here we go.
template<typename T>
T from_vlv(std::vector<uint8_t>& varLen)
{
T value = 0;
// Check that the size of the varlen fits into the max number of bytes we have available
if (varLen.size() > ((sizeof(T)*8)/7))
{
throw std::runtime_error("Variable Length Value to long for type!");
return 0;
}
// get the last element of the vector and verify that it doesnt
// have the contiuation bit set.
if (((* --varLen.end()) & 0x80) != 0)
{
throw std::runtime_error("Invalid Variable Length Value!");
}
for(auto &byte : varLen)
{
value = (value << 7) | (byte & 0x7F);
}
return value;
}
template<typename T>
std::vector<uint8_t> to_vlv(T value)
{
uint8_t scratch;
int byteCount = 0;
std::vector<uint8_t> output;
do {
scratch = value & 0x7F;
if (byteCount != 0 ) {
scratch |= 0x80;
}
output.push_back(scratch);
value >>= 7;
byteCount++;
} while(value != 0 && byteCount < ((sizeof(T)*8)/7));
std::reverse(output.begin(), output.end());
return output;
}
template<typename T>
T read_vlv(std::istream &stream)
{
std::vector<uint8_t> varLen;
uint8_t c;
do {
c = read_type<uint8_t>(stream);
varLen.push_back(c);
} while(c & 0x80 && varLen.size() < ((sizeof(T)*8)/7));
return from_vlv<T>(varLen);
}
template<typename T>
void write_vlv(std::ostream &stream, T value)
{
std::vector<uint8_t> varLen = to_vlv<T>(value);
stream.write(reinterpret_cast<char*>(&varLen[0]), sizeof(uint8_t)*varLen.size());
}
| 24.457227
| 92
| 0.569051
|
mdsitton
|
89e9eb41496407e950fa2e4dfa325f03fbd589ab
| 1,064
|
hpp
|
C++
|
test/mock/src/runtime/block_builder_api_mock.hpp
|
GeniusVentures/SuperGenius
|
ae43304f4a2475498ef56c971296175acb88d0ee
|
[
"MIT"
] | 1
|
2021-07-10T21:25:03.000Z
|
2021-07-10T21:25:03.000Z
|
test/mock/src/runtime/block_builder_api_mock.hpp
|
GeniusVentures/SuperGenius
|
ae43304f4a2475498ef56c971296175acb88d0ee
|
[
"MIT"
] | null | null | null |
test/mock/src/runtime/block_builder_api_mock.hpp
|
GeniusVentures/SuperGenius
|
ae43304f4a2475498ef56c971296175acb88d0ee
|
[
"MIT"
] | null | null | null |
#ifndef SUPERGENIUS_TEST_MOCK_SRC_RUNTIME_BLOCK_BUILDER_API_MOCK_HPP
#define SUPERGENIUS_TEST_MOCK_SRC_RUNTIME_BLOCK_BUILDER_API_MOCK_HPP
#include <gmock/gmock.h>
#include "runtime/block_builder.hpp"
namespace sgns::runtime {
class BlockBuilderApiMock : public BlockBuilder {
public:
MOCK_METHOD1(apply_extrinsic,
outcome::result<primitives::ApplyResult>(
const primitives::Extrinsic &));
MOCK_METHOD0(finalise_block, outcome::result<primitives::BlockHeader>());
MOCK_METHOD1(inherent_extrinsics,
outcome::result<std::vector<primitives::Extrinsic>>(
const primitives::InherentData &));
MOCK_METHOD2(check_inherents,
outcome::result<primitives::CheckInherentsResult>(
const primitives::Block &,
const primitives::InherentData &));
MOCK_METHOD0(random_seed, outcome::result<base::Hash256>());
};
} // namespace sgns::runtime
#endif // SUPERGENIUS_TEST_MOCK_SRC_RUNTIME_BLOCK_BUILDER_API_MOCK_HPP
| 36.689655
| 77
| 0.696429
|
GeniusVentures
|
89ea91dc748032a9aa5dcfa585deb49f6d17fce0
| 9,269
|
cxx
|
C++
|
test/itkVectorKernelPCATest.cxx
|
mseng10/ITKPrincipalComponentsAnalysis
|
ae0107041089450f0e921fef811f647808d27b79
|
[
"Apache-2.0"
] | 2
|
2018-04-26T15:26:29.000Z
|
2018-04-26T15:55:50.000Z
|
test/itkVectorKernelPCATest.cxx
|
mseng10/ITKPrincipalComponentsAnalysis
|
ae0107041089450f0e921fef811f647808d27b79
|
[
"Apache-2.0"
] | 15
|
2017-04-21T13:16:53.000Z
|
2021-01-11T20:59:30.000Z
|
test/itkVectorKernelPCATest.cxx
|
mseng10/ITKPrincipalComponentsAnalysis
|
ae0107041089450f0e921fef811f647808d27b79
|
[
"Apache-2.0"
] | 4
|
2017-04-11T16:54:54.000Z
|
2020-07-03T00:21:32.000Z
|
/*=========================================================================
*
* Copyright NumFOCUS
*
* 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.txt
*
* 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 "itkMesh.h"
#include "itkMeshFileReader.h"
#include "itkVectorFieldPCA.h"
#include "itkTestingMacros.h"
#include "vnl/vnl_vector.h"
#include "vnl/vnl_vector.h"
template <typename TPixel, typename TMesh, typename TVectorContainer>
int
ParseVectorFields(std::vector<std::string> vectorFieldFilenames, typename TVectorContainer::Pointer vectorFieldSet)
{
int testStatus = EXIT_SUCCESS;
using ReaderType = itk::MeshFileReader<TMesh>;
typename ReaderType::Pointer meshReader = ReaderType::New();
unsigned int fieldSetCount = vectorFieldFilenames.size();
vectorFieldSet->Reserve(fieldSetCount);
typename TVectorContainer::Element vectorField;
unsigned int vectorFieldDim = 0;
unsigned int vectorFieldCount = 0;
unsigned int setIx = 0;
for (unsigned int i = 0; i < fieldSetCount; i++)
{
std::string vectorFieldName = vectorFieldFilenames[i];
meshReader->SetFileName(vectorFieldName);
ITK_TRY_EXPECT_NO_EXCEPTION(meshReader->Update());
// Get the objects
typename TMesh::Pointer meshWithField = meshReader->GetOutput();
typename TMesh::PointDataContainerPointer pointData = meshWithField->GetPointData();
if (setIx == 0)
{
vectorFieldCount = pointData->Size();
if (vectorFieldCount)
{
TPixel oneDataSetVal = pointData->GetElement(0);
vectorFieldDim = oneDataSetVal.size();
}
if (vectorFieldCount != meshWithField->GetNumberOfPoints())
{
std::cerr << "Test failed!" << std::endl;
std::cerr << "Vector field count (" << vectorFieldCount << ") doesn't match mesh vertext count ("
<< meshWithField->GetNumberOfPoints() << ")." << std::endl;
testStatus = EXIT_FAILURE;
}
vectorField.set_size(vectorFieldCount, vectorFieldDim);
}
else
{
if (vectorFieldDim != vectorField.cols() || vectorFieldCount != meshWithField->GetNumberOfPoints())
{
std::cerr << "Test failed!" << std::endl;
std::cerr << "Unexpected dimensions in vector field file " << vectorFieldName << std::endl;
std::cerr << "Expected: " << vectorFieldCount << " x " << vectorFieldDim << ", but got "
<< meshWithField->GetNumberOfPoints() << " x " << vectorField.cols() << std::endl;
testStatus = EXIT_FAILURE;
}
}
for (unsigned int k = 0; k < pointData->Size(); k++)
{
TPixel oneDataSetVal = pointData->GetElement(k);
vectorField.set_row(k, oneDataSetVal);
}
vectorFieldSet->SetElement(setIx++, vectorField);
}
return testStatus;
}
int
itkVectorKernelPCATest(int argc, char * argv[])
{
if (argc < 6)
{
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << argv[0] << "<vtkMeshFile> <vectorField1> ... <vectorFieldN> " << std::endl;
std::cerr << "where N must be greater than 3" << std::endl;
return EXIT_FAILURE;
}
int testStatus = EXIT_SUCCESS;
const unsigned int Dimension = 3;
using PointDataType = double;
using PointDataVectorType = itk::Array<PointDataType>;
using PixelType = PointDataVectorType;
using CoordRep = double;
using PCAResultsType = double;
// Declare the type of the input mesh
using MeshType = itk::Mesh<PixelType, Dimension>;
// Declare the type of the kernel function class
using KernelType = itk::GaussianDistanceKernel<CoordRep>;
// Declare the type of the PCA calculator
using PCACalculatorType =
itk::VectorFieldPCA<PointDataType, PCAResultsType, PixelType, CoordRep, KernelType, MeshType>;
// Instantiate the reader
using ReaderType = itk::MeshFileReader<MeshType>;
ReaderType::Pointer meshReader = ReaderType::New();
meshReader->SetFileName(argv[1]);
ITK_TRY_EXPECT_NO_EXCEPTION(meshReader->Update());
// Get the input mesh
MeshType::Pointer mesh = meshReader->GetOutput();
PCACalculatorType::Pointer pcaCalc = PCACalculatorType::New();
ITK_EXERCISE_BASIC_OBJECT_METHODS(pcaCalc, VectorFieldPCA, Object);
// Test exception when trying to compute before setting much of anything
ITK_TRY_EXPECT_EXCEPTION(pcaCalc->Compute());
// Set user variables
unsigned int pcaCount = 3;
pcaCalc->SetComponentCount(pcaCount);
// Connect the input
pcaCalc->SetPointSet(mesh);
ITK_TEST_SET_GET_VALUE(mesh, pcaCalc->GetPointSet());
// Set vector fields
PCACalculatorType::VectorFieldType vectorField;
// Should know vector field dimensions now
unsigned int vectorFieldDim = 0;
// how many vector field sets?
std::vector<std::string> vectorFieldFilenames;
unsigned int firstVectorFieldIdx = 2;
unsigned int fieldSetCount = argc - firstVectorFieldIdx;
for (unsigned int i = firstVectorFieldIdx; i < firstVectorFieldIdx + fieldSetCount; i++)
{
vectorFieldFilenames.emplace_back(argv[i]);
}
PCACalculatorType::VectorFieldSetTypePointer vectorFieldSet = PCACalculatorType::VectorFieldSetType::New();
testStatus =
ParseVectorFields<PixelType, MeshType, PCACalculatorType::VectorFieldSetType>(vectorFieldFilenames, vectorFieldSet);
pcaCalc->SetVectorFieldSet(vectorFieldSet);
ITK_TEST_SET_GET_VALUE(vectorFieldSet, pcaCalc->GetVectorFieldSet());
// Execute the PCA calculator
ITK_TRY_EXPECT_NO_EXCEPTION(pcaCalc->Compute());
double kernelSigma = 6.25;
KernelType::Pointer distKernel = KernelType::New();
distKernel->SetKernelSigma(kernelSigma);
pcaCalc->SetKernelFunction(distKernel);
std::ofstream debugOut;
debugOut.precision(15);
// Get the output and perform basic checks
unsigned int computedNumberOfAverageVectorFieldCols = pcaCalc->GetAveVectorField().cols();
unsigned int computedNumberOfAverageVectorFieldRows = pcaCalc->GetAveVectorField().rows();
for (unsigned int j = 0; j < pcaCalc->GetComponentCount(); j++)
{
unsigned int expectedBasisVectorCols = pcaCalc->GetVectorFieldSet()->GetElement(j).cols();
unsigned int computedBasisVectorCols = pcaCalc->GetBasisVectors()->GetElement(j).cols();
if (computedBasisVectorCols != expectedBasisVectorCols)
{
std::cout << "Test failed!" << std::endl;
std::cout << "Error in GetBasisVectors() dimension check at index [" << j << "]" << std::endl;
std::cout << "Expected: " << expectedBasisVectorCols << " columns, but got: " << computedBasisVectorCols
<< std::endl;
testStatus = EXIT_FAILURE;
}
unsigned int expectedBasisVectorRows = pcaCalc->GetVectorFieldSet()->GetElement(j).rows();
unsigned int computedBasisVectorRows = pcaCalc->GetBasisVectors()->GetElement(j).rows();
if (computedBasisVectorRows != expectedBasisVectorRows)
{
std::cout << "Test failed!" << std::endl;
std::cout << "Error in GetBasisVectors() dimension check at index [" << j << "]" << std::endl;
std::cout << "Expected: " << expectedBasisVectorRows << " row, but got: " << computedBasisVectorRows << std::endl;
testStatus = EXIT_FAILURE;
}
if (computedNumberOfAverageVectorFieldCols != expectedBasisVectorCols)
{
std::cout << "Test failed!" << std::endl;
std::cout << "Error in GetAveVectorField() dimension check at index [" << j << "]" << std::endl;
std::cout << "Expected: " << vectorFieldDim << " columns, but got: " << computedNumberOfAverageVectorFieldCols
<< std::endl;
testStatus = EXIT_FAILURE;
}
if (computedNumberOfAverageVectorFieldRows != expectedBasisVectorRows)
{
std::cout << "Test failed!" << std::endl;
std::cout << "Error in GetAveVectorField() dimension check at index [" << j << "]" << std::endl;
std::cout << "Expected: " << vectorFieldDim << " rows, but got: " << computedNumberOfAverageVectorFieldRows
<< std::endl;
testStatus = EXIT_FAILURE;
}
}
unsigned int computedNumberOfEigenValueVectors = pcaCalc->GetPCAEigenValues().size();
if (computedNumberOfEigenValueVectors != pcaCount)
{
std::cout << "Test failed!" << std::endl;
std::cout << "Error in GetPCAEigenValues() dimension check." << std::endl;
std::cout << "Expected: " << pcaCount << ", but got: " << computedNumberOfEigenValueVectors << std::endl;
testStatus = EXIT_FAILURE;
}
// Test exception when trying to compute with a requested input count greater
// than the number of vector field sets
pcaCalc->SetComponentCount(fieldSetCount + 1);
ITK_TRY_EXPECT_EXCEPTION(pcaCalc->Compute());
std::cout << "Test finished." << std::endl;
return testStatus;
}
| 35.243346
| 120
| 0.678067
|
mseng10
|
89eb2120447028e417e22256bded7dcdc1020ad4
| 1,728
|
cc
|
C++
|
chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
|
wedataintelligence/vivaldi-source
|
22a46f2c969f6a0b7ca239a05575d1ea2738768c
|
[
"BSD-3-Clause"
] | null | null | null |
chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
|
wedataintelligence/vivaldi-source
|
22a46f2c969f6a0b7ca239a05575d1ea2738768c
|
[
"BSD-3-Clause"
] | null | null | null |
chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
|
wedataintelligence/vivaldi-source
|
22a46f2c969f6a0b7ca239a05575d1ea2738768c
|
[
"BSD-3-Clause"
] | null | null | null |
// Copyright 2015 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.
#include "extensions/shell/browser/shell_oauth2_token_service_delegate.h"
#include <vector>
namespace extensions {
ShellOAuth2TokenServiceDelegate::ShellOAuth2TokenServiceDelegate(
content::BrowserContext* browser_context,
std::string account_id,
std::string refresh_token)
: browser_context_(browser_context),
account_id_(account_id),
refresh_token_(refresh_token) {
}
ShellOAuth2TokenServiceDelegate::~ShellOAuth2TokenServiceDelegate() {
}
bool ShellOAuth2TokenServiceDelegate::RefreshTokenIsAvailable(
const std::string& account_id) const {
if (account_id != account_id_)
return false;
return !refresh_token_.empty();
}
OAuth2AccessTokenFetcher*
ShellOAuth2TokenServiceDelegate::CreateAccessTokenFetcher(
const std::string& account_id,
net::URLRequestContextGetter* getter,
OAuth2AccessTokenConsumer* consumer) {
DCHECK_EQ(account_id, account_id_);
DCHECK(!refresh_token_.empty());
return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token_);
}
net::URLRequestContextGetter*
ShellOAuth2TokenServiceDelegate::GetRequestContext() const {
return browser_context_->GetRequestContext();
}
std::vector<std::string> ShellOAuth2TokenServiceDelegate::GetAccounts() {
std::vector<std::string> accounts;
accounts.push_back(account_id_);
return accounts;
}
void ShellOAuth2TokenServiceDelegate::UpdateCredentials(
const std::string& account_id,
const std::string& refresh_token) {
account_id_ = account_id;
refresh_token_ = refresh_token;
}
} // namespace extensions
| 28.8
| 76
| 0.782407
|
wedataintelligence
|
8852a42eff8e4b8e8846aa31b40a7b2a69c52a73
| 1,299
|
cpp
|
C++
|
ex00/srcs/megaphone.cpp
|
JonathanDUFOUR/cpp_modul_00
|
d7ebbf1a42b0af46309ed835644e2d2f8897ad06
|
[
"MIT"
] | null | null | null |
ex00/srcs/megaphone.cpp
|
JonathanDUFOUR/cpp_modul_00
|
d7ebbf1a42b0af46309ed835644e2d2f8897ad06
|
[
"MIT"
] | null | null | null |
ex00/srcs/megaphone.cpp
|
JonathanDUFOUR/cpp_modul_00
|
d7ebbf1a42b0af46309ed835644e2d2f8897ad06
|
[
"MIT"
] | null | null | null |
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* megaphone.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jodufour <jodufour@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/11 18:48:52 by jodufour #+# #+# */
/* Updated: 2022/03/01 18:32:30 by jodufour ### ########.fr */
/* */
/* ************************************************************************** */
#include <cstdlib>
#include <iostream>
typedef unsigned int uint;
int main(int const ac, char const **av)
{
uint idx0;
uint idx1;
if (ac > 1)
for (idx0 = 1 ; av[idx0] ; ++idx0)
for (idx1 = 0 ; av[idx0][idx1] ; ++idx1)
std::cout << static_cast<char>(std::toupper(av[idx0][idx1]));
else
std::cout << "* LOUD AND UNBEARABLE FEEDBACK NOISE *";
std::cout << std::endl;
return EXIT_SUCCESS;
}
| 40.59375
| 80
| 0.277136
|
JonathanDUFOUR
|
8856f46ea022534fedca141936406e76b9b777bc
| 4,996
|
cpp
|
C++
|
tightvnc/desktop/WinD3D11Device.cpp
|
jjzhang166/qmlvncviewer2
|
b888c416ab88b81fe802ab0559bb87361833a0b5
|
[
"Apache-2.0"
] | 47
|
2016-08-17T03:18:32.000Z
|
2022-01-14T01:33:15.000Z
|
tightvnc/desktop/WinD3D11Device.cpp
|
jjzhang166/qmlvncviewer2
|
b888c416ab88b81fe802ab0559bb87361833a0b5
|
[
"Apache-2.0"
] | 3
|
2018-06-29T06:13:28.000Z
|
2020-11-26T02:31:49.000Z
|
tightvnc/desktop/WinD3D11Device.cpp
|
jjzhang166/qmlvncviewer2
|
b888c416ab88b81fe802ab0559bb87361833a0b5
|
[
"Apache-2.0"
] | 15
|
2016-08-17T07:03:55.000Z
|
2021-08-02T14:42:02.000Z
|
// Copyright (C) 2012 GlavSoft LLC.
// All rights reserved.
//
//-------------------------------------------------------------------------
// This file is part of the TightVNC software. Please visit our Web site:
//
// http://www.tightvnc.com/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 02110-1301 USA.
//-------------------------------------------------------------------------
//
#include "util/Exception.h"
#include "region/Rect.h"
// The header including of this cpp file must be at last place to avoid build conflicts.
#include "WinD3D11Device.h"
typedef HRESULT (WINAPI *D3D11CreateDeviceFunType)(
_In_opt_ IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
_In_reads_opt_( FeatureLevels ) CONST D3D_FEATURE_LEVEL* pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
_Out_opt_ ID3D11Device** ppDevice,
_Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel,
_Out_opt_ ID3D11DeviceContext** ppImmediateContext );
WinD3D11Device::WinD3D11Device(LogWriter *log)
: m_device(0),
m_context(0),
m_d3d11Lib(_T("d3d11.dll")),
m_log(log)
{
D3D11CreateDeviceFunType d3d11CreateDevice;
d3d11CreateDevice = (D3D11CreateDeviceFunType)m_d3d11Lib.getProcAddress("D3D11CreateDevice");
if (d3d11CreateDevice == 0) {
throw Exception(_T("Unable to load the D3D11CreateDevice() function"));
}
// Driver types supported
D3D_DRIVER_TYPE driverTypes[] =
{
D3D_DRIVER_TYPE_HARDWARE
};
UINT driverTypeCount = ARRAYSIZE(driverTypes);
// Feature levels supported
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_1
};
UINT featureLevelCount = ARRAYSIZE(featureLevels);
D3D_FEATURE_LEVEL featureLevel;
// Create device
HRESULT hr;
for (UINT iDriverType = 0; iDriverType < driverTypeCount; ++iDriverType) {
m_log->debug(_T("Creating of (%u) driverType device"), iDriverType);
hr = d3d11CreateDevice(0,
driverTypes[iDriverType],
0,
0,
featureLevels,
featureLevelCount,
D3D11_SDK_VERSION,
&m_device,
&featureLevel,
&m_context);
if (SUCCEEDED(hr)) {
m_log->debug(_T("Creating of %u driverType device is successfull, supported D3D_FEATURE_LEVEL is %u"), iDriverType, featureLevel);
break;
}
}
if (FAILED(hr)) {
StringStorage errMess;
errMess.format(_T("D3D11CreateDevice function was failed with code error = (%dl)"), (long)hr);
m_log->debug(_T("D3D11CreateDevice function was failed with code error = (%dl)"), (long)hr);
throw Exception(errMess.getString());
}
}
WinD3D11Device::WinD3D11Device(const WinD3D11Device &src)
{
copy(src);
}
WinD3D11Device::~WinD3D11Device()
{
if (m_device != 0) {
m_device->Release();
m_device = 0;
}
if (m_context != 0) {
m_context->Release();
m_context = 0;
}
}
WinD3D11Device &WinD3D11Device::operator = (WinD3D11Device const &src)
{
copy(src);
return *this;
}
void WinD3D11Device::copy(const WinD3D11Device &src)
{
if (this != &src) {
m_device = src.m_device;
m_device->AddRef();
m_context = src.m_context;
m_context->AddRef();
}
}
HRESULT WinD3D11Device::deviceQueryInterface(REFIID riid, void **ppvObject)
{
return m_device->QueryInterface(riid, ppvObject);
}
HRESULT WinD3D11Device::contextQueryInterface(REFIID riid, void **ppvObject)
{
return m_context->QueryInterface(riid, ppvObject);
}
ID3D11Device *WinD3D11Device::getDevice()
{
return m_device;
}
ID3D11DeviceContext *WinD3D11Device::getContext()
{
return m_context;
}
void WinD3D11Device::copySubresourceRegion(ID3D11Texture2D *dstTexture2D, int dstX, int dstY,
ID3D11Texture2D *srcTexture2D, const Rect *srcRect,
UINT front, UINT back)
{
D3D11_BOX box;
box.left = srcRect->left;
box.top = srcRect->top;
box.right = srcRect->right;
box.bottom = srcRect->bottom;
box.front = front;
box.back = back;
m_context->CopySubresourceRegion(dstTexture2D, 0, dstX, dstY, 0, srcTexture2D, 0, &box);
}
| 29.916168
| 136
| 0.657326
|
jjzhang166
|
885a29976d90fc532e7db7e3dd64f5ba1ce0a8e1
| 958
|
cpp
|
C++
|
codechef/MAY COOK 15/REARRSTR.cpp
|
DevGithub007/My_Codes
|
e506050b97abc058fa8b1e24b3b936cc2315c664
|
[
"MIT"
] | null | null | null |
codechef/MAY COOK 15/REARRSTR.cpp
|
DevGithub007/My_Codes
|
e506050b97abc058fa8b1e24b3b936cc2315c664
|
[
"MIT"
] | null | null | null |
codechef/MAY COOK 15/REARRSTR.cpp
|
DevGithub007/My_Codes
|
e506050b97abc058fa8b1e24b3b936cc2315c664
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
char s[N], res[N];
pair <int, int> e[42];
int main() {
int tt;
scanf("%d", &tt);
while (tt--) {
scanf("%s", s);
int n = strlen(s);
int cnt[42];
for (int j = 0; j < 26; j++) {
cnt[j] = 0;
}
for (int i = 0; i < n; i++) {
cnt[s[i] - 'a']++;
}
for (int j = 0; j < 26; j++) {
e[j] = make_pair(cnt[j], j);
}
sort(e, e + 26);
reverse(e, e + 26);
int pos = 0;
for (int j = 0; j < 26; j++) {
char c = e[j].second + 'a';
for (int u = 0; u < e[j].first; u++) {
res[pos] = c;
pos += 2;
if (pos >= n) {
pos = 1;
}
}
}
bool ok = true;
for (int i = 0; i < n - 1; i++) {
if (res[i] == res[i + 1]) {
ok = false;
}
}
res[n] = 0;
if (ok) {
puts(res);
} else {
printf("%d\n", -1);
}
}
return 0;
}
| 17.740741
| 44
| 0.368476
|
DevGithub007
|
885cb59e61a9a3bccd94588f2776de5036634e70
| 1,768
|
cc
|
C++
|
src/hardware_limits.cc
|
yotabits/sleep_analyzer
|
20cddedf3682badf89694c2e1ef8a37e32b469fd
|
[
"MIT"
] | null | null | null |
src/hardware_limits.cc
|
yotabits/sleep_analyzer
|
20cddedf3682badf89694c2e1ef8a37e32b469fd
|
[
"MIT"
] | null | null | null |
src/hardware_limits.cc
|
yotabits/sleep_analyzer
|
20cddedf3682badf89694c2e1ef8a37e32b469fd
|
[
"MIT"
] | null | null | null |
// Copyrigth (c) 2015
// Mines-Paristech
// 60, boulevard Saint-Michel
// 75271 Paris cedex 06 (FRANCE). All rights reserved.
// This file is a part of GLCU library.
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Author(s) : T.Kostas, O.Stab
//
//
// File : hardware_limits.cc
// Object :
// Modification(s) :
//
/*
* hardware_limits.cc
*
* Created on: 10 sept. 2015
* Author: tkostas
*/
#include "hardware_limits.hh"
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cmath>
unsigned int get_max_threads_1d()
{
static int max_threads_per_block_1d;
static bool initialized = false;
if (!initialized)
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
max_threads_per_block_1d = prop.maxThreadsPerBlock;
initialized = true;
}
return max_threads_per_block_1d;
}
unsigned int get_max_threads_2d()
{
static int max_threads_per_block_2d;
static bool initialized = false;
if (!initialized)
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
max_threads_per_block_2d = static_cast<unsigned int>(sqrt(prop.maxThreadsPerBlock));
initialized = true;
}
return max_threads_per_block_2d;
}
unsigned int get_max_blocks()
{
static int max_blocks;
static bool initialized = false;
if (!initialized)
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
max_blocks = prop.maxGridSize[0];
initialized = true;
}
return max_blocks;
}
void get_threads_blocks(unsigned int *threads, unsigned int *blocks, unsigned int data_size )
{
*threads = get_max_threads_1d();
*blocks = (data_size + *threads - 1) / *threads;
}
| 19.010753
| 93
| 0.70871
|
yotabits
|
885d118ccb5971df73ddbcdfb944c637722db389
| 494
|
cpp
|
C++
|
GFSSOC/Equation Solver.cpp
|
Joon7891/Competitive-Programming
|
d860b7ad932cd5a6fb91fdc8c53101da57f4a408
|
[
"MIT"
] | 2
|
2021-04-13T00:19:56.000Z
|
2021-04-13T01:19:45.000Z
|
GFSSOC/Equation Solver.cpp
|
Joon7891/Competitive-Programming
|
d860b7ad932cd5a6fb91fdc8c53101da57f4a408
|
[
"MIT"
] | null | null | null |
GFSSOC/Equation Solver.cpp
|
Joon7891/Competitive-Programming
|
d860b7ad932cd5a6fb91fdc8c53101da57f4a408
|
[
"MIT"
] | 1
|
2020-08-26T12:36:08.000Z
|
2020-08-26T12:36:08.000Z
|
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
int current;
cin >> current;
char op; int value;
while (true)
{
cin >> op;
if (op == '=') break;
cin >> value;
if (op == 'M')
{
current -= value;
}
else if (op == 'P')
{
current += value;
}
}
cout << current << endl;
}
| 14.969697
| 46
| 0.423077
|
Joon7891
|
8860acc08b23db785b649ae1f4d3e9bf23e03462
| 1,612
|
cpp
|
C++
|
test/math/vector/hypersphere_to_cartesian.cpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
test/math/vector/hypersphere_to_cartesian.cpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
test/math/vector/hypersphere_to_cartesian.cpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
// Copyright Carl Philipp Reh 2009 - 2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <fcppt/math/vector/componentwise_equal.hpp>
#include <fcppt/math/vector/hypersphere_to_cartesian.hpp>
#include <fcppt/math/vector/static.hpp>
#include <fcppt/config/external_begin.hpp>
#include <catch2/catch.hpp>
#include <cmath>
#include <limits>
#include <fcppt/config/external_end.hpp>
TEST_CASE(
"math::vector::hypersphere_to_cartesian",
"[math],[vector]"
)
{
typedef
float
real;
real const epsilon{
std::numeric_limits<
real
>::epsilon()
};
typedef
fcppt::math::vector::static_<
real,
1
>
fvector1;
typedef
fcppt::math::vector::static_<
real,
2
>
fvector2;
typedef
fcppt::math::vector::static_<
real,
3
>
fvector3;
real const
phi1{
fcppt::literal<
real
>(
1.5
)
},
phi2{
fcppt::literal<
real
>(
0.5
)
};
CHECK(
fcppt::math::vector::componentwise_equal(
fcppt::math::vector::hypersphere_to_cartesian(
fvector1{
phi1
}
),
fvector2{
std::cos(
phi1
),
std::sin(
phi1
)
},
epsilon
)
);
CHECK(
fcppt::math::vector::componentwise_equal(
fcppt::math::vector::hypersphere_to_cartesian(
fvector2{
phi1,
phi2
}
),
fvector3(
std::cos(
phi1
),
std::sin(
phi1
) *
std::cos(
phi2
),
std::sin(
phi1
) *
std::sin(
phi2
)
),
epsilon
)
);
}
| 13.777778
| 61
| 0.597395
|
pmiddend
|
8865092e6cbea3b4d4128f0e80fc9c5da9a14a20
| 6,309
|
cpp
|
C++
|
examples/tutorial/dynatype.cpp
|
Hower91/Apache-C-Standard-Library-4.2.x
|
4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3
|
[
"Apache-2.0"
] | null | null | null |
examples/tutorial/dynatype.cpp
|
Hower91/Apache-C-Standard-Library-4.2.x
|
4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3
|
[
"Apache-2.0"
] | null | null | null |
examples/tutorial/dynatype.cpp
|
Hower91/Apache-C-Standard-Library-4.2.x
|
4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3
|
[
"Apache-2.0"
] | null | null | null |
/**************************************************************************
*
* dynatype.cpp - Example program of map. See Class Reference Section
*
* $Id: //stdlib/dev/examples/stdlib/tutorial/dynatype.cpp#11 $
*
***************************************************************************
*
* Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
* Software division. 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 <iostream>
#include <map>
#include <typeinfo>
#include <examples.h>
// ordinary class whose objects are dynamically typed at runtime
class dynatype
{
// member template class that encapsulates a per-specialization copy
// of an associative container (map) used to bind a specific instance
// of dynatype to its value
template <class T>
struct map {
typedef std::map<const dynatype*, T> map_type;
static map_type& get () {
static map_type m;
return m;
}
};
// helper: removes this instance of dynatype from map
template <class T>
void remove () {
map<T>::get ().erase (this);
}
// helper: copies one instance of dynatype to another
template <class T>
void copy (const dynatype &rhs) {
*this = static_cast<T>(rhs);
}
// pointers to the helpers (do not depend on a template parameter)
void (dynatype::*p_remove)();
void (dynatype::*p_copy)(const dynatype&);
public:
dynatype ();
// construct a dynatype object from a value of any type
template <class T>
dynatype (const T&);
// copy one dynatype object to another
dynatype (const dynatype &rhs)
: p_remove (rhs.p_remove),
p_copy (rhs.p_copy) {
(this->*p_copy)(rhs);
}
// assign one dynatype object to another
dynatype& operator= (const dynatype &rhs);
// remove `this' from the map destroy the object
~dynatype () {
(this->*p_remove)();
}
// retrieve a reference to the concrete type from an instance of
// dynatype throws std::bad_cast if the types don't match exactly
template <class T>
operator T& () {
if (map<T>::get ().end () == map<T>::get ().find (this))
throw std::bad_cast ();
return map<T>::get () [this];
}
// retrieve a value of the concrete type from an instance of
// dynatype throws std::bad_cast if the types don't match exactly
template <class T>
operator T () const {
return static_cast<T&> (*const_cast<dynatype*>(this));
}
// assign a value of any type to an instance of dynatype
template <class T>
dynatype& operator= (const T &t);
};
// 14.7.3, p6 - explicit specializations must be defined before first use
template <>
inline void dynatype::remove<dynatype::map<void> >()
{ /* no-op */ }
template <>
inline void dynatype::copy<dynatype::map<void> >(const dynatype&)
{ /* no-op */ }
template <>
inline dynatype& dynatype::operator= (const dynatype::map<void>&)
{
// no-op
return *this;
}
// initialize with pointers to no-ops
inline dynatype::dynatype ()
: p_remove (&dynatype::remove<map<void> >),
p_copy (&dynatype::copy<map<void> >)
{
}
// construct a dynatype object from a value of any type
template <class T>
inline dynatype::dynatype (const T &t)
: p_remove (&dynatype::remove<T>),
p_copy (&dynatype::copy<T>)
{
*this = t;
}
// assign one dynatype object to another
inline dynatype& dynatype::operator= (const dynatype &rhs)
{
if (this != &rhs) {
// remove `this' from the associated map
(this->*p_remove)();
// copy pointers to helpers from the right-hand-side
p_remove = rhs.p_remove;
p_copy = rhs.p_copy;
// copy value of unknown type from rhs to `*this'
(this->*p_copy)(rhs);
}
return *this;
}
// assign a value of any type to an instance of dynatype
template <class T>
inline dynatype& dynatype::operator= (const T &t)
{
// remove `this' from the map of the corresponding type
(this->*p_remove)();
// insert `t' into the map specialized on `T'
map<T>::get () [this] = t;
// assign pointers to the helpers
p_remove = &dynatype::remove<T>;
p_copy = &dynatype::copy<T>;
return *this;
}
int main ()
{
try {
std::cout << "dynatype v1 = 1\n";
// create an instance of dynatype an initialized it with an int
dynatype v1 = 1;
std::cout << "int (v1) = "
<< int (v1) << std::endl;
// assign a double to an instance of dynatype
v1 = 3.14;
std::cout << "double (v1 = 3.14) = "
<< double (v1) << std::endl;
// copy construct an instance of dynatype
dynatype v2 = v1;
std::cout << "double (v2 = v1) = "
<< double (v2) << std::endl;
// assign a const char* literal to an instance of dynatype
const char* const literal = "abc";
v2 = literal;
std::cout << "(const char*)(v2 = \"abc\") = "
<< (const char*)v2 << std::endl;
// assign one instance of dynatype to another
v1 = v2;
std::cout << "(const char*)(v1 = v2) = "
<< (const char*)v1 << std::endl;
// create uninitialized (untyped) instances of dynatype
dynatype v3, v4;
// assign one uninitialized instance to another
v3 = v4;
// attempt to extract any value from an unitialized dynatype fails
std::cout << "char (v3) = "
<< char (v1) << std::endl;
}
catch (...) {
std::cerr << "exception\n";
}
}
| 27.430435
| 76
| 0.574735
|
Hower91
|
8869c530483f17355d8fb24b24a2f801b994fc7a
| 811
|
cpp
|
C++
|
EDCBSupport/EDCBSupport/StatusBar.cpp
|
abt8WG/EDCB
|
669262b158a25e1c84443ff00597fc981fa78aa6
|
[
"MIT"
] | 13
|
2016-04-26T09:00:46.000Z
|
2021-04-17T00:24:01.000Z
|
EDCBSupport/EDCBSupport/StatusBar.cpp
|
abt8WG/EDCB
|
669262b158a25e1c84443ff00597fc981fa78aa6
|
[
"MIT"
] | 16
|
2016-07-02T07:43:51.000Z
|
2016-10-13T23:03:32.000Z
|
EDCBSupport/EDCBSupport/StatusBar.cpp
|
abt8WG/EDCB
|
669262b158a25e1c84443ff00597fc981fa78aa6
|
[
"MIT"
] | 9
|
2015-11-26T12:12:24.000Z
|
2019-09-23T02:40:02.000Z
|
#include "stdafx.h"
#include "EDCBSupport.h"
#include "StatusBar.h"
namespace EDCBSupport
{
CStatusBar::CStatusBar()
{
}
CStatusBar::~CStatusBar()
{
Destroy();
}
bool CStatusBar::Create(HWND hwndParent,INT_PTR ID)
{
Destroy();
m_hwnd=::CreateWindowEx(0,STATUSCLASSNAME,NULL,
WS_CHILD | WS_CLIPSIBLINGS | SBARS_SIZEGRIP,
0,0,0,0,
hwndParent,
reinterpret_cast<HMENU>(ID),
g_hinstDLL,NULL);
if (m_hwnd==NULL)
return false;
return true;
}
bool CStatusBar::SetText(LPCTSTR pszText)
{
if (m_hwnd==NULL)
return false;
::SendMessage(m_hwnd,SB_SETTEXT,SB_SIMPLEID,reinterpret_cast<LPARAM>(pszText));
::SendMessage(m_hwnd,SB_SIMPLE,TRUE,0);
return true;
}
} // namespace EDCBSupport
| 16.55102
| 82
| 0.633785
|
abt8WG
|