Skip to content

Commit 20efcca

Browse files
committed
Add int_ptr() function to enable unique identification of objects through their address - useful in python where the wrapped object has a different address
1 parent c0a6bb8 commit 20efcca

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

ObjCryst/ObjCryst/Molecule.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ bool MolAtom::IsNonFlipAtom() const
354354
return mIsNonFlipAtom;
355355
}
356356

357+
size_t MolAtom::int_ptr() const {return (size_t)this;}
358+
357359
#ifdef __WX__CRYST__
358360
WXCrystObjBasic* MolAtom::WXCreate(wxWindow* parent)
359361
{
@@ -633,6 +635,9 @@ void MolBond::SetFreeTorsion(const bool isFreeTorsion)
633635
mIsFreeTorsion=isFreeTorsion;
634636
mpMol->GetBondListClock().Click();
635637
}
638+
639+
size_t MolBond::int_ptr() const {return (size_t)this;}
640+
636641
#ifdef __WX__CRYST__
637642
WXCrystObjBasic* MolBond::WXCreate(wxWindow* parent)
638643
{
@@ -940,6 +945,9 @@ void MolBondAngle::SetAtom3(MolAtom& at){mvpAtom[2]=&at;}
940945
std::size_t MolBondAngle::size() const {return mvpAtom.size();}
941946
vector<MolAtom*>::const_iterator MolBondAngle::begin() const {return mvpAtom.begin();}
942947
vector<MolAtom*>::const_iterator MolBondAngle::end() const {return mvpAtom.end();}
948+
949+
size_t MolBondAngle::int_ptr() const {return (size_t)this;}
950+
943951
#ifdef __WX__CRYST__
944952
WXCrystObjBasic* MolBondAngle::WXCreate(wxWindow* parent)
945953
{
@@ -1300,6 +1308,9 @@ MolAtom& MolDihedralAngle::GetAtom4(){return *(mvpAtom[3]);}
13001308
std::size_t MolDihedralAngle::size() const {return mvpAtom.size();}
13011309
vector<MolAtom*>::const_iterator MolDihedralAngle::begin() const {return mvpAtom.begin();}
13021310
vector<MolAtom*>::const_iterator MolDihedralAngle::end() const {return mvpAtom.end();}
1311+
1312+
size_t MolDihedralAngle::int_ptr() const {return (size_t)this;}
1313+
13031314
#ifdef __WX__CRYST__
13041315
WXCrystObjBasic* MolDihedralAngle::WXCreate(wxWindow* parent)
13051316
{
@@ -1324,6 +1335,9 @@ string RigidGroup::GetName()const
13241335
for(;at!=this->end();++at) name+=", "+(*at)->GetName();
13251336
return name;
13261337
}
1338+
1339+
size_t RigidGroup::int_ptr() const {return (size_t)this;}
1340+
13271341
//######################################################################
13281342
//
13291343
// MolRing
@@ -1337,6 +1351,9 @@ const std::list<MolAtom*>& MolRing::GetAtomList()const
13371351

13381352
std::list<MolAtom*>& MolRing::GetAtomList()
13391353
{return mvpAtom;}
1354+
1355+
size_t MolRing::int_ptr() const {return (size_t)this;}
1356+
13401357
//######################################################################
13411358
//
13421359
// Quaternion

ObjCryst/ObjCryst/Molecule.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ class MolAtom
117117
void SetNonFlipAtom(const bool nonflip);
118118
/// Can this atom be flipped (return=false) or should its absolute configuration be kept (return=true)
119119
bool IsNonFlipAtom() const;
120+
/// Access to the integer address of this object, for unique identification from python
121+
size_t int_ptr() const;
120122
private:
121123
/// Name for this atom
122124
string mName;
@@ -229,7 +231,8 @@ class MolBond:public Restraint
229231
void SetBondOrder(const REAL length);
230232
bool IsFreeTorsion()const;
231233
void SetFreeTorsion(const bool isInRing);
232-
234+
/// Access to the integer address of this object, for unique identification from python
235+
size_t int_ptr() const;
233236
private:
234237
pair<MolAtom*,MolAtom*> mAtomPair;
235238
REAL mLength0,mDelta,mSigma;
@@ -320,6 +323,8 @@ class MolBondAngle:public Restraint
320323
std::size_t size() const;
321324
vector<MolAtom*>::const_iterator begin() const;
322325
vector<MolAtom*>::const_iterator end() const;
326+
/// Access to the integer address of this object, for unique identification from python
327+
size_t int_ptr() const;
323328
private:
324329
/// The vector of the 3 atoms involved in the bond angle.
325330
vector<MolAtom*> mvpAtom;
@@ -415,6 +420,8 @@ class MolDihedralAngle:public Restraint
415420
std::size_t size() const;
416421
vector<MolAtom*>::const_iterator begin() const;
417422
vector<MolAtom*>::const_iterator end() const;
423+
/// Access to the integer address of this object, for unique identification from python
424+
size_t int_ptr() const;
418425
private:
419426
/// The vector of the 4 atoms involved in the bond angle.
420427
vector<MolAtom*> mvpAtom;
@@ -454,6 +461,8 @@ class MolRing
454461
MolRing();
455462
const std::list<MolAtom*>& GetAtomList()const;
456463
std::list<MolAtom*>& GetAtomList();
464+
/// Access to the integer address of this object, for unique identification from python
465+
size_t int_ptr() const;
457466
private:
458467
std::list<MolAtom*> mvpAtom;
459468
};
@@ -529,6 +538,8 @@ class RigidGroup:public std::set<MolAtom *>
529538
/// Temporary list of the atoms indices in the molecule, used during optimization
530539
/// This is created in Molecule::BeginOptimization()
531540
mutable std::set<unsigned int> mvIdx;
541+
/// Access to the integer address of this object, for unique identification from python
542+
size_t int_ptr() const;
532543
};
533544

534545
/** Abstract base Stretch Mode for Molecule objects

ObjCryst/RefinableObj/RefinableObj.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,7 @@ void RefinableObj::TagNewBestConfig()const
19811981
}
19821982
const RefinableObjClock& RefinableObj::GetClockMaster()const{return mClockMaster;}
19831983

1984+
size_t RefinableObj::int_ptr() const {return (size_t)this;}
19841985

19851986
void RefinableObj::UpdateDisplay()const
19861987
{

ObjCryst/RefinableObj/RefinableObj.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,8 @@ class RefinableObj
12381238
virtual void TagNewBestConfig()const;
12391239
/// This clocks records _any_ change in the object. See refinableObj::mClockMaster
12401240
const RefinableObjClock& GetClockMaster()const;
1241+
/// Access to the integer address of this object, for unique identification from python
1242+
size_t int_ptr() const;
12411243
protected:
12421244
/// Find a refinable parameter with a given name
12431245
long FindPar(const string &name) const;

0 commit comments

Comments
 (0)