1 /* $Id: field_handler.hpp 542379 2017-07-31 13:06:45Z dicuccio $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * Authors: Colleen Bollin 27 */ 28 29 30 #ifndef _FIELD_HANDLER_H_ 31 #define _FIELD_HANDLER_H_ 32 33 #include <corelib/ncbistd.hpp> 34 35 #include <objmgr/scope.hpp> 36 37 #include <objmgr/scope.hpp> 38 #include <objmgr/bioseq_handle.hpp> 39 #include <objects/seq/Seqdesc.hpp> 40 #include <objects/seqfeat/Seq_feat.hpp> 41 42 #include <objtools/edit/string_constraint.hpp> 43 #include <objtools/edit/apply_object.hpp> 44 45 BEGIN_NCBI_SCOPE 46 47 BEGIN_SCOPE(objects) 48 BEGIN_SCOPE(edit) 49 50 51 class NCBI_XOBJEDIT_EXPORT CFieldHandler : public CObject 52 { 53 public: 54 virtual vector<CConstRef<CObject> > GetObjects(CBioseq_Handle bsh) = 0; 55 virtual vector<CConstRef<CObject> > GetObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<CStringConstraint> string_constraint) = 0; 56 virtual vector<CRef<CApplyObject> > GetApplyObjects(CBioseq_Handle bsh) = 0; 57 virtual string GetVal(const CObject& object) = 0; 58 virtual vector<string> GetVals(const CObject& object) = 0; 59 virtual bool IsEmpty(const CObject& object) const = 0; 60 virtual void ClearVal(CObject& object) = 0; 61 virtual bool SetVal(CObject& object, const string& val, EExistingText existing_text) = 0; IsValid(const string &)62 virtual string IsValid(const string& /*val*/) { return ""; }; IsValid(const vector<string> &)63 virtual vector<string> IsValid(const vector<string>& /*values*/) { vector<string> x; return x; }; 64 virtual CSeqFeatData::ESubtype GetFeatureSubtype() = 0; 65 virtual CSeqdesc::E_Choice GetDescriptorSubtype() = 0; 66 virtual void SetConstraint(const string& field, CConstRef<CStringConstraint> string_constraint) = 0; 67 virtual bool AllowMultipleValues() = 0; 68 virtual vector<CConstRef<CObject> > GetRelatedObjects(const CObject& object, CRef<CScope> scope) = 0; 69 virtual vector<CConstRef<CObject> > GetRelatedObjects(const CApplyObject& object) = 0; 70 virtual vector<CRef<CApplyObject> > GetRelatedApplyObjects(const CObject& object, CRef<CScope> scope); 71 static bool QualifierNamesAreEquivalent (string name1, string name2); 72 static vector<CRef<CApplyObject> > GetApplyObjectsFromRelatedObjects(vector<CConstRef<CObject> >, CRef<CScope> scope); 73 }; 74 75 76 class NCBI_XOBJEDIT_EXPORT CFieldHandlerFactory 77 { 78 public: 79 static CRef<CFieldHandler> Create(const string &field_name); 80 static bool s_IsSequenceIDField(const string& field); 81 }; 82 83 84 NCBI_XOBJEDIT_EXPORT bool DoesObjectMatchFieldConstraint (const CObject& object, const string& field_name, CRef<CStringConstraint> string_constraint, CRef<CScope> scope); 85 NCBI_XOBJEDIT_EXPORT bool DoesApplyObjectMatchFieldConstraint (const CApplyObject& object, const string& field_name, CRef<CStringConstraint> string_constraint); 86 NCBI_XOBJEDIT_EXPORT vector<CConstRef<CSeq_feat> > GetRelatedFeatures(const CSeq_feat& obj_feat, CSeqFeatData::ESubtype constraint_type, CRef<CScope> scope); 87 88 static const string kFieldTypeSeqId = "SeqId"; 89 const string kDefinitionLineLabel = "Definition Line"; 90 const string kCommentDescriptorLabel = "Comment Descriptor"; 91 const string kGenbankBlockKeyword = "Keyword"; 92 93 END_SCOPE(edit) 94 END_SCOPE(objects) 95 END_NCBI_SCOPE 96 97 #endif 98 99